feat: 新增remote-only主题模式,优化首屏包体积
1. 新增theme-override.js实现主题远端拉取逻辑 2. 新增empty-style-stub.js作为主题包占位符,减少主包~75KB 3. 在vue.config.js中添加构建期主题stub替换逻辑 4. 重构config-external.js的主题配置,新增remote-only模式支持 5. 重构store的applyThemeWithRemote方法,适配远端主题拉取 6. 在bootstrap中新增主题初始化和异步拉取逻辑
This commit is contained in:
9
main.js
9
main.js
@@ -17,6 +17,7 @@ import {
|
||||
import configExternal from './common/js/config-external.js'
|
||||
import PrivacyManager from './common/js/privacy.js'
|
||||
import splashState from './common/js/splash-state.js'
|
||||
import ThemeOverride from './common/js/theme-override.js'
|
||||
|
||||
Vue.prototype.$store = store //挂在vue
|
||||
|
||||
@@ -105,7 +106,15 @@ async function bootstrap() {
|
||||
if (Lang.isRemoteOnly && Lang.isRemoteOnly()) {
|
||||
splashState.show();
|
||||
try {
|
||||
// 1) i18n: 拉远端语言包 (langConfig.source === 'remote-only')
|
||||
await Lang.boot();
|
||||
// 2) theme: 阻塞式预热 brand 桶覆写 (themeConfig.overrideRemote.source)
|
||||
await ThemeOverride.boot();
|
||||
// 3) theme(remote-only): 异步拉全量 8 个 preset 替换 stub
|
||||
// 失败静默, 兜底用 webpack stub(只含 default),首屏不白屏
|
||||
ThemeOverride.loadAllPresets().catch((e) => {
|
||||
console.warn('[theme-presets] load fail', e);
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('[i18n] remote-only boot fail', e);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user