fix theme

This commit is contained in:
jxxghp
2024-04-28 18:36:10 +08:00
parent c9c897ffb5
commit d70f477bc1
3 changed files with 68 additions and 81 deletions

View File

@@ -98,18 +98,18 @@ async function fetchThemeConfig() {
return null
}
// 设置主题
// 生效主题
async function setTheme() {
let themeValue = await fetchThemeConfig() || localStorage.getItem('theme') || 'light'
let themeValue = (await fetchThemeConfig()) || localStorage.getItem('theme') || 'light'
const autoTheme = checkPrefersColorSchemeIsDark() ? 'dark' : 'light'
globalTheme.name.value = themeValue === 'auto' ? autoTheme : themeValue
// 修改载入时背景色
localStorage.setItem('materio-initial-loader-bg', globalTheme.current.value.colors.background)
// 存储主题到本地
localStorage.setItem('theme', themeValue)
localStorage.setItem('materio-initial-loader-bg', globalTheme.current.value.colors.background)
}
async function afterLogin() {
// 主题配置
// 生效主题配置
await setTheme()
// 尝试加载用户监控面板配置(本地无配置时才加载)
await tryLoadDashboardConfig()