From 7b443ee5b5abe17518b57c02de7449f83868d42b Mon Sep 17 00:00:00 2001 From: BTMuli Date: Fri, 21 Apr 2023 12:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(store):=20=E5=BC=95=E5=85=A5?= =?UTF-8?q?=20theme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/app.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index a5a1ac57..ea871c8c 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -38,6 +38,8 @@ export const useAppStore = defineStore( }); // 开发者模式 const devMode = ref(false); + // 应用主题 + const theme = ref("default"); const dataPath = reactive({ appDataDir, @@ -62,6 +64,7 @@ export const useAppStore = defineStore( devMode.value = false; sidebar.submenu.mihoyo = false; sidebar.submenu.wiki = false; + theme.value = "default"; } function getSubmenu (): string[] { @@ -71,7 +74,13 @@ export const useAppStore = defineStore( return open; } + function changeTheme (): void { + if (theme.value === "default") theme.value = "dark"; + else theme.value = "default"; + } + return { + theme, loading, sidebar, devMode, @@ -80,6 +89,7 @@ export const useAppStore = defineStore( userPath, init, getSubmenu, + changeTheme, }; }, { @@ -99,6 +109,11 @@ export const useAppStore = defineStore( storage: window.localStorage, paths: ["sidebar"], }, + { + key: "theme", + storage: window.localStorage, + paths: ["theme"], + }, ], }, );