feat: 实现多主题系统,支持6套主题切换和设置页面
重构 ThemeContext 为多主题模型(themeId + followSystem + systemIsDark), 新增设置页面(主题下拉栏 + 跟随系统开关),移除旧 ThemeToggle 按钮, 引入 antd-style 和 clsx 依赖支持 MUI/shadcn/Bootstrap/玻璃主题。
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
import { useState } from 'react';
|
||||
import { Layout, Menu } from 'antd';
|
||||
import { CloudServerOutlined, BarChartOutlined } from '@ant-design/icons';
|
||||
import { CloudServerOutlined, BarChartOutlined, SettingOutlined } from '@ant-design/icons';
|
||||
import { Outlet, useLocation, useNavigate } from 'react-router';
|
||||
import { ThemeToggle } from '@/components/ThemeToggle';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
|
||||
const menuItems = [
|
||||
{ key: '/providers', label: '供应商管理', icon: <CloudServerOutlined /> },
|
||||
{ key: '/stats', label: '用量统计', icon: <BarChartOutlined /> },
|
||||
{ type: 'divider' as const },
|
||||
{ key: '/settings', label: '设置', icon: <SettingOutlined /> },
|
||||
];
|
||||
|
||||
export function AppLayout() {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const { mode } = useTheme();
|
||||
const { effectiveThemeId } = useTheme();
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
|
||||
const getPageTitle = () => {
|
||||
if (location.pathname === '/providers') return '供应商管理';
|
||||
if (location.pathname === '/stats') return '用量统计';
|
||||
if (location.pathname === '/settings') return '设置';
|
||||
return 'AI Gateway';
|
||||
};
|
||||
|
||||
@@ -62,27 +64,16 @@ export function AppLayout() {
|
||||
onClick={({ key }) => navigate(key)}
|
||||
style={{ flex: 1, overflow: 'auto' }}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
padding: '16px 0',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
borderTop: '1px solid rgba(255, 255, 255, 0.1)',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</div>
|
||||
</Layout.Sider>
|
||||
<Layout style={{ marginLeft: collapsed ? 80 : 200, transition: 'all 0.2s' }}>
|
||||
<Layout.Header
|
||||
style={{
|
||||
padding: '0 2rem',
|
||||
background: mode === 'dark' ? '#141414' : '#fff',
|
||||
background: effectiveThemeId === 'dark' ? '#141414' : '#fff',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
borderBottom: mode === 'dark' ? '1px solid #303030' : '1px solid #f0f0f0',
|
||||
borderBottom: effectiveThemeId === 'dark' ? '1px solid #303030' : '1px solid #f0f0f0',
|
||||
}}
|
||||
>
|
||||
<h1 style={{ margin: 0, fontSize: '1.25rem' }}>{getPageTitle()}</h1>
|
||||
|
||||
Reference in New Issue
Block a user