Theme bug fixed
This commit is contained in:
parent
12222a864e
commit
f45e0be4de
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue