perf: optimize for some details and comments (#4030)
* perf: optimize for some details and comments * fix: test case * chore: update ci
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# inject-app-loading
|
||||
|
||||
用于在应用加载时显示加载动画的插件。可自行选择加载动画的样式。
|
||||
用于在应用加载时显示加载动画的插件,可自行选择加载动画的样式。
|
||||
|
@@ -25,7 +25,7 @@
|
||||
pointer-events: none;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
transition: all 0.6s ease-out;
|
||||
transition: all 1s ease-out;
|
||||
}
|
||||
|
||||
.dark .loading {
|
||||
|
@@ -52,19 +52,15 @@ async function viteInjectAppLoadingPlugin(
|
||||
* 用于获取loading的html模板
|
||||
*/
|
||||
async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
const defaultLoadingPath = join(__dirname, './default-loading.html');
|
||||
// 支持在app内自定义loading模板,模版参考default-loading.html即可
|
||||
const appLoadingPath = join(process.cwd(), loadingTemplate);
|
||||
let loadingPath = defaultLoadingPath;
|
||||
let appLoadingPath = join(process.cwd(), loadingTemplate);
|
||||
|
||||
if (fs.existsSync(appLoadingPath)) {
|
||||
loadingPath = appLoadingPath;
|
||||
return;
|
||||
if (!fs.existsSync(appLoadingPath)) {
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
appLoadingPath = join(__dirname, './default-loading.html');
|
||||
}
|
||||
|
||||
const htmlRaw = await fsp.readFile(loadingPath, 'utf8');
|
||||
return htmlRaw;
|
||||
return await fsp.readFile(appLoadingPath, 'utf8');
|
||||
}
|
||||
|
||||
export { viteInjectAppLoadingPlugin };
|
||||
|
Reference in New Issue
Block a user