@@ -5,6 +5,7 @@ import type { ThemeConfig } from 'antd';
55import { ConfigProvider , theme } from 'antd' ;
66import type { ThemeMode } from '@/lib/cookies' ;
77import { setThemeCookie } from '@/lib/cookies' ;
8+ import { getToken , getComponents , getCssVarConfig } from '@/lib/antd-theme' ;
89
910interface ThemeContextType {
1011 themeMode : ThemeMode ;
@@ -34,141 +35,18 @@ export const ThemeClientProvider: React.FC<ThemeClientProviderProps> = ({
3435 initialMode || { mode : 'auto' , theme : 'light' } ,
3536 ) ;
3637
37- const antdTheme : ThemeConfig = useMemo ( ( ) => ( {
38- algorithm :
39- themeMode . theme === 'dark' ? theme . darkAlgorithm : theme . defaultAlgorithm ,
40- token : {
41- // 主色调 - GitHub风格蓝色
42- colorPrimary : themeMode . theme === 'dark' ? '#58a6ff' : '#0d6efd' ,
43-
44- // 背景色 - GitHub风格背景,增强层次感
45- colorBgContainer : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
46- colorBgElevated : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
47- colorBgLayout : themeMode . theme === 'dark' ? '#0d1117' : '#f6f8fa' ,
48- colorBgSpotlight : themeMode . theme === 'dark' ? '#21262d' : '#f0f3f6' ,
49-
50- // 文本色 - GitHub风格文本对比度
51- colorText : themeMode . theme === 'dark' ? '#f8f8f2' : '#24292f' ,
52- colorTextSecondary : themeMode . theme === 'dark' ? '#8b949e' : '#57606a' ,
53- colorTextTertiary : themeMode . theme === 'dark' ? '#6e7681' : '#8b949e' ,
54- colorTextDescription : themeMode . theme === 'dark' ? '#6e7681' : '#8b949e' ,
55-
56- // 边框色 - GitHub风格边框
57- colorBorder : themeMode . theme === 'dark' ? '#30363d' : '#d0d7de' ,
58- colorBorderSecondary : themeMode . theme === 'dark' ? '#21262d' : '#d8dee4' ,
59-
60- // 分割线
61- colorSplit : themeMode . theme === 'dark' ? '#30363d' : '#d0d7de' ,
62-
63- // 成功、警告、错误色 - 保持原有的语义化颜色
64- colorSuccess : '#22c55e' ,
65- colorWarning : '#f59e0b' ,
66- colorError : '#ef4444' ,
67- colorInfo : themeMode . theme === 'dark' ? '#58a6ff' : '#0d6efd' ,
68-
69- // 链接色
70- colorLink : themeMode . theme === 'dark' ? '#58a6ff' : '#0969da' ,
71- colorLinkHover : themeMode . theme === 'dark' ? '#4f95e5' : '#0550ae' ,
72-
73- // 字体 - 使用 Geist 字体
74- fontFamily : `"Geist", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif` ,
75- fontSize : 14 ,
76-
77- // 圆角 - 现代化圆角设计
78- borderRadius : 8 ,
79- borderRadiusLG : 12 ,
80- borderRadiusSM : 6 ,
81- borderRadiusXS : 4 ,
82-
83- // 阴影 - 现代化阴影系统
84- boxShadow :
85- themeMode . theme === 'dark'
86- ? '0 1px 2px 0 rgba(0, 0, 0, 0.4), 0 1px 3px 0 rgba(0, 0, 0, 0.3)'
87- : '0 1px 2px 0 rgba(17, 24, 39, 0.05), 0 1px 3px 0 rgba(17, 24, 39, 0.1)' ,
88- boxShadowSecondary :
38+ const antdTheme : ThemeConfig = useMemo (
39+ ( ) => ( {
40+ cssVar : getCssVarConfig ( themeMode . theme ) ,
41+ algorithm :
8942 themeMode . theme === 'dark'
90- ? '0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4)'
91- : '0 4px 6px -1px rgba(17, 24, 39, 0.1), 0 2px 4px -1px rgba(17, 24, 39, 0.06)' ,
92-
93- // 动画时长
94- motionDurationSlow : '0.3s' ,
95- motionDurationMid : '0.2s' ,
96- motionDurationFast : '0.1s' ,
97- } ,
98- components : {
99- // 按钮组件 - GitHub风格按钮
100- Button : {
101- colorPrimary : themeMode . theme === 'dark' ? '#58a6ff' : '#0d6efd' ,
102- colorPrimaryHover : themeMode . theme === 'dark' ? '#4f95e5' : '#0b5ed7' ,
103- colorPrimaryActive : themeMode . theme === 'dark' ? '#4184e4' : '#0a52be' ,
104- primaryShadow :
105- themeMode . theme === 'dark'
106- ? '0 2px 0 rgba(88, 166, 255, 0.1)'
107- : '0 2px 0 rgba(13, 110, 253, 0.1)' ,
108- } ,
109-
110- // 卡片组件 - GitHub风格卡片
111- Card : {
112- colorBorderSecondary :
113- themeMode . theme === 'dark' ? '#30363d' : '#d0d7de' ,
114- colorBgContainer : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
115- } ,
116-
117- // 菜单组件 - GitHub风格菜单
118- Menu : {
119- colorBgContainer : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
120- colorItemBgSelected : themeMode . theme === 'dark' ? '#21262d' : '#ebf5ff' ,
121- colorItemBgHover : themeMode . theme === 'dark' ? '#21262d' : '#f6f8fa' ,
122- colorItemTextSelected :
123- themeMode . theme === 'dark' ? '#58a6ff' : '#0969da' ,
124- } ,
125-
126- // 输入框组件 - GitHub风格输入框
127- Input : {
128- colorBgContainer : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
129- colorBorder : themeMode . theme === 'dark' ? '#30363d' : '#d0d7de' ,
130- activeBorderColor : themeMode . theme === 'dark' ? '#58a6ff' : '#0d6efd' ,
131- hoverBorderColor : themeMode . theme === 'dark' ? '#58a6ff' : '#0d6efd' ,
132- } ,
133-
134- // 表格组件 - GitHub风格表格
135- Table : {
136- colorBgContainer : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
137- colorBorderSecondary :
138- themeMode . theme === 'dark' ? '#30363d' : '#d0d7de' ,
139- colorFillAlter : themeMode . theme === 'dark' ? '#21262d' : '#f6f8fa' ,
140- } ,
141-
142- // 模态框组件 - 现代化模态框
143- Modal : {
144- colorBgElevated : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
145- colorBgMask :
146- themeMode . theme === 'dark'
147- ? 'rgba(13, 17, 23, 0.6)'
148- : 'rgba(0, 0, 0, 0.45)' ,
149- } ,
150-
151- // 提示组件 - 现代化提示
152- Tooltip : {
153- colorBgSpotlight : themeMode . theme === 'dark' ? '#30363d' : '#1f2937' ,
154- colorText : themeMode . theme === 'dark' ? '#f8f8f2' : '#ffffff' ,
155- } ,
156-
157- // 标签组件 - 现代化标签
158- Tag : {
159- colorFill : themeMode . theme === 'dark' ? '#21262d' : '#f3f4f6' ,
160- colorText : themeMode . theme === 'dark' ? '#8b949e' : '#4b5563' ,
161- colorBorder : themeMode . theme === 'dark' ? '#30363d' : '#e5e7eb' ,
162- } ,
163-
164- // 分页组件 - 现代化分页
165- Pagination : {
166- colorPrimary : themeMode . theme === 'dark' ? '#58a6ff' : '#3b82f6' ,
167- colorPrimaryHover : themeMode . theme === 'dark' ? '#4f95e5' : '#2563eb' ,
168- colorBgContainer : themeMode . theme === 'dark' ? '#161b22' : '#ffffff' ,
169- } ,
170- } ,
171- } ) , [ themeMode . theme ] ) ;
43+ ? theme . darkAlgorithm
44+ : theme . defaultAlgorithm ,
45+ token : getToken ( themeMode . theme ) ,
46+ components : getComponents ( themeMode . theme ) ,
47+ } ) ,
48+ [ themeMode . theme ] ,
49+ ) ;
17250
17351 useEffect ( ( ) => {
17452 // 记录到cookie
0 commit comments