From c1734a094cd6896ec48e630662fbeeac1ae92da5 Mon Sep 17 00:00:00 2001 From: GyDi Date: Mon, 8 Aug 2022 22:28:44 +0800 Subject: [PATCH] fix: limit theme mode value --- src/components/layout/use-custom-theme.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/layout/use-custom-theme.ts b/src/components/layout/use-custom-theme.ts index 86a9d9d..dd6c17e 100644 --- a/src/components/layout/use-custom-theme.ts +++ b/src/components/layout/use-custom-theme.ts @@ -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; }