import React from 'react';
import {
Card,
Row,
Col,
Statistic,
Table,
Tag,
Progress,
List,
Button,
Typography,
Space,
} from 'antd';
import {
ThunderboltOutlined,
DashboardOutlined,
DotChartOutlined,
RocketOutlined,
BellOutlined,
CloudUploadOutlined,
} from '@ant-design/icons';
import { DEVICES, ALERTS } from '../constants';
import { useNavigate } from 'react-router-dom';
const { Text, Title } = Typography;
const AntdCard = Card as any;
export default function Home() {
const navigate = useNavigate();
const stats = [
{ title: '芯片温度', value: 32.08, icon: , color: '#ff4d4f', suffix: '℃' },
{ title: '设备电流', value: 0, icon: , color: '#1677ff', suffix: 'A' },
{ title: '设备电压', value: 0, icon: , color: '#fa8c16', suffix: 'V' },
{ title: '设备数量', value: DEVICES.length, icon: , color: '#52c41a', suffix: '' },
{ title: '告警数量', value: ALERTS.filter(a => !a.handled).length, icon: , color: '#ff4d4f', suffix: '' },
{ title: '上报事件', value: 1, icon: , color: '#52c41a', suffix: '' },
];
const columns = [
{
title: 'Node / 标识',
dataIndex: 'name',
key: 'name',
render: (text: string, record: any) => (
{text}
{record.id}
),
},
{
title: 'Status / 状态',
dataIndex: 'status',
key: 'status',
width: 110,
render: (status: string) => (
{status.toUpperCase()}
),
},
{
title: 'Batt / 电量',
dataIndex: 'battery',
key: 'battery',
width: 140,
render: (percent: number) => (
),
},
{
title: 'Load / 负载',
dataIndex: 'cpu',
key: 'cpu',
width: 100,
render: (cpu: number) => (
{cpu}%
),
},
{
title: 'Ping / 延迟',
key: 'ping',
width: 100,
align: 'right',
render: () => 12ms,
},
];
return (
{/* 统计卡片 */}
{stats.map((stat, idx) => (
{stat.title}}
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={{stat.suffix}}
/>
))}
{/* 设备表格 */}
核心节点实时清单}
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }}
bodyStyle={{ padding: 0 }}
>
({ ...d, key: d.id }))}
pagination={false}
onRow={(record) => ({
onClick: () => navigate('/devices'),
style: { cursor: 'pointer' },
})}
rowHoverable
/>
{/* 告警列表 */}
当日重点警报}
extra={
}
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }}
bodyStyle={{ padding: 0, height: 460, overflowY: 'auto' }}
>
(
{alert.type}
{alert.time.split(' ')[1]}
{alert.message}
设备:{alert.deviceName}
)}
/>
);
}