Files
web-Iot/src/pages/VideoMonitorPage.tsx
2026-05-08 13:28:27 +08:00

335 lines
14 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useState } from 'react';
import {
Card, Row, Col, Button, Space, Input, Select, Table, Tag, Typography, Dropdown, Menu,
Timeline
} from 'antd';
import {
VideoCameraOutlined, BellOutlined, BorderOutlined, DatabaseOutlined,
PauseOutlined, SoundOutlined, CameraOutlined, FullscreenOutlined,
DownOutlined, AlertOutlined, UserOutlined, FireOutlined, ClockCircleOutlined,
ScanOutlined, PlayCircleOutlined, DownloadOutlined
} from '@ant-design/icons';
const { Text } = Typography;
const { Option } = Select;
export default function VideoMonitorPage() {
const [camList] = useState([
{ key: '1', name: 'CAM-01', position: '1#阵列区', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:45' },
{ key: '2', name: 'CAM-02', position: '逆变器室', status: '在线', recStatus: '录制中', time: '2025-05-20 10:24:10' },
{ key: '3', name: 'CAM-03', position: '电站大门', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:58' },
{ key: '4', name: 'CAM-04', position: '周界北侧', status: '在线', recStatus: '录制中', time: '2025-05-20 10:24:01' },
{ key: '5', name: 'CAM-05', position: '气象站', status: '在线', recStatus: '录制中', time: '2025-05-20 10:24:05' },
{ key: '6', name: 'CAM-06', position: '设备区', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:50' },
{ key: '7', name: 'CAM-07', position: '储能区', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:47' },
{ key: '8', name: 'CAM-08', position: '周界南侧', status: '离线', recStatus: '停止', time: '2025-05-20 09:12:31' },
{ key: '9', name: 'CAM-09', position: '1#阵列区西侧', status: '离线', recStatus: '停止', time: '2025-05-20 08:55:02' },
]);
const camColumns = [
{ title: '摄像头名称', dataIndex: 'name', key: 'name' },
{ title: '位置', dataIndex: 'position', key: 'position' },
{
title: '状态', dataIndex: 'status', key: 'status',
render: (text) => text === '在线'
? <Tag color="green">在线</Tag>
: <Tag color="red">离线</Tag>
},
{ title: '录像状态', dataIndex: 'recStatus', key: 'recStatus' },
{ title: '最后事件时间', dataIndex: 'time', key: 'time' },
{
title: '操作', key: 'action',
render: () => (
<Space size="small">
<Button type="text" icon={<CameraOutlined />} />
</Space>
)
}
];
return (
<div className="p-6 bg-[#f5f7fa] min-h-screen">
<div style={{ marginBottom: 16 }}>
<Typography.Title level={4} style={{ margin: 0 }}>视频监控</Typography.Title>
<p style={{ color: '#666', margin: '4px 0 0' }}>实时视频监控、云台控制、录像回放与智能告警一体化管理</p>
</div>
{/* ========== 顶部统计卡片:统一高度 ========== */}
<Row gutter={[16, 16]} style={{ marginBottom: 16, display: 'flex', alignItems: 'stretch' }}>
<Col style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }} bodyStyle={{ padding: '16px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 24, fontWeight: 700 }}>32 台</div>
<div style={{ color: '#0837A8', fontSize: 14, marginTop: 4 }}>在线摄像头</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>在线率 <span style={{ color: '#52c41a' }}>↑ 4.1%</span></div>
</div>
<VideoCameraOutlined style={{ fontSize: 28, color: '#1890ff' }} />
</div>
</Card>
</Col>
<Col style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }} bodyStyle={{ padding: '16px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 24, fontWeight: 700 }}>2 台</div>
<div style={{ color: '#0837A8', fontSize: 14, marginTop: 4 }}>离线摄像头</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>离线率 <span style={{ color: '#ff4d4f' }}>↑ 5.9%</span></div>
</div>
<VideoCameraOutlined style={{ fontSize: 28, color: '#999' }} />
</div>
</Card>
</Col>
<Col style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }} bodyStyle={{ padding: '16px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 24, fontWeight: 700 }}>6 起</div>
<div style={{ color: '#0837A8', fontSize: 14, marginTop: 4 }}>今日告警事件</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>较昨日 <span style={{ color: '#ff4d4f' }}>↑ 50%</span></div>
</div>
<BellOutlined style={{ fontSize: 28, color: '#faad14' }} />
</div>
</Card>
</Col>
<Col style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }} bodyStyle={{ padding: '16px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 24, fontWeight: 700 }}>2 起</div>
<div style={{ color: '#0837A8', fontSize: 14, marginTop: 4 }}>周界告警</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>较昨日 <span style={{ color: '#ff4d4f' }}>↑ 100%</span></div>
</div>
<BorderOutlined style={{ fontSize: 28, color: '#ff4d4f' }} />
</div>
</Card>
</Col>
<Col style={{ flex: 1 }}>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }} bodyStyle={{ padding: '16px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 24, fontWeight: 700 }}>78.6TB</div>
<div style={{ color: '#0837A8', fontSize: 14, marginTop: 4 }}>存储使用率</div>
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>使用率 <span style={{ color: '#52c41a' }}>65.5%</span></div>
</div>
<DatabaseOutlined style={{ fontSize: 28, color: '#1890ff' }} />
</div>
</Card>
</Col>
</Row>
{/* ========== 视频区域 + AI:高度对齐 ========== */}
<Row gutter={[16, 16]} className="mb-6">
<Col xs={24} lg={18}>
<Card title="视频监控中心" className="h-[520px]" extra={
<Space>
<Button type="link">自定义布局</Button>
<Button type="link">全屏</Button>
</Space>
}>
<div className="flex gap-4 h-full">
<div className="flex-1 relative rounded overflow-hidden h-[420px]">
<img
src="https://picsum.photos/id/10/1200/500"
className="w-full h-full object-cover"
alt="video"
/>
<div className="absolute top-0 left-0 w-full p-2 bg-gradient-to-b from-black/60 to-transparent text-white">
<div className="font-bold">主画面:1#阵列区球机</div>
<div className="text-xs opacity-80">2025-05-20 10:24:15</div>
</div>
<div className="absolute bottom-0 w-full p-2 bg-gradient-to-t from-black/60 to-transparent">
<Space>
<Button type="text" icon={<PauseOutlined />} className="text-white" />
<Button type="text" icon={<SoundOutlined />} className="text-white" />
<Button type="text" icon={<CameraOutlined />} className="text-white" />
<Button type="text" icon={<FullscreenOutlined />} className="text-white" />
<Dropdown overlay={
<Menu>
<Menu.Item>超清</Menu.Item>
<Menu.Item>高清</Menu.Item>
<Menu.Item>标清</Menu.Item>
</Menu>
}>
<Button type="text" className="text-white">高清 <DownOutlined /></Button>
</Dropdown>
</Space>
</div>
</div>
<div className="w-[220px] grid grid-cols-2 gap-2">
{[11, 12, 13, 14, 15, 16].map((id) => (
<div key={id} className="relative rounded overflow-hidden">
<img src={`https://picsum.photos/id/${id}/200/100`} className="w-full h-[70px] object-cover" />
<div className="absolute bottom-1 right-1 text-xs bg-black/60 text-white px-1 rounded">直播中</div>
</div>
))}
</div>
</div>
</Card>
</Col>
<Col xs={24} lg={6}>
<Card title="AI视频智能分析" className="h-[520px]" extra={<Button type="link">设置</Button>}>
<div className="space-y-4">
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-red-100 flex items-center justify-center text-red-500">
<AlertOutlined />
</div>
<div className="flex-1">
<div className="font-medium">周界入侵检测</div>
<div className="text-xs text-gray-500">识别翻越、攀爬、破坏围栏</div>
</div>
<div className="text-red-500 font-bold">2</div>
</div>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-500">
<UserOutlined />
</div>
<div className="flex-1">
<div className="font-medium">人员闯入</div>
<div className="text-xs text-gray-500">识别未经授权人员进入</div>
</div>
<div className="text-red-500 font-bold">1</div>
</div>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-orange-100 flex items-center justify-center text-orange-500">
<FireOutlined />
</div>
<div className="flex-1">
<div className="font-medium">烟火识别</div>
<div className="text-xs text-gray-500">识别烟雾、明火等异常</div>
</div>
<div className="text-green-500 font-bold">0</div>
</div>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-yellow-100 flex items-center justify-center text-yellow-600">
<ClockCircleOutlined />
</div>
<div className="flex-1">
<div className="font-medium">设备区域滞留</div>
<div className="text-xs text-gray-500">识别人员超时停留</div>
</div>
<div className="text-red-500 font-bold">1</div>
</div>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center text-purple-500">
<ScanOutlined />
</div>
<div className="flex-1">
<div className="font-medium">运动检测</div>
<div className="text-xs text-gray-500">识别画面异常运动</div>
</div>
<div className="text-red-500 font-bold">2</div>
</div>
</div>
</Card>
</Col>
</Row>
{/* ========== 底部三张卡片:高度完全统一 ========== */}
<Row gutter={[16, 16]}>
<Col xs={24} lg={10}>
<Card className="h-[500px]"
title="摄像头设备列表"
extra={
<Space>
<Input.Search placeholder="搜索摄像头" style={{ width: 200 }} />
<Select defaultValue="all" style={{ width: 120 }}>
<Option value="all">全部状态</Option>
<Option value="online">在线</Option>
<Option value="offline">离线</Option>
</Select>
</Space>
}
>
<Table
columns={camColumns}
dataSource={camList}
pagination={false}
size="small"
scroll={{ y: 380 }}
/>
</Card>
</Col>
<Col xs={24} lg={7}>
<Card className="h-[500px]"
title="事件时间线"
extra={
<Select defaultValue="all" style={{ width: 120 }}>
<Select.Option value="all">全部类型</Select.Option>
<Select.Option value="perimeter">周界入侵</Select.Option>
<Select.Option value="intrusion">人员闯入</Select.Option>
</Select>
}
>
<Timeline mode="alternate" style={{ marginTop: 10 }}>
<Timeline.Item color="red">
<div className="text-xs text-gray-500">10:23:41</div>
<div className="font-medium text-sm mt-1">周界入侵检测</div>
<div className="text-xs text-gray-500 mt-1">周界北侧区域检测到翻越围栏事件</div>
</Timeline.Item>
<Timeline.Item color="orange">
<div className="text-xs text-gray-500">10:18:09</div>
<div className="font-medium text-sm mt-1">人员闯入</div>
<div className="text-xs text-gray-500 mt-1">设备区检测到人员闯入</div>
</Timeline.Item>
<Timeline.Item color="orange">
<div className="text-xs text-gray-500">10:05:33</div>
<div className="font-medium text-sm mt-1">设备区域滞留</div>
<div className="text-xs text-gray-500 mt-1">逆变器区人员滞留超过5分钟</div>
</Timeline.Item>
<Timeline.Item color="blue">
<div className="text-xs text-gray-500">09:52:17</div>
<div className="font-medium text-sm mt-1">运动检测</div>
<div className="text-xs text-gray-500 mt-1">气象站区域检测到异常运动</div>
</Timeline.Item>
<Timeline.Item color="red">
<div className="text-xs text-gray-500">09:41:28</div>
<div className="font-medium text-sm mt-1">周界入侵检测</div>
<div className="text-xs text-gray-500 mt-1">周界南侧区域检测到攀爬事件</div>
</Timeline.Item>
</Timeline>
<div className="text-center mt-4">
<Button type="link">查看更多</Button>
</div>
</Card>
</Col>
<Col xs={24} lg={7}>
<Card className="h-[500px]" title="最近告警快照" extra={<Button type="link">查看更多</Button>}>
<div className="space-y-3">
{[20, 21, 22, 23].map((id) => (
<div key={id} className="flex gap-2 items-center">
<img src={`https://picsum.photos/id/${id}/120/70`} className="w-[120px] h-[70px] object-cover rounded" />
<div className="flex-1">
<div className="font-medium text-sm">告警事件</div>
<div className="text-xs text-gray-500">2025-05-20 10:23</div>
</div>
<Space>
<Button type="text" icon={<PlayCircleOutlined />} />
<Button type="text" icon={<DownloadOutlined />} />
</Space>
</div>
))}
</div>
</Card>
</Col>
</Row>
</div>
);
}