兼容处理不支持黑白配色的老旧设备

This commit is contained in:
Allen
2024-04-28 16:40:47 +08:00
parent 0268df0e24
commit 4e7a0084dd
4 changed files with 20 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ import api from '@/api'
import router from '@/router'
import logo from '@images/logo.png'
import { useTheme } from 'vuetify'
import { checkPrefersColorSchemeIsDark } from '@/@core/utils'
const { global: globalTheme } = useTheme()
@@ -100,7 +101,7 @@ async function fetchThemeConfig() {
// 设置主题
async function setTheme() {
let themeValue = await fetchThemeConfig() || localStorage.getItem('theme') || 'light'
const autoTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
const autoTheme = checkPrefersColorSchemeIsDark() ? 'dark' : 'light'
globalTheme.name.value = themeValue === 'auto' ? autoTheme : themeValue
// 修改载入时背景色
localStorage.setItem('materio-initial-loader-bg', globalTheme.current.value.colors.background)