feat(web): 多主题系统 — 4 套主题 + CSS 变量 + Ant Design 动态主题

- CSS 变量层: :root 默认 blue, [data-theme] 覆盖 warm/dark/emerald
- Ant Design: ConfigProvider 按 ThemeName 切换 token + algorithm
- ThemeSwitcher: 下拉面板含 4 主题色块预览 + localStorage 持久化
- useThemeMode: 从 store 读取主题名替代色值比对(修复 33 页面暗色失效)
- index.html: 添加 Noto Serif SC 字体(warm 主题衬线标题)
This commit is contained in:
iven
2026-04-28 00:20:02 +08:00
parent 50eae8b809
commit e56cd73e49
8 changed files with 918 additions and 276 deletions

View File

@@ -96,54 +96,175 @@
--erp-line-height-normal: 1.5;
--erp-line-height-relaxed: 1.625;
/* Heading font — override per theme */
--erp-font-heading: 'Noto Sans SC', -apple-system, system-ui, sans-serif;
/* Layout */
--erp-sidebar-width: 240px;
--erp-sidebar-collapsed-width: 72px;
--erp-header-height: 56px;
}
/* --- Dark Mode Tokens --- */
[data-theme='dark'] {
--erp-primary-light: rgba(37, 99, 235, 0.15);
--erp-primary-light-hover: rgba(37, 99, 235, 0.22);
--erp-primary-bg-subtle: rgba(37, 99, 235, 0.1);
/* ─── Theme: 温润东方 (warm) ─── */
[data-theme='warm'] {
--erp-primary: #C4623A;
--erp-primary-hover: #B55A33;
--erp-primary-active: #8B3E1F;
--erp-primary-light: #F0DDD4;
--erp-primary-light-hover: #E8CEBF;
--erp-primary-bg-subtle: #FAF5F0;
--erp-bg-page: #0f172a;
--erp-bg-container: #1e293b;
--erp-bg-elevated: #334155;
--erp-bg-spotlight: #1e293b;
--erp-bg-sidebar: #0f172a;
--erp-bg-sidebar-hover: #1e293b;
--erp-success: #5B7A5E;
--erp-success-bg: #E8F0E8;
--erp-warning: #C4873A;
--erp-warning-bg: #FFF3E0;
--erp-error: #B54A4A;
--erp-error-bg: #FDEAEA;
--erp-info: #8B7A5E;
--erp-info-bg: #F5F0E8;
--erp-text-primary: rgba(255, 255, 255, 0.95);
--erp-text-secondary: #94a3b8;
--erp-text-tertiary: #64748b;
--erp-text-sidebar: #94a3b8;
--erp-text-sidebar-active: #60a5fa;
--erp-bg-page: #F5F0EB;
--erp-bg-container: #FFFFFF;
--erp-bg-elevated: #FFFFFF;
--erp-bg-spotlight: #EDE8E2;
--erp-bg-sidebar: #FFFFFF;
--erp-bg-sidebar-hover: #F5F0EB;
--erp-bg-sidebar-active: #F0DDD4;
--erp-border: #334155;
--erp-border-light: rgba(255, 255, 255, 0.06);
--erp-border-dark: rgba(255, 255, 255, 0.12);
--erp-text-primary: #2D2A26;
--erp-text-secondary: #7A756E;
--erp-text-tertiary: #A8A29E;
--erp-text-inverse: #FFFFFF;
--erp-text-sidebar: #7A756E;
--erp-text-sidebar-active: #C4623A;
--erp-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
--erp-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
--erp-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.2);
--erp-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
--erp-border: #E8E2DC;
--erp-border-light: #F0EBE5;
--erp-border-dark: #D5CFC8;
--erp-trend-up: #34d399;
--erp-trend-down: #f87171;
--erp-trend-neutral: #94a3b8;
--erp-shadow-xs: 0 1px 2px rgba(45,42,38,0.04);
--erp-shadow-sm: 0 1px 3px rgba(45,42,38,0.06), 0 1px 2px rgba(45,42,38,0.03);
--erp-shadow-md: 0 4px 6px rgba(45,42,38,0.07), 0 2px 4px rgba(45,42,38,0.04);
--erp-shadow-lg: 0 8px 30px rgba(45,42,38,0.10);
--erp-shadow-xl: 0 12px 40px rgba(45,42,38,0.14);
--erp-success-bg: rgba(5, 150, 105, 0.15);
--erp-warning-bg: rgba(217, 119, 6, 0.15);
--erp-error-bg: rgba(220, 38, 38, 0.15);
--erp-info-bg: rgba(2, 132, 199, 0.15);
--erp-radius-sm: 8px;
--erp-radius-md: 12px;
--erp-radius-lg: 14px;
--erp-radius-xl: 18px;
--erp-trend-up: #5B7A5E;
--erp-trend-down: #B54A4A;
--erp-trend-neutral: #7A756E;
--erp-font-heading: 'Noto Serif SC', Georgia, serif;
}
/* ─── Theme: 深邃夜色 (dark) ─── */
[data-theme='dark'] {
--erp-primary: #60A5FA;
--erp-primary-hover: #93C5FD;
--erp-primary-active: #3B82F6;
--erp-primary-light: rgba(96,165,250,0.15);
--erp-primary-light-hover: rgba(96,165,250,0.22);
--erp-primary-bg-subtle: rgba(96,165,250,0.10);
--erp-success: #34D399;
--erp-success-bg: rgba(5,150,105,0.15);
--erp-warning: #FBBF24;
--erp-warning-bg: rgba(217,119,6,0.15);
--erp-error: #F87171;
--erp-error-bg: rgba(220,38,38,0.15);
--erp-info: #38BDF8;
--erp-info-bg: rgba(2,132,199,0.15);
--erp-bg-page: #0F172A;
--erp-bg-container: #1E293B;
--erp-bg-elevated: #334155;
--erp-bg-spotlight: #1E293B;
--erp-bg-sidebar: #0F172A;
--erp-bg-sidebar-hover: #1E293B;
--erp-bg-sidebar-active: rgba(96,165,250,0.15);
--erp-text-primary: rgba(255,255,255,0.95);
--erp-text-secondary: #94A3B8;
--erp-text-tertiary: #64748B;
--erp-text-inverse: #0F172A;
--erp-text-sidebar: #94A3B8;
--erp-text-sidebar-active: #60A5FA;
--erp-border: #334155;
--erp-border-light: rgba(255,255,255,0.06);
--erp-border-dark: rgba(255,255,255,0.12);
--erp-shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
--erp-shadow-sm: 0 2px 8px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.2);
--erp-shadow-md: 0 4px 12px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.2);
--erp-shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
--erp-shadow-xl: 0 12px 40px rgba(0,0,0,0.5);
--erp-trend-up: #34D399;
--erp-trend-down: #F87171;
--erp-trend-neutral: #94A3B8;
--erp-font-heading: 'Noto Sans SC', -apple-system, system-ui, sans-serif;
}
/* ─── Theme: 翡翠清雅 (emerald) ─── */
[data-theme='emerald'] {
--erp-primary: #5B7A5E;
--erp-primary-hover: #4D6B50;
--erp-primary-active: #3E5C41;
--erp-primary-light: #E0EBE1;
--erp-primary-light-hover: #D1E0D3;
--erp-primary-bg-subtle: #F0F5F0;
--erp-success: #3D7A42;
--erp-success-bg: #E0F0E2;
--erp-warning: #B8863A;
--erp-warning-bg: #FFF3E0;
--erp-error: #A54A4A;
--erp-error-bg: #FDEAEA;
--erp-info: #4A7A8B;
--erp-info-bg: #E0F0F5;
--erp-bg-page: #F4F7F4;
--erp-bg-container: #FFFFFF;
--erp-bg-elevated: #FFFFFF;
--erp-bg-spotlight: #EDF2ED;
--erp-bg-sidebar: #FFFFFF;
--erp-bg-sidebar-hover: #F4F7F4;
--erp-bg-sidebar-active: #E0EBE1;
--erp-text-primary: #1A2E1A;
--erp-text-secondary: #5A6E5A;
--erp-text-tertiary: #8FA08F;
--erp-text-inverse: #FFFFFF;
--erp-text-sidebar: #5A6E5A;
--erp-text-sidebar-active: #5B7A5E;
--erp-border: #D5DED5;
--erp-border-light: #E5ECE5;
--erp-border-dark: #B8C5B8;
--erp-shadow-xs: 0 1px 2px rgba(30,60,30,0.04);
--erp-shadow-sm: 0 1px 3px rgba(30,60,30,0.06), 0 1px 2px rgba(30,60,30,0.03);
--erp-shadow-md: 0 4px 6px rgba(30,60,30,0.07), 0 2px 4px rgba(30,60,30,0.04);
--erp-shadow-lg: 0 8px 30px rgba(30,60,30,0.10);
--erp-shadow-xl: 0 12px 40px rgba(30,60,30,0.14);
--erp-radius-sm: 8px;
--erp-radius-md: 10px;
--erp-radius-lg: 14px;
--erp-radius-xl: 18px;
--erp-trend-up: #3D7A42;
--erp-trend-down: #A54A4A;
--erp-trend-neutral: #5A6E5A;
--erp-font-heading: 'Noto Sans SC', -apple-system, system-ui, sans-serif;
}
[data-theme='dark'] .erp-stat-card-trend-up { color: #34d399; }
[data-theme='dark'] .erp-stat-card-trend-down { color: #f87171; }
[data-theme='dark'] .erp-stat-card-trend-neutral { color: #94a3b8; }
[data-theme='dark'] .erp-stat-card-trend-label { color: #94a3b8; }
/* --- Global Reset & Base --- */
body {
@@ -156,6 +277,23 @@ body {
-moz-osx-font-smoothing: grayscale;
}
/* Force Ant Design Layout backgrounds to follow theme */
.ant-layout {
background: var(--erp-bg-page) !important;
}
.ant-layout-content {
background: transparent !important;
}
.ant-layout-sider {
background: var(--erp-bg-sidebar) !important;
}
.ant-layout-header {
background: var(--erp-bg-container) !important;
}
.ant-layout-footer {
background: transparent !important;
}
/* --- Smooth Scrolling --- */
* {
scroll-behavior: smooth;
@@ -182,7 +320,7 @@ body {
/* --- Selection --- */
::selection {
background-color: rgba(37, 99, 235, 0.15);
background-color: var(--erp-primary-bg-subtle);
color: var(--erp-text-primary);
}
@@ -546,16 +684,16 @@ body {
}
.erp-sidebar-menu .ant-menu-item-selected {
background: #eff6ff !important;
color: #2563eb !important;
background: var(--erp-bg-sidebar-active) !important;
color: var(--erp-text-sidebar-active) !important;
}
.erp-sidebar-menu .ant-menu-item-selected .anticon {
color: #2563eb !important;
color: var(--erp-text-sidebar-active) !important;
}
.erp-sidebar-menu .ant-menu-item:not(.ant-menu-item-selected):hover {
background: #f1f5f9 !important;
background: var(--erp-bg-sidebar-hover) !important;
}
/* Sidebar group label */
@@ -565,17 +703,17 @@ body {
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.8px;
color: #94a3b8;
color: var(--erp-text-tertiary);
}
/* ====================================================================
* MainLayout — CSS classes replacing inline styles
* ==================================================================== */
/* Sider — White sidebar, Soft UI style */
/* Sider */
.erp-sider-dark {
background: #ffffff !important;
border-right: 1px solid #e2e8f0 !important;
background: var(--erp-bg-sidebar) !important;
border-right: 1px solid var(--erp-border) !important;
position: fixed !important;
left: 0;
top: 0;
@@ -584,25 +722,16 @@ body {
overflow: auto;
}
[data-theme='dark'] .erp-sider-dark {
background: #0f172a !important;
border-right: 1px solid #334155 !important;
}
/* Logo */
.erp-sidebar-logo {
height: 56px;
display: flex;
align-items: center;
padding: 0 20px;
border-bottom: 1px solid #e2e8f0;
border-bottom: 1px solid var(--erp-border);
cursor: pointer;
}
[data-theme='dark'] .erp-sidebar-logo {
border-bottom: 1px solid #334155;
}
.ant-layout-sider-collapsed .erp-sidebar-logo {
justify-content: center;
padding: 0;
@@ -612,7 +741,7 @@ body {
width: 28px;
height: 28px;
border-radius: var(--erp-radius-sm);
background: #2563eb;
background: var(--erp-primary);
display: flex;
align-items: center;
justify-content: center;
@@ -624,17 +753,13 @@ body {
.erp-sidebar-logo-text {
margin-left: 10px;
color: #0f172a;
color: var(--erp-text-primary);
font-size: 15px;
font-weight: 700;
letter-spacing: -0.3px;
white-space: nowrap;
}
[data-theme='dark'] .erp-sidebar-logo-text {
color: rgba(255, 255, 255, 0.95);
}
/* Sidebar menu item */
.erp-sidebar-item {
display: flex;
@@ -644,7 +769,7 @@ body {
padding: 0 12px;
border-radius: var(--erp-radius-md);
cursor: pointer;
color: #475569;
color: var(--erp-text-sidebar);
font-size: 14px;
font-weight: 400;
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
@@ -657,30 +782,16 @@ body {
}
.erp-sidebar-item:hover:not(.erp-sidebar-item-active) {
background: #f1f5f9;
color: #0f172a;
}
[data-theme='dark'] .erp-sidebar-item {
color: #94a3b8;
}
[data-theme='dark'] .erp-sidebar-item:hover:not(.erp-sidebar-item-active) {
background: #1e293b;
color: rgba(255, 255, 255, 0.95);
background: var(--erp-bg-sidebar-hover);
color: var(--erp-text-primary);
}
.erp-sidebar-item-active {
background: #eff6ff;
color: #2563eb;
background: var(--erp-bg-sidebar-active);
color: var(--erp-text-sidebar-active);
font-weight: 500;
}
[data-theme='dark'] .erp-sidebar-item-active {
background: rgba(37, 99, 235, 0.15);
color: #60a5fa;
}
.erp-sidebar-item-icon {
font-size: 16px;
display: flex;
@@ -700,7 +811,7 @@ body {
padding: 0 12px;
border-radius: var(--erp-radius-md);
cursor: pointer;
color: #94a3b8;
color: var(--erp-text-tertiary);
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
@@ -710,25 +821,12 @@ body {
}
.erp-sidebar-submenu-title:hover {
background: #f1f5f9;
color: #475569;
}
[data-theme='dark'] .erp-sidebar-submenu-title {
color: #64748b;
}
[data-theme='dark'] .erp-sidebar-submenu-title:hover {
background: #1e293b;
color: #94a3b8;
background: var(--erp-bg-sidebar-hover);
color: var(--erp-text-secondary);
}
.erp-sidebar-submenu-title-active {
color: #2563eb;
}
[data-theme='dark'] .erp-sidebar-submenu-title-active {
color: #60a5fa;
color: var(--erp-text-sidebar-active);
}
.erp-sidebar-submenu-arrow {
@@ -750,12 +848,10 @@ body {
/* Main layout */
.erp-main-layout {
background: var(--erp-bg-page) !important;
transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.erp-main-layout-light { background: #f8fafc; }
.erp-main-layout-dark { background: #0f172a; }
/* Header */
.erp-header {
height: 56px !important;
@@ -767,17 +863,8 @@ body {
top: 0;
z-index: 99;
line-height: 56px !important;
}
.erp-header-light {
background: #ffffff !important;
border-bottom: 1px solid #e2e8f0;
box-shadow: none;
}
.erp-header-dark {
background: #1e293b !important;
border-bottom: 1px solid #334155;
background: var(--erp-bg-container) !important;
border-bottom: 1px solid var(--erp-border) !important;
box-shadow: none;
}
@@ -790,24 +877,20 @@ body {
justify-content: center;
cursor: pointer;
transition: all 0.15s ease;
color: #475569;
color: var(--erp-text-secondary);
will-change: background;
}
.erp-header-light .erp-header-btn { color: #475569; }
.erp-header-dark .erp-header-btn { color: #94a3b8; }
.erp-header-btn:hover { background: #f1f5f9; }
.erp-header-dark .erp-header-btn:hover { background: #334155; }
.erp-header-btn:hover { background: var(--erp-bg-spotlight); }
.erp-header-title { font-size: 15px; font-weight: 600; }
.erp-text-light { color: #0f172a; }
.erp-text-dark { color: rgba(255, 255, 255, 0.95); }
.erp-text-light-secondary { color: #475569; }
.erp-text-dark-secondary { color: #94a3b8; }
.erp-header-title {
font-size: 15px;
font-weight: 600;
color: var(--erp-text-primary);
font-family: var(--erp-font-heading);
}
.erp-header-divider { width: 1px; height: 24px; margin: 0 8px; }
.erp-header-divider-light { background: rgba(0, 0, 0, 0.06); }
.erp-header-divider-dark { background: rgba(255, 255, 255, 0.06); }
.erp-header-divider { width: 1px; height: 24px; margin: 0 8px; background: var(--erp-border-light); }
/* User avatar */
.erp-header-user {
@@ -820,20 +903,17 @@ body {
transition: all 0.15s ease;
}
.erp-header-user:hover { background: #f1f5f9; }
.erp-header-dark .erp-header-user:hover { background: #334155; }
.erp-header-user:hover { background: var(--erp-bg-spotlight); }
.erp-user-avatar {
background: #2563eb !important;
background: var(--erp-primary) !important;
font-size: 13px !important;
}
.erp-user-name { font-size: 13px; font-weight: 500; }
.erp-user-name { font-size: 13px; font-weight: 500; color: var(--erp-text-secondary); }
/* Footer */
.erp-footer { text-align: center; padding: 12px 24px !important; background: transparent !important; font-size: 12px; }
.erp-footer-light { color: #94a3b8; }
.erp-footer-dark { color: #64748b; }
.erp-footer { text-align: center; padding: 12px 24px !important; background: transparent !important; font-size: 12px; color: var(--erp-text-tertiary); }
/* ====================================================================
* Dashboard — Stat Cards & Quick Actions
@@ -864,7 +944,7 @@ body {
left: 0;
right: 0;
height: 3px;
background: var(--card-gradient, linear-gradient(135deg, #2563eb, #60a5fa));
background: var(--card-gradient, linear-gradient(135deg, var(--erp-primary), var(--erp-primary-hover)));
}
.erp-stat-card-body {
@@ -895,7 +975,7 @@ body {
width: 48px;
height: 48px;
border-radius: var(--erp-radius-lg);
background: var(--card-icon-bg, rgba(37, 99, 235, 0.08));
background: var(--card-icon-bg, var(--erp-primary-bg-subtle));
display: flex;
align-items: center;
justify-content: center;
@@ -913,7 +993,7 @@ body {
.erp-section-icon {
font-size: 16px;
color: #2563eb;
color: var(--erp-primary);
}
.erp-section-title {
@@ -936,17 +1016,8 @@ body {
}
.erp-quick-action:hover {
background: #eff6ff;
border-color: var(--action-color, #2563eb);
}
[data-theme='dark'] .erp-quick-action {
background: #0f172a;
}
[data-theme='dark'] .erp-quick-action:hover {
background: #1e293b;
border-color: var(--action-color, #2563eb);
background: var(--erp-primary-bg-subtle);
border-color: var(--action-color, var(--erp-primary));
}
.erp-quick-action-icon {
@@ -956,8 +1027,8 @@ body {
display: flex;
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--action-color, #2563eb) 8%, transparent);
color: var(--action-color, #2563eb);
background: color-mix(in srgb, var(--action-color, var(--erp-primary)) 8%, transparent);
color: var(--action-color, var(--erp-primary));
font-size: 16px;
flex-shrink: 0;
}
@@ -1008,12 +1079,12 @@ body {
font-weight: 500;
}
.erp-stat-card-trend-up { color: #059669; }
.erp-stat-card-trend-down { color: #dc2626; }
.erp-stat-card-trend-neutral { color: #475569; }
.erp-stat-card-trend-up { color: var(--erp-trend-up); }
.erp-stat-card-trend-down { color: var(--erp-trend-down); }
.erp-stat-card-trend-neutral { color: var(--erp-trend-neutral); }
.erp-stat-card-trend-label {
color: #475569;
color: var(--erp-text-secondary);
font-weight: 400;
}
@@ -1046,8 +1117,8 @@ body {
display: flex;
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--action-color, #2563eb) 8%, transparent);
color: var(--action-color, #2563eb);
background: color-mix(in srgb, var(--action-color, var(--erp-primary)) 8%, transparent);
color: var(--action-color, var(--erp-primary));
font-size: 18px;
flex-shrink: 0;
transition: transform 0.15s ease;
@@ -1075,7 +1146,7 @@ body {
padding: 12px 16px;
border-radius: var(--erp-radius-md);
background: var(--erp-bg-spotlight);
border-left: 3px solid var(--task-color, #2563eb);
border-left: 3px solid var(--task-color, var(--erp-primary));
cursor: pointer;
transition: all 0.15s ease;
}
@@ -1093,7 +1164,7 @@ body {
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--task-color, #2563eb) 8%, transparent);
color: var(--task-color, #2563eb);
color: var(--task-color, var(--erp-primary));
font-size: 14px;
flex-shrink: 0;
}
@@ -1115,7 +1186,7 @@ body {
gap: 12px;
margin-top: 2px;
font-size: var(--erp-font-size-xs);
color: #94a3b8;
color: var(--erp-text-tertiary);
}
.erp-task-priority {
@@ -1127,13 +1198,9 @@ body {
font-weight: 600;
}
.erp-task-priority-high { background: #fef2f2; color: #dc2626; }
.erp-task-priority-medium { background: #fffbeb; color: #d97706; }
.erp-task-priority-low { background: #ecfdf5; color: #059669; }
[data-theme='dark'] .erp-task-priority-high { background: rgba(220, 38, 38, 0.15); color: #f87171; }
[data-theme='dark'] .erp-task-priority-medium { background: rgba(217, 119, 6, 0.15); color: #fbbf24; }
[data-theme='dark'] .erp-task-priority-low { background: rgba(5, 150, 105, 0.15); color: #34d399; }
.erp-task-priority-high { background: var(--erp-error-bg); color: var(--erp-error); }
.erp-task-priority-medium { background: var(--erp-warning-bg); color: var(--erp-warning); }
.erp-task-priority-low { background: var(--erp-success-bg); color: var(--erp-success); }
/* Activity Timeline */
.erp-activity-list {
@@ -1189,14 +1256,10 @@ body {
.erp-activity-time {
font-size: 11px;
color: #94a3b8;
color: var(--erp-text-tertiary);
margin-top: 2px;
}
[data-theme='dark'] .erp-activity-time {
color: #64748b;
}
/* Empty State */
.erp-empty-state {
display: flex;