Browse Source

fix: 暗黑模式bug

xingyu 2 years ago
parent
commit
a97db2754a
1 changed files with 3 additions and 8 deletions
  1. 3 8
      yudao-ui-admin-vue3/src/App.vue

+ 3 - 8
yudao-ui-admin-vue3/src/App.vue

@@ -15,15 +15,10 @@ const { wsCache } = useCache()
 
 // 根据浏览器当前主题设置系统主题色
 const setDefaultTheme = () => {
-  if (wsCache.get(CACHE_KEY.IS_DARK)) {
-    if (wsCache.get(CACHE_KEY.IS_DARK) || wsCache.get(CACHE_KEY.IS_DARK) === 'true') {
-      appStore.setIsDark(true)
-    } else {
-      appStore.setIsDark(false)
-    }
-    return
+  let isDarkTheme = wsCache.get(CACHE_KEY.IS_DARK)
+  if (isDarkTheme === null) {
+    isDarkTheme = isDark()
   }
-  const isDarkTheme = isDark()
   appStore.setIsDark(isDarkTheme)
 }
 setDefaultTheme()