Skip to content

Commit

Permalink
🐛 fix: 修复themeConfig.prefersColor.switch配置不生效的问题 (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedRiceNoodles committed Mar 19, 2024
1 parent c2201ca commit 69882d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/slots/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ import { useThemeStore } from '../../store/useThemeStore';
import { useStyle } from './style';

const Switcher = () => {
const allowSwitchTheme = useSiteStore((s) => s.siteData.themeConfig.prefersColor.switch);
const themeMode = useThemeStore((s) => s.themeMode);
const [, , setColorMode] = usePrefersColor();
useEffect(() => setColorMode(themeMode), [themeMode]);
return (
return allowSwitchTheme ? (
<ThemeSwitch
value={themeMode}
onChange={(mode) => {
useThemeStore.setState({ themeMode: mode });
}}
/>
);
) : null;
};

const Header: FC = () => {
Expand Down

0 comments on commit 69882d1

Please sign in to comment.