From 0f6344792e06a2c0b0e669d29d4e4f3797b10d7a Mon Sep 17 00:00:00 2001 From: hxr <1490493387@qq.com> Date: Sun, 5 Nov 2023 10:56:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E7=99=BB=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E4=B8=BB=E9=A2=98=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=90=8E=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE?= =?UTF-8?q?=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/layout/components/Sidebar/Logo.vue | 6 ++---- src/store/modules/settings.ts | 7 ++++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue index 6fd3763..93d81bb 100644 --- a/src/layout/components/Settings/index.vue +++ b/src/layout/components/Settings/index.vue @@ -79,11 +79,8 @@ const currentThemeColor = computed(() => { }); onMounted(() => { window.document.body.setAttribute("layout", settingsStore.layout); - const theme = - localStorage.getItem("vueuse-color-scheme") || defaultSettings.theme; - settingsStore.changeSetting({ key: "theme", value: theme }); - - if (theme != "light") { + const theme = settingsStore.theme; + if (theme == "dark") { document.documentElement.classList.add("dark"); } diff --git a/src/layout/components/Sidebar/Logo.vue b/src/layout/components/Sidebar/Logo.vue index 96a3c57..7f1f4fb 100644 --- a/src/layout/components/Sidebar/Logo.vue +++ b/src/layout/components/Sidebar/Logo.vue @@ -10,8 +10,6 @@ defineProps({ }, }); -const layout = computed(() => settingsStore.layout); - const logo = ref(new URL(`../../../assets/logo.png`, import.meta.url).href); @@ -36,8 +34,8 @@ const logo = ref(new URL(`../../../assets/logo.png`, import.meta.url).href); to="/" > - vue3-element-admin + {{ $t("login.title") }} diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts index 6689823..ebb391d 100644 --- a/src/store/modules/settings.ts +++ b/src/store/modules/settings.ts @@ -20,9 +20,7 @@ export const useSettingsStore = defineStore("setting", () => { ); const theme = useStorage("theme", defaultSettings.theme); - if (theme.value == "light") { - document.body.classList.remove("dark"); - } + // actions function changeSetting(param: { key: string; value: any }) { const { key, value } = param; @@ -47,6 +45,9 @@ export const useSettingsStore = defineStore("setting", () => { break; case "theme": theme.value = value; + if (theme.value !== "dark") { + document.documentElement.classList.remove("dark"); + } break; } }