色彩优化

This commit is contained in:
‘Liammcl’
2024-12-26 22:10:19 +08:00
parent 6a86447029
commit bde0a8fd65
9 changed files with 129 additions and 188 deletions

View File

@@ -1,144 +1,10 @@
import React from "react";
import { BrowserRouter } from "react-router-dom";
import { ConfigProvider, theme } from "antd";
import { ThemeProvider } from "./contexts/ThemeContext";
import { AuthProvider } from "./contexts/AuthContext";
import AppRoutes from "./routes/AppRoutes";
import { useTheme } from "./contexts/ThemeContext";
import { RootStoreProvider } from "./contexts/RootStore";
const ThemedApp = () => {
const { isDarkMode } = useTheme();
return (
<ConfigProvider
theme={{
algorithm: isDarkMode ? theme.darkAlgorithm : theme.defaultAlgorithm,
token: {
// 颜色
colorPrimary: '#006494',
colorSuccess: '#16A34A',
colorWarning: '#FBBF24',
colorError: '#DC2626',
colorInfo: '#006494',
// 中性色
colorText: isDarkMode ? 'rgba(255, 255, 255, 0.87)' : 'rgba(0, 0, 0, 0.87)',
colorTextSecondary: isDarkMode ? 'rgba(255, 255, 255, 0.60)' : 'rgba(0, 0, 0, 0.60)',
colorTextTertiary: isDarkMode ? 'rgba(255, 255, 255, 0.38)' : 'rgba(0, 0, 0, 0.38)',
colorBgContainer: isDarkMode ? '#121212' : '#ffffff',
colorBgElevated: isDarkMode ? '#242424' : '#ffffff',
colorBorder: isDarkMode ? 'rgba(255, 255, 255, 0.12)' : 'rgba(0, 0, 0, 0.12)',
// 字体
fontFamily: '"Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
fontSize: 16,
// 圆角
borderRadius: 8,
borderRadiusLG: 12,
borderRadiusSM: 4,
borderRadiusXS: 2,
// 线框
lineWidth: 1,
lineType: 'solid',
// 动画
motionDurationMid: '0.2s',
motionEaseInOut: 'cubic-bezier(0.4, 0, 0.2, 1)',
motionEaseOut: 'cubic-bezier(0.0, 0, 0.2, 1)',
motionEaseIn: 'cubic-bezier(0.4, 0, 1, 1)',
// 阴影
boxShadow: isDarkMode
? '0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15)'
: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 4px 8px 3px rgba(0, 0, 0, 0.08)',
boxShadowSecondary: isDarkMode
? '0 4px 12px 6px rgba(0, 0, 0, 0.4)'
: '0 4px 12px 6px rgba(0, 0, 0, 0.12)',
},
components: {
// 按钮样式
Button: {
borderRadius: 8,
controlHeight: 40,
paddingContentHorizontal: 24,
primaryShadow: 'none',
},
// 输入框样式
Input: {
controlHeight: 48,
borderRadius: 8,
paddingContentHorizontal: 16,
variant: 'filled',
},
// 选择器样式
Select: {
controlHeight: 48,
borderRadius: 8,
variant: 'filled',
},
// 表单样式
Form: {
labelFontSize: 14,
margin: 24,
itemMarginBottom: 24,
variant: 'filled',
},
// 卡片样式
Card: {
borderRadius: 12,
padding: 24,
},
// 模态框样式
Modal: {
borderRadius: 12,
paddingContentHorizontal: 24,
paddingContentVertical: 24,
},
// 下拉菜单样式
Dropdown: {
borderRadius: 8,
controlHeight: 40,
},
// 标签页样式
Tabs: {
inkBarColor: '#006494',
cardGutter: 8,
},
// 表格样式
Table: {
borderRadius: 8,
padding: 16,
cellPaddingBlock: 16,
cellPaddingInline: 16,
},
// 其他组件的 filled 变体设置
DatePicker: {
variant: 'filled',
},
TimePicker: {
variant: 'filled',
},
Cascader: {
variant: 'filled',
},
TreeSelect: {
variant: 'filled',
},
AutoComplete: {
variant: 'filled',
},
},
}}
>
<div className={isDarkMode ? "dark" : ""}>
<AppRoutes />
</div>
</ConfigProvider>
);
};
const App = () => {
return (
@@ -146,7 +12,7 @@ const App = () => {
<AuthProvider>
<RootStoreProvider>
<ThemeProvider>
<ThemedApp />
<AppRoutes />
</ThemeProvider>
</RootStoreProvider>
</AuthProvider>