diff --git a/src/store/modules/theme/index.ts b/src/store/modules/theme/index.ts index 7e390ae..b55de5b 100644 --- a/src/store/modules/theme/index.ts +++ b/src/store/modules/theme/index.ts @@ -1,7 +1,7 @@ import { computed, effectScope, onScopeDispose, ref, toRefs, watch } from 'vue'; import type { Ref } from 'vue'; import { defineStore } from 'pinia'; -import { useEventListener, usePreferredColorScheme } from '@vueuse/core'; +import { usePreferredColorScheme } from '@vueuse/core'; import { SetupStoreId } from '@/enum'; import { localStg } from '@/utils/storage'; import { addThemeVarsToHtml, createThemeToken, getAntdTheme, initThemeSettings, toggleCssDarkMode } from './shared'; @@ -102,18 +102,18 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => { } /** Cache theme settings */ - function cacheThemeSettings() { - const isProd = import.meta.env.PROD; - - if (!isProd) return; - - localStg.set('themeSettings', settings.value); - } - - // cache theme settings when page is closed or refreshed - useEventListener(window, 'beforeunload', () => { - cacheThemeSettings(); - }); + // function cacheThemeSettings() { + // const isProd = import.meta.env.PROD; + // + // if (!isProd) return; + // + // localStg.set('themeSettings', settings.value); + // } + // + // // cache theme settings when page is closed or refreshed + // useEventListener(window, 'beforeunload', () => { + // cacheThemeSettings(); + // }); // watch store scope.run(() => { diff --git a/src/store/modules/theme/shared.ts b/src/store/modules/theme/shared.ts index f29ff45..83d2b17 100644 --- a/src/store/modules/theme/shared.ts +++ b/src/store/modules/theme/shared.ts @@ -10,6 +10,8 @@ const DARK_CLASS = 'dark'; /** Init theme settings */ export function initThemeSettings() { + return themeSettings; // 直接使用默认设置 src/store/modules/theme/index.ts 注释104行Cache theme settings相关 + const isProd = import.meta.env.PROD; // if it is development mode, the theme settings will not be cached, by update `themeSettings` in `src/theme/settings.ts` to update theme settings