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'