From 35de124efba7e021ef2542a295075bfc61f1ee7e Mon Sep 17 00:00:00 2001 From: zclzone Date: Tue, 14 May 2024 18:03:55 +0800 Subject: [PATCH] fix(projects): fixed issue that themeStore was not reset to the initial settings when resetting it. --- src/store/modules/theme/index.ts | 5 +++-- src/store/plugins/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/store/modules/theme/index.ts b/src/store/modules/theme/index.ts index 7685c546..fa2e77f6 100644 --- a/src/store/modules/theme/index.ts +++ b/src/store/modules/theme/index.ts @@ -5,6 +5,7 @@ import { useEventListener, usePreferredColorScheme } from '@vueuse/core'; import { getPaletteColorByNumber } from '@sa/color'; import { SetupStoreId } from '@/enum'; import { localStg } from '@/utils/storage'; +import { themeSettings } from '@/theme/settings'; import { addThemeVarsToHtml, createThemeToken, @@ -57,8 +58,8 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => { /** Reset store */ function resetStore() { const themeStore = useThemeStore(); - - themeStore.$reset(); + const reset = themeStore.$reset as (arg?: Partial) => void; + reset(themeSettings); } /** diff --git a/src/store/plugins/index.ts b/src/store/plugins/index.ts index 8b9566bb..a9982755 100644 --- a/src/store/plugins/index.ts +++ b/src/store/plugins/index.ts @@ -15,8 +15,8 @@ export function resetSetupStore(context: PiniaPluginContext) { const defaultStore = cloneDeep($state); - context.store.$reset = () => { - context.store.$patch(defaultStore); + context.store.$reset = (state?: Partial) => { + context.store.$patch(state || defaultStore); }; } }