This commit is contained in:
2026-03-25 14:54:15 +08:00
commit ab4646b43a
827 changed files with 123812 additions and 0 deletions
@@ -0,0 +1,25 @@
declare const uni: any;
type SystemTheme = 'light' | 'dark';
/**
* 非 H5 平台获取当前系统主题
*/
export function getSystemDarkMode(): SystemTheme {
try {
if (typeof uni !== 'undefined' && typeof uni.getSystemInfoSync === 'function') {
const systemInfo = uni.getSystemInfoSync();
const theme = systemInfo.osTheme || systemInfo.theme || 'light';
if (theme === 'dark') {
return 'dark';
}
if (theme === 'light') {
return 'light';
}
}
} catch (e) {
// 获取失败时默认返回亮色
console.warn('[system-theme] getSystemDarkMode failed', e);
}
return 'light';
}