From a53668379ce7c9c201fae6e25617f390176d84d9 Mon Sep 17 00:00:00 2001 From: wanglu Date: Wed, 15 Feb 2023 15:09:12 +0800 Subject: [PATCH] chore:v1.4.2 --- ui/website/src/components/DarkSwitch/index.tsx | 10 ++++++---- ui/website/src/utils/theme.ts | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/website/src/components/DarkSwitch/index.tsx b/ui/website/src/components/DarkSwitch/index.tsx index 7f63762..17ab5da 100644 --- a/ui/website/src/components/DarkSwitch/index.tsx +++ b/ui/website/src/components/DarkSwitch/index.tsx @@ -21,7 +21,8 @@ const DarkSwitch = () => { applyTheme(realTheme, "autoThemeTimer", true); }, 10000); } - },[theme]) + // eslint-disable-next-line react-hooks/exhaustive-deps + },[ theme]) useLayoutEffect(() => { @@ -35,7 +36,8 @@ const DarkSwitch = () => { setTheme(iTheme); } } - }); + // eslint-disable-next-line react-hooks/exhaustive-deps + },[]); const lightIcon = ( { ) const handleSwitch = () => { - if (theme == "light") { + if (theme === "light") { setTheme("dark"); - } else if (theme == "dark") { + } else if (theme === "dark") { setTheme("auto"); } else { setTheme("light"); diff --git a/ui/website/src/utils/theme.ts b/ui/website/src/utils/theme.ts index 0a94e37..ca5197b 100644 --- a/ui/website/src/utils/theme.ts +++ b/ui/website/src/utils/theme.ts @@ -15,7 +15,7 @@ export function decodeAuto() { } } export const decodeTheme = (t: "auto" | "light" | "dark") => { - if (t == "auto") { + if (t === "auto") { return decodeAuto(); } else { return t; @@ -41,7 +41,7 @@ export const initTheme = () => { return "auto"; } // 2种情况: 1. 自动。 2.手动 - if (!("theme" in localStorage) || localStorage.theme == "auto") { + if (!("theme" in localStorage) || localStorage.theme === "auto") { return "auto"; } else { if (localStorage.theme === "dark") {