Skip to content

Commit

Permalink
fix: 修复切换主题色缓存失败
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong321200875 committed Dec 20, 2023
1 parent 7314065 commit 1074520
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/App.vue
Expand Up @@ -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()
Expand All @@ -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>
Expand Down

0 comments on commit 1074520

Please sign in to comment.