ym923 | bfa214f | 2025-06-09 18:10:32 +0800 | [diff] [blame] | 1 | import React, { useState } from 'react'; |
| 2 | import { Layout, Menu, Button } from 'antd'; |
| 3 | import { |
| 4 | FileTextOutlined, |
| 5 | FlagOutlined, |
| 6 | TagsOutlined, |
| 7 | DeploymentUnitOutlined, |
| 8 | HomeOutlined, |
| 9 | FileSearchOutlined |
| 10 | } from '@ant-design/icons'; |
| 11 | import { useNavigate } from 'react-router-dom'; |
| 12 | import PostAdminPanel from '../components/PostAdminPanel'; |
| 13 | import AdminActivityManager from '../components/AdminActivityManager'; |
| 14 | import ActivityAdminPanel from '../components/ActivityAdminPanel'; |
| 15 | import RequestAdminPanel from '../components/RequestAdminPanel'; |
| 16 | import ComplainAdminPanel from '../components/ComplainAdminPanel'; |
| 17 | import TorrentManagement from '../components/torrentmanage'; |
| 18 | import UserManagement from '../components/UserManagement'; |
| 19 | |
| 20 | const { Header, Sider, Content, Footer } = Layout; |
| 21 | |
| 22 | const AdminPage = () => { |
| 23 | const navigate = useNavigate(); |
| 24 | const [selectedKey, setSelectedKey] = useState('posts'); |
| 25 | |
| 26 | const renderContent = () => { |
| 27 | switch (selectedKey) { |
| 28 | case 'posts': |
| 29 | return <PostAdminPanel />; |
| 30 | case 'activities': |
| 31 | return <ActivityAdminPanel />; |
| 32 | case 'requests': |
| 33 | return <RequestAdminPanel />; |
| 34 | case 'complain': |
| 35 | return <ComplainAdminPanel />; |
| 36 | case 'torrent': |
| 37 | return <TorrentManagement/>; |
| 38 | case 'user': |
| 39 | return <UserManagement/>; |
| 40 | default: |
| 41 | return null; |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | return ( |
| 46 | <Layout style={{ minHeight: '100vh' }}> |
| 47 | {/* 侧边栏 */} |
| 48 | <Sider breakpoint="lg" collapsedWidth="0" theme="dark"> |
| 49 | <div className="logo" style={{ |
| 50 | height: 64, |
| 51 | display: 'flex', |
| 52 | alignItems: 'center', |
| 53 | justifyContent: 'center', |
| 54 | fontSize: 22, |
| 55 | color: 'white', |
| 56 | fontWeight: 'bold', |
| 57 | }}> |
| 58 | 后台管理 |
| 59 | </div> |
| 60 | <Menu |
| 61 | theme="dark" |
| 62 | mode="inline" |
| 63 | selectedKeys={[selectedKey]} |
| 64 | onClick={({ key }) => setSelectedKey(key)} |
| 65 | items={[ |
| 66 | { |
| 67 | key: 'posts', |
| 68 | icon: <FileTextOutlined />, |
| 69 | label: '帖子管理', |
| 70 | }, |
| 71 | { |
| 72 | key: 'activities', |
| 73 | icon: <DeploymentUnitOutlined />, |
| 74 | label: '公告管理', |
| 75 | }, |
| 76 | { |
| 77 | key: 'requests', |
| 78 | icon: <FileSearchOutlined />, |
| 79 | label: '求助帖管理', |
| 80 | }, |
| 81 | { |
| 82 | key: 'complain', |
| 83 | icon: <FlagOutlined />, |
| 84 | label: '举报管理', |
| 85 | }, |
| 86 | { |
| 87 | key: 'torrent', |
| 88 | icon: <TagsOutlined />, |
| 89 | label: '种子管理', |
| 90 | }, |
| 91 | { |
| 92 | key: 'user', |
| 93 | icon: <TagsOutlined />, |
| 94 | label: '用户管理', |
| 95 | }, |
| 96 | ]} |
| 97 | /> |
| 98 | <div style={{ padding: 16 }}> |
| 99 | <Button |
| 100 | type="primary" |
| 101 | block |
| 102 | icon={<HomeOutlined />} |
| 103 | onClick={() => navigate('/')} |
| 104 | > |
| 105 | 返回首页 |
| 106 | </Button> |
| 107 | </div> |
| 108 | </Sider> |
| 109 | |
| 110 | {/* 内容区 */} |
| 111 | <Layout> |
| 112 | <Header style={{ background: '#fff', padding: '0 24px', fontSize: 20 }}> |
| 113 | {(() => { |
| 114 | switch (selectedKey) { |
| 115 | case 'posts': return '📄 帖子管理'; |
| 116 | case 'activities': return '🎯 公告管理'; |
| 117 | case 'requests': return '🆘 求助帖管理'; |
| 118 | case 'complain': return '🚨 举报管理'; |
| 119 | case 'torrent': return '🧲 种子管理'; |
| 120 | default: return ''; |
| 121 | } |
| 122 | })()} |
| 123 | </Header> |
| 124 | <Content style={{ margin: '24px 16px 0', padding: 24, background: '#fff', minHeight: '85vh' }}> |
| 125 | {renderContent()} |
| 126 | </Content> |
| 127 | <Footer style={{ textAlign: 'center' }}> |
| 128 | PT管理系统 ©{new Date().getFullYear()} Created by Jiaxin Liu, Man Yang, Shuo Wang |
| 129 | </Footer> |
| 130 | </Layout> |
| 131 | </Layout> |
| 132 | ); |
| 133 | }; |
| 134 | |
| 135 | export default AdminPage; |