mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
fix: make theme toggle respond on first click
This commit is contained in:
1 parent
cb3dbe4ca4
commit
b0fa4bf5d0
4 files changed
+33
-9
No files matched your search
@@ -17,8 +17,16 @@ export function saveTheme(theme: ThemeMode): void {
|
||||
applyTheme(theme);
|
||||
}
|
||||
|
||||
export function isDarkTheme(theme: ThemeMode): boolean {
|
||||
if (theme === "dark") return true;
|
||||
if (theme === "light") return false;
|
||||
return typeof window !== "undefined" && typeof window.matchMedia === "function"
|
||||
? window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
: false;
|
||||
}
|
||||
|
||||
export function nextTheme(theme: ThemeMode): ThemeMode {
|
||||
return theme === "system" ? "light" : theme === "light" ? "dark" : "system";
|
||||
return isDarkTheme(theme) ? "light" : "dark";
|
||||
}
|
||||
|
||||
applyTheme(getStoredTheme());
|
||||
Reference in new issue
Block a user