import { Tabs, Layout, Menu, Space } from 'antd';
import { useAuth } from '../../contexts/AuthContext.tsx';
import { useState, type SetStateAction } from 'react';
import UserProfile from './UserProfile.tsx';
import useIsMobile from '../../hooks/useIsMobile';
import {
UserOutlined,
BgColorsOutlined,
BellOutlined,
} from '@ant-design/icons';
const { TabPane } = Tabs;
const { Sider, Content } = Layout;
function Settings() {
useAuth();
const isMobile = useIsMobile();
const [activeMenu, setActiveMenu] = useState('profile');
const [activeTab, setActiveTab] = useState('basic');
const renderContent = () => {
switch (activeMenu) {
case 'profile':
return (
);
case 'appearance':
return (
);
case 'notifications':
return (
);
default:
return null;
}
};
// 菜单项配置
const menuItems = [
{
key: 'profile',
icon: ,
label: '个人资料',
},
{
key: 'appearance',
icon: ,
label: '外观设置',
},
{
key: 'notifications',
icon: ,
label: '通知设置',
},
].filter(Boolean);
const handleMenuChange = (key: SetStateAction) => {
setActiveMenu(key);
switch (key) {
case 'profile':
setActiveTab('basic');
break;
case 'system':
setActiveTab('basic');
break;
case 'appearance':
setActiveTab('theme');
break;
case 'notifications':
setActiveTab('types');
break;
}
};
if (isMobile) {
return (
handleMenuChange(key)}
centered
size="large"
tabBarStyle={{
marginBottom: 16,
fontWeight: 500,
backgroundColor: '#f5f5f5',
padding: '8px 0',
borderRadius: '8px'
}}
>
{menuItems.map((item) => (
{item?.icon}
{item?.label}
}
key={item?.key || ''}
>
{renderContent()}
))}
);
}
// 桌面版使用侧边栏
return (
{renderContent()}
);
}
export default Settings;