Files
web-Iot/src/pages/VideoMonitorPage.tsx
2026-05-14 12:44:18 +08:00

397 lines
21 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 React, { useState } from 'react';
import {
Card, Row, Col, Button, Space, Input, Select, Table, Tag, Typography, Dropdown, Menu,
Timeline, Badge, Divider, Tooltip
} from 'antd';
import {
VideoCameraOutlined, BellOutlined, BorderOutlined, DatabaseOutlined,
PauseOutlined, SoundOutlined, CameraOutlined, FullscreenOutlined,
DownOutlined, AlertOutlined, UserOutlined, FireOutlined, ClockCircleOutlined,
ScanOutlined, PlayCircleOutlined, DownloadOutlined, ReloadOutlined,
PictureOutlined, VideoCameraAddOutlined, ScissorOutlined,
ExpandOutlined, SettingOutlined, SearchOutlined, MoreOutlined
} from '@ant-design/icons';
import { Fence, Monitor, HardDrive, BellRing, History, Eye, Play, Square, Volume2, ChevronRight } from 'lucide-react';
const { Text, Title } = Typography;
const { Option } = Select;
export default function VideoMonitorPage() {
const cardStyle = {
borderRadius: 12,
border: '1px solid #f0f0f0',
boxShadow: '0 4px 12px rgba(0,0,0,0.05)',
overflow: 'hidden'
};
const [camList] = useState([
{ key: '1', name: 'CAM-01 1#阵列区球机', position: '1#阵列区', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:45' },
{ key: '2', name: 'CAM-02 2#逆变器室', position: '逆变器室', status: '在线', recStatus: '录制中', time: '2025-05-20 10:24:10' },
{ key: '3', name: 'CAM-03 3#电站大门', position: '电站大门', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:58' },
{ key: '4', name: 'CAM-04 4#周界北侧', position: '周界北侧', status: '在线', recStatus: '录制中', time: '2025-05-20 10:24:01' },
{ key: '5', name: 'CAM-05 5#气象站', position: '气象站', status: '在线', recStatus: '录制中', time: '2025-05-20 10:24:05' },
{ key: '6', name: 'CAM-06 6#设备区', position: '设备区', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:50' },
{ key: '7', name: 'CAM-07 7#储能电池舱', position: '储能区', status: '在线', recStatus: '录制中', time: '2025-05-20 10:23:47' },
{ key: '8', name: 'CAM-08 8#周界南侧', position: '周界南侧', status: '离线', recStatus: '停止', time: '2025-05-20 09:12:31' },
{ key: '9', name: 'CAM-09 9#阵列区西侧', position: '1#阵列区西侧', status: '离线', recStatus: '停止', time: '2025-05-20 08:55:02' },
]);
const camColumns = [
{ title: '摄像头名称', dataIndex: 'name', key: 'name', width: 200 },
{ title: '位置', dataIndex: 'position', key: 'position', width: 120 },
{
title: '状态', dataIndex: 'status', key: 'status', width: 100,
render: (text: string) => (
<Space size={4}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: text === '在线' ? '#00B42A' : '#F53F3F' }}></div>
<span style={{ color: text === '在线' ? '#00B42A' : '#F53F3F' }}>{text}</span>
</Space>
)
},
{
title: '录像状态', dataIndex: 'recStatus', key: 'recStatus', width: 100,
render: (text: string) => (
<Space size={4}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: text === '录制中' ? '#00B42A' : '#86909C' }}></div>
<span style={{ color: text === '录制中' ? '#00B42A' : '#86909C' }}>{text}</span>
</Space>
)
},
{ title: '最后事件时间', dataIndex: 'time', key: 'time', width: 180 },
{
title: '操作', key: 'action', width: 60,
render: () => (
<Button type="text" icon={<PlayCircleOutlined />} size="small" />
)
}
];
return (
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px', boxSizing: 'border-box' }}>
<style>
{`
.compact-table .ant-table-thead > tr > th {
background: #f8fafc;
padding: 8px 12px !important;
font-size: 12px;
color: #4E5969;
}
.compact-table .ant-table-tbody > tr > td {
padding: 8px 12px !important;
font-size: 12px;
}
.video-item:hover .video-mask {
opacity: 1;
}
.video-mask {
opacity: 0;
transition: opacity 0.3s;
background: rgba(0,0,0,0.4);
}
.timeline-item-custom .ant-timeline-item-content {
margin-left: 50px !important;
}
`}
</style>
{/* 顶部统计卡片 */}
<Row
gutter={[16, 16]}
style={{
marginBottom: 16,
flexWrap: 'wrap',
}}
>
{[
{
title: '在线摄像头',
value: '32',
unit: '台',
sub: '在线率 ↑ 4.1%',
subColor: '#52c41a',
icon: <VideoCameraOutlined />,
color: '#1890ff',
bg: '#E8F3FF'
},
{
title: '离线摄像头',
value: '2',
unit: '台',
sub: '离线率 ↑ 5.9%',
subColor: '#ff4d4f',
icon: <VideoCameraOutlined />,
color: '#999',
bg: '#F5F7FA'
},
{
title: '今日告警事件',
value: '6',
unit: '起',
sub: '较昨日 ↑ 50%',
subColor: '#ff4d4f',
icon: <BellOutlined />,
color: '#faad14',
bg: '#FFF7E8'
},
{
title: '周界告警',
value: '2',
unit: '起',
sub: '较昨日 ↑ 100%',
subColor: '#ff4d4f',
icon: <BorderOutlined />,
color: '#ff4d4f',
bg: '#FFF1F0'
},
{
title: '存储使用率',
value: '78.6',
unit: 'TB',
sub: '使用率 65.5%',
subColor: '#52c41a',
icon: <DatabaseOutlined />,
color: '#1890ff',
bg: '#E8F3FF'
},
].map((item, index) => (
<Col key={index} style={{ minWidth: '168px', flex: '1 0 auto' }}>
<Card
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ borderRadius: 8, height: 120 }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', height: '100%' }}>
<div>
<div style={{ fontSize: 14, color: '#0837A8', marginBottom: 4 }}>{item.title}</div>
<div style={{ display: 'flex', alignItems: 'baseline', marginBottom: 4 }}>
<span style={{ fontSize: 24, fontWeight: 700, color: '#333' }}>{item.value}</span>
<span style={{ fontSize: 14, marginLeft: 4, color: '#333' }}>{item.unit}</span>
</div>
<div style={{ fontSize: 12, color: '#999' }}>
在线率 <span style={{ color: item.subColor }}>{item.sub.replace('在线率 ', '')}</span>
</div>
</div>
<div style={{
width: 48,
height: 48,
borderRadius: '50%',
background: item.bg,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0
}}>
{React.cloneElement(item.icon, { style: { fontSize: 24, color: item.color } })}
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 中间视频监控中心 */}
<Row gutter={[12, 12]} style={{ marginBottom: 16 }}>
<Col xs={24} xl={18}>
<Card
title={<span style={{ fontSize: 16, fontWeight: 800, color: '#1D2129' }}>视频监控中心</span>}
extra={
<Space size={16}>
<Button type="link" size="small" icon={<ExpandOutlined />}>自定义布局</Button>
<Button type="link" size="small" icon={<FullscreenOutlined />}>全屏</Button>
</Space>
}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: 16 }}
>
<Row gutter={[12, 12]}>
<Col span={14}>
<div style={{ position: 'relative', background: '#000', borderRadius: 8, overflow: 'hidden', height: 420 }}>
<img src="https://images.unsplash.com/photo-1509391366360-2e959784a276?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80" style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
<div style={{ position: 'absolute', top: 0, left: 0, width: '100%', padding: '10px 16px', background: 'linear-gradient(to bottom, rgba(0,0,0,0.6), transparent)', color: '#fff', display: 'flex', justifyContent: 'space-between' }}>
<span style={{ fontSize: 13, fontWeight: 700 }}>主画面:1#阵列区球机</span>
<span style={{ fontSize: 11, opacity: 0.8 }}>2025-05-20 10:24:15</span>
</div>
<div style={{ position: 'absolute', bottom: 0, left: 0, width: '100%', padding: '12px 16px', background: 'linear-gradient(to top, rgba(0,0,0,0.6), transparent)', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Space size={20}>
<PauseOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<SoundOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<VideoCameraAddOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<ScissorOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<CameraOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<ExpandOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<Select defaultValue="高清" size="small" style={{ width: 80 }} bordered={false} className="video-select">
<Option value="超清">超清</Option>
<Option value="高清">高清</Option>
<Option value="标清">标清</Option>
</Select>
</Space>
<div style={{ color: '#fff', cursor: 'pointer' }}><MoreOutlined style={{ fontSize: 20 }} /></div>
</div>
</div>
</Col>
<Col span={10}>
<Row gutter={[8, 8]}>
{[
{ title: '2#逆变器室', img: 'https://images.unsplash.com/photo-1581094794329-c8112a89af12?auto=format&fit=crop&w=400&q=60' },
{ title: '3#电站大门', img: 'https://images.unsplash.com/photo-1541888946425-d81bb19480c5?auto=format&fit=crop&w=400&q=60' },
{ title: '4#周界北侧', img: 'https://images.unsplash.com/photo-1504384308090-c894fdcc538d?auto=format&fit=crop&w=400&q=60' },
{ title: '5#气象站', img: 'https://images.unsplash.com/photo-1534088568595-a066f7104211?auto=format&fit=crop&w=400&q=60' },
{ title: '6#设备区', img: 'https://images.unsplash.com/photo-1581092160562-40aa08e78837?auto=format&fit=crop&w=400&q=60' },
{ title: '7#储能电池舱', img: 'https://images.unsplash.com/photo-1593941707882-a5bba14938c7?auto=format&fit=crop&w=400&q=60' },
].map((v, i) => (
<Col span={12} key={i}>
<div className="video-item" style={{ position: 'relative', background: '#000', borderRadius: 6, overflow: 'hidden', height: 135 }}>
<img src={v.img} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
<div style={{ position: 'absolute', top: 0, left: 0, width: '100%', padding: '4px 8px', background: 'rgba(0,0,0,0.4)', color: '#fff', fontSize: 10 }}>{v.title}</div>
<div style={{ position: 'absolute', bottom: 4, right: 8, display: 'flex', alignItems: 'center', gap: 4 }}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: '#00B42A' }}></div>
<span style={{ color: '#fff', fontSize: 9 }}>直播中</span>
</div>
<div className="video-mask" style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<PlayCircleOutlined style={{ color: '#fff', fontSize: 32, cursor: 'pointer' }} />
</div>
</div>
</Col>
))}
</Row>
</Col>
</Row>
</Card>
</Col>
<Col xs={24} xl={6}>
<Card
title={<span style={{ fontSize: 16, fontWeight: 800, color: '#1D2129' }}>AI 视频智能分析</span>}
extra={<Button type="link" size="small">设置 <ChevronRight size={14} /></Button>}
bordered={false}
style={{ ...cardStyle, height: '100%' }}
bodyStyle={{ padding: '16px 20px' }}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{[
{ icon: <img src="https://img.icons8.com/fluency/48/alarm.png" style={{ width: 24 }} />, bg: '#FFF1F0', title: '周界入侵检测', desc: '识别翻越、攀爬、破坏围栏等行为', count: 2, color: '#F53F3F' },
{ icon: <img src="https://img.icons8.com/fluency/48/user-male-circle.png" style={{ width: 24 }} />, bg: '#E8F3FF', title: '人员闯入', desc: '识别未经授权人员进入区域', count: 1, color: '#165DFF' },
{ icon: <svg t="1778729206689" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4980" width="24" height="24"><path d="M336.349867 969.728c42.564267 14.199467 56.746667-24.814933 39.0144-38.997333-56.746667-39.0144-85.128533-109.943467-63.829334-173.7728 21.265067-70.929067 78.011733-99.310933 78.011734-205.704534 0 0 70.929067 53.1968 56.746666 134.775467 70.929067-81.578667 39.0144-187.972267 24.814934-237.6192 180.872533 95.744 336.930133 304.9984 156.0576 482.321067-21.282133 17.749333 0 49.664 31.914666 39.0144 492.970667-280.1664 120.576-698.658133 56.746667-748.305067 21.282133 49.646933 24.832 127.658667-17.732267 166.673067C623.616 107.946667 442.743467 51.2 442.743467 51.2c21.282133 145.408-81.578667 301.448533-177.322667 422.0416-3.549867-60.296533-7.099733-99.310933-35.464533-152.507733-7.099733 102.843733-88.661333 187.972267-109.943467 294.365866C91.648 756.957867 141.312 859.8016 336.349867 969.728z" fill="#f33b24" p-id="4981"></path></svg>, bg: '#FFF7E8', title: '烟火识别', desc: '识别烟雾、明火等异常情况', count: 0, color: '#86909C' },
{ icon: <svg t="1778729276274" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6131" width="24" height="24"><path d="M0 0m0 0l1024 0q0 0 0 0l0 1024q0 0 0 0l-1024 0q0 0 0 0l0-1024q0 0 0 0Z" fill="#E8EFF8" p-id="6132"></path><path d="M139.636364 558.545455a23.272727 23.272727 0 0 1 23.272727-23.272728h698.181818a23.272727 23.272727 0 0 1 23.272727 23.272728v116.363636a23.272727 23.272727 0 0 1-23.272727 23.272727H162.909091a23.272727 23.272727 0 0 1-23.272727-23.272727v-116.363636z" fill="#247ADE" p-id="6133"></path><path d="M372.363636 616.727273a58.181818 58.181818 0 1 1-116.363636 0 58.181818 58.181818 0 0 1 116.363636 0zM558.545455 616.727273a58.181818 58.181818 0 1 1-116.363637 0 58.181818 58.181818 0 0 1 116.363637 0zM744.727273 616.727273a58.181818 58.181818 0 1 1-116.363637 0 58.181818 58.181818 0 0 1 116.363637 0zM139.636364 325.818182a23.272727 23.272727 0 0 1 23.272727-23.272727h698.181818a23.272727 23.272727 0 0 1 23.272727 23.272727v116.363636a23.272727 23.272727 0 0 1-23.272727 23.272727H162.909091a23.272727 23.272727 0 0 1-23.272727-23.272727v-116.363636z" fill="#9DBCF3" p-id="6134"></path><path d="M372.363636 384a58.181818 58.181818 0 1 1-116.363636 0 58.181818 58.181818 0 0 1 116.363636 0zM558.545455 384a58.181818 58.181818 0 1 1-116.363637 0 58.181818 58.181818 0 0 1 116.363637 0zM744.727273 384a58.181818 58.181818 0 1 1-116.363637 0 58.181818 58.181818 0 0 1 116.363637 0z" fill="#2479DC" p-id="6135"></path></svg>, bg: '#FFF7E8', title: '设备区域滞留', desc: '识别人员在设备区滞留行为', count: 1, color: '#F7BA1E' },
{ icon: <img src="https://img.icons8.com/fluency/48/motion-detector.png" style={{ width: 24 }} />, bg: '#E8FFEA', title: '运动检测', desc: '识别画面异常运动目标', count: 2, color: '#00B42A' },
].map((item, idx) => (
<div key={idx} style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<div style={{ width: 44, height: 44, background: item.bg, borderRadius: 10, display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
{item.icon}
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 13, fontWeight: 700, color: '#1D2129' }}>{item.title}</div>
<div style={{ fontSize: 11, color: '#86909C', marginTop: 2 }}>{item.desc}</div>
</div>
<div style={{ fontSize: 18, fontWeight: 800, color: item.count > 0 ? '#F53F3F' : '#86909C' }}>{item.count}</div>
</div>
))}
</div>
</Card>
</Col>
</Row>
{/* 底部三栏 */}
<Row gutter={[12, 12]}>
<Col xs={24} xl={10}>
<Card
title={<span style={{ fontSize: 15, fontWeight: 800, color: '#1D2129' }}>摄像头设备列表</span>}
extra={
<Space>
<Input placeholder="搜索摄像头名称/位置" prefix={<SearchOutlined />} style={{ width: 200 }} size="small" />
<Select defaultValue="全部状态" size="small" style={{ width: 120 }}>
<Option value="全部状态">全部状态</Option>
<Option value="在线">在线</Option>
<Option value="离线">离线</Option>
</Select>
</Space>
}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: 0 }}
>
<Table
columns={camColumns}
dataSource={camList}
pagination={false}
size="small"
className="compact-table"
scroll={{ y: 350 }}
/>
</Card>
</Col>
<Col xs={24} xl={7}>
<Card
title={<span style={{ fontSize: 15, fontWeight: 800, color: '#1D2129' }}>事件时间线</span>}
extra={<Select defaultValue="全部类型" size="small" style={{ width: 100 }}><Option value="全部类型">全部类型</Option></Select>}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: '16px 20px' }}
>
<Timeline style={{ marginTop: 8 }}>
{[
{ time: '10:23:41', title: '周界入侵检测', desc: '周界北侧区域检测到翻越围栏事件', color: '#F53F3F' },
{ time: '10:18:09', title: '人员闯入', desc: '设备区检测到人员闯入', color: '#F7BA1E' },
{ time: '10:05:33', title: '设备区域滞留', desc: '逆变器区人员滞留超过5分钟', color: '#F7BA1E' },
{ time: '09:52:17', title: '运动检测', desc: '气象站区域检测到异常运动', color: '#165DFF' },
{ time: '09:41:28', title: '周界入侵检测', desc: '周界南侧区域检测到攀爬事件', color: '#F53F3F' },
].map((item, idx) => (
<Timeline.Item key={idx} label={<span style={{ fontSize: 11, color: '#86909C' }}>{item.time}</span>} dot={<div style={{ width: 8, height: 8, borderRadius: '50%', background: item.color }}></div>}>
<div style={{ marginLeft: 8 }}>
<div style={{ fontSize: 13, fontWeight: 700, color: '#1D2129' }}>{item.title}</div>
<div style={{ fontSize: 11, color: '#86909C', marginTop: 4 }}>{item.desc}</div>
</div>
</Timeline.Item>
))}
</Timeline>
<div style={{ textAlign: 'center', marginTop: 16 }}>
<Button type="link" size="small">查看更多</Button>
</div>
</Card>
</Col>
<Col xs={24} xl={7}>
<Card
title={<span style={{ fontSize: 15, fontWeight: 800, color: '#1D2129' }}>最近告警快照</span>}
extra={<Button type="link" size="small">查看更多 <ChevronRight size={14} /></Button>}
bordered={false}
style={cardStyle}
bodyStyle={{ padding: '16px 20px' }}
>
<div style={{ display: 'flex', flexWrap: "wrap", gap: 12, paddingBottom: 8 }} >
{[
{ title: '周界北侧', time: '10:23:41', type: '周界入侵', img: 'https://images.unsplash.com/photo-1504384308090-c894fdcc538d?auto=format&fit=crop&w=300&q=60', boxColor: '#F53F3F' },
{ title: '设备区', time: '10:18:09', type: '人员闯入', img: 'https://images.unsplash.com/photo-1581092160562-40aa08e78837?auto=format&fit=crop&w=300&q=60', boxColor: '#F7BA1E' },
{ title: '逆变器室', time: '10:05:33', type: '设备区域滞留', img: 'https://images.unsplash.com/photo-1581094794329-c8112a89af12?auto=format&fit=crop&w=300&q=60', boxColor: '#F7BA1E' },
//{ title: '气象站', time: '09:52:17', type: '运动检测', img: 'https://images.unsplash.com/photo-1534088568595-a066f7104211?auto=format&fit=crop&w=300&q=60', boxColor: '#165DFF' },
].map((item, idx) => (
<div key={idx} style={{ minWidth: 140, flex: '0 0 140px' }}>
<div style={{ position: 'relative', borderRadius: 8, overflow: 'hidden', height: 160 }}>
<img src={item.img} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
{/* 模拟检测框 */}
<div style={{ position: 'absolute', top: '30%', left: '30%', width: '40%', height: '50%', border: `2px solid ${item.boxColor}`, borderRadius: 2 }}>
<div style={{ position: 'absolute', top: -18, left: -2, background: item.boxColor, color: '#fff', fontSize: 9, padding: '0 4px', borderRadius: '2px 2px 0 0', whiteSpace: 'nowrap' }}>{item.type}</div>
</div>
<div style={{ position: 'absolute', bottom: 0, left: 0, width: '100%', background: 'rgba(0,0,0,0.5)', color: '#fff', padding: '4px 8px', fontSize: 10 }}>
<div style={{ fontWeight: 700 }}>{item.time}</div>
<div style={{ opacity: 0.8 }}>{item.title}</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'center', gap: 8, marginTop: 10 }}>
<Tooltip title="播放"><Button type="text" icon={<PlayCircleOutlined />} size="small" /></Tooltip>
<Tooltip title="下载"><Button type="text" icon={<DownloadOutlined />} size="small" /></Tooltip>
<Tooltip title="详情"><Button type="text" icon={<Eye />} size="small" /></Tooltip>
</div>
</div>
))}
</div>
</Card>
</Col>
</Row>
</div>
);
}