From beac9b19b4ed0d9a162e56574ed2874b2ef34d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Tue, 1 Mar 2022 23:53:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 3 ++- src/components/RightPanel/index.vue | 1 - src/components/ThemePicker/index.vue | 5 +++-- src/store/modules/settings.ts | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index 5d320f89..95686194 100644 --- a/src/App.vue +++ b/src/App.vue @@ -9,6 +9,7 @@ import {computed, onMounted, ref, watch} from "vue"; import {useAppStoreHook} from "@/store/modules/app"; import {ElConfigProvider} from 'element-plus' +import {localStorage} from "@/utils/storage"; //官方文档: https://element-plus.gitee.io/zh-CN/guide/i18n.html @@ -30,7 +31,7 @@ watch(language, (value) => { immediate: true }) onMounted(()=>{ - const style = localStorage.getItem("style"); + const style = localStorage.get("style"); document.documentElement.style.cssText = style as string; }) diff --git a/src/components/RightPanel/index.vue b/src/components/RightPanel/index.vue index e72e10e2..4ebfd11a 100644 --- a/src/components/RightPanel/index.vue +++ b/src/components/RightPanel/index.vue @@ -35,7 +35,6 @@ const theme = computed(() => useSettingStoreHook().theme) const show = ref(false) watch(show, (value) => { - console.log('show', value) if (value) { addEventClick() } diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index 193a8425..a35c4717 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -12,6 +12,7 @@ import {computed, nextTick, watch} from "vue"; import {useSettingStoreHook} from "@/store/modules/settings"; import {useTagsViewStoreHook} from "@/store/modules/tagsView"; import {useRoute, useRouter} from "vue-router"; +import {localStorage} from "@/utils/storage"; // 参考连接:https://juejin.cn/post/7024025899813044232#heading-1 import {mix} from "@/utils"; @@ -26,14 +27,14 @@ const theme = computed(() => useSettingStoreHook().theme) watch(theme, (color: string) => { node.style.setProperty("--el-color-primary", color); - localStorage.setItem("theme", color) + localStorage.set("theme", color) for (let i = 1; i < 10; i += 1) { node.style.setProperty(`--el-color-primary-light-${i}`, mix(color, mixWhite, i * 0.1)); } node.style.setProperty("--el-color-primary-dark", mix(color, mixBlack, 0.1)); - localStorage.setItem("style", node.style.cssText); + localStorage.set("style", node.style.cssText); }) diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts index 51c250ac..b4025559 100644 --- a/src/store/modules/settings.ts +++ b/src/store/modules/settings.ts @@ -2,6 +2,7 @@ import {defineStore} from "pinia"; import {store} from "@/store"; import {SettingState} from "@/store/interface"; import defaultSettings from '../../settings' +import {localStorage} from "@/utils/storage"; const {showSettings, tagsView, fixedHeader, sidebarLogo} = defaultSettings import variables from '@/styles/element-variables.module.scss'