| | |
| | | import { initPreferences, preferencesManager } from './packages/preferences/src'; |
| | | import { watch } from 'vue'; |
| | | import { initPreferences, preferences, preferencesManager } from './packages/preferences/src'; |
| | | import { unmountGlobalLoading } from './packages/utils/src'; |
| | | |
| | | import { overridesPreferences, preferencesExtension } from './preferences'; |
| | |
| | | overrides: overridesPreferences, |
| | | }); |
| | | |
| | | // 首次升级同步品牌主色,避免旧的蓝色偏好遮盖本次主题更新。 |
| | | // 升级后用户在偏好设置中选择的颜色和明暗模式仍会保留。 |
| | | document.documentElement.dataset.brandTheme = 'herbal'; |
| | | const brandThemeKey = `${namespace}-herbal-theme-v1`; |
| | | try { |
| | | if (!localStorage.getItem(brandThemeKey)) { |
| | | preferencesManager.updatePreferences({ |
| | | theme: { builtinType: 'custom', colorPrimary: '#a51d24' }, |
| | | }); |
| | | localStorage.setItem(brandThemeKey, '1'); |
| | | } |
| | | } catch { |
| | | preferencesManager.updatePreferences({ |
| | | theme: { builtinType: 'custom', colorPrimary: '#a51d24' }, |
| | | }); |
| | | } |
| | | watch( |
| | | () => preferences.theme.colorPrimary, |
| | | (color) => { document.documentElement.dataset.herbalPalette = String(color.toLowerCase() === '#a51d24'); }, |
| | | { immediate: true, flush: 'sync' }, |
| | | ); |
| | | |
| | | // 强制覆盖公司 logo 和 favicon,绕过 localStorage 缓存 |
| | | if (__APP_LOGO__) { |
| | | preferencesManager.updatePreferences({ logo: { source: __APP_LOGO__ } }); |