🐛 修复潜在的ssg问题

This commit is contained in:
li-chx
2025-10-05 03:01:52 +08:00
parent 51a39d498b
commit 1cefa4c661
7 changed files with 56 additions and 44 deletions
+4 -4
View File
@@ -5,12 +5,12 @@ function getInitialMode(): 'light' | 'dark' {
if (document.documentElement.classList.contains('light')) return 'light';
// 其次用 localStorage
const val = localStorage.getItem('system-theme-mode');
if (!!val || (val !== 'light' && val !== 'dark'))
return 'light';
return val;
if (val === 'dark') return 'dark';
if (val === 'light') return 'light';
return 'light'; // 默认
}
return 'light'; // SSR 默认
};
}
const useColorModeStore = defineStore('colorMode', {
state: () => ({