机器人状态界面 在线状态实时更新 i修复返航物和障碍物保存和新增 互斥 障碍物支持矩形 手柄拖拽

This commit is contained in:
mmc
2026-11-03 12:42:07 +08:00
parent 82a7ec1f40
commit 36b6856a90
4 changed files with 502 additions and 521 deletions

View File

@@ -1016,6 +1016,33 @@ export default function DeviceStatusPage() {
}, [device, wsDeviceInfo, isUAV, locationInfo]);
// 统一在线状态判断:优先实时数据,兜底接口数据
const isDeviceOnline = useMemo(() => {
// 1. 优先检查实时数据源(WebSocket 推送的 wsDeviceInfo / locationInfo)
const hasWsData = wsDeviceInfo && Object.keys(wsDeviceInfo).length > 0;
const hasLocData = locationInfo && Object.keys(locationInfo).length > 0;
if (hasWsData || hasLocData) {
return true;
}
// 2. 检查 runningStatus 里是否有有效经纬度或实时状态字段
const runningLon = runningStatus?.longitude;
const runningLat = runningStatus?.latitude;
const hasValidCoords = runningLon !== undefined && runningLon !== null && runningLon !== 0
&& runningLat !== undefined && runningLat !== null && runningLat !== 0;
const hasFeStatus = runningStatus?.feStatus !== 3;
const hasStatusField = runningStatus?.status !== 0;
if (hasValidCoords || hasFeStatus || hasStatusField) {
return true;
}
// 3. 兜底用接口返回的 onlineStatus
return device?.onlineStatus === 1;
}, [device, wsDeviceInfo, locationInfo, runningStatus]);
const { video: robotVideo, error, ready } = useWebRTCPlayer(
@@ -1552,7 +1579,8 @@ export default function DeviceStatusPage() {
const blockIfGamepadConnected = useCallback(() => {
if (!isGamepadConnected) return false;
// 没连接手柄 或 还没获取控制权限 → 不拦截(没控制权限本来就发不出消息)
if (!isGamepadConnected || !isControlled) return false;
const now = Date.now();
@@ -1566,7 +1594,7 @@ export default function DeviceStatusPage() {
return true;
}, [isGamepadConnected, t, messageApi]);
}, [isGamepadConnected, isControlled, t, messageApi]);
@@ -2281,9 +2309,9 @@ export default function DeviceStatusPage() {
<Tag color={device?.onlineStatus == 1 ? 'green' : 'default'}>
<Tag color={isDeviceOnline ? 'green' : 'default'}>
{device?.onlineStatus === 1 ? t('devices.online') : t('devices.offline')}
{isDeviceOnline ? t('devices.online') : t('devices.offline')}
</Tag>
@@ -2537,7 +2565,7 @@ export default function DeviceStatusPage() {
title={<><DashboardOutlined /> {t('devices.deviceStatus')}</>}
badge={<ConsoleBadge online={device?.onlineStatus === 1} text={device?.onlineStatus === 1 ? t('devices.online') : t('devices.offline')} />}
badge={<ConsoleBadge online={isDeviceOnline} text={isDeviceOnline ? t('devices.online') : t('devices.offline')} />}
>
@@ -2555,11 +2583,11 @@ export default function DeviceStatusPage() {
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginTop: 6, fontSize: 12, color: device?.onlineStatus === 1 ? '#52c41a' : '#8c8c8c' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginTop: 6, fontSize: 12, color: isDeviceOnline ? '#52c41a' : '#8c8c8c' }}>
<span style={{ width: 6, height: 6, borderRadius: '50%', background: device?.onlineStatus === 1 ? '#52c41a' : '#8c8c8c' }} />
<span style={{ width: 6, height: 6, borderRadius: '50%', background: isDeviceOnline ? '#52c41a' : '#8c8c8c' }} />
{device?.onlineStatus === 1 ? t('devices.online') : t('devices.offline')}
{isDeviceOnline ? t('devices.online') : t('devices.offline')}
</div>