Skip to content

Commit

Permalink
chore:v1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Feb 15, 2023
1 parent 80ec693 commit a536683
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions ui/website/src/components/DarkSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const DarkSwitch = () => {
applyTheme(realTheme, "autoThemeTimer", true);
}, 10000);
}
},[theme])
// eslint-disable-next-line react-hooks/exhaustive-deps
},[ theme])


useLayoutEffect(() => {
Expand All @@ -35,7 +36,8 @@ const DarkSwitch = () => {
setTheme(iTheme);
}
}
});
// eslint-disable-next-line react-hooks/exhaustive-deps
},[]);

const lightIcon = (<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -67,9 +69,9 @@ const DarkSwitch = () => {
<path d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z"></path>
</svg>)
const handleSwitch = () => {
if (theme == "light") {
if (theme === "light") {
setTheme("dark");
} else if (theme == "dark") {
} else if (theme === "dark") {
setTheme("auto");
} else {
setTheme("light");
Expand Down
4 changes: 2 additions & 2 deletions ui/website/src/utils/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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") {
Expand Down

0 comments on commit a536683

Please sign in to comment.