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

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

@@ -118,3 +118,12 @@ export function isNullOrEmptyObject(obj: any): boolean {
// 然后判断是否为空对象
return !!(typeof obj === 'object' && Object.keys(obj).length === 0)
}
// 判断系统配置色是否是黑暗的
export function checkPrefersColorSchemeIsDark(): boolean {
try {
return window.matchMedia('(prefers-color-scheme: dark)').matches
} catch (e) {
return false
}
}