fix: limit theme mode value

This commit is contained in:
GyDi 2022-08-08 22:28:44 +08:00
parent 99c46685ac
commit c1734a094c
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084

View File

@ -16,8 +16,12 @@ export default function useCustomTheme() {
const [mode, setMode] = useRecoilState(atomThemeMode);
useEffect(() => {
if (theme_mode !== "system") {
setMode(theme_mode ?? "light");
const themeMode = ["light", "dark", "system"].includes(theme_mode!)
? theme_mode!
: "light";
if (themeMode !== "system") {
setMode(themeMode);
return;
}