Skip to content

Commit 3c0dedc

Browse files
committed
feat(projects): 集成主题切换
1 parent 37ae52c commit 3c0dedc

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/features/themeSchema/ThemeProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const ThemeProvider: FC<PropsWithChildren> = ({ children }) => {
4040
// 在组件卸载时清理监听器
4141
mediaQuery.removeEventListener('change', handler);
4242
};
43+
// eslint-disable-next-line react-hooks/exhaustive-deps
4344
}, []);
4445

4546
return (

src/features/themeSchema/ThemeSchemaSwitch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ButtonProps, TooltipProps } from 'antd';
22
import type { CSSProperties } from 'react';
33

4-
import ButtonIcon from '@/components/stateless/custom/ButtonIcon';
4+
import ButtonIcon from '@/components/ButtonIcon';
55

66
import { ThemeContext, icons } from './themeContext';
77

src/features/themeSchema/themeContext.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ export function toggleCssDarkMode(darkMode = false) {
3737
htmlElementClassList.remove(DARK_CLASS);
3838
}
3939
}
40+
41+
export function useTheme() {
42+
return useContext(ThemeContext);
43+
}

0 commit comments

Comments
 (0)