fix: 修复切换主题色缓存失败

This commit is contained in:
kailong321200875 2023-12-20 10:26:51 +08:00
parent 7314065c90
commit 10745207e6
1 changed files with 6 additions and 14 deletions

View File

@ -2,9 +2,8 @@
import { computed } from 'vue'
import { useAppStore } from '@/store/modules/app'
import { ConfigGlobal } from '@/components/ConfigGlobal'
import { isDark } from '@/utils/is'
import { useDesign } from '@/hooks/web/useDesign'
import { useStorage } from '@/hooks/web/useStorage'
import { useDark } from '@vueuse/core'
const { getPrefixCls } = useDesign()
@ -16,19 +15,12 @@ const currentSize = computed(() => appStore.getCurrentSize)
const greyMode = computed(() => appStore.getGreyMode)
const { getStorage } = useStorage()
const isDark = useDark({
valueDark: 'dark',
valueLight: 'light'
})
//
const setDefaultTheme = () => {
if (getStorage('isDark') !== null) {
appStore.setIsDark(getStorage('isDark'))
return
}
const isDarkTheme = isDark()
appStore.setIsDark(isDarkTheme)
}
setDefaultTheme()
isDark.value = appStore.getIsDark
</script>
<template>