fix: theme

pull/28/head
xingyu 2023-08-06 13:07:26 +08:00
parent b505773475
commit 5fffb3591d
2 changed files with 4 additions and 4 deletions

View File

@ -50,6 +50,7 @@ export function initAppConfigStore() {
appStore.setProjectConfig(projCfg) appStore.setProjectConfig(projCfg)
// init dark mode // init dark mode
appStore.setDarkMode(darkMode as ThemeEnum)
updateDarkTheme(darkMode) updateDarkTheme(darkMode)
if (darkMode === ThemeEnum.DARK) { if (darkMode === ThemeEnum.DARK) {
updateHeaderBgColor() updateHeaderBgColor()

View File

@ -80,12 +80,11 @@ export const useAppStore = defineStore('app', {
setDarkMode(mode: ThemeEnum): void { setDarkMode(mode: ThemeEnum): void {
this.darkMode = mode this.darkMode = mode
console.info(mode)
this.setThemeConfig() this.setThemeConfig()
localStorage.setItem(APP_DARK_MODE_KEY_, mode) localStorage.setItem(APP_DARK_MODE_KEY_, mode)
}, },
setThemeConfig(color?: string): void { setThemeConfig(color?: string): void {
console.info(this.darkMode)
let themeConfig = reactive<ThemeConfig>({ let themeConfig = reactive<ThemeConfig>({
algorithm: antdTheme.defaultAlgorithm, algorithm: antdTheme.defaultAlgorithm,
token: { token: {
@ -109,7 +108,6 @@ export const useAppStore = defineStore('app', {
components: {}, components: {},
} }
} }
console.info(themeConfig)
this.themeConfig = themeConfig this.themeConfig = themeConfig
}, },
@ -122,8 +120,9 @@ export const useAppStore = defineStore('app', {
}, },
setProjectConfig(config: DeepPartial<ProjectConfig>): void { setProjectConfig(config: DeepPartial<ProjectConfig>): void {
this.projectConfig = deepMerge(this.projectConfig || {}, config) this.projectConfig = deepMerge(this.projectConfig, config)
Persistent.setLocal(PROJ_CFG_KEY, this.projectConfig) Persistent.setLocal(PROJ_CFG_KEY, this.projectConfig)
this.setThemeConfig(config.themeColor)
}, },
setMenuSetting(setting: Partial<MenuSetting>): void { setMenuSetting(setting: Partial<MenuSetting>): void {