2026-04-17 17:20:41 +08:00
|
|
|
|
import React, { useState } from 'react';
|
2026-04-21 08:51:57 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Table,
|
|
|
|
|
|
Input,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Tag,
|
|
|
|
|
|
Progress,
|
|
|
|
|
|
Space,
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
Statistic,
|
|
|
|
|
|
Descriptions,
|
|
|
|
|
|
Tabs,
|
|
|
|
|
|
Card
|
2026-04-17 17:20:41 +08:00
|
|
|
|
} from 'antd';
|
2026-04-21 08:51:57 +08:00
|
|
|
|
import {
|
|
|
|
|
|
SearchOutlined,
|
|
|
|
|
|
PlusOutlined,
|
|
|
|
|
|
SettingOutlined,
|
|
|
|
|
|
PoweroffOutlined,
|
|
|
|
|
|
ClusterOutlined,
|
|
|
|
|
|
ArrowRightOutlined,
|
|
|
|
|
|
CloseOutlined,
|
|
|
|
|
|
DashboardOutlined,
|
|
|
|
|
|
HeatMapOutlined,
|
|
|
|
|
|
InfoCircleOutlined,
|
|
|
|
|
|
LineChartOutlined,
|
|
|
|
|
|
ThunderboltOutlined
|
2026-04-17 17:20:41 +08:00
|
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
import { DEVICES } from '../constants';
|
|
|
|
|
|
import { motion, AnimatePresence } from 'motion/react';
|
|
|
|
|
|
|
|
|
|
|
|
const { Text, Title } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
export default function Devices() {
|
2026-04-21 08:51:57 +08:00
|
|
|
|
const [selectedDeviceId, setSelectedDeviceId] = useState<string | null>(null);
|
|
|
|
|
|
const selectedDevice = DEVICES.find(d => d.id === selectedDeviceId);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
const columns = [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '节点身份',
|
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
|
key: 'name',
|
|
|
|
|
|
render: (text: string, record: any) => (
|
|
|
|
|
|
<Space direction="vertical" size={0}>
|
|
|
|
|
|
<Text strong style={{ fontSize: 13 }}>{text}</Text>
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 10, fontFamily: 'monospace' }}>{record.id} | {record.type}</Text>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '负载/状态',
|
|
|
|
|
|
key: 'status',
|
|
|
|
|
|
render: (record: any) => (
|
|
|
|
|
|
<Space direction="vertical" size={0}>
|
|
|
|
|
|
<Text
|
|
|
|
|
|
strong
|
|
|
|
|
|
italic
|
|
|
|
|
|
style={{
|
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
|
color: record.status === 'online' ? '#52c41a' : record.status === 'alert' ? '#f5222d' : '#bfbfbf'
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{record.status.toUpperCase()}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<Space size="small">
|
|
|
|
|
|
<ClusterOutlined style={{ fontSize: 10, color: 'rgba(0,0,0,0.25)' }} />
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>{record.cpu}%</Text>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '能量效率',
|
|
|
|
|
|
dataIndex: 'battery',
|
|
|
|
|
|
key: 'battery',
|
|
|
|
|
|
render: (percent: number) => (
|
|
|
|
|
|
<Space size="middle">
|
|
|
|
|
|
<Progress
|
|
|
|
|
|
percent={percent}
|
|
|
|
|
|
size={[60, 4]}
|
|
|
|
|
|
showInfo={false}
|
|
|
|
|
|
status={percent < 20 ? 'exception' : 'active'}
|
|
|
|
|
|
strokeColor={percent < 20 ? '#f5222d' : percent < 50 ? '#faad14' : '#52c41a'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Text style={{ fontSize: 11, fontFamily: 'monospace' }}>{percent}%</Text>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '类型',
|
|
|
|
|
|
dataIndex: 'battery',
|
|
|
|
|
|
key: 'battery',
|
|
|
|
|
|
render: (percent: number) => (
|
|
|
|
|
|
<Space size="middle">
|
|
|
|
|
|
<Progress
|
|
|
|
|
|
percent={percent}
|
|
|
|
|
|
size={[60, 4]}
|
|
|
|
|
|
showInfo={false}
|
|
|
|
|
|
status={percent < 20 ? 'exception' : 'active'}
|
|
|
|
|
|
strokeColor={percent < 20 ? '#f5222d' : percent < 50 ? '#faad14' : '#52c41a'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Text style={{ fontSize: 11, fontFamily: 'monospace' }}>{percent}%</Text>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '管理',
|
|
|
|
|
|
key: 'action',
|
|
|
|
|
|
align: 'right' as const,
|
|
|
|
|
|
render: () => (
|
|
|
|
|
|
<Space>
|
|
|
|
|
|
<Button type="text" size="small" icon={<SettingOutlined />} />
|
|
|
|
|
|
<Button type="text" size="small" danger icon={<PoweroffOutlined />} />
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div className="flex flex-col h-full gap-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 type="primary" icon={<PlusOutlined />} style={{ borderRadius: 2 }}>
|
|
|
|
|
|
接入新节点
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Row gutter={16} className="flex-1 " style={{ minHeight: 0, flexWrap: 'nowrap', }}>
|
|
|
|
|
|
<Col flex="auto" className="h-full overflow-hidden">
|
|
|
|
|
|
<Card styles={{ body: { padding: 0 } }} className="h-full overflow-hidden flex flex-col">
|
|
|
|
|
|
<Table
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
columns={columns}
|
|
|
|
|
|
dataSource={DEVICES.map(d => ({ ...d, key: d.id }))}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
sticky
|
|
|
|
|
|
scroll={{ y: 'calc(100vh - 250px)' }}
|
|
|
|
|
|
onRow={(record) => ({
|
|
|
|
|
|
onClick: () => setSelectedDeviceId(record.id),
|
|
|
|
|
|
className: selectedDeviceId === record.id ? 'bg-blue-50' : '',
|
|
|
|
|
|
style: { cursor: 'pointer' }
|
|
|
|
|
|
})}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<AnimatePresence>
|
|
|
|
|
|
{selectedDevice && (
|
|
|
|
|
|
<Col flex="0 0 340px" className="h-full">
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ x: 340, opacity: 0 }}
|
|
|
|
|
|
animate={{ x: 0, opacity: 1 }}
|
|
|
|
|
|
exit={{ x: 340, opacity: 0 }}
|
|
|
|
|
|
className="h-full"
|
|
|
|
|
|
>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
className="h-full overflow-hidden"
|
|
|
|
|
|
styles={{ body: { padding: 0, height: '100%', display: 'flex', flexDirection: 'column' } }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className="p-4 border-b border-gray-100 flex justify-between items-start bg-gray-50">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 10, letterSpacing: 2, textTransform: 'uppercase', display: 'block' }}>
|
|
|
|
|
|
Asset Intelligence / v4.0
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<Title level={4} style={{ margin: '4px 0' }}>{selectedDevice.name}</Title>
|
|
|
|
|
|
<Space>
|
2026-04-28 11:01:54 +08:00
|
|
|
|
<Tag color="blue" variant={false} style={{ fontSize: 10, fontWeight: 'bold' }}>{selectedDevice.type}</Tag>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>ID: {selectedDevice.id}</Text>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
icon={<CloseOutlined />}
|
|
|
|
|
|
onClick={() => setSelectedDeviceId(null)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<div className="flex-1 overflow-y-auto">
|
|
|
|
|
|
<Tabs
|
|
|
|
|
|
defaultActiveKey="1"
|
|
|
|
|
|
className="px-4"
|
|
|
|
|
|
items={[
|
|
|
|
|
|
{
|
|
|
|
|
|
key: '1',
|
|
|
|
|
|
label: '基本信息',
|
|
|
|
|
|
children: (
|
|
|
|
|
|
<div className="space-y-6 pt-4 pb-4">
|
2026-04-28 11:01:54 +08:00
|
|
|
|
<Descriptions column={1} size="small" variant>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Descriptions.Item label="设备名称">{selectedDevice.name}</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="设备 ID">{selectedDevice.id}</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="设备类型">{selectedDevice.type}</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="最后心跳">{selectedDevice.lastUpdate}</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="固件版本">FW_2.5.4_REL</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="接入协议">MQTT_SSL</Descriptions.Item>
|
|
|
|
|
|
</Descriptions>
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<div className="p-3 bg-blue-50 border border-blue-100 rounded">
|
|
|
|
|
|
<Space size="small" align="start">
|
|
|
|
|
|
<InfoCircleOutlined style={{ color: '#1890ff', marginTop: 3 }} />
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 11 }}>
|
|
|
|
|
|
该设备目前运行正常,已通过节点身份验证,正在进行全量数据透传。
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: '2',
|
|
|
|
|
|
label: '运行状态',
|
|
|
|
|
|
children: (
|
|
|
|
|
|
<div className="space-y-6 pt-4 pb-4">
|
|
|
|
|
|
<Row gutter={[12, 12]}>
|
|
|
|
|
|
<Col span={12}>
|
2026-04-28 11:01:54 +08:00
|
|
|
|
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Statistic title={<Space><ClusterOutlined />负载率</Space>} value={selectedDevice.cpu} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} />
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-04-28 11:01:54 +08:00
|
|
|
|
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Statistic title={<Space><HeatMapOutlined />核心温度</Space>} value={selectedDevice.temp} suffix="°C" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#f5222d' }} />
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-04-28 11:01:54 +08:00
|
|
|
|
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Statistic title={<Space><ThunderboltOutlined />剩余能量</Space>} value={selectedDevice.battery} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#52c41a' }} />
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
2026-04-28 11:01:54 +08:00
|
|
|
|
<Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<Statistic title={<Space><DashboardOutlined />系统健康</Space>} value={98.2} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} />
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<div className="pt-2 border-t border-gray-100">
|
|
|
|
|
|
<Text strong type="secondary" style={{ fontSize: 11, textTransform: 'uppercase', display: 'block', marginBottom: 12 }}>
|
|
|
|
|
|
实时动态 (SIGNAL)
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<Space direction="vertical" className="w-full" size="small">
|
|
|
|
|
|
<div className="flex justify-between items-center bg-gray-50 p-2 rounded">
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 11 }}>上行链路速率</Text>
|
|
|
|
|
|
<Text style={{ fontFamily: 'monospace', fontSize: 11 }}>1.2 Mbps</Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex justify-between items-center bg-gray-50 p-2 rounded">
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 11 }}>下行链路速率</Text>
|
|
|
|
|
|
<Text style={{ fontFamily: 'monospace', fontSize: 11 }}>0.4 Mbps</Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex justify-between items-center bg-gray-50 p-2 rounded">
|
|
|
|
|
|
<Text type="secondary" style={{ fontSize: 11 }}>当前信号强度</Text>
|
|
|
|
|
|
<Tag color="success" style={{ margin: 0, fontSize: 10 }}>EXCELLENT</Tag>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-04-21 08:51:57 +08:00
|
|
|
|
<div className="p-4 border-t border-gray-100 bg-gray-50">
|
|
|
|
|
|
<Space direction="vertical" className="w-full" size="small">
|
|
|
|
|
|
<Button type="primary" block icon={<ArrowRightOutlined />} style={{ borderRadius: 2 }}>
|
|
|
|
|
|
发起远程诊断
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
<Button block icon={<LineChartOutlined />} style={{ borderRadius: 2 }}>
|
|
|
|
|
|
同步设备策略
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
}
|