告警详情和 总览界面 修改 布局调整
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/x-icon" href="./src/assets/logo.png" />
|
||||
<title>机器人智慧服务系统</title>
|
||||
<title>光伏电站智能监控与运维系统</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "机器人智慧服务系统",
|
||||
"name": "光伏电站智能监控与运维系统",
|
||||
"description": "提供设备管理、视频监控、状态预警、警报处理及视频下载功能的一站式机器人智能管理平台。",
|
||||
"requestFramePermissions": [],
|
||||
"majorCapabilities": []
|
||||
|
||||
980
package-lock.json
generated
980
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/charts": "^2.6.7",
|
||||
"@ant-design/icons": "^6.1.1",
|
||||
"@reduxjs/toolkit": "^2.11.2",
|
||||
"@tailwindcss/vite": "^4.1.14",
|
||||
|
||||
@@ -1,36 +1,20 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
Layout,
|
||||
Menu,
|
||||
Button,
|
||||
Avatar,
|
||||
Space,
|
||||
ConfigProvider,
|
||||
theme,
|
||||
Breadcrumb,
|
||||
Badge,
|
||||
message
|
||||
Layout, Menu, Button, Space, ConfigProvider, theme,
|
||||
Breadcrumb, Badge, message
|
||||
} from 'antd';
|
||||
import {
|
||||
DashboardOutlined,
|
||||
ExperimentOutlined,
|
||||
VideoCameraOutlined,
|
||||
BellOutlined,
|
||||
DownloadOutlined,
|
||||
UserOutlined,
|
||||
LogoutOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
MenuFoldOutlined,
|
||||
GlobalOutlined,
|
||||
TeamOutlined,
|
||||
MenuOutlined
|
||||
DashboardOutlined, ExperimentOutlined, VideoCameraOutlined,
|
||||
BellOutlined, DownloadOutlined, UserOutlined, LogoutOutlined,
|
||||
MenuUnfoldOutlined, MenuFoldOutlined, TeamOutlined, MenuOutlined
|
||||
} from '@ant-design/icons';
|
||||
import logo from '../assets/logo.png';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState, useAppDispatch } from '../store';
|
||||
import { logout } from '../store/userSlice';
|
||||
import { getMenuList } from '../api/mune';
|
||||
|
||||
const { Header, Sider, Content } = Layout;
|
||||
|
||||
export default function AppLayout() {
|
||||
@@ -41,6 +25,7 @@ export default function AppLayout() {
|
||||
const location = useLocation();
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const getMenu = () => {
|
||||
getMenuList().then(res => {
|
||||
if (res.code == 200) {
|
||||
@@ -48,12 +33,6 @@ export default function AppLayout() {
|
||||
} else {
|
||||
message.error("获取菜单失败:" + res.msg)
|
||||
}
|
||||
console.log("菜单列表:", res);
|
||||
//if (res.code == 200) {
|
||||
// setMenuList(res.data)
|
||||
//} else {
|
||||
// //message.error("获取菜单失败:"+res.msg)
|
||||
//}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -66,118 +45,103 @@ export default function AppLayout() {
|
||||
const handleLogout = async () => {
|
||||
await dispatch(logout());
|
||||
navigate('/login', { replace: true });
|
||||
|
||||
};
|
||||
|
||||
const menuItems = [
|
||||
{ key: '/', icon: <DashboardOutlined />, label: '概览控制台', roles: ['admin', 'operator', 'viewer'] },
|
||||
{ key: '/', icon: <DashboardOutlined />, label: '总览首页', roles: ['admin', 'operator', 'viewer'] },
|
||||
{ key: '/devices', icon: <ExperimentOutlined />, label: '设备管理', roles: ['admin', 'operator'] },
|
||||
{ key: '/video', icon: <VideoCameraOutlined />, label: '在线视频', roles: ['admin', 'operator', 'viewer'] },
|
||||
{ key: '/alerts', icon: <BellOutlined />, label: '警报中心', roles: ['admin', 'operator'] },
|
||||
{ key: '/alerts', icon: <BellOutlined />, label: '告警中心', roles: ['admin', 'operator'] },
|
||||
{ key: '/downloads', icon: <DownloadOutlined />, label: '视频下载', roles: ['admin', 'operator'] },
|
||||
{ key: '/serialNumGenerate', icon: <UserOutlined />, label: '序列号生成', roles: ['admin'] },
|
||||
{ key: '/users', icon: <TeamOutlined />, label: '用户管理', roles: ['admin'] },
|
||||
|
||||
{ key: '/roles', icon: <UserOutlined />, label: '角色管理', roles: ['admin'] },
|
||||
|
||||
{
|
||||
key: '/menuList',
|
||||
icon: <MenuOutlined />,
|
||||
label: '菜单管理',
|
||||
roles: ['admin']
|
||||
},
|
||||
{
|
||||
key: '/organization',
|
||||
icon: <MenuOutlined />,
|
||||
label: '组织管理',
|
||||
roles: ['admin']
|
||||
},
|
||||
{
|
||||
key: '/station',
|
||||
icon: <MenuOutlined />,
|
||||
label: '场站管理',
|
||||
roles: ['admin']
|
||||
}
|
||||
{ key: '/menuList', icon: <MenuOutlined />, label: '菜单管理', roles: ['admin'] },
|
||||
{ key: '/organization', icon: <MenuOutlined />, label: '组织管理', roles: ['admin'] },
|
||||
{ key: '/station', icon: <MenuOutlined />, label: '场站管理', roles: ['admin'] }
|
||||
];
|
||||
|
||||
const filteredMenu = menuItems
|
||||
//.filter(item => item.roles.includes(userInfo?.role));
|
||||
|
||||
const currentPathLabel = menuItems.find(i => i.key === location.pathname)?.label || '概览控制台';
|
||||
const filteredMenu = menuItems;
|
||||
const currentPathLabel = menuItems.find(i => i.key === location.pathname)?.label || '总览首页';
|
||||
|
||||
return (
|
||||
<ConfigProvider
|
||||
theme={{
|
||||
algorithm: theme.defaultAlgorithm,
|
||||
token: {
|
||||
colorPrimary: '#1890ff',
|
||||
borderRadius: 2,
|
||||
},
|
||||
token: { colorPrimary: '#1890ff', borderRadius: 2 },
|
||||
components: {
|
||||
Layout: {
|
||||
headerBg: '#fff',
|
||||
siderBg: '#001529',
|
||||
},
|
||||
Menu: {
|
||||
darkItemBg: '#001529',
|
||||
darkItemSelectedBg: '#1890ff',
|
||||
}
|
||||
Layout: { headerBg: '#fff', siderBg: '#001529' },
|
||||
Menu: { darkItemBg: '#001529', darkItemSelectedBg: '#1890ff' }
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
<Layout style={{ minHeight: '100vh' }}>
|
||||
<Sider trigger={null} collapsible collapsed={collapsed} width={220} theme="dark">
|
||||
<Layout style={{ maxHeight: '100vh' }}>
|
||||
{/* 顶部通栏 */}
|
||||
<Header className=" px-6 flex items-center justify-between shadow-sm border-b border-gray-100 h-0 shrink-0 z-10" style={{
|
||||
background: '#0837a8',
|
||||
color: '#fff',
|
||||
height: "50px"
|
||||
}}>
|
||||
<div className="h-16 flex items-center justify-center border-b border-white/10 overflow-hidden">
|
||||
<Space size="small" className="px-2">
|
||||
<img src={logo} alt="Logo" style={{ width: "24px", height: "24px" }} />
|
||||
{!collapsed && <span className="text-white font-bold text-lg whitespace-nowrap">机器人智慧服务系统</span>}
|
||||
{!collapsed && (
|
||||
<span className="text-white font-bold text-lg whitespace-nowrap">
|
||||
光伏电站智能监控与运维系统
|
||||
</span>
|
||||
)}
|
||||
</Space>
|
||||
</div>
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="inline"
|
||||
selectedKeys={[location.pathname]}
|
||||
items={filteredMenu}
|
||||
onClick={({ key }) => navigate(key)}
|
||||
/>
|
||||
|
||||
</Sider>
|
||||
<div className="flex items-center gap-6">
|
||||
<div className="flex items-center gap-3 pr-6 border-r border-gray-100">
|
||||
<span className="text-gray-400 font-mono text-[13px]">{time}</span>
|
||||
<Badge status="success" />
|
||||
<span className="text-white font-medium">{userInfo?.username}</span>
|
||||
</div>
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
icon={<LogoutOutlined />}
|
||||
onClick={handleLogout}
|
||||
className="font-bold text-[12px] uppercase"
|
||||
>
|
||||
退出登录
|
||||
</Button>
|
||||
</div>
|
||||
</Header>
|
||||
|
||||
<Layout>
|
||||
<Header className="px-6 flex items-center justify-between shadow-sm border-b border-gray-100 h-16 bg-white shrink-0 z-10">
|
||||
<div className="flex items-center gap-4">
|
||||
<Button
|
||||
type="text"
|
||||
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
|
||||
onClick={() => setCollapsed(!collapsed)}
|
||||
style={{ fontSize: '16px', width: 40, height: 40 }}
|
||||
/>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ title: '系统首页' },
|
||||
{ title: currentPathLabel }
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{/* 左侧:菜单 + 下部区域 */}
|
||||
<Sider
|
||||
trigger={null}
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
width={220}
|
||||
theme="light"
|
||||
style={{
|
||||
overflow: 'auto', background: '#ffffff',
|
||||
borderRight: '1px solid #e5e7eb',
|
||||
}}
|
||||
>
|
||||
|
||||
<div className="flex items-center gap-6">
|
||||
<div className="flex items-center gap-3 pr-6 border-r border-gray-100">
|
||||
<span className="text-gray-400 font-mono text-[13px]">{time}</span>
|
||||
<Badge status="success" />
|
||||
<span className="text-gray-800 font-medium">{userInfo?.username}</span>
|
||||
</div>
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
icon={<LogoutOutlined />}
|
||||
onClick={handleLogout}
|
||||
className="font-bold text-[12px] uppercase"
|
||||
>
|
||||
退出登录
|
||||
</Button>
|
||||
|
||||
<Menu
|
||||
theme="light"
|
||||
mode="inline"
|
||||
selectedKeys={[location.pathname]}
|
||||
items={filteredMenu}
|
||||
onClick={({ key }) => navigate(key)}
|
||||
/>
|
||||
|
||||
{/* 左侧下方固定区域(你可以放任何内容) */}
|
||||
<div className="p-3 text-white text-xs opacity-70 text-center mt-4">
|
||||
{!collapsed && '快捷操作面板'}
|
||||
</div>
|
||||
</Header>
|
||||
<Content className="p-4 overflow-y-auto bg-[#f4f7f9] min-h-0">
|
||||
</Sider>
|
||||
|
||||
{/* 右侧:主内容 */}
|
||||
<Content className=" overflow-y-auto bg-[#f4f7f9] min-h-0">
|
||||
<Outlet />
|
||||
</Content>
|
||||
</Layout>
|
||||
|
||||
@@ -1,150 +1,322 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Table,
|
||||
Tag,
|
||||
Input,
|
||||
Button,
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Typography,
|
||||
Space,
|
||||
Statistic
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Table,
|
||||
Tag,
|
||||
Input,
|
||||
Button,
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Typography,
|
||||
Space,
|
||||
Statistic,
|
||||
Select,
|
||||
DatePicker,
|
||||
List,
|
||||
} from 'antd';
|
||||
import {
|
||||
BellOutlined,
|
||||
AlertOutlined,
|
||||
InfoCircleOutlined,
|
||||
SearchOutlined,
|
||||
FilterOutlined,
|
||||
CheckCircleOutlined,
|
||||
SyncOutlined
|
||||
import {
|
||||
BellOutlined,
|
||||
AlertOutlined,
|
||||
SyncOutlined,
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
RiseOutlined,
|
||||
FallOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { ALERTS } from '../constants';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
export default function Alerts() {
|
||||
const columns = [
|
||||
{
|
||||
title: '级别',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
render: (type: string) => {
|
||||
const config = {
|
||||
critical: { color: 'error', text: '紧急', icon: <AlertOutlined /> },
|
||||
warning: { color: 'warning', text: '警告', icon: <BellOutlined /> },
|
||||
info: { color: 'processing', text: '提示', icon: <InfoCircleOutlined /> },
|
||||
}[type] || { color: 'default', text: '其他', icon: <InfoCircleOutlined /> };
|
||||
const [selectedAlert, setSelectedAlert] = useState<any>(null);
|
||||
const AntdCard = Card as any;
|
||||
|
||||
return (
|
||||
<Tag color={config.color} icon={config.icon} bordered={false} style={{ fontWeight: 'bold' }}>
|
||||
{config.text}
|
||||
</Tag>
|
||||
);
|
||||
},
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '设备来源',
|
||||
key: 'device',
|
||||
render: (record: any) => (
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text strong style={{ fontSize: 13 }}>{record.deviceName}</Text>
|
||||
<Text type="secondary" style={{ fontSize: 10, fontFamily: 'monospace' }}>{record.deviceId}</Text>
|
||||
</Space>
|
||||
),
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '内容描述',
|
||||
dataIndex: 'message',
|
||||
key: 'message',
|
||||
render: (text: string) => <Text ellipsis style={{ maxWidth: 300 }}>{text}</Text>,
|
||||
},
|
||||
{
|
||||
title: '发生时间',
|
||||
dataIndex: 'time',
|
||||
key: 'time',
|
||||
render: (time: string) => <Text type="secondary" style={{ fontFamily: 'monospace', fontSize: 11 }}>{time}</Text>,
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'status',
|
||||
render: (record: any) => (
|
||||
record.handled ?
|
||||
<Text type="success" italic style={{ fontSize: 11 }}><CheckCircleOutlined /> 已归档</Text> :
|
||||
<Text type="warning" strong style={{ fontSize: 11 }}><SyncOutlined spin /> 待处理</Text>
|
||||
),
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
align: 'right' as const,
|
||||
render: () => (
|
||||
<Space>
|
||||
<Button type="primary" size="small" style={{ borderRadius: 2 }}>处理</Button>
|
||||
<Button type="default" size="small" style={{ borderRadius: 2 }}>忽略</Button>
|
||||
</Space>
|
||||
),
|
||||
width: 140,
|
||||
},
|
||||
];
|
||||
// 模拟告警数据(和参考图一致)
|
||||
const alertList = [
|
||||
{
|
||||
id: 'AL20250525001',
|
||||
content: '逆变器停机',
|
||||
device: '逆变器 12 (组串式)',
|
||||
level: '严重',
|
||||
time: '2025-05-25 09:18:32',
|
||||
duration: '2小时18分',
|
||||
status: '处理中',
|
||||
handler: '张运维'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525002',
|
||||
content: '发电量下降 > 15%',
|
||||
device: '汇流箱 05',
|
||||
level: '重要',
|
||||
time: '2025-05-25 08:46:11',
|
||||
duration: '3小时50分',
|
||||
status: '处理中',
|
||||
handler: '李工程师'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525003',
|
||||
content: '逆变器温度过高',
|
||||
device: '逆变器 07 (组串式)',
|
||||
level: '重要',
|
||||
time: '2025-05-25 07:32:45',
|
||||
duration: '4小时24分',
|
||||
status: '待处理',
|
||||
handler: '-'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525004',
|
||||
content: '通信中断',
|
||||
device: '气象站 01',
|
||||
level: '一般',
|
||||
time: '2025-05-25 06:51:20',
|
||||
duration: '5小时05分',
|
||||
status: '待处理',
|
||||
handler: '王运维'
|
||||
},
|
||||
{
|
||||
id: 'AL20250525005',
|
||||
content: '数据异常',
|
||||
device: '电表 01 (并网点)',
|
||||
level: '提示',
|
||||
time: '2025-05-25 06:20:18',
|
||||
duration: '3小时36分',
|
||||
status: '已关闭',
|
||||
handler: '赵工程师'
|
||||
},
|
||||
];
|
||||
|
||||
const summary = [
|
||||
{ label: '严重故障', count: ALERTS.filter(a => a.type === 'critical').length, color: '#f5222d', icon: <AlertOutlined />, bgColor: '#fff1f0', borderColor: '#ffa39e' },
|
||||
{ label: '异常警告', count: ALERTS.filter(a => a.type === 'warning').length, color: '#faad14', icon: <BellOutlined />, bgColor: '#fffbe6', borderColor: '#ffe58f' },
|
||||
{ label: '状态提示', count: ALERTS.filter(a => a.type === 'info').length, color: '#1890ff', icon: <InfoCircleOutlined />, bgColor: '#e6f7ff', borderColor: '#91d5ff' },
|
||||
];
|
||||
const columns = [
|
||||
{ title: '告警编号', dataIndex: 'id', key: 'id', width: 120 },
|
||||
{ title: '告警内容', dataIndex: 'content', key: 'content' },
|
||||
{ title: '来源设备', dataIndex: 'device', key: 'device', width: 140 },
|
||||
{
|
||||
title: '告警级别',
|
||||
dataIndex: 'level',
|
||||
key: 'level',
|
||||
width: 80,
|
||||
render: (level: string) => {
|
||||
const colorMap: Record<string, string> = {
|
||||
'严重': 'red',
|
||||
'重要': 'orange',
|
||||
'一般': 'gold',
|
||||
'提示': 'blue'
|
||||
};
|
||||
return <Tag color={colorMap[level]}>{level}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '发生时间', dataIndex: 'time', key: 'time', width: 160 },
|
||||
{ title: '持续时长', dataIndex: 'duration', key: 'duration', width: 100 },
|
||||
{
|
||||
title: '处理状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (status: string) => {
|
||||
const colorMap: Record<string, string> = {
|
||||
'处理中': 'blue',
|
||||
'待处理': 'orange',
|
||||
'已关闭': 'green'
|
||||
};
|
||||
return <Tag color={colorMap[status]}>{status}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 60,
|
||||
render: () => <Button type="link" size="small">查看</Button>
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<Title level={5} style={{ margin: 0 }}>警报中心: 实时检索</Title>
|
||||
<Space>
|
||||
<Input
|
||||
prefix={<SearchOutlined style={{ color: 'rgba(0,0,0,0.25)' }} />}
|
||||
placeholder="搜索设备ID或警报内容..."
|
||||
style={{ width: 250, borderRadius: 2 }}
|
||||
/>
|
||||
<Button icon={<FilterOutlined />} style={{ borderRadius: 2 }}>
|
||||
高级过滤
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
// 顶部统计数据
|
||||
const stats = [
|
||||
{ title: '今日告警总数', value: 36, suffix: '', change: '+28.6%', up: true, extra: '昨日 28', icon: <BellOutlined style={{ color: '#ff4d4f' }} /> },
|
||||
{ title: '严重告警', value: 8, suffix: '', change: '+33.3%', up: true, extra: '昨日 6', icon: <AlertOutlined style={{ color: '#ff4d4f' }} /> },
|
||||
{ title: '处理中', value: 12, suffix: '', change: '+20.0%', up: true, extra: '昨日 10', icon: <SyncOutlined style={{ color: '#fa8c16' }} /> },
|
||||
{ title: '已关闭', value: 16, suffix: '', change: '+45.5%', up: true, extra: '昨日 11', icon: <CheckCircleOutlined style={{ color: '#52c41a' }} /> },
|
||||
{ title: '平均响应时长', value: '18分32秒', suffix: '', change: '-12.6%', up: false, extra: '昨日 21分12秒', icon: <ClockCircleOutlined style={{ color: '#1890ff' }} /> },
|
||||
];
|
||||
|
||||
<Row gutter={16}>
|
||||
{summary.map((item) => (
|
||||
<Col span={8} key={item.label}>
|
||||
<Card
|
||||
size="small"
|
||||
style={{
|
||||
backgroundColor: item.bgColor,
|
||||
borderColor: item.borderColor,
|
||||
borderRadius: 4
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', opacity: 0.7 }}>{item.label}</Text>}
|
||||
value={item.count}
|
||||
valueStyle={{ color: item.color, fontWeight: 900, fontSize: 24 }}
|
||||
prefix={React.cloneElement(item.icon, { style: { opacity: 0.4 } })}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
return (
|
||||
<div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
|
||||
<p className="text-lg font-semibold text-[#000] mb-2">
|
||||
告警中心
|
||||
</p>
|
||||
{/* 顶部筛选栏 */}
|
||||
<AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}>
|
||||
<Row gutter={[16, 16]} align="middle">
|
||||
<Col span={4}>
|
||||
<Select placeholder="告警级别" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '严重', value: 'critical' }, { label: '重要', value: 'important' }, { label: '一般', value: 'normal' }, { label: '提示', value: 'info' }]} />
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Select placeholder="告警类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Select placeholder="设备类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<RangePicker defaultValue={[null, null]} style={{ width: '100%' }} />
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Select placeholder="处理状态" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '处理中', value: 'processing' }, { label: '已关闭', value: 'closed' }]} />
|
||||
</Col>
|
||||
<Col span={24} style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
|
||||
<Input placeholder="请输入告警编号内容" style={{ width: 200 }} />
|
||||
<Button>重置</Button>
|
||||
<Button type="primary">查询</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</AntdCard>
|
||||
|
||||
<Card styles={{ body: { padding: 0 } }} className="overflow-hidden">
|
||||
<Table
|
||||
size="small"
|
||||
columns={columns}
|
||||
dataSource={ALERTS.map(a => ({ ...a, key: a.id }))}
|
||||
pagination={{ pageSize: 12, size: 'small' }}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
{/* 统计卡片 */}
|
||||
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
||||
{stats.map((stat, idx) => (
|
||||
<Col xs={24} sm={12} md={8} lg={4} key={idx}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>}
|
||||
value={stat.value}
|
||||
valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }}
|
||||
prefix={stat.icon}
|
||||
suffix={stat.suffix}
|
||||
/>
|
||||
<div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>{stat.extra}</Text>
|
||||
<Text style={{ fontSize: 12, color: stat.up ? '#ff4d4f' : '#52c41a' }}>
|
||||
{stat.change} {stat.up ? <RiseOutlined /> : <FallOutlined />}
|
||||
</Text>
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
|
||||
<Row gutter={[16, 16]}>
|
||||
{/* 左侧主内容区 */}
|
||||
<Col xs={24} lg={18}>
|
||||
{/* 告警列表 */}
|
||||
<AntdCard size="small" title={
|
||||
<div style={{ display: 'flex', gap: 4, fontSize: 14, fontWeight: 600 }}>
|
||||
<span style={{ color: '#165DFF' }}>告警列表</span>
|
||||
<span style={{ color: '#1f2937' }}>(共36条)</span>
|
||||
</div>
|
||||
} style={{ borderRadius: 8, marginBottom: 16 }}>
|
||||
<Table
|
||||
size="small"
|
||||
columns={columns}
|
||||
dataSource={alertList}
|
||||
pagination={{ pageSize: 10, total: 36, showSizeChanger: true }}
|
||||
rowKey="id"
|
||||
onRow={(record) => ({ onClick: () => setSelectedAlert(record) })}
|
||||
rowSelection={{ selectedRowKeys: selectedAlert ? [selectedAlert.id] : [], type: 'radio' }}
|
||||
/>
|
||||
</AntdCard>
|
||||
|
||||
{/* 底部图表占位(和参考图结构一致) */}
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col xs={24} lg={8}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8 }}>
|
||||
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
趋势图占位
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
<Col xs={24} lg={8}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8 }}>
|
||||
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
占比图占位
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
<Col xs={24} lg={8}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8 }}>
|
||||
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
分布图占位
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
</Row>
|
||||
</Col>
|
||||
|
||||
{/* 右侧告警详情面板 */}
|
||||
<Col xs={24} lg={6}>
|
||||
<AntdCard size="small" style={{ borderRadius: 8, height: '100%' }}>
|
||||
{selectedAlert ? (
|
||||
<div>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
|
||||
<Text strong style={{ fontSize: 16 }}>{selectedAlert.content}</Text>
|
||||
<Tag color="red">{selectedAlert.level}</Tag>
|
||||
</div>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>告警编号 AL20250525001</Text>
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: '#666' }}>
|
||||
<div>来源设备:{selectedAlert.device}(设备类型:逆变器)</div>
|
||||
<div>发生时间:{selectedAlert.time} | 持续时长:{selectedAlert.duration}</div>
|
||||
<div>处理状态:<Tag color="blue">{selectedAlert.status}</Tag> | 负责人:{selectedAlert.handler}</div>
|
||||
<div>当前处理人:{selectedAlert.handler}({selectedAlert.time.split(' ')[0]} 接收)</div>
|
||||
<div>告警描述:逆变器因内部故障自动停机,当前无功率输出。</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>根因分析建议</Text>
|
||||
<List size="small" dataSource={[
|
||||
'逆变器内部保护触发(IGBT/继电器故障)',
|
||||
'交流侧电压异常或并网不稳定',
|
||||
'散热风扇故障导致过温保护'
|
||||
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} />
|
||||
<Button type="primary" size="small" style={{ marginTop: 8 }}>AI 诊断分析</Button>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>相关趋势</Text>
|
||||
<div style={{ height: 100, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
趋势图占位
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>推荐处理措施</Text>
|
||||
<List size="small" dataSource={[
|
||||
'现场检查逆变器告警记录及指示灯状态',
|
||||
'检查散热风扇运行及通风条件',
|
||||
'检查交流侧电压及并网条件',
|
||||
'如无法恢复,建议联系厂家或更换模块'
|
||||
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} />
|
||||
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成工单</Button>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>通知与订阅</Text>
|
||||
<Space direction="vertical" size="small" style={{ width: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<span style={{ fontSize: 12 }}>短信</span>
|
||||
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<span style={{ fontSize: 12 }}>Telegram</span>
|
||||
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<span style={{ fontSize: 12 }}>邮件</span>
|
||||
<span style={{ fontSize: 12, color: '#888' }}>未开启</span>
|
||||
</div>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<Button type="primary" block>标记为已解决</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ textAlign: 'center', padding: '40px 0', color: '#888' }}>请选择一条告警查看详情</div>
|
||||
)}
|
||||
</AntdCard>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ export default function Devices() {
|
||||
</Text>
|
||||
<Title level={4} style={{ margin: '4px 0' }}>{selectedDevice.name}</Title>
|
||||
<Space>
|
||||
<Tag color="blue" bordered={false} style={{ fontSize: 10, fontWeight: 'bold' }}>{selectedDevice.type}</Tag>
|
||||
<Tag color="blue" variant={false} style={{ fontSize: 10, fontWeight: 'bold' }}>{selectedDevice.type}</Tag>
|
||||
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>ID: {selectedDevice.id}</Text>
|
||||
</Space>
|
||||
</div>
|
||||
@@ -194,7 +194,7 @@ export default function Devices() {
|
||||
label: '基本信息',
|
||||
children: (
|
||||
<div className="space-y-6 pt-4 pb-4">
|
||||
<Descriptions column={1} size="small" bordered>
|
||||
<Descriptions column={1} size="small" variant>
|
||||
<Descriptions.Item label="设备名称">{selectedDevice.name}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备 ID">{selectedDevice.id}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备类型">{selectedDevice.type}</Descriptions.Item>
|
||||
@@ -221,22 +221,22 @@ export default function Devices() {
|
||||
<div className="space-y-6 pt-4 pb-4">
|
||||
<Row gutter={[12, 12]}>
|
||||
<Col span={12}>
|
||||
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Statistic title={<Space><ClusterOutlined />负载率</Space>} value={selectedDevice.cpu} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Statistic title={<Space><HeatMapOutlined />核心温度</Space>} value={selectedDevice.temp} suffix="°C" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#f5222d' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Statistic title={<Space><ThunderboltOutlined />剩余能量</Space>} value={selectedDevice.battery} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#52c41a' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
||||
<Statistic title={<Space><DashboardOutlined />系统健康</Space>} value={98.2} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
@@ -1,218 +1,401 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Card,
|
||||
Row,
|
||||
Col,
|
||||
Statistic,
|
||||
Table,
|
||||
Tag,
|
||||
Progress,
|
||||
List,
|
||||
Button,
|
||||
Typography,
|
||||
Space,
|
||||
import {
|
||||
Card,
|
||||
Row,
|
||||
Col,
|
||||
Statistic,
|
||||
Table,
|
||||
Tag,
|
||||
Progress,
|
||||
List,
|
||||
Button,
|
||||
Typography,
|
||||
Space,
|
||||
} from 'antd';
|
||||
import {
|
||||
ThunderboltOutlined,
|
||||
DashboardOutlined,
|
||||
DotChartOutlined,
|
||||
RocketOutlined,
|
||||
BellOutlined,
|
||||
CloudUploadOutlined,
|
||||
import {
|
||||
ThunderboltOutlined,
|
||||
DashboardOutlined,
|
||||
DotChartOutlined,
|
||||
RocketOutlined,
|
||||
BellOutlined,
|
||||
CloudUploadOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { DEVICES, ALERTS } from '../constants';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Line, Column } from '@ant-design/charts';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const AntdCard = Card as any;
|
||||
|
||||
export default function Home() {
|
||||
const navigate = useNavigate();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const stats = [
|
||||
{ title: '芯片温度', value: 32.08, icon: <DashboardOutlined />, color: '#ff4d4f', suffix: '℃' },
|
||||
{ title: '设备电流', value: 0, icon: <ThunderboltOutlined />, color: '#1677ff', suffix: 'A' },
|
||||
{ title: '设备电压', value: 0, icon: <DotChartOutlined />, color: '#fa8c16', suffix: 'V' },
|
||||
{ title: '设备数量', value: DEVICES.length, icon: <RocketOutlined />, color: '#52c41a', suffix: '' },
|
||||
{ title: '告警数量', value: ALERTS.filter(a => !a.handled).length, icon: <BellOutlined />, color: '#ff4d4f', suffix: '' },
|
||||
{ title: '上报事件', value: 1, icon: <CloudUploadOutlined />, color: '#52c41a', suffix: '' },
|
||||
];
|
||||
// 顶部统计卡片数据(和参考图完全一致)
|
||||
const topStats = [
|
||||
{
|
||||
title: '今日发电量',
|
||||
value: 4752,
|
||||
suffix: 'kWh',
|
||||
extra: <span style={{ color: '#52c41a', fontSize: 12 }}>日目标 5,000 kWh</span>,
|
||||
percent: 95,
|
||||
color: '#52c41a'
|
||||
},
|
||||
{
|
||||
title: '当前功率',
|
||||
value: 812.6,
|
||||
suffix: 'kW',
|
||||
extra: <span style={{ color: '#888', fontSize: 12 }}>装机容量 1,000 kWp</span>,
|
||||
color: '#1890ff'
|
||||
},
|
||||
{
|
||||
title: 'Performance Ratio(PR)',
|
||||
value: 82.6,
|
||||
suffix: '%',
|
||||
extra: <span style={{ color: '#888', fontSize: 12 }}>昨日 81.3% 环比 ↑1.3%</span>,
|
||||
color: '#13c2c2'
|
||||
},
|
||||
{
|
||||
title: '系统可用率',
|
||||
value: 99.35,
|
||||
suffix: '%',
|
||||
extra: <span style={{ color: '#888', fontSize: 12 }}>昨日 99.12% 环比 ↑0.23%</span>,
|
||||
color: '#52c41a'
|
||||
},
|
||||
{
|
||||
title: '告警数量',
|
||||
value: 8,
|
||||
extra: <span style={{ color: '#888', fontSize: 12 }}>未处理 5 / 已处理 3</span>,
|
||||
color: '#ff4d4f'
|
||||
},
|
||||
{
|
||||
title: '节省运维成本',
|
||||
value: 36540,
|
||||
prefix: '¥',
|
||||
extra: <span style={{ color: '#888', fontSize: 12 }}>本月累计节省</span>,
|
||||
color: '#faad14'
|
||||
},
|
||||
];
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'Node / 标识',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: (text: string, record: any) => (
|
||||
<Space direction="vertical" size={2}>
|
||||
<Text strong style={{ fontSize: 13 }}>{text}</Text>
|
||||
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>{record.id}</Text>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Status / 状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 110,
|
||||
render: (status: string) => (
|
||||
<Tag
|
||||
color={status === 'online' ? 'success' : status === 'alert' ? 'error' : 'default'}
|
||||
style={{
|
||||
borderRadius: 4,
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
padding: '2px 8px'
|
||||
}}
|
||||
>
|
||||
{status.toUpperCase()}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Batt / 电量',
|
||||
dataIndex: 'battery',
|
||||
key: 'battery',
|
||||
width: 140,
|
||||
render: (percent: number) => (
|
||||
<Progress
|
||||
percent={percent}
|
||||
size="small"
|
||||
status={percent < 20 ? 'exception' : 'active'}
|
||||
strokeColor={percent < 20 ? '#ff4d4f' : '#52c41a'}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Load / 负载',
|
||||
dataIndex: 'cpu',
|
||||
key: 'cpu',
|
||||
width: 100,
|
||||
render: (cpu: number) => (
|
||||
<Text style={{ fontFamily: 'monospace', fontSize: 12 }}>{cpu}%</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Ping / 延迟',
|
||||
key: 'ping',
|
||||
width: 100,
|
||||
align: 'right',
|
||||
render: () => <Text style={{ fontFamily: 'monospace', fontSize: 12 }}>12ms</Text>,
|
||||
},
|
||||
];
|
||||
// 发电趋势图数据
|
||||
const powerTrendData = [
|
||||
{ time: '00:00', actual: 0, forecast: 0 },
|
||||
{ time: '06:00', actual: 200, forecast: 180 },
|
||||
{ time: '09:00', actual: 800, forecast: 750 },
|
||||
{ time: '12:00', actual: 1100, forecast: 1050 },
|
||||
{ time: '15:00', actual: 900, forecast: 920 },
|
||||
{ time: '18:00', actual: 300, forecast: 280 },
|
||||
{ time: '24:00', actual: 0, forecast: 0 },
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: '16px' }}>
|
||||
{/* 统计卡片 */}
|
||||
<Row gutter={[16, 16]}>
|
||||
{stats.map((stat, idx) => (
|
||||
<Col xs={12} sm={12} md={8} lg={4} xl={4} key={idx}>
|
||||
<AntdCard
|
||||
size="small"
|
||||
bordered={false}
|
||||
hoverable
|
||||
style={{
|
||||
borderRadius: 10,
|
||||
boxShadow: '0 2px 12px rgba(0,0,0,0.06)',
|
||||
transition: 'all 0.3s',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px 14px' }}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#666', fontWeight: 500 }}>{stat.title}</span>}
|
||||
value={stat.value}
|
||||
precision={idx === 0 ? 2 : 0}
|
||||
valueStyle={{
|
||||
color: '#1f2329',
|
||||
fontWeight: 600,
|
||||
fontSize: 22,
|
||||
marginTop: 4,
|
||||
}}
|
||||
prefix={React.cloneElement(stat.icon as React.ReactElement, {
|
||||
style: { color: stat.color, fontSize: 16, marginRight: 6 },
|
||||
})}
|
||||
suffix={<span style={{ fontSize: 13, color: '#888' }}>{stat.suffix}</span>}
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
// 辐照度与温度趋势数据
|
||||
const irradianceData = [
|
||||
{ time: '00:00', irradiance: 0, temp: 20 },
|
||||
{ time: '06:00', irradiance: 200, temp: 22 },
|
||||
{ time: '09:00', irradiance: 800, temp: 28 },
|
||||
{ time: '12:00', irradiance: 1050, temp: 35 },
|
||||
{ time: '15:00', irradiance: 750, temp: 32 },
|
||||
{ time: '18:00', irradiance: 200, temp: 26 },
|
||||
{ time: '24:00', irradiance: 0, temp: 21 },
|
||||
];
|
||||
|
||||
<Row gutter={[16, 16]} style={{ marginTop: 4 }}>
|
||||
{/* 设备表格 */}
|
||||
<Col xs={24} lg={16}>
|
||||
<AntdCard
|
||||
title={<span style={{ fontSize: 14, fontWeight: 600 }}>核心节点实时清单</span>}
|
||||
bordered={false}
|
||||
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }}
|
||||
bodyStyle={{ padding: 0 }}
|
||||
>
|
||||
<Table
|
||||
size="middle"
|
||||
columns={columns}
|
||||
dataSource={DEVICES.map(d => ({ ...d, key: d.id }))}
|
||||
pagination={false}
|
||||
onRow={(record) => ({
|
||||
onClick: () => navigate('/devices'),
|
||||
style: { cursor: 'pointer' },
|
||||
})}
|
||||
rowHoverable
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
// 逆变器效率数据
|
||||
const inverterData = [
|
||||
{ name: 'INV-01', value: 98.2 },
|
||||
{ name: 'INV-02', value: 97.6 },
|
||||
{ name: 'INV-03', value: 98.9 },
|
||||
{ name: 'INV-04', value: 97.1 },
|
||||
{ name: 'INV-05', value: 98.0 },
|
||||
];
|
||||
|
||||
{/* 告警列表 */}
|
||||
<Col xs={24} lg={8}>
|
||||
<Card
|
||||
title={<span style={{ fontSize: 14, fontWeight: 600 }}>当日重点警报</span>}
|
||||
extra={
|
||||
<Button type="text" danger size="small" style={{ fontWeight: 500 }}>
|
||||
一键清除
|
||||
</Button>
|
||||
}
|
||||
bordered={false}
|
||||
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }}
|
||||
bodyStyle={{ padding: 0, height: 460, overflowY: 'auto' }}
|
||||
>
|
||||
<List
|
||||
dataSource={ALERTS.slice(0, 10)}
|
||||
renderItem={(alert) => (
|
||||
<List.Item
|
||||
style={{
|
||||
padding: '12px 16px',
|
||||
borderBottom: '1px solid #f5f5f5',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
hoverable
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
|
||||
<Tag
|
||||
color={alert.type === 'critical' ? 'error' : alert.type === 'warning' ? 'warning' : 'processing'}
|
||||
style={{
|
||||
borderRadius: 4,
|
||||
fontSize: 11,
|
||||
fontWeight: 600,
|
||||
padding: '0 6px',
|
||||
}}
|
||||
>
|
||||
{alert.type}
|
||||
</Tag>
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
{alert.time.split(' ')[1]}
|
||||
</Text>
|
||||
</div>
|
||||
<Text style={{ fontSize: 13, fontWeight: 500, lineHeight: 1.4 }}>
|
||||
{alert.message}
|
||||
</Text>
|
||||
<Text type="secondary" style={{ fontSize: 11, marginTop: 4, display: 'block' }}>
|
||||
设备:{alert.deviceName}
|
||||
</Text>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
// 告警列表数据
|
||||
const alertList = [
|
||||
{ key: 1, content: 'INV-03 逆变直流电压异常', level: '严重', time: '10:24:15' },
|
||||
{ key: 2, content: '组串 String-07 绝缘电阻低', level: '重要', time: '10:18:42' },
|
||||
{ key: 3, content: '汇流箱 Combiner-12 过温', level: '重要', time: '10:12:33' },
|
||||
{ key: 4, content: '气象站辐照度传感器离线', level: '次要', time: '09:58:11' },
|
||||
{ key: 5, content: '组件温度异常偏高', level: '次要', time: '09:41:28' },
|
||||
];
|
||||
|
||||
// 巡检记录数据
|
||||
const patrolData = [
|
||||
{ key: 1, type: '日常巡检', time: '2025-05-23 09:30', person: '张运维', status: '已完成' },
|
||||
{ key: 2, type: '无人机巡检', time: '2025-05-22 14:15', person: '无人机01号', status: '已完成' },
|
||||
{ key: 3, type: '夜间巡检', time: '2025-05-21 20:45', person: '李班长', status: '已完成' },
|
||||
{ key: 4, type: '专项巡检', time: '2025-05-20 10:20', person: '王技术员', status: '已完成' },
|
||||
{ key: 5, type: '日常巡检', time: '2025-05-19 09:25', person: '张运维', status: '已完成' },
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
|
||||
{/* 顶部统计卡片 */}
|
||||
<Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
|
||||
{topStats.map((stat, idx) => (
|
||||
<Col xs={24} sm={12} md={8} lg={4} key={idx}>
|
||||
<AntdCard
|
||||
size="small"
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>}
|
||||
value={stat.value}
|
||||
precision={stat.value % 1 !== 0 ? 1 : 0}
|
||||
valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }}
|
||||
prefix={stat.prefix}
|
||||
suffix={stat.suffix}
|
||||
/>
|
||||
<div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
{stat.extra}
|
||||
{stat.percent && <Progress percent={stat.percent} size="small" style={{ width: 60 }} />}
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
|
||||
<Row gutter={[16, 16]}>
|
||||
{/* 左侧图表区域 */}
|
||||
<Col xs={24} lg={6}>
|
||||
{/* 发电趋势 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>今日发电功率趋势</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
|
||||
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#52c41a' }}>■</span> 实际功率</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#1890ff' }}>■</span> 预测功率</span></Space>}
|
||||
>
|
||||
<Line
|
||||
data={powerTrendData}
|
||||
xField="time"
|
||||
yField="actual"
|
||||
smooth
|
||||
color="#52c41a"
|
||||
style={{ height: 120 }}
|
||||
yAxis={{ min: 0, max: 1250 }}
|
||||
/>
|
||||
</AntdCard>
|
||||
|
||||
{/* 辐照度与温度趋势 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>辐照度与温度趋势</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
|
||||
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#fa8c16' }}>■</span> 辐照度(W/m²)</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#1890ff' }}>■</span> 环境温度(℃)</span></Space>}
|
||||
>
|
||||
<Line
|
||||
data={irradianceData}
|
||||
xField="time"
|
||||
yField="irradiance"
|
||||
smooth
|
||||
color="#fa8c16"
|
||||
style={{ height: 120 }}
|
||||
yAxis={{ min: 0, max: 1250 }}
|
||||
/>
|
||||
</AntdCard>
|
||||
|
||||
{/* 逆变器效率对比 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>逆变器效率对比</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
>
|
||||
<Column
|
||||
data={inverterData}
|
||||
xField="name"
|
||||
yField="value"
|
||||
color="#1890ff"
|
||||
style={{ height: 120 }}
|
||||
yAxis={{ min: 60, max: 100 }}
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
|
||||
{/* 中间:电站概览 */}
|
||||
<Col xs={24} lg={12}>
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>电站概览</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', height: '100%' }}
|
||||
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#52c41a' }}>●</span> 正常</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#ff4d4f' }}>●</span> 告警</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#888' }}>●</span> 离线</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#faad14' }}>●</span> 维护中</span></Space>}
|
||||
>
|
||||
{/* 这里替换成你的电站3D图 */}
|
||||
<div style={{ width: '100%', height: 400, background: '#e6f7ff', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
|
||||
电站3D概览图(可替换为你的图片/地图组件)
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
|
||||
{/* 右侧信息面板 */}
|
||||
<Col xs={24} lg={6}>
|
||||
{/* 实时告警 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>实时告警</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
|
||||
extra={<Button type="link" size="small">更多></Button>}
|
||||
>
|
||||
<List
|
||||
size="small"
|
||||
dataSource={alertList}
|
||||
renderItem={(item) => (
|
||||
<List.Item style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<div>
|
||||
<span style={{ fontSize: 12 }}>{item.content}</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<Tag color={item.level === '严重' ? 'error' : item.level === '重要' ? 'warning' : 'default'} size="small" style={{ fontSize: 10 }}>{item.level}</Tag>
|
||||
<span style={{ fontSize: 11, color: '#888' }}>{item.time}</span>
|
||||
</div>
|
||||
</div>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</AntdCard>
|
||||
|
||||
{/* 设备在线状态 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>设备在线状态</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
|
||||
extra={<Button type="link" size="small">更多></Button>}
|
||||
>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>组件阵列</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>320/320</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>逆变器</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>5/5</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>汇流箱</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>20/20</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>气象站</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>摄像头</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>12/12</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>环境传感器</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>8/8</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>无人机</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
|
||||
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>巡检机器人</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
|
||||
</div>
|
||||
</AntdCard>
|
||||
|
||||
{/* 天气信息 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>天气信息</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
|
||||
extra={<Button type="link" size="small">详细></Button>}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
|
||||
<span style={{ fontSize: 32 }}>☀️</span>
|
||||
<div>
|
||||
<div style={{ fontSize: 24, fontWeight: 600 }}>28℃</div>
|
||||
<div style={{ fontSize: 12, color: '#888' }}>晴</div>
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: '#888', marginLeft: 16 }}>
|
||||
<div>辐照度: 815 W/m²</div>
|
||||
<div>组件温度: 45.6℃</div>
|
||||
<div>环境温度: 28.3℃</div>
|
||||
<div>风速: 2.6 m/s</div>
|
||||
<div>风向: 东南风</div>
|
||||
<div>湿度: 56%</div>
|
||||
</div>
|
||||
</div>
|
||||
</AntdCard>
|
||||
|
||||
{/* 清洗建议 */}
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>清洗建议</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
extra={<Button type="link" size="small">更多></Button>}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
|
||||
<Progress percent={85} type="circle" size={60} strokeColor="#52c41a" />
|
||||
<div>
|
||||
<div style={{ fontSize: 12 }}>建议清洗时间: 3 天内</div>
|
||||
<div style={{ fontSize: 12 }}>预计提升发电量: 2.6%</div>
|
||||
<div style={{ fontSize: 12 }}>预计提升电量: 120 kWh/天</div>
|
||||
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成清洗工单</Button>
|
||||
</div>
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 底部:运维任务/巡检记录/AI分析 */}
|
||||
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
|
||||
<Col xs={24} lg={6}>
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>运维任务进度</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
extra={<Button type="link" size="small">更多></Button>}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
|
||||
<Progress percent={58} type="circle" size={80} strokeColor="#52c41a" successPercent={25} />
|
||||
<div style={{ fontSize: 12 }}>
|
||||
<div><span style={{ color: '#52c41a' }}>●</span> 已完成 7 (58%)</div>
|
||||
<div><span style={{ color: '#faad14' }}>●</span> 进行中 3 (25%)</div>
|
||||
<div><span style={{ color: '#1890ff' }}>●</span> 待开始 2 (17%)</div>
|
||||
<div><span style={{ color: '#ff4d4f' }}>●</span> 已延期 0 (0%)</div>
|
||||
</div>
|
||||
</div>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} lg={12}>
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>近期巡检记录</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
extra={<Button type="link" size="small">更多></Button>}
|
||||
>
|
||||
<Table
|
||||
size="small"
|
||||
dataSource={patrolData}
|
||||
pagination={false}
|
||||
columns={[
|
||||
{ title: '巡检类型', dataIndex: 'type', key: 'type', width: 80 },
|
||||
{ title: '巡检时间', dataIndex: 'time', key: 'time', width: 120 },
|
||||
{ title: '巡检人员', dataIndex: 'person', key: 'person', width: 100 },
|
||||
{ title: '状态', dataIndex: 'status', key: 'status', render: (status) => <Tag color="success" size="small">{status}</Tag> },
|
||||
]}
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
|
||||
<Col xs={24} lg={6}>
|
||||
<AntdCard
|
||||
size="small"
|
||||
title={<span style={{ fontSize: 13 }}>AI分析摘要</span>}
|
||||
variant={false}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
>
|
||||
<List
|
||||
size="small"
|
||||
dataSource={[
|
||||
{ title: '热点检测', desc: '发现 2 处组件存在异常热斑', link: '查看详情' },
|
||||
{ title: '组串异常', desc: '3 个组串存在发电异常', link: '查看详情' },
|
||||
{ title: '发电偏差分析', desc: '整体发电偏差 -2.8%', link: '查看详情' },
|
||||
]}
|
||||
renderItem={(item) => (
|
||||
<List.Item style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
||||
<div>
|
||||
<div style={{ fontSize: 12, fontWeight: 500 }}>{item.title}</div>
|
||||
<div style={{ fontSize: 11, color: '#888' }}>{item.desc}</div>
|
||||
</div>
|
||||
<Button type="link" size="small">{item.link}</Button>
|
||||
</div>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export default function Login() {
|
||||
className="w-full max-w-5xl"
|
||||
>
|
||||
<Card
|
||||
bordered={false}
|
||||
variant={false}
|
||||
className="shadow-xl overflow-hidden rounded-2xl"
|
||||
styles={{ body: { padding: 0 } }}
|
||||
>
|
||||
@@ -92,7 +92,7 @@ export default function Login() {
|
||||
<div className="md:w-1/2 bg-white p-10 md:p-16 flex flex-col justify-center relative z-10">
|
||||
<motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.2 }}>
|
||||
<Title level={2} style={{ marginBottom: 40, color: '#111', fontWeight: 700 }}>
|
||||
机器人智慧服务系统
|
||||
光伏电站智能监控与运维系统
|
||||
</Title>
|
||||
|
||||
<Form name="login" layout="vertical" onFinish={onFinish} autoComplete="off" size="large">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Table, Button, Typography, Space, Modal, Form, Tree, message,
|
||||
Input, Popconfirm, Select
|
||||
@@ -52,7 +52,7 @@ const roleList = [
|
||||
{ name: '场站员工', key: 'site_staff' },
|
||||
];
|
||||
|
||||
// 3. 扁平化菜单
|
||||
// 扁平化菜单
|
||||
const flattenMenu = (menus) => {
|
||||
let arr = [];
|
||||
const loop = (list, parentPath = '') => {
|
||||
@@ -66,12 +66,31 @@ const flattenMenu = (menus) => {
|
||||
return arr;
|
||||
};
|
||||
|
||||
// 转树形结构(用于Tree组件)
|
||||
const buildTree = (flatten) => {
|
||||
const map = {};
|
||||
const tree = [];
|
||||
flatten.forEach(item => {
|
||||
map[item.id] = { ...item, children: [] };
|
||||
});
|
||||
flatten.forEach(item => {
|
||||
if (item.parentId === 0) {
|
||||
tree.push(map[item.id]);
|
||||
} else {
|
||||
if (map[item.parentId]) {
|
||||
map[item.parentId].children.push(map[item.id]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return tree;
|
||||
};
|
||||
|
||||
// 存储角色权限
|
||||
const rolePermissionMap = {};
|
||||
|
||||
export default function Roles() {
|
||||
const [menus, setMenus] = useState(flattenMenu(menuData));
|
||||
const [menuTree, setMenuTree] = useState(menuData);
|
||||
const [menuTree, setMenuTree] = useState(buildTree(flattenMenu(menuData)));
|
||||
|
||||
// 新增/编辑菜单
|
||||
const [menuModal, setMenuModal] = useState(false);
|
||||
@@ -83,26 +102,48 @@ export default function Roles() {
|
||||
const [selectedRole, setSelectedRole] = useState('');
|
||||
const [checkedKeys, setCheckedKeys] = useState([]);
|
||||
|
||||
// 菜单类型:一级/二级
|
||||
const menuType = Form.useWatch('menuType', menuForm);
|
||||
|
||||
// 每次菜单变化,重新生成树形
|
||||
useEffect(() => {
|
||||
setMenuTree(buildTree(menus));
|
||||
}, [menus]);
|
||||
|
||||
// 打开编辑
|
||||
const handleEdit = (record) => {
|
||||
setEditMenu(record);
|
||||
menuForm.setFieldsValue(record);
|
||||
menuForm.setFieldsValue({
|
||||
...record,
|
||||
menuType: record.parentId === 0 ? 'top' : 'sub',
|
||||
});
|
||||
setMenuModal(true);
|
||||
};
|
||||
|
||||
// 保存菜单(新增+编辑)
|
||||
const handleSaveMenu = () => {
|
||||
menuForm.validateFields().then(values => {
|
||||
const { menuType, parentId, title, path } = values;
|
||||
if (editMenu) {
|
||||
// 编辑
|
||||
setMenus(menus.map(m => m.id === editMenu.id ? { ...m, ...values } : m));
|
||||
setMenus(menus.map(m =>
|
||||
m.id === editMenu.id
|
||||
? {
|
||||
...m,
|
||||
title,
|
||||
path,
|
||||
parentId: menuType === 'top' ? 0 : Number(parentId)
|
||||
}
|
||||
: m
|
||||
));
|
||||
message.success('编辑成功');
|
||||
} else {
|
||||
// 新增
|
||||
const newMenu = {
|
||||
...values,
|
||||
id: Date.now(),
|
||||
parentId: 0,
|
||||
title,
|
||||
path,
|
||||
parentId: menuType === 'top' ? 0 : Number(parentId),
|
||||
};
|
||||
setMenus([...menus, newMenu]);
|
||||
message.success('新增菜单成功');
|
||||
@@ -123,7 +164,6 @@ export default function Roles() {
|
||||
message.warning('请先选择角色');
|
||||
return;
|
||||
}
|
||||
// 回显已保存权限
|
||||
const saved = rolePermissionMap[selectedRole] || [];
|
||||
setCheckedKeys(saved);
|
||||
setPermModal(true);
|
||||
@@ -136,6 +176,9 @@ export default function Roles() {
|
||||
setPermModal(false);
|
||||
};
|
||||
|
||||
// 一级菜单列表(用于父级选择)
|
||||
const topMenus = menus.filter(m => m.parentId === 0);
|
||||
|
||||
const columns = [
|
||||
{ title: '菜单名称', dataIndex: 'title', key: 'title', width: 180 },
|
||||
{ title: '路由地址', dataIndex: 'fullPath', key: 'fullPath' },
|
||||
@@ -202,7 +245,7 @@ export default function Roles() {
|
||||
dataSource={menus}
|
||||
rowKey="id"
|
||||
pagination={false}
|
||||
bordered
|
||||
variant
|
||||
/>
|
||||
|
||||
{/* 菜单 新增/编辑 弹窗 */}
|
||||
@@ -214,6 +257,24 @@ export default function Roles() {
|
||||
width={500}
|
||||
>
|
||||
<Form form={menuForm} layout="vertical">
|
||||
<Form.Item name="menuType" label="菜单类型" rules={[{ required: true }]}>
|
||||
<Select placeholder="请选择菜单类型">
|
||||
<Option value="top">一级菜单</Option>
|
||||
<Option value="sub">二级菜单</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
{/* 二级菜单才显示父级选择 */}
|
||||
{menuType === 'sub' && (
|
||||
<Form.Item name="parentId" label="上级菜单" rules={[{ required: true }]}>
|
||||
<Select placeholder="请选择上级菜单">
|
||||
{topMenus.map(m => (
|
||||
<Option key={m.id} value={m.id}>{m.title}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
)}
|
||||
|
||||
<Form.Item name="title" label="菜单名称" rules={[{ required: true }]}>
|
||||
<Input placeholder="请输入菜单名称" />
|
||||
</Form.Item>
|
||||
|
||||
@@ -139,13 +139,7 @@ export default function Organization() {
|
||||
<Form.Item name="code" label="组织编码" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="parentId" label="上级组织">
|
||||
<TreeSelect
|
||||
treeData={treeData}
|
||||
placeholder="选择上级"
|
||||
fieldNames={{ label: 'name', value: 'id' }}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select>
|
||||
<Option value="0">正常</Option>
|
||||
|
||||
@@ -1,208 +1,208 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Button,
|
||||
Tag,
|
||||
Typography,
|
||||
Space,
|
||||
Tooltip,
|
||||
List,
|
||||
Avatar,
|
||||
Select,
|
||||
Divider,
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
Card,
|
||||
Button,
|
||||
Tag,
|
||||
Typography,
|
||||
Space,
|
||||
Tooltip,
|
||||
List,
|
||||
Avatar,
|
||||
Select,
|
||||
Divider,
|
||||
} from 'antd';
|
||||
import {
|
||||
CaretUpOutlined,
|
||||
CaretDownOutlined,
|
||||
CaretLeftOutlined,
|
||||
CaretRightOutlined,
|
||||
FullscreenOutlined,
|
||||
ReloadOutlined,
|
||||
MonitorOutlined,
|
||||
VideoCameraOutlined,
|
||||
ThunderboltOutlined,
|
||||
CustomerServiceOutlined,
|
||||
AlertOutlined,
|
||||
EyeOutlined
|
||||
import {
|
||||
CaretUpOutlined,
|
||||
CaretDownOutlined,
|
||||
CaretLeftOutlined,
|
||||
CaretRightOutlined,
|
||||
FullscreenOutlined,
|
||||
ReloadOutlined,
|
||||
MonitorOutlined,
|
||||
VideoCameraOutlined,
|
||||
ThunderboltOutlined,
|
||||
CustomerServiceOutlined,
|
||||
AlertOutlined,
|
||||
EyeOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { DEVICES } from '../constants';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
function cn(...classes: string[]) {
|
||||
return classes.filter(Boolean).join(' ');
|
||||
return classes.filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
export default function VideoControl() {
|
||||
const [selectedDevice, setSelectedDevice] = useState(DEVICES[0]);
|
||||
const onlineDevices = DEVICES.filter(d => d.status === 'online' || d.status === 'alert');
|
||||
const [selectedDevice, setSelectedDevice] = useState(DEVICES[0]);
|
||||
const onlineDevices = DEVICES.filter(d => d.status === 'online' || d.status === 'alert');
|
||||
|
||||
const getVideoConfig = (type: string) => {
|
||||
switch (type) {
|
||||
case '安防型':
|
||||
return {
|
||||
count: 4,
|
||||
labels: ['Front/主前', 'Back/后视', 'Left/左侧', 'Right/右侧'],
|
||||
gridClass: 'grid-cols-2 grid-rows-2'
|
||||
};
|
||||
case '运输型':
|
||||
return {
|
||||
count: 5,
|
||||
labels: ['Front/前驱', 'Back/后置', 'Left/左翼', 'Right/右翼', 'Cargo/货舱'],
|
||||
gridClass: 'grid-cols-4 grid-rows-2'
|
||||
};
|
||||
case '巡检型':
|
||||
default:
|
||||
return {
|
||||
count: 3,
|
||||
labels: ['Main/主探', 'Pan/全景', 'Detail/细节'],
|
||||
gridClass: 'grid-cols-2 grid-rows-2'
|
||||
};
|
||||
}
|
||||
};
|
||||
const getVideoConfig = (type: string) => {
|
||||
switch (type) {
|
||||
case '安防型':
|
||||
return {
|
||||
count: 4,
|
||||
labels: ['Front/主前', 'Back/后视', 'Left/左侧', 'Right/右侧'],
|
||||
gridClass: 'grid-cols-2 grid-rows-2'
|
||||
};
|
||||
case '运输型':
|
||||
return {
|
||||
count: 5,
|
||||
labels: ['Front/前驱', 'Back/后置', 'Left/左翼', 'Right/右翼', 'Cargo/货舱'],
|
||||
gridClass: 'grid-cols-4 grid-rows-2'
|
||||
};
|
||||
case '巡检型':
|
||||
default:
|
||||
return {
|
||||
count: 3,
|
||||
labels: ['Main/主探', 'Pan/全景', 'Detail/细节'],
|
||||
gridClass: 'grid-cols-2 grid-rows-2'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const config = getVideoConfig(selectedDevice.type);
|
||||
const config = getVideoConfig(selectedDevice.type);
|
||||
|
||||
return (
|
||||
<Row gutter={16} className="h-full overflow-hidden" style={{ minHeight: 0 }}>
|
||||
{/* Video Content */}
|
||||
<Col flex="auto" className="h-full flex flex-col gap-4 overflow-hidden">
|
||||
{/* Top Control Bar */}
|
||||
<div className="flex items-center justify-between bg-white p-3 rounded shadow-sm border border-gray-100">
|
||||
<Space size="large">
|
||||
<div className="flex flex-col">
|
||||
<Text type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: 1 }}>当前执勤设备</Text>
|
||||
<Select
|
||||
value={selectedDevice.id}
|
||||
onChange={(id) => setSelectedDevice(onlineDevices.find(d => d.id === id)!)}
|
||||
style={{ width: 220, fontWeight: 'bold' }}
|
||||
bordered={false}
|
||||
options={onlineDevices.map(d => ({ label: d.name, value: d.id }))}
|
||||
suffixIcon={<VideoCameraOutlined style={{ color: '#1890ff' }} />}
|
||||
/>
|
||||
</div>
|
||||
<Divider type="vertical" style={{ height: 32 }} />
|
||||
<div className="flex flex-col">
|
||||
<Text type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: 1 }}>视频流路数</Text>
|
||||
<Tag color="processing" style={{ marginTop: 2, fontWeight: 'bold', fontFamily: 'monospace' }}>
|
||||
{config.count} CHANNELS ACTIVE
|
||||
</Tag>
|
||||
</div>
|
||||
</Space>
|
||||
<Space>
|
||||
<Button size="small" icon={<ReloadOutlined />}>刷新信号</Button>
|
||||
<Button size="small" type="primary" ghost>全屏墙</Button>
|
||||
</Space>
|
||||
</div>
|
||||
return (
|
||||
<Row gutter={16} className="h-full overflow-hidden" style={{ minHeight: 0 }}>
|
||||
{/* Video Content */}
|
||||
<Col flex="auto" className="h-full flex flex-col gap-4 overflow-hidden">
|
||||
{/* Top Control Bar */}
|
||||
<div className="flex items-center justify-between bg-white p-3 rounded shadow-sm border border-gray-100">
|
||||
<Space size="large">
|
||||
<div className="flex flex-col">
|
||||
<Text type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: 1 }}>当前执勤设备</Text>
|
||||
<Select
|
||||
value={selectedDevice.id}
|
||||
onChange={(id) => setSelectedDevice(onlineDevices.find(d => d.id === id)!)}
|
||||
style={{ width: 220, fontWeight: 'bold' }}
|
||||
variant={false}
|
||||
options={onlineDevices.map(d => ({ label: d.name, value: d.id }))}
|
||||
suffixIcon={<VideoCameraOutlined style={{ color: '#1890ff' }} />}
|
||||
/>
|
||||
</div>
|
||||
<Divider type="vertical" style={{ height: 32 }} />
|
||||
<div className="flex flex-col">
|
||||
<Text type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: 1 }}>视频流路数</Text>
|
||||
<Tag color="processing" style={{ marginTop: 2, fontWeight: 'bold', fontFamily: 'monospace' }}>
|
||||
{config.count} CHANNELS ACTIVE
|
||||
</Tag>
|
||||
</div>
|
||||
</Space>
|
||||
<Space>
|
||||
<Button size="small" icon={<ReloadOutlined />}>刷新信号</Button>
|
||||
<Button size="small" type="primary" ghost>全屏墙</Button>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
{/* Multi-Video Grid */}
|
||||
<div className={cn(
|
||||
"bg-black rounded border border-gray-800 p-1 gap-1 flex-1 overflow-hidden grid",
|
||||
config.gridClass
|
||||
)}>
|
||||
{Array.from({ length: config.count }).map((_, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className={cn(
|
||||
"relative bg-gray-900 overflow-hidden flex items-center justify-center group border border-white/5",
|
||||
config.count === 3 && idx === 0 && "col-span-2",
|
||||
config.count === 5 && idx === 0 && "col-span-2 row-span-2"
|
||||
)}
|
||||
>
|
||||
<img
|
||||
src={`https://picsum.photos/seed/${selectedDevice.id}_cam${idx}/640/360`}
|
||||
alt={`Camera ${idx}`}
|
||||
className="w-full h-full object-cover opacity-60 group-hover:opacity-100 transition-opacity"
|
||||
/>
|
||||
<div className="absolute top-2 left-2 bg-black/60 text-white px-2 py-0.5 text-[10px] rounded-sm backdrop-blur-sm flex items-center gap-2 border border-white/10 uppercase font-mono">
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.8)]" />
|
||||
CAM-0{idx + 1} | {config.labels[idx]}
|
||||
</div>
|
||||
|
||||
<div className="absolute inset-0 bg-blue-500/10 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none">
|
||||
<Button shape="circle" icon={<FullscreenOutlined />} className="pointer-events-auto shadow-2xl" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{/* Multi-Video Grid */}
|
||||
<div className={cn(
|
||||
"bg-black rounded border border-gray-800 p-1 gap-1 flex-1 overflow-hidden grid",
|
||||
config.gridClass
|
||||
)}>
|
||||
{Array.from({ length: config.count }).map((_, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className={cn(
|
||||
"relative bg-gray-900 overflow-hidden flex items-center justify-center group border border-white/5",
|
||||
config.count === 3 && idx === 0 && "col-span-2",
|
||||
config.count === 5 && idx === 0 && "col-span-2 row-span-2"
|
||||
)}
|
||||
>
|
||||
<img
|
||||
src={`https://picsum.photos/seed/${selectedDevice.id}_cam${idx}/640/360`}
|
||||
alt={`Camera ${idx}`}
|
||||
className="w-full h-full object-cover opacity-60 group-hover:opacity-100 transition-opacity"
|
||||
/>
|
||||
<div className="absolute top-2 left-2 bg-black/60 text-white px-2 py-0.5 text-[10px] rounded-sm backdrop-blur-sm flex items-center gap-2 border border-white/10 uppercase font-mono">
|
||||
<div className="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.8)]" />
|
||||
CAM-0{idx + 1} | {config.labels[idx]}
|
||||
</div>
|
||||
|
||||
{/* Console Controls */}
|
||||
<Card size="small" styles={{ body: { padding: 12 } }}>
|
||||
<Row gutter={16} align="middle">
|
||||
<Col flex="0 0 160px" style={{ borderRight: '1px solid #f0f0f0', paddingRight: 24 }}>
|
||||
<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', display: 'block', textAlign: 'center', marginBottom: 8 }}>PTZ 舵机控制</Text>
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<Button type="text" size="small" icon={<CaretUpOutlined />} />
|
||||
<Space>
|
||||
<Button type="text" size="small" icon={<CaretLeftOutlined />} />
|
||||
<div className="w-4 h-4 rounded-full bg-blue-500 shadow-[0_0_8px_rgba(24,144,255,0.8)]" />
|
||||
<Button type="text" size="small" icon={<CaretRightOutlined />} />
|
||||
</Space>
|
||||
<Button type="text" size="small" icon={<CaretDownOutlined />} />
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
<Col flex="auto">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase' }}>系统集成作业指令 ({selectedDevice.type})</Text>
|
||||
<Tag color="success" bordered={false} style={{ fontSize: 10, fontWeight: 'bold' }}>SIGNAL: 100% EXCELLENT</Tag>
|
||||
</div>
|
||||
<Space className="w-full" size="middle">
|
||||
<Button icon={<CustomerServiceOutlined />} style={{ borderRadius: 2 }} block>双轴双向对讲</Button>
|
||||
<Button danger icon={<AlertOutlined />} style={{ borderRadius: 2 }} block>触发远程驱逐</Button>
|
||||
<Button type="primary" icon={<EyeOutlined />} style={{ borderRadius: 2 }} block>AI 视觉追踪锁定</Button>
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
<div className="absolute inset-0 bg-blue-500/10 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none">
|
||||
<Button shape="circle" icon={<FullscreenOutlined />} className="pointer-events-auto shadow-2xl" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Sidebar Channels */}
|
||||
<Col flex="0 0 260px" className="h-full">
|
||||
<Card
|
||||
title={<Space><MonitorOutlined /><Text strong style={{ fontSize: 13 }}>活跃视频流 ({onlineDevices.length})</Text></Space>}
|
||||
extra={<Button type="text" size="small" icon={<ReloadOutlined />} />}
|
||||
styles={{ body: { padding: 0 } }}
|
||||
className="h-full flex flex-col overflow-hidden"
|
||||
>
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<List
|
||||
dataSource={onlineDevices}
|
||||
renderItem={(device) => (
|
||||
<List.Item
|
||||
onClick={() => setSelectedDevice(device)}
|
||||
className={cn(
|
||||
"px-4 py-3 cursor-pointer transition-colors border-b last:border-0",
|
||||
selectedDevice.id === device.id ? "bg-blue-50 border-l-4 border-l-blue-500" : "hover:bg-gray-50 border-l-4 border-l-transparent"
|
||||
)}
|
||||
>
|
||||
<List.Item.Meta
|
||||
avatar={
|
||||
<div className={cn("w-12 h-12 rounded overflow-hidden border", selectedDevice.id === device.id ? "border-blue-300" : "border-gray-200")}>
|
||||
<img src={`https://picsum.photos/seed/${device.id}/80/80`} className="w-full h-full object-cover" />
|
||||
</div>
|
||||
}
|
||||
title={
|
||||
<Text strong style={{ fontSize: 13, color: selectedDevice.id === device.id ? '#1890ff' : 'inherit' }}>
|
||||
{device.name}
|
||||
</Text>
|
||||
}
|
||||
description={
|
||||
<Space size={4} style={{ fontSize: 10 }}>
|
||||
<Text type="secondary" style={{ fontFamily: 'monospace' }}>{device.id}</Text>
|
||||
<div className={cn("w-2 h-2 rounded-full", device.status === 'alert' ? "bg-red-500" : "bg-green-500")} />
|
||||
<Text type="secondary" italic>{device.type}</Text>
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
{/* Console Controls */}
|
||||
<Card size="small" styles={{ body: { padding: 12 } }}>
|
||||
<Row gutter={16} align="middle">
|
||||
<Col flex="0 0 160px" style={{ borderRight: '1px solid #f0f0f0', paddingRight: 24 }}>
|
||||
<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', display: 'block', textAlign: 'center', marginBottom: 8 }}>PTZ 舵机控制</Text>
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<Button type="text" size="small" icon={<CaretUpOutlined />} />
|
||||
<Space>
|
||||
<Button type="text" size="small" icon={<CaretLeftOutlined />} />
|
||||
<div className="w-4 h-4 rounded-full bg-blue-500 shadow-[0_0_8px_rgba(24,144,255,0.8)]" />
|
||||
<Button type="text" size="small" icon={<CaretRightOutlined />} />
|
||||
</Space>
|
||||
<Button type="text" size="small" icon={<CaretDownOutlined />} />
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
<Col flex="auto">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase' }}>系统集成作业指令 ({selectedDevice.type})</Text>
|
||||
<Tag color="success" variant={false} style={{ fontSize: 10, fontWeight: 'bold' }}>SIGNAL: 100% EXCELLENT</Tag>
|
||||
</div>
|
||||
<Space className="w-full" size="middle">
|
||||
<Button icon={<CustomerServiceOutlined />} style={{ borderRadius: 2 }} block>双轴双向对讲</Button>
|
||||
<Button danger icon={<AlertOutlined />} style={{ borderRadius: 2 }} block>触发远程驱逐</Button>
|
||||
<Button type="primary" icon={<EyeOutlined />} style={{ borderRadius: 2 }} block>AI 视觉追踪锁定</Button>
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
{/* Sidebar Channels */}
|
||||
<Col flex="0 0 260px" className="h-full">
|
||||
<Card
|
||||
title={<Space><MonitorOutlined /><Text strong style={{ fontSize: 13 }}>活跃视频流 ({onlineDevices.length})</Text></Space>}
|
||||
extra={<Button type="text" size="small" icon={<ReloadOutlined />} />}
|
||||
styles={{ body: { padding: 0 } }}
|
||||
className="h-full flex flex-col overflow-hidden"
|
||||
>
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<List
|
||||
dataSource={onlineDevices}
|
||||
renderItem={(device) => (
|
||||
<List.Item
|
||||
onClick={() => setSelectedDevice(device)}
|
||||
className={cn(
|
||||
"px-4 py-3 cursor-pointer transition-colors border-b last:border-0",
|
||||
selectedDevice.id === device.id ? "bg-blue-50 border-l-4 border-l-blue-500" : "hover:bg-gray-50 border-l-4 border-l-transparent"
|
||||
)}
|
||||
>
|
||||
<List.Item.Meta
|
||||
avatar={
|
||||
<div className={cn("w-12 h-12 rounded overflow-hidden border", selectedDevice.id === device.id ? "border-blue-300" : "border-gray-200")}>
|
||||
<img src={`https://picsum.photos/seed/${device.id}/80/80`} className="w-full h-full object-cover" />
|
||||
</div>
|
||||
}
|
||||
title={
|
||||
<Text strong style={{ fontSize: 13, color: selectedDevice.id === device.id ? '#1890ff' : 'inherit' }}>
|
||||
{device.name}
|
||||
</Text>
|
||||
}
|
||||
description={
|
||||
<Space size={4} style={{ fontSize: 10 }}>
|
||||
<Text type="secondary" style={{ fontFamily: 'monospace' }}>{device.id}</Text>
|
||||
<div className={cn("w-2 h-2 rounded-full", device.status === 'alert' ? "bg-red-500" : "bg-green-500")} />
|
||||
<Text type="secondary" italic>{device.type}</Text>
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
import React, { lazy, Suspense } from 'react';
|
||||
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
|
||||
import { createBrowserRouter } from 'react-router-dom';
|
||||
import type { RouteObject } from 'react-router-dom';
|
||||
|
||||
// ============================================================
|
||||
// 路由懒加载 & 分层架构
|
||||
// 所有业务 Page 均通过 React.lazy 实现按需加载,减小首屏 JS 体积
|
||||
// ============================================================
|
||||
|
||||
// 布局组件
|
||||
const Layout = lazy(() => import('../components/Layout'));
|
||||
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
|
||||
const Login = lazy(() => import('../pages/Login'));
|
||||
|
||||
// 业务页面(按需加载)
|
||||
const Home = lazy(() => import('../pages/Home'));
|
||||
const Devices = lazy(() => import('../pages/Devices'));
|
||||
const Video = lazy(() => import('../pages/Video'));
|
||||
@@ -25,86 +18,79 @@ const Organization = lazy(() => import('../pages/Organization'));
|
||||
const StationManage = lazy(() => import('../pages/StationManage'));
|
||||
const SerialNumGenerate = lazy(() => import('../pages/SerialNumGenerate'));
|
||||
|
||||
// 公共加载骨架(路由切换时闪烁优化)
|
||||
function PageFallback() {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full min-h-[200px]">
|
||||
<div className="w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin" />
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full min-h-[200px]">
|
||||
<div className="w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 路由元信息表(权限 · 标题 · 图标)
|
||||
// ============================================================
|
||||
export const routeMeta: Record<string, {
|
||||
title: string;
|
||||
roles: string[];
|
||||
requiresAuth: boolean;
|
||||
title: string;
|
||||
roles: string[];
|
||||
requiresAuth: boolean;
|
||||
}> = {
|
||||
'/': { title: '概览控制台', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
||||
'/devices': { title: '设备管理', roles: ['admin', 'operator'], requiresAuth: true },
|
||||
'/video': { title: '在线视频', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
||||
'/alerts': { title: '警报中心', roles: ['admin', 'operator'], requiresAuth: true },
|
||||
'/downloads': { title: '视频下载', roles: ['admin', 'operator'], requiresAuth: true },
|
||||
'/serialNumGenerate': { title: '序列号生成', roles: ['admin'], requiresAuth: true },
|
||||
'/users': { title: '用户管理', roles: ['admin'], requiresAuth: true },
|
||||
'/roles': { title: '角色管理', roles: ['admin'], requiresAuth: true },
|
||||
'/menuList': { title: '菜单管理', roles: ['admin'], requiresAuth: true },
|
||||
'/organization': { title: '组织管理', roles: ['admin'], requiresAuth: true },
|
||||
'/station': { title: '场站管理', roles: ['admin'], requiresAuth: true },
|
||||
'/': { title: '总览首页', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
||||
'/devices': { title: '设备管理', roles: ['admin', 'operator'], requiresAuth: true },
|
||||
'/video': { title: '在线视频', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
||||
'/alerts': { title: '告警中心', roles: ['admin', 'operator'], requiresAuth: true },
|
||||
'/downloads': { title: '视频下载', roles: ['admin', 'operator'], requiresAuth: true },
|
||||
'/serialNumGenerate': { title: '序列号生成', roles: ['admin'], requiresAuth: true },
|
||||
'/users': { title: '用户管理', roles: ['admin'], requiresAuth: true },
|
||||
'/roles': { title: '角色管理', roles: ['admin'], requiresAuth: true },
|
||||
'/menuList': { title: '菜单管理', roles: ['admin'], requiresAuth: true },
|
||||
'/organization': { title: '组织管理', roles: ['admin'], requiresAuth: true },
|
||||
'/station': { title: '场站管理', roles: ['admin'], requiresAuth: true },
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// 路由表(完整配置,支持权限过滤)
|
||||
// ============================================================
|
||||
const routes: RouteObject[] = [
|
||||
{
|
||||
path: '/login',
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Login />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<ProtectedRoute />
|
||||
</Suspense>
|
||||
),
|
||||
children: [
|
||||
{
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Layout />
|
||||
</Suspense>
|
||||
),
|
||||
children: [
|
||||
{ index: true, element: <Home /> },
|
||||
{ path: 'devices', element: <Devices /> },
|
||||
{ path: 'video', element: <Video /> },
|
||||
{ path: 'alerts', element: <Alerts /> },
|
||||
{ path: 'downloads', element: <Downloads /> },
|
||||
{ path: 'roles', element: <Roles /> },
|
||||
{ path: 'users', element: <Users /> },
|
||||
{ path: 'serialNumGenerate', element: <SerialNumGenerate /> },
|
||||
{ path: 'menuList', element: <MenuList /> },
|
||||
{ path: 'organization', element: <Organization /> },
|
||||
{ path: 'station', element: <StationManage /> },
|
||||
{
|
||||
path: '*',
|
||||
element: (
|
||||
<div className="flex flex-col items-center justify-center h-full gap-4 text-gray-400 select-none">
|
||||
<span className="text-6xl opacity-20">🚧</span>
|
||||
<p className="text-lg font-medium">模块开发中</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Login />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<ProtectedRoute />
|
||||
</Suspense>
|
||||
),
|
||||
children: [
|
||||
{
|
||||
element: (
|
||||
<Suspense fallback={<PageFallback />}>
|
||||
<Layout />
|
||||
</Suspense>
|
||||
),
|
||||
children: [
|
||||
{ index: true, element: <Home /> },
|
||||
{ path: 'devices', element: <Devices /> },
|
||||
{ path: 'video', element: <Video /> },
|
||||
{ path: 'alerts', element: <Alerts /> },
|
||||
{ path: 'downloads', element: <Downloads /> },
|
||||
{ path: 'roles', element: <Roles /> },
|
||||
{ path: 'users', element: <Users /> },
|
||||
{ path: 'serialNumGenerate', element: <SerialNumGenerate /> },
|
||||
{ path: 'menuList', element: <MenuList /> },
|
||||
{ path: 'organization', element: <Organization /> },
|
||||
{ path: 'station', element: <StationManage /> },
|
||||
{
|
||||
path: '*',
|
||||
element: (
|
||||
<div className="flex flex-col items-center justify-center h-full gap-4 text-gray-400 select-none">
|
||||
<span className="text-6xl opacity-20">🚧</span>
|
||||
<p className="text-lg font-medium">模块开发中</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const router = createBrowserRouter(routes);
|
||||
|
||||
@@ -1,177 +1,177 @@
|
||||
// ============================================================
|
||||
// 机器人智慧服务系统 - 全局类型定义
|
||||
// 光伏电站智能监控与运维系统 - 全局类型定义
|
||||
// ============================================================
|
||||
|
||||
// ------------------- 通用 -------------------
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number;
|
||||
data: T;
|
||||
msg: string;
|
||||
token?: string;
|
||||
userId?: string;
|
||||
code: number;
|
||||
data: T;
|
||||
msg: string;
|
||||
token?: string;
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
export interface PageResult<T = any> {
|
||||
rows: T[];
|
||||
total: number;
|
||||
code: number;
|
||||
msg: string;
|
||||
rows: T[];
|
||||
total: number;
|
||||
code: number;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
export interface PageQuery {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
[key: string]: any;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// ------------------- 多租户 -------------------
|
||||
export interface Tenant {
|
||||
id: string | number;
|
||||
name: string;
|
||||
code: string;
|
||||
logo?: string;
|
||||
theme?: 'light' | 'dark';
|
||||
status: 'active' | 'inactive';
|
||||
expiresAt?: string;
|
||||
id: string | number;
|
||||
name: string;
|
||||
code: string;
|
||||
logo?: string;
|
||||
theme?: 'light' | 'dark';
|
||||
status: 'active' | 'inactive';
|
||||
expiresAt?: string;
|
||||
}
|
||||
|
||||
export interface TenantConfig {
|
||||
// 当前激活的租户
|
||||
current: Tenant | null;
|
||||
// 租户列表(超级管理员可用)
|
||||
list: Tenant[];
|
||||
// 租户域名/路径标识
|
||||
identifier: string;
|
||||
// 当前激活的租户
|
||||
current: Tenant | null;
|
||||
// 租户列表(超级管理员可用)
|
||||
list: Tenant[];
|
||||
// 租户域名/路径标识
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
// ------------------- 用户 & 权限 -------------------
|
||||
export interface UserInfo {
|
||||
userId: string | number;
|
||||
username: string;
|
||||
nickname?: string;
|
||||
avatar?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
deptId?: string | number;
|
||||
deptName?: string;
|
||||
tenantId?: string | number;
|
||||
tenantName?: string;
|
||||
roleIds?: (string | number)[];
|
||||
roles?: Role[];
|
||||
permissions?: string[];
|
||||
status: number;
|
||||
userId: string | number;
|
||||
username: string;
|
||||
nickname?: string;
|
||||
avatar?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
deptId?: string | number;
|
||||
deptName?: string;
|
||||
tenantId?: string | number;
|
||||
tenantName?: string;
|
||||
roleIds?: (string | number)[];
|
||||
roles?: Role[];
|
||||
permissions?: string[];
|
||||
status: number;
|
||||
}
|
||||
|
||||
export interface LoginForm {
|
||||
username: string;
|
||||
password: string;
|
||||
code?: string;
|
||||
uuid?: string;
|
||||
captcha?: string;
|
||||
sourceType: number | string;
|
||||
tenantCode?: string; // 多租户登录时传入
|
||||
username: string;
|
||||
password: string;
|
||||
code?: string;
|
||||
uuid?: string;
|
||||
captcha?: string;
|
||||
sourceType: number | string;
|
||||
tenantCode?: string; // 多租户登录时传入
|
||||
}
|
||||
|
||||
export interface LoginResult {
|
||||
token: string;
|
||||
userId: string | number;
|
||||
userInfo: UserInfo;
|
||||
expiresIn?: number; // token 过期时间(秒)
|
||||
token: string;
|
||||
userId: string | number;
|
||||
userInfo: UserInfo;
|
||||
expiresIn?: number; // token 过期时间(秒)
|
||||
}
|
||||
|
||||
export interface Role {
|
||||
id: string | number;
|
||||
name: string;
|
||||
code: string;
|
||||
remark?: string;
|
||||
sort?: number;
|
||||
status: number;
|
||||
menuIds?: (string | number)[];
|
||||
deptIds?: (string | number)[];
|
||||
id: string | number;
|
||||
name: string;
|
||||
code: string;
|
||||
remark?: string;
|
||||
sort?: number;
|
||||
status: number;
|
||||
menuIds?: (string | number)[];
|
||||
deptIds?: (string | number)[];
|
||||
}
|
||||
|
||||
export interface Menu {
|
||||
id: string | number;
|
||||
title: string;
|
||||
path: string;
|
||||
name?: string;
|
||||
component?: string;
|
||||
redirect?: string;
|
||||
parentId: string | number;
|
||||
icon?: string;
|
||||
sort?: number;
|
||||
visible?: 0 | 1;
|
||||
status?: 0 | 1;
|
||||
isCache?: 0 | 1;
|
||||
isFrame?: 0 | 1;
|
||||
menuType?: 0 | 1 | 2; // 0=目录 1=菜单 2=按钮
|
||||
perms?: string; // 按钮权限标识
|
||||
children?: Menu[];
|
||||
id: string | number;
|
||||
title: string;
|
||||
path: string;
|
||||
name?: string;
|
||||
component?: string;
|
||||
redirect?: string;
|
||||
parentId: string | number;
|
||||
icon?: string;
|
||||
sort?: number;
|
||||
visible?: 0 | 1;
|
||||
status?: 0 | 1;
|
||||
isCache?: 0 | 1;
|
||||
isFrame?: 0 | 1;
|
||||
menuType?: 0 | 1 | 2; // 0=目录 1=菜单 2=按钮
|
||||
perms?: string; // 按钮权限标识
|
||||
children?: Menu[];
|
||||
}
|
||||
|
||||
// ------------------- 路由 -------------------
|
||||
export interface RouteMeta {
|
||||
title: string;
|
||||
icon?: string;
|
||||
roles?: string[];
|
||||
requiresAuth?: boolean;
|
||||
hideBreadcrumb?: boolean;
|
||||
hideMenu?: boolean;
|
||||
keepAlive?: boolean;
|
||||
affix?: boolean;
|
||||
orderNo?: number;
|
||||
title: string;
|
||||
icon?: string;
|
||||
roles?: string[];
|
||||
requiresAuth?: boolean;
|
||||
hideBreadcrumb?: boolean;
|
||||
hideMenu?: boolean;
|
||||
keepAlive?: boolean;
|
||||
affix?: boolean;
|
||||
orderNo?: number;
|
||||
}
|
||||
|
||||
export interface AppRoute {
|
||||
path: string;
|
||||
name?: string;
|
||||
component?: React.LazyExoticComponent<any>;
|
||||
children?: AppRoute[];
|
||||
redirect?: string;
|
||||
meta?: RouteMeta;
|
||||
metaAuth?: boolean;
|
||||
/** 不在菜单中展示 */
|
||||
hidden?: boolean;
|
||||
path: string;
|
||||
name?: string;
|
||||
component?: React.LazyExoticComponent<any>;
|
||||
children?: AppRoute[];
|
||||
redirect?: string;
|
||||
meta?: RouteMeta;
|
||||
metaAuth?: boolean;
|
||||
/** 不在菜单中展示 */
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
// ------------------- 设备 -------------------
|
||||
export interface Device {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
status: 'online' | 'offline' | 'alert' | 'warning';
|
||||
battery: number;
|
||||
cpu: number;
|
||||
temp: number;
|
||||
lastUpdate: string;
|
||||
tenantId?: string | number;
|
||||
deptId?: string | number;
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
status: 'online' | 'offline' | 'alert' | 'warning';
|
||||
battery: number;
|
||||
cpu: number;
|
||||
temp: number;
|
||||
lastUpdate: string;
|
||||
tenantId?: string | number;
|
||||
deptId?: string | number;
|
||||
}
|
||||
|
||||
export interface AlertRecord {
|
||||
id: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
type: 'critical' | 'warning' | 'info';
|
||||
message: string;
|
||||
time: string;
|
||||
handled: boolean;
|
||||
tenantId?: string | number;
|
||||
id: string;
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
type: 'critical' | 'warning' | 'info';
|
||||
message: string;
|
||||
time: string;
|
||||
handled: boolean;
|
||||
tenantId?: string | number;
|
||||
}
|
||||
|
||||
// ------------------- 请求相关 -------------------
|
||||
export interface RequestConfig {
|
||||
baseURL?: string;
|
||||
headers?: Record<string, string>;
|
||||
timeout?: number;
|
||||
retry?: number;
|
||||
retryDelay?: number;
|
||||
loading?: boolean;
|
||||
tenantAware?: boolean;
|
||||
baseURL?: string;
|
||||
headers?: Record<string, string>;
|
||||
timeout?: number;
|
||||
retry?: number;
|
||||
retryDelay?: number;
|
||||
loading?: boolean;
|
||||
tenantAware?: boolean;
|
||||
}
|
||||
|
||||
export interface RequestError {
|
||||
code: string | number;
|
||||
message: string;
|
||||
detail?: any;
|
||||
code: string | number;
|
||||
message: string;
|
||||
detail?: any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user