mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-02 01:31:53 +08:00
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:
@@ -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");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user