2025-12-19 20:01:15 +08:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { Layout, Menu, theme, Button } from 'antd';
|
2025-12-18 10:45:13 +08:00
|
|
|
import { BrowserRouter as Router, Routes, Route, Link } from 'react-router-dom';
|
2025-12-20 08:20:51 +08:00
|
|
|
import { BarChartOutlined, DatabaseOutlined, CloudServerOutlined, MenuUnfoldOutlined, MenuFoldOutlined, EyeOutlined } from '@ant-design/icons';
|
2025-12-18 10:45:13 +08:00
|
|
|
import Dashboard from './pages/Dashboard';
|
|
|
|
|
import DeviceManagement from './pages/DeviceManagement';
|
|
|
|
|
import RackManagement from './pages/RackManagement';
|
|
|
|
|
import RoomManagement from './pages/RoomManagement';
|
|
|
|
|
import DeviceFieldManagement from './pages/DeviceFieldManagement';
|
2025-12-20 08:20:51 +08:00
|
|
|
import RackVisualization from './pages/RackVisualization';
|
2025-12-18 10:45:13 +08:00
|
|
|
|
|
|
|
|
|
2025-12-19 15:05:31 +08:00
|
|
|
const { Content, Sider } = Layout;
|
2025-12-18 10:45:13 +08:00
|
|
|
|
|
|
|
|
function App() {
|
2025-12-19 20:01:15 +08:00
|
|
|
const [collapsed, setCollapsed] = useState(false);
|
2025-12-18 10:45:13 +08:00
|
|
|
const {
|
|
|
|
|
token: { colorBgContainer, borderRadiusLG },
|
|
|
|
|
} = theme.useToken();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Router>
|
|
|
|
|
<Layout>
|
2025-12-19 20:01:15 +08:00
|
|
|
<Sider
|
|
|
|
|
width={200}
|
|
|
|
|
collapsedWidth={80}
|
|
|
|
|
collapsed={collapsed}
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: colorBgContainer,
|
|
|
|
|
boxShadow: '2px 0 8px rgba(0,0,0,0.08)'
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* 自定义收起/展开按钮 */}
|
|
|
|
|
<div style={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
height: 64,
|
|
|
|
|
borderBottom: '1px solid #f0f0f0',
|
|
|
|
|
marginBottom: 16
|
|
|
|
|
}}>
|
|
|
|
|
<Button
|
|
|
|
|
type="text"
|
|
|
|
|
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
|
|
|
|
|
onClick={() => setCollapsed(!collapsed)}
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
padding: '8px',
|
|
|
|
|
borderRadius: 4,
|
|
|
|
|
transition: 'all 0.3s',
|
|
|
|
|
'&:hover': {
|
|
|
|
|
backgroundColor: '#e6f7ff'
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-12-18 10:45:13 +08:00
|
|
|
<Menu
|
|
|
|
|
mode="inline"
|
|
|
|
|
defaultSelectedKeys={['1']}
|
2025-12-19 20:01:15 +08:00
|
|
|
style={{
|
|
|
|
|
height: 'calc(100% - 80px)',
|
|
|
|
|
borderRight: 0,
|
|
|
|
|
backgroundColor: 'transparent'
|
|
|
|
|
}}
|
2025-12-18 10:45:13 +08:00
|
|
|
items={[
|
|
|
|
|
{
|
|
|
|
|
key: '1',
|
|
|
|
|
icon: <BarChartOutlined />,
|
|
|
|
|
label: <Link to="/">仪表盘</Link>,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '2',
|
|
|
|
|
icon: <CloudServerOutlined />,
|
|
|
|
|
label: <Link to="/devices">设备管理</Link>,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '3',
|
|
|
|
|
icon: <DatabaseOutlined />,
|
|
|
|
|
label: <Link to="/racks">机柜管理</Link>,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '4',
|
|
|
|
|
icon: <DatabaseOutlined />,
|
|
|
|
|
label: <Link to="/rooms">机房管理</Link>,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '5',
|
|
|
|
|
icon: <BarChartOutlined />,
|
|
|
|
|
label: <Link to="/fields">字段管理</Link>,
|
|
|
|
|
},
|
2025-12-20 08:20:51 +08:00
|
|
|
{
|
|
|
|
|
key: '6',
|
|
|
|
|
icon: <EyeOutlined />,
|
|
|
|
|
label: <Link to="/visualization">机柜可视化</Link>,
|
|
|
|
|
},
|
2025-12-18 10:45:13 +08:00
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
</Sider>
|
2025-12-19 15:05:31 +08:00
|
|
|
<Layout style={{ padding: '0 24px 24px' }}>
|
|
|
|
|
<Content
|
|
|
|
|
style={{
|
|
|
|
|
padding: 24,
|
|
|
|
|
margin: 0,
|
|
|
|
|
minHeight: 280,
|
|
|
|
|
background: colorBgContainer,
|
|
|
|
|
borderRadius: borderRadiusLG,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Routes>
|
|
|
|
|
<Route path="/" element={<Dashboard />} />
|
|
|
|
|
<Route path="/devices" element={<DeviceManagement />} />
|
|
|
|
|
<Route path="/racks" element={<RackManagement />} />
|
|
|
|
|
<Route path="/rooms" element={<RoomManagement />} />
|
|
|
|
|
<Route path="/fields" element={<DeviceFieldManagement />} />
|
2025-12-20 08:20:51 +08:00
|
|
|
<Route path="/visualization" element={<RackVisualization />} />
|
2025-12-19 15:05:31 +08:00
|
|
|
</Routes>
|
|
|
|
|
</Content>
|
2025-12-18 10:45:13 +08:00
|
|
|
</Layout>
|
|
|
|
|
</Layout>
|
|
|
|
|
</Router>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|