fix: 修复子路径部署静态资源引用
- 修复 admin 与 usercenter 登录验证码资源在 /flow 子路径下的加载路径 - 统一 logo、空状态图、兜底头像与模型服务商图标的 BASE_URL 处理 - 补齐 usercenter 公共布局与 loading 注入的子路径兼容
This commit is contained in:
@@ -20,6 +20,7 @@ async function viteInjectAppLoadingPlugin(
|
||||
const { version } = await readPackageJSON(process.cwd());
|
||||
const envRaw = isBuild ? 'prod' : 'dev';
|
||||
const cacheName = `'${env.VITE_APP_NAMESPACE}-${version}-${envRaw}-preferences-theme'`;
|
||||
const appBase = JSON.stringify(ensureTrailingSlash(env.VITE_BASE || '/'));
|
||||
|
||||
// 获取缓存的主题
|
||||
// 保证黑暗主题下,刷新页面时,loading也是黑暗主题
|
||||
@@ -29,7 +30,7 @@ async function viteInjectAppLoadingPlugin(
|
||||
document.documentElement.classList.toggle('dark', /dark/.test(theme));
|
||||
setTimeout(() => {
|
||||
if (/dark/.test(theme)) {
|
||||
document.querySelector('#__app-loading__ img').src = '/logoDark.svg';
|
||||
document.querySelector('#__app-loading__ img').src = ${appBase} + 'logoDark.svg';
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -68,4 +69,8 @@ async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
|
||||
return await fsp.readFile(appLoadingPath, 'utf8');
|
||||
}
|
||||
|
||||
function ensureTrailingSlash(path: string) {
|
||||
return path.endsWith('/') ? path : `${path}/`;
|
||||
}
|
||||
|
||||
export { viteInjectAppLoadingPlugin };
|
||||
|
||||
Reference in New Issue
Block a user