chore: 📌 优化后台风格显示
This commit is contained in:
34
frontend/src/components/ThemeProvider.tsx
Normal file
34
frontend/src/components/ThemeProvider.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ReactNode, useMemo } from 'react';
|
||||
import { ConfigProvider, theme } from 'antd';
|
||||
import zhCN from 'antd/locale/zh_CN';
|
||||
import { useThemeStore } from '../stores/themeStore';
|
||||
import { getThemeByMode } from '../theme';
|
||||
|
||||
interface ThemeProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
// 主题提供者组件
|
||||
export const ThemeProvider = ({ children }: ThemeProviderProps) => {
|
||||
const { themeMode } = useThemeStore();
|
||||
|
||||
// 根据主题模式获取主题配置和算法
|
||||
const currentTheme = useMemo(() => {
|
||||
const customTheme = getThemeByMode(themeMode);
|
||||
const algorithm = themeMode === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm;
|
||||
|
||||
return {
|
||||
algorithm,
|
||||
...customTheme,
|
||||
};
|
||||
}, [themeMode]);
|
||||
|
||||
return (
|
||||
<ConfigProvider
|
||||
locale={zhCN}
|
||||
theme={currentTheme}
|
||||
>
|
||||
{children}
|
||||
</ConfigProvider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user