切换视频 初始化
This commit is contained in:
@@ -35,7 +35,7 @@ export default function DroneLivePlayer({
|
||||
|
||||
// ---------------- 解析 RTC 参数 ----------------
|
||||
|
||||
const params = new URLSearchParams(streamData.url);
|
||||
const params = new URLSearchParams(streamData?.url);
|
||||
|
||||
const appId = (
|
||||
params.get("app_id") ||
|
||||
@@ -69,8 +69,8 @@ export default function DroneLivePlayer({
|
||||
const liveheartbeat = async () => {
|
||||
try {
|
||||
await postLiveHeartbeat({
|
||||
sn: streamData.sn,
|
||||
cameraIndex: streamData.camera_index,
|
||||
sn: streamData?.sn,
|
||||
cameraIndex: streamData?.camera_index,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("心跳失败", err);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import {
|
||||
Layout, Card, Row, Col, Statistic, Tag, Button, Table,
|
||||
Typography, Space, Progress, Badge, Timeline, message,
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from '@ant-design/icons';
|
||||
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getDeviceListApi, getLiveStream, getPlaneDeviceList } from '../../api/device.ts';
|
||||
import { changeCameragateway, getDeviceListApi, getLiveStream, getPlaneDeviceList } from '../../api/device.ts';
|
||||
import { RootState } from '@/src/store';
|
||||
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
|
||||
import AgoraTextTest from '../AgoraRtc.tsx';
|
||||
@@ -27,9 +27,6 @@ import CesiumMap from '../Map.jsx';
|
||||
const { Content } = Layout;
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
|
||||
|
||||
|
||||
const taskTimeline = [
|
||||
{ time: '10:24:18', color: 'blue', text: 'UAV-C01 开始执行清洗航线 C-05', status: '任务开始' },
|
||||
{ time: '10:21:35', color: 'orange', text: 'RBT-01 开始执行巡检航线 P-02', status: '任务开始' },
|
||||
@@ -48,70 +45,41 @@ const logs = [
|
||||
{ time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' },
|
||||
];
|
||||
|
||||
// 设备总览组件
|
||||
export default function DeviceOverviewPage({ devices, planedevices, devicesAll, onViewStatus, selectedSn, onDeviceSelect }) {
|
||||
const [planeVideo, setPlaneVideo] = useState([]); // 初始为空数组
|
||||
const [zoomedVideo, setZoomedVideo] = useState(null); // 放大查看的视频数据
|
||||
const [planeVideo, setPlaneVideo] = useState([]);
|
||||
const [zoomedVideo, setZoomedVideo] = useState(null);
|
||||
const [mowerView, setMowerView] = useState('front');
|
||||
const videoTypeRef = useRef('drone'); // drone → 无人机镜头 station → 机场镜头
|
||||
|
||||
// 衍生状态:从 SN 获取设备对象
|
||||
const selectedDevice = React.useMemo(() => {
|
||||
const sn = selectedSn || (devicesAll?.[0]?.device_sn || devicesAll?.[0]?.serialNumber);
|
||||
return devicesAll?.find(item => (item.device_sn || item.serialNumber) === sn) || null;
|
||||
}, [devicesAll, selectedSn]);
|
||||
|
||||
// 动态计算顶部卡片数据
|
||||
const isUAV = !!selectedDevice?.gateway_sn;
|
||||
|
||||
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
||||
selectedDevice?.serialNumber || '',
|
||||
`webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`,
|
||||
);
|
||||
|
||||
const dynamicTopCards = React.useMemo(() => {
|
||||
const totalDrones = planedevices?.length || 0;
|
||||
const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0;
|
||||
|
||||
const totalRobots = devicesAll?.filter(d => d.productName?.includes('巡检')).length || 0;
|
||||
const activeRobots = devicesAll?.filter(d => d.productName?.includes('巡检') && d.onlineStatus === 1).length || 0;
|
||||
|
||||
const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0;
|
||||
const activeMowers = devicesAll?.filter(d => d.productName?.includes('割草机') && d.onlineStatus === 1).length || 0;
|
||||
|
||||
const washDroneStandby = planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0;
|
||||
|
||||
return [
|
||||
{
|
||||
title: '无人机机场状态',
|
||||
icon: <EnvironmentOutlined />,
|
||||
value: `${onlineDrones} / ${totalDrones}`,
|
||||
sub: `可调度 ${onlineDrones} 架`,
|
||||
color: '#1890ff'
|
||||
},
|
||||
{
|
||||
title: '机器人',
|
||||
icon: <BranchesOutlined />,
|
||||
value: `${totalMowers} 台`,
|
||||
sub: `作业中 ${activeMowers}`,
|
||||
color: '#13c2c2'
|
||||
},
|
||||
{
|
||||
title: '无人机',
|
||||
icon: <CloudOutlined />,
|
||||
value: `${totalDrones} 架`,
|
||||
sub: `待命 ${washDroneStandby}`,
|
||||
color: '#eb2f96'
|
||||
},
|
||||
{
|
||||
title: '设备平均电量',
|
||||
icon: <ThunderboltOutlined />,
|
||||
value: '86%',
|
||||
sub: '',
|
||||
color: '#52c41a'
|
||||
},
|
||||
{
|
||||
title: '今日任务执行',
|
||||
icon: <CheckCircleOutlined />,
|
||||
value: '12 / 15',
|
||||
sub: '完成率 80%',
|
||||
color: '#2f54eb'
|
||||
},
|
||||
{ title: '无人机机场状态', icon: <EnvironmentOutlined />, value: `${onlineDrones} / ${totalDrones}`, sub: `可调度 ${onlineDrones} 架`, color: '#1890ff' },
|
||||
{ title: '机器人', icon: <BranchesOutlined />, value: `${totalMowers} 台`, sub: `作业中 ${activeMowers}`, color: '#13c2c2' },
|
||||
{ title: '无人机', icon: <CloudOutlined />, value: `${totalDrones} 架`, sub: `待命 ${washDroneStandby}`, color: '#eb2f96' },
|
||||
{ title: '设备平均电量', icon: <ThunderboltOutlined />, value: '86%', sub: '', color: '#52c41a' },
|
||||
{ title: '今日任务执行', icon: <CheckCircleOutlined />, value: '12 / 15', sub: '完成率 80%', color: '#2f54eb' },
|
||||
];
|
||||
}, [devicesAll, planedevices]);
|
||||
|
||||
// 动态生成调度列表
|
||||
const dynamicScheduleList = React.useMemo(() => {
|
||||
return devicesAll.map((d, index) => ({
|
||||
id: d.deviceId || index,
|
||||
@@ -126,105 +94,73 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
}));
|
||||
}, [devicesAll]);
|
||||
|
||||
const [mowerView, setMowerView] = useState('front');
|
||||
const isUAV = !!selectedDevice?.device_sn;
|
||||
|
||||
// 机器人 WebRTC 视频(和你第二个页面逻辑一致)
|
||||
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
||||
selectedDevice?.serialNumber || '',
|
||||
`webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`,
|
||||
);
|
||||
|
||||
|
||||
const handleStart = () => message.success('任务已启动');
|
||||
const handlePause = () => message.info('任务已暂停');
|
||||
const handleReturn = () => message.info('返航指令已下发');
|
||||
const handleRecharge = () => message.info('回充指令已下发');
|
||||
const handleEmergencyStop = () => message.error('已触发急停!');
|
||||
const getLiveDefault = () => {
|
||||
|
||||
// ====================== ✅ 核心:无人机视频获取逻辑(优先无人机 → 无则机场) ======================
|
||||
const getDroneLiveStream = async () => {
|
||||
if (!selectedDevice?.gateway_sn) return;
|
||||
const data = {
|
||||
getway_sn: selectedDevice?.gateway_sn,
|
||||
drone_sn: selectedDevice?.device_sn,
|
||||
getway_camera_list: selectedDevice?.gateway_camera_list ?? [],
|
||||
drone_camera_list: selectedDevice?.drone_camera_list ?? [],
|
||||
video_expire: 7200,
|
||||
quality_type: "adaptive",
|
||||
}
|
||||
getLiveStream(data).then(res => {
|
||||
if (res.code == 200) {
|
||||
setPlaneVideo(res.data);
|
||||
console.log(selectedDevice, "selectedDevice")
|
||||
try {
|
||||
if (selectedDevice.gateway_camera_list && selectedDevice.gateway_camera_list.length > 0) {
|
||||
const droneData = {
|
||||
sn: selectedDevice.gateway_sn,
|
||||
cameraIndex: selectedDevice.gateway_camera_list.filter(item => item.camera_position
|
||||
== "indoor")[0]?.camera_index || "",
|
||||
|
||||
cameraPosition: "indoor",
|
||||
qualityType: "adaptive",
|
||||
videoExpire: 7200,
|
||||
};
|
||||
changeCameragateway(droneData).then(res => {
|
||||
if (res.code == 200) {
|
||||
setPlaneVideo(res.data)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
setPlaneVideo({});
|
||||
} catch (err) {
|
||||
console.error('视频拉流失败', err);
|
||||
setPlaneVideo({});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 数字保留两位小数
|
||||
const fix2 = (val) => {
|
||||
if (val === null || val === undefined || isNaN(val)) return '-';
|
||||
return Number(val).toFixed(2);
|
||||
};
|
||||
|
||||
// 安全取值
|
||||
const getVal = (val) => val == "no_rain" ? "无" : (val || '-');
|
||||
|
||||
// 默认选中第一个
|
||||
useEffect(() => {
|
||||
getLiveDefault();
|
||||
}, [selectedDevice])
|
||||
|
||||
// 切换设备
|
||||
const handleDeviceChange = (id) => {
|
||||
if (onDeviceSelect) {
|
||||
onDeviceSelect(id);
|
||||
if (isUAV) {
|
||||
setPlaneVideo({});
|
||||
getDroneLiveStream();
|
||||
}
|
||||
}, [selectedDevice]);
|
||||
|
||||
const handleDeviceChange = (id) => {
|
||||
if (onDeviceSelect) onDeviceSelect(id);
|
||||
};
|
||||
|
||||
return (
|
||||
<Content style={{ maxWidth: 1800, margin: '0 auto', }}>
|
||||
{/*<AgoraTextTest />*/}
|
||||
<Row gutter={[8, 8]} style={{ marginBottom: 12, flexWrap: 'wrap' }}>
|
||||
{dynamicTopCards.map((card, idx) => (
|
||||
<Col key={idx} style={{ minWidth: '160px', flex: '1 0 auto' }}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{
|
||||
borderRadius: 8,
|
||||
boxShadow: '0 2px 8px rgba(0,0,0,0.05)',
|
||||
height: 90,
|
||||
}}
|
||||
bodyStyle={{ padding: '12px', height: '100%' }}
|
||||
>
|
||||
<Card bordered={false} style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.05)', height: 90 }} bodyStyle={{ padding: '12px', height: '100%' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 10, height: '100%' }}>
|
||||
{/* 左侧图标 */}
|
||||
<div
|
||||
style={{
|
||||
width: 40,
|
||||
height: 40,
|
||||
borderRadius: 8,
|
||||
background: `${card.color}15`,
|
||||
color: card.color,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: 'clamp(14px, 1.2vw, 18px)',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<div style={{ width: 40, height: 40, borderRadius: 8, background: `${card.color}15`, color: card.color, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 'clamp(14px, 1.2vw, 18px)', flexShrink: 0 }}>
|
||||
{card.icon}
|
||||
</div>
|
||||
|
||||
{/* 右侧文字 */}
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 'clamp(11px, 0.9vw, 13px)', color: '#666' }}>{card.title}</div>
|
||||
<div style={{ fontSize: 'clamp(18px, 1.6vw, 24px)', fontWeight: 700, color: '#222', lineHeight: '30px' }}>
|
||||
{card.value}
|
||||
</div>
|
||||
{card.sub && (
|
||||
<div style={{ fontSize: 'clamp(10px, 0.8vw, 12px)', color: '#999', marginTop: 2 }}>
|
||||
{card.sub}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: 'clamp(18px, 1.6vw, 24px)', fontWeight: 700, color: '#222', lineHeight: '30px' }}>{card.value}</div>
|
||||
{card.sub && <div style={{ fontSize: 'clamp(10px, 0.8vw, 12px)', color: '#999', marginTop: 2 }}>{card.sub}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -244,7 +180,6 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<div><span style={{ color: '#52c41a' }}>———</span> 清洗路径</div>
|
||||
<div>🚗 机器位置</div>
|
||||
<div>✈️ 无人机位置</div>
|
||||
|
||||
<div><span style={{ color: '#1890ff' }}>●</span> 补给/充电点</div>
|
||||
<div><span style={{ color: '#ff4d4f' }}>■</span> 障碍/禁入区</div>
|
||||
</div>
|
||||
@@ -264,7 +199,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
{ title: '位置', dataIndex: 'position', width: 90 },
|
||||
{ title: '当前任务', dataIndex: 'task', width: 100 },
|
||||
{ title: '通讯状态', dataIndex: 'comm', width: 70, render: v => <Badge status={v.includes('-') ? 'warning' : 'success'} text={v} /> },
|
||||
{ title: '操作', key: 'action', width: 80, render: () => <Space size={4}><Button size="small" type="text" icon={<EditOutlined />} /><Button size="small" type="text" icon={<SettingOutlined />} /></Space> }
|
||||
{ title: '操作', key: 'action', width: 80, render: () => <Space size={4}><Button size="small" type="text" icon={<EditOutlined />} /><Button size="small" type="text" icon={<SettingOutlined />} /></Space> },
|
||||
]}
|
||||
dataSource={dynamicScheduleList}
|
||||
scroll={{ x: 'max-content', y: 280 }}
|
||||
@@ -286,46 +221,21 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
</Col>
|
||||
|
||||
<Col xs={24} lg={10}>
|
||||
<Card
|
||||
title={<><SettingOutlined style={{ marginRight: 6, }} /> 设备控制面板</>}
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8, marginBottom: 8 }}
|
||||
bodyStyle={{ padding: 12, paddingBottom: 0 }}
|
||||
>
|
||||
<Card title={<><SettingOutlined style={{ marginRight: 6, }} /> 设备控制面板</>} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }} bodyStyle={{ padding: 12, paddingBottom: 0 }}>
|
||||
<Select
|
||||
style={{ width: "80%", marginBottom: 8 }}
|
||||
placeholder="请选择设备"
|
||||
value={selectedDevice?.device_sn || selectedDevice?.serialNumber}
|
||||
onChange={handleDeviceChange}
|
||||
size="small"
|
||||
showSearch // 👈 开启搜索
|
||||
allowClear // 允许删除/清空
|
||||
optionFilterProp="label" // 👈 按设备名称搜索
|
||||
filterOption={(input, option) =>
|
||||
option.label.toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
showSearch
|
||||
allowClear
|
||||
optionFilterProp="label"
|
||||
filterOption={(input, option) => option.label.toLowerCase().includes(input.toLowerCase())}
|
||||
options={[
|
||||
{
|
||||
label: <span>机器人</span>,
|
||||
title: 'manager',
|
||||
options: devices.map(item => ({
|
||||
value: item.device_sn || item.serialNumber,
|
||||
label: item.deviceAlias || item.deviceName || '未知设备'
|
||||
})),
|
||||
},
|
||||
{
|
||||
label: <span>无人机</span>,
|
||||
title: 'engineer',
|
||||
options: planedevices.map(item => ({
|
||||
value: item.device_sn,
|
||||
label: item.drone_callsign || item.callsign || '未知设备'
|
||||
})),
|
||||
},
|
||||
{ label: <span>机器人</span>, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) },
|
||||
{ label: <span>无人机</span>, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) },
|
||||
]}
|
||||
//options={devicesAll.map(item => ({
|
||||
// value: item.device_sn || item.serialNumber,
|
||||
// label: item.deviceAlias || item.drone_callsign || item.callsign || item.deviceName || '未知设备'
|
||||
//}))}
|
||||
/>
|
||||
|
||||
{selectedDevice && (
|
||||
@@ -333,29 +243,20 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<Col span={12}>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12, flexWrap: "wrap" }}>
|
||||
{selectedDevice.deviceType === 'drone' ||
|
||||
selectedDevice.deviceName?.includes('无人机') ||
|
||||
selectedDevice.drone_callsign ? (
|
||||
{selectedDevice.deviceType === 'drone' || selectedDevice.deviceName?.includes('无人机') || selectedDevice.drone_callsign ? (
|
||||
<span style={{ fontSize: 20, color: '#1890ff' }}><RocketOutlined /></span>
|
||||
) : (
|
||||
<span style={{ fontSize: 20, color: '#1890ff' }}><CarOutlined /></span>
|
||||
)}
|
||||
|
||||
<span style={{ fontSize: 14, fontWeight: 600 }}>{selectedDevice.deviceAlias || selectedDevice.drone_callsign || selectedDevice.callsign || selectedDevice.deviceName}</span>
|
||||
<Tag color={selectedDevice.onlineStatus === 1 ? "success" : "default"} size="small" style={{ margin: 0 }}>
|
||||
{selectedDevice.onlineStatus == 1 ? "在线" : "离线"}
|
||||
</Tag>
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
ghost
|
||||
|
||||
icon={<InfoCircleOutlined />}
|
||||
type="primary" size="small" ghost icon={<InfoCircleOutlined />}
|
||||
style={{ borderRadius: 4, fontSize: 11, marginLeft: 'auto' }}
|
||||
onClick={() => onViewStatus && onViewStatus(selectedDevice.device_sn || selectedDevice.serialNumber)}
|
||||
>
|
||||
详情
|
||||
</Button>
|
||||
>详情</Button>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
|
||||
@@ -369,30 +270,18 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<span style={{ color: '#faad14' }}>{fix2(selectedDevice.environment_temperature || 25)}℃</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 12, maxHeight: "160px", overflow: "auto", scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
|
||||
{selectedDevice.productName && (
|
||||
<>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<span style={{ color: '#666', fontSize: 12 }}>产品类型</span>
|
||||
<span style={{ fontSize: 12 }}>{getVal(selectedDevice.productName)}</span>
|
||||
</div>
|
||||
</>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<span style={{ color: '#666', fontSize: 12 }}>产品类型</span>
|
||||
<span style={{ fontSize: 12 }}>{getVal(selectedDevice.productName)}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 8 }}>
|
||||
<span style={{ color: '#666', fontSize: 12, whiteSpace: 'nowrap' }}>设备SN</span>
|
||||
<span
|
||||
style={{
|
||||
fontSize: 12,
|
||||
wordBreak: 'break-all', // 强制换行
|
||||
whiteSpace: 'normal', // 允许换行
|
||||
textAlign: 'right', // 右对齐
|
||||
maxWidth: '70%', // 限制宽度,避免撑满
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 12, wordBreak: 'break-all', whiteSpace: 'normal', textAlign: 'right', maxWidth: '70%' }}>
|
||||
{getVal(selectedDevice.device_sn || selectedDevice.serialNumber)}
|
||||
</span>
|
||||
</div>
|
||||
@@ -408,7 +297,6 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<span style={{ fontSize: 12 }}>v{selectedDevice.firmwareVersion}</span>
|
||||
</div>
|
||||
)}
|
||||
{/* 无人机特定信息 */}
|
||||
{(selectedDevice.productName?.includes('无人机') || selectedDevice.device_sn) && (
|
||||
<>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
@@ -421,7 +309,6 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: "space-between", flexWrap: 'wrap', gap: 6 }}>
|
||||
@@ -434,48 +321,36 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
</Col>
|
||||
|
||||
<Col span={12}>
|
||||
{/* 实时画面 */}
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
|
||||
<span style={{ fontSize: 14, fontWeight: 500, color: "#666" }}>实时画面</span>
|
||||
{/* 角度选择下拉框 */}
|
||||
{!isUAV && (
|
||||
<Select
|
||||
size="small"
|
||||
style={{ width: 110 }}
|
||||
value={mowerView}
|
||||
onChange={setMowerView}
|
||||
options={[
|
||||
{ label: '前视', value: 'front' },
|
||||
{ label: '后视', value: 'back' },
|
||||
{ label: '左视', value: 'left' },
|
||||
{ label: '右视', value: 'right' },
|
||||
]}
|
||||
<Select size="small" style={{ width: 110 }} value={mowerView} onChange={setMowerView}
|
||||
options={[{ label: '前视', value: 'front' }, { label: '后视', value: 'back' }, { label: '左视', value: 'left' }, { label: '右视', value: 'right' }]}
|
||||
/>
|
||||
)}
|
||||
{/* 显示当前镜头类型 */}
|
||||
{isUAV && (
|
||||
<Tag size="small" color={videoTypeRef.current === 'drone' ? 'blue' : 'orange'}>
|
||||
{videoTypeRef.current === 'drone' ? '无人机镜头' : '机场镜头'}
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ width: '100%', height: 160, borderRadius: 8, position: 'relative', overflow: 'hidden', background: '#000' }}>
|
||||
{/* 无人机视频 */}
|
||||
{isUAV ? (
|
||||
planeVideo?.length > 0 ? (
|
||||
<DroneLivePlayer streamData={planeVideo[0]} />
|
||||
planeVideo ? (
|
||||
<DroneLivePlayer streamData={planeVideo} />
|
||||
) : (
|
||||
<div style={{ color: '#ccc', display: 'flex', height: '100%', alignItems: 'center', justifyContent: 'center' }}>
|
||||
暂无视频流
|
||||
<ReloadOutlined spin style={{ marginRight: 6 }} /> 视频加载中...
|
||||
</div>
|
||||
)
|
||||
) : (
|
||||
// 机器人单画面 + 角度切换
|
||||
robotVideo ? (
|
||||
<VideoPlayer
|
||||
deviceId={selectedDevice?.device_sn || selectedDevice?.serialNumber}
|
||||
idx={
|
||||
mowerView === 'front' ? 1
|
||||
: mowerView === 'back' ? 2
|
||||
: mowerView === 'left' ? 3
|
||||
: 4
|
||||
}
|
||||
idx={mowerView === 'front' ? 1 : mowerView === 'back' ? 2 : mowerView === 'left' ? 3 : 4}
|
||||
className="w-full h-full object-contain"
|
||||
video={robotVideo}
|
||||
error={error}
|
||||
@@ -488,7 +363,6 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
)
|
||||
)}
|
||||
|
||||
{/* 视频底部信息条 */}
|
||||
{selectedDevice?.device_sn && (
|
||||
<div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, background: 'rgba(0,0,0,0.6)', color: '#fff', display: 'flex', justifyContent: 'space-between', padding: '8px 12px', fontSize: 12 }}>
|
||||
<span>高度 {fix2(selectedDevice.height)}m</span>
|
||||
@@ -507,6 +381,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
)}
|
||||
</Card>
|
||||
|
||||
{/* 下面的卡片逻辑保持不变 */}
|
||||
<Card title={<><ApiOutlined /> AI分析与操作建议</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
|
||||
<Row gutter={16} style={{ marginBottom: 20 }}>
|
||||
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(255,77,79,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#ff4d4f', fontSize: 20 }}><span role="img" aria-label="hotspot">🔥</span></div><div><div style={{ fontSize: 11, color: '#666' }}>热斑疑似</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>2 <span style={{ fontSize: 12 }}>处</span></div></div></div></Col>
|
||||
@@ -537,7 +412,6 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
{/* 条件渲染:只有无人机显示环境与飞行条件 */}
|
||||
{(selectedDevice?.productName?.includes('无人机') || selectedDevice?.device_sn) && (
|
||||
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
|
||||
@@ -551,84 +425,29 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<div className="flex items-center gap-1">
|
||||
<div style={{ fontSize: 12, fontWeight: 700, color: '#52c41a' }}>适宜执行</div>
|
||||
<div style={{ width: 18, height: 18, borderRadius: '50%', background: '#52c41a', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><CheckCircleOutlined style={{ fontSize: 12, color: '#fff' }} /></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div style={{ fontSize: 11, color: '#666' }}>可正常作业</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* 条件渲染:机器人显示其余信息(此处以任务详情为例) */}
|
||||
{(!selectedDevice?.productName?.includes('无人机') && !selectedDevice?.device_sn) && (
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}>
|
||||
<RobotOutlined style={{ color: '#165DFF' }} />
|
||||
机器人作业状态
|
||||
</div>
|
||||
}
|
||||
bordered={false}
|
||||
style={{
|
||||
borderRadius: 12,
|
||||
marginBottom: 16,
|
||||
boxShadow: '0 2px 8px rgba(0,0,0,0.06)',
|
||||
border: '1px solid #f0f0f0',
|
||||
}}
|
||||
>
|
||||
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />机器人作业状态</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
|
||||
<Row gutter={16} style={{ alignItems: 'center' }}>
|
||||
<Col span={8}>
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
borderRadius: 8,
|
||||
background: '#f8fafc',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#86909C' }}>累计里程</span>}
|
||||
value={128.5}
|
||||
suffix="km"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}
|
||||
/>
|
||||
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>
|
||||
<Statistic title={<span style={{ fontSize: 12, color: '#86909C' }}>累计里程</span>} value={128.5} suffix="km" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
borderRadius: 8,
|
||||
background: '#f8fafc',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#86909C' }}>本次作业耗时</span>}
|
||||
value={45}
|
||||
suffix="min"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}
|
||||
/>
|
||||
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>
|
||||
<Statistic title={<span style={{ fontSize: 12, color: '#86909C' }}>本次作业耗时</span>} value={45} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<div
|
||||
style={{
|
||||
padding: '8px 12px',
|
||||
borderRadius: 8,
|
||||
background: '#f8fafc',
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
<Statistic
|
||||
title={<span style={{ fontSize: 12, color: '#86909C' }}>预计剩余时间</span>}
|
||||
value={12}
|
||||
suffix="min"
|
||||
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }}
|
||||
/>
|
||||
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>
|
||||
<Statistic title={<span style={{ fontSize: 12, color: '#86909C' }}>预计剩余时间</span>} value={12} suffix="min" valueStyle={{ fontSize: 20, fontWeight: 700, color: '#1D2129' }} />
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -649,16 +468,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Modal
|
||||
title="视频预览"
|
||||
open={!!zoomedVideo}
|
||||
onCancel={() => setZoomedVideo(null)}
|
||||
footer={null}
|
||||
width={1000}
|
||||
centered
|
||||
bodyStyle={{ padding: 0, height: 600, background: '#000' }}
|
||||
destroyOnClose
|
||||
>
|
||||
<Modal title="视频预览" open={!!zoomedVideo} onCancel={() => setZoomedVideo(null)} footer={null} width={1000} centered bodyStyle={{ padding: 0, height: 600, background: '#000' }} destroyOnClose>
|
||||
{zoomedVideo && <DroneLivePlayer streamData={zoomedVideo} videoMode="LARGE" />}
|
||||
</Modal>
|
||||
</Content>
|
||||
|
||||
Reference in New Issue
Block a user