Skip to content

Commit

Permalink
fix: 🐛 修复 Storage 在缺失 DESIGN-SETTING 时设置根节点属性的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangshu233 committed Mar 4, 2024
1 parent 8e5979c commit e62d598
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
17 changes: 6 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@
<body>
<div id="app">
<script>
const designSetting = JSON.parse(
window.localStorage.getItem('DESIGN-SETTING'),
)

;(() => {
const { darkMode, appTheme = '#5d9dfe' } =
JSON.parse(window.localStorage.getItem('DESIGN-SETTING')) || {}

let htmlRoot = document.getElementById('htmlRoot')
let darkMode = designSetting.darkMode
if (htmlRoot && darkMode) {
htmlRoot.setAttribute('data-theme', darkMode)
darkMode = htmlRoot = null
} else {
htmlRoot.setAttribute('data-theme', 'light')
if (htmlRoot) {
htmlRoot.setAttribute('data-theme', darkMode || 'light')
}

// 设置主题色变量
document.documentElement.style.setProperty(
'--app-theme-color',
designSetting.appTheme,
appTheme,
)
})()
</script>
Expand Down
3 changes: 1 addition & 2 deletions src/components/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
<script setup lang="ts">
import { useDesignSettingStore } from '@/store/modules/designSetting'
import { hexToRgba } from '@/utils/index'
const { appThemeList } = designSetting
import { appThemeList } from '@/settings/designSetting'
const defaultAppTheme = appThemeList[0]
const designStore = useDesignSettingStore()
Expand Down

0 comments on commit e62d598

Please sign in to comment.