无人机组件 终于可以显示两个视频了!!!!
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import {
|
||||
Layout, Card, Row, Col, Statistic, Tag, Button, Table,
|
||||
Typography, Space, Progress, Badge, Timeline, message,
|
||||
@@ -59,7 +59,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
const isUAV = !!selectedDevice?.gateway_sn;
|
||||
|
||||
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
||||
selectedDevice?.serialNumber || '',
|
||||
!isUAV ? selectedDevice?.serialNumber || '' : '',
|
||||
`webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`,
|
||||
);
|
||||
|
||||
@@ -111,6 +111,15 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
if (onDeviceSelect) onDeviceSelect(id);
|
||||
};
|
||||
|
||||
// 用于视频、状态展示的实时设备数据(只合并一次)
|
||||
const realtimeDevice = useMemo(() => {
|
||||
if (!selectedDevice) return null;
|
||||
return {
|
||||
...selectedDevice,
|
||||
...uavState, // 无人机实时状态覆盖
|
||||
};
|
||||
}, [selectedDevice, uavState]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const fetchUavState = async () => {
|
||||
@@ -131,7 +140,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
}
|
||||
};
|
||||
|
||||
fetchUavState();
|
||||
fetchUavState();
|
||||
|
||||
|
||||
}, [isUAV, selectedDevice]);
|
||||
@@ -184,7 +193,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
{ title: '类型', dataIndex: 'type', width: 90 },
|
||||
{ title: '当前状态', dataIndex: 'status', width: 70, render: s => <Tag color={s === '作业中' || s === '在线' ? 'success' : 'default'} style={{ margin: 0 }}>{s}</Tag> },
|
||||
{ title: '模式', dataIndex: 'mode', width: 70 },
|
||||
{ title: '电量', dataIndex: 'battery', width: 70, render: v => <Progress percent={v} size="small" status={v < 40 ? 'exception' : 'active'} /> },
|
||||
{ title: '电量', dataIndex: 'capacity_percent', width: 70, render: v => <Progress percent={v} size="small" status={v < 40 ? 'exception' : 'active'} /> },
|
||||
{ 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} /> },
|
||||
@@ -344,10 +353,9 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
|
||||
<div style={{ width: '100%', height: 160, borderRadius: 8, position: 'relative', overflow: 'hidden', background: '#000' }}>
|
||||
{isUAV ? (
|
||||
<DroneVideoPlayer
|
||||
device={selectedDevice}
|
||||
device={realtimeDevice}
|
||||
height={160}
|
||||
wind_speed={uavState?.wind_speed}
|
||||
h={uavState?.height}
|
||||
|
||||
showSourceSelect={false}
|
||||
videoSource={videoSource}
|
||||
onSourceChange={setVideoSource}
|
||||
|
||||
Reference in New Issue
Block a user