Theme bug fixed 2

This commit is contained in:
pqcqaq 2024-07-16 22:54:55 +08:00
parent f45e0be4de
commit b71b89ae26
1 changed files with 3 additions and 0 deletions

View File

@ -68,6 +68,9 @@ export function ThemeProvider({
useEffect(() => {
if (activeTheme && activeTheme !== "system") {
setTheme(activeTheme);
} else {
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
mediaQuery.matches ? setTheme("dark") : setTheme("light");
}
localStorage.setItem(storageKey, activeTheme || "system");
}, [activeTheme]);