feat: 实现多主题系统,支持6套主题切换和设置页面
重构 ThemeContext 为多主题模型(themeId + followSystem + systemIsDark), 新增设置页面(主题下拉栏 + 跟随系统开关),移除旧 ThemeToggle 按钮, 引入 antd-style 和 clsx 依赖支持 MUI/shadcn/Bootstrap/玻璃主题。
This commit is contained in:
40
frontend/src/pages/Settings/index.tsx
Normal file
40
frontend/src/pages/Settings/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Card, Select, Switch, Space, Typography } from 'antd';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { themeOptions, type ThemeId } from '@/themes';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
export function SettingsPage() {
|
||||
const { themeId, followSystem, setThemeId, setFollowSystem } = useTheme();
|
||||
|
||||
return (
|
||||
<Space direction="vertical" size="large" style={{ width: '100%' }}>
|
||||
<Card title="主题">
|
||||
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<Text strong>主题</Text>
|
||||
</div>
|
||||
<Select
|
||||
value={themeId}
|
||||
onChange={(value: ThemeId) => setThemeId(value)}
|
||||
style={{ width: 180 }}
|
||||
options={themeOptions.map((opt) => ({
|
||||
value: opt.id,
|
||||
label: opt.label,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<Text strong>跟随系统</Text>
|
||||
<br />
|
||||
<Text type="secondary">开启后自动跟随系统暗色模式</Text>
|
||||
</div>
|
||||
<Switch checked={followSystem} onChange={setFollowSystem} />
|
||||
</div>
|
||||
</Space>
|
||||
</Card>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user