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

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