Theme bug fixed

This commit is contained in:
pqcqaq 2024-07-16 22:53:38 +08:00
parent 12222a864e
commit f45e0be4de
1 changed files with 2 additions and 4 deletions

View File

@ -37,10 +37,7 @@ export function ThemeProvider({
const [theme, setTheme] = useState<ThemeSection>(
() => (localStorage.getItem(storageKey) as ThemeSection) || defaultTheme
);
useEffect(() => {
localStorage.setItem(storageKey, theme);
}, [theme]);
// const [theme, setTheme] = useState<ThemeSection>("system");
// 在组件退出前监听系统主题变化,实时切换主题
useEffect(() => {
@ -72,6 +69,7 @@ export function ThemeProvider({
if (activeTheme && activeTheme !== "system") {
setTheme(activeTheme);
}
localStorage.setItem(storageKey, activeTheme || "system");
}, [activeTheme]);
const value = {