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:
@@ -1,15 +1,11 @@
|
||||
import { theme } from 'antd';
|
||||
import { useAppStore } from '../stores/app';
|
||||
|
||||
/**
|
||||
* 判断当前是否处于暗色主题模式。
|
||||
*
|
||||
* 通过 antd design token 的 colorBgContainer 色值检测,
|
||||
* 统一替代各页面中重复的 `token.colorBgContainer === '#111827'` 内联判断。
|
||||
* 通过 store 的主题名称判断,替代旧的 token 色值检测,
|
||||
* 支持多主题系统(blue / warm / dark / emerald)。
|
||||
*/
|
||||
export function useThemeMode(): boolean {
|
||||
const { token } = theme.useToken();
|
||||
return (
|
||||
token.colorBgContainer === '#111827' ||
|
||||
token.colorBgContainer === 'rgb(17, 24, 39)'
|
||||
);
|
||||
return useAppStore((s) => s.theme) === 'dark';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user