From 720471aaee612caf2aaea4969c381f3ba4108e9f Mon Sep 17 00:00:00 2001 From: hxr <1490493387@qq.com> Date: Thu, 2 Nov 2023 23:34:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E5=88=B7=E6=96=B0=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=9A=97=E9=BB=91=E6=A8=A1=E5=BC=8F=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Settings/index.vue | 7 ++++++- src/store/modules/settings.ts | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue index 745adda..6fd3763 100644 --- a/src/layout/components/Settings/index.vue +++ b/src/layout/components/Settings/index.vue @@ -81,7 +81,12 @@ onMounted(() => { window.document.body.setAttribute("layout", settingsStore.layout); const theme = localStorage.getItem("vueuse-color-scheme") || defaultSettings.theme; - localStorage.setItem("vueuse-color-scheme", theme); + settingsStore.changeSetting({ key: "theme", value: theme }); + + if (theme != "light") { + document.documentElement.classList.add("dark"); + } + document.documentElement.style.setProperty( "--el-color-primary", settingsStore.themeColor diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts index ad58399..6689823 100644 --- a/src/store/modules/settings.ts +++ b/src/store/modules/settings.ts @@ -45,6 +45,9 @@ export const useSettingsStore = defineStore("setting", () => { case "themeColor": themeColor.value = value; break; + case "theme": + theme.value = value; + break; } } @@ -56,5 +59,6 @@ export const useSettingsStore = defineStore("setting", () => { layout, themeColor, changeSetting, + theme, }; });