refactor(theme): drop unused MouseEvent param from setTheme

Now that the view transition animation is gone, setTheme no longer
needs click coordinates. Reduce the API surface to (theme: Theme) =>
void and simplify the call sites in mode-toggle and ThemeSettings.
This commit is contained in:
Jason
2026-05-02 17:38:37 +08:00
parent bc1f9341f4
commit 8e59a634fd
3 changed files with 7 additions and 9 deletions
+3 -5
View File
@@ -7,13 +7,11 @@ export function ModeToggle() {
const { theme, setTheme } = useTheme();
const { t } = useTranslation();
const toggleTheme = (event: React.MouseEvent) => {
// 如果当前是 dark 或 system(且系统是暗色),切换到 light
// 否则切换到 dark
const toggleTheme = () => {
if (theme === "dark") {
setTheme("light", event);
setTheme("light");
} else {
setTheme("dark", event);
setTheme("dark");
}
};
+3 -3
View File
@@ -19,21 +19,21 @@ export function ThemeSettings() {
<div className="inline-flex gap-1 rounded-md border border-border-default bg-background p-1">
<ThemeButton
active={theme === "light"}
onClick={(e) => setTheme("light", e)}
onClick={() => setTheme("light")}
icon={Sun}
>
{t("settings.themeLight")}
</ThemeButton>
<ThemeButton
active={theme === "dark"}
onClick={(e) => setTheme("dark", e)}
onClick={() => setTheme("dark")}
icon={Moon}
>
{t("settings.themeDark")}
</ThemeButton>
<ThemeButton
active={theme === "system"}
onClick={(e) => setTheme("system", e)}
onClick={() => setTheme("system")}
icon={Monitor}
>
{t("settings.themeSystem")}
+1 -1
View File
@@ -17,7 +17,7 @@ interface ThemeProviderProps {
interface ThemeContextValue {
theme: Theme;
setTheme: (theme: Theme, event?: React.MouseEvent) => void;
setTheme: (theme: Theme) => void;
}
const ThemeProviderContext = createContext<ThemeContextValue | undefined>(