优化主题设置逻辑,简化代码结构

This commit is contained in:
jxxghp
2025-01-28 07:32:45 +08:00
parent 4d4c9516c6
commit 589007a22a

View File

@@ -3,14 +3,11 @@ import { useTheme } from 'vuetify'
import { checkPrefersColorSchemeIsDark } from '@/@core/utils'
import { ensureRenderComplete, removeEl } from './@core/utils/dom'
const { global: globalTheme } = useTheme()
// 生效主题
async function setTheme() {
let themeValue = localStorage.getItem('theme') || 'light'
const autoTheme = checkPrefersColorSchemeIsDark() ? 'dark' : 'light'
globalTheme.name.value = themeValue === 'auto' ? autoTheme : themeValue
}
const { global: globalTheme } = useTheme()
let themeValue = localStorage.getItem('theme') || 'light'
const autoTheme = checkPrefersColorSchemeIsDark() ? 'dark' : 'light'
globalTheme.name.value = themeValue === 'auto' ? autoTheme : themeValue
// ApexCharts 全局配置
declare global {
@@ -43,7 +40,6 @@ if (window.Apex) {
}
onMounted(() => {
setTheme()
ensureRenderComplete(() => {
nextTick(() => {
setTimeout(() => {