From 69b28f3a6601945f5f2b39fae380ebbf3aadb703 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Thu, 27 Feb 2025 11:56:17 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BD=BF=E7=94=A8=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/theme/index.ts | 26 +++++++++++++------------- src/store/modules/theme/shared.ts | 2 ++ 2 files changed, 15 insertions(+), 13 deletions(-) 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