mirror of
https://github.com/xiangshu233/vue3-vant4-mobile.git
synced 2025-04-06 03:57:47 +08:00
fix: 🐛 修复 Storage 在缺失 DESIGN-SETTING 时设置根节点属性的错误
This commit is contained in:
parent
8e5979c808
commit
e62d5988e1
17
index.html
17
index.html
@ -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>
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user