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:
Vben
2024-08-04 05:42:59 +08:00
committed by GitHub
parent d3ed6757ac
commit b6415fad2d
20 changed files with 37 additions and 134 deletions

View File

@@ -1,3 +1,3 @@
# inject-app-loading
用于在应用加载时显示加载动画的插件可自行选择加载动画的样式。
用于在应用加载时显示加载动画的插件可自行选择加载动画的样式。

View File

@@ -25,7 +25,7 @@
pointer-events: none;
visibility: hidden;
opacity: 0;
transition: all 0.6s ease-out;
transition: all 1s ease-out;
}
.dark .loading {

View File

@@ -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 };