Compare commits

...

5 Commits

8 changed files with 455 additions and 183 deletions

View File

@@ -0,0 +1,232 @@
import React, { useEffect, useRef, useState } from "react";
import AgoraRTC, { IAgoraRTCClient, IRemoteVideoTrack } from "agora-rtc-sdk-ng";
import { Badge, message } from "antd";
const APP_ID = "875f6494d87548e783fefbf33f598c97";
const TOKEN = "007eJxTYIjPuZr09PC0znd6+z0MMyL6ZHb68OetXW+kO1vHU2ZNtYECg4W5aZqZiaVJCpBhYpFqbmGclpqWlGZsnGZqaZFsaT6pZH5WQyAjA7e+LysjAwSC+JwMxmYlqcUlugZGDAwAbuYeJg==";
export default function AgrtcRoomRobot({ CHANNEL }) {
const [uid] = useState(() => Number(Math.floor(Math.random() * 100000)));
const [connected, setConnected] = useState(false);
const [joined, setJoined] = useState(false);
// 标记是否存在远端视频流
const [hasRemoteVideo, setHasRemoteVideo] = useState(false);
const remoteVideoRef = useRef<HTMLDivElement>(null);
const clientRef = useRef<IAgoraRTCClient | null>(null);
const remoteVideoTrackRef = useRef<IRemoteVideoTrack | null>(null);
const joiningRef = useRef(false);
const reconnectTimerRef = useRef<NodeJS.Timeout | null>(null);
useEffect(() => {
const client = AgoraRTC.createClient({
mode: "live",
codec: "h264",
});
clientRef.current = client;
client.setClientRole("audience");
let isUnmounted = false;
// 停止并清空远端视频
const clearRemoteVideo = () => {
if (remoteVideoTrackRef.current) {
try {
remoteVideoTrackRef.current.stop();
} catch (e) { /* */ }
remoteVideoTrackRef.current = null;
}
if (remoteVideoRef.current) {
remoteVideoRef.current.innerHTML = "";
}
setHasRemoteVideo(false);
};
// 重连逻辑
const doReconnect = async () => {
if (isUnmounted || joiningRef.current) return;
console.log("执行RTC重连");
clearRemoteVideo();
setJoined(false);
try {
joiningRef.current = true;
await client.join(APP_ID, CHANNEL, TOKEN, uid);
if (isUnmounted) return;
setJoined(true);
message.info("RTC重连成功");
// 重连成功后重新订阅已经在线的上位机
for (const remoteUser of client.remoteUsers) {
if (isUnmounted) break;
if (remoteUser.hasVideo) {
await client.subscribe(remoteUser, "video");
remoteVideoTrackRef.current = remoteUser.videoTrack;
remoteUser.videoTrack?.play(remoteVideoRef.current!);
setHasRemoteVideo(true);
}
}
} catch (err: any) {
if (err?.code !== "OPERATION_ABORTED") {
console.error("重连失败", err);
}
} finally {
joiningRef.current = false;
}
};
// 连接状态变化
const onConnStateChange = (curState: string, prevState: string) => {
if (isUnmounted) return;
console.log("连接状态变更", prevState, "→", curState);
setConnected(curState === "CONNECTED");
// 信令断开,延迟重连
if (curState === "DISCONNECTED") {
clearRemoteVideo();
if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
reconnectTimerRef.current = setTimeout(() => {
doReconnect();
}, 2000);
}
};
// 远端用户发布流
const onUserPublished = async (user: any, mediaType: "video" | "audio") => {
if (isUnmounted) return;
console.log("user-published", user.uid, mediaType);
await client.subscribe(user, mediaType);
if (mediaType === "video" && remoteVideoRef.current) {
clearRemoteVideo();
remoteVideoTrackRef.current = user.videoTrack;
user.videoTrack?.play(remoteVideoRef.current);
setHasRemoteVideo(true);
}
};
// 远端停止发布流(上位机停止推流)
const onUserUnpublished = (user: any, mediaType: "video" | "audio") => {
if (isUnmounted) return;
console.log("user-unpublished", user.uid, mediaType);
if (mediaType === "video") {
clearRemoteVideo();
}
};
// 远端用户离开频道
const onUserLeft = (user: any) => {
if (isUnmounted) return;
console.log("user-left", user.uid);
clearRemoteVideo();
};
// 远端用户进入
const onUserJoined = (user: any) => {
if (!isUnmounted) console.log("远端用户进入频道:", user.uid);
};
// Token即将过期提醒(测试Token有效期有限)
const onTokenWillExpire = () => {
console.warn("token即将过期,请更新token");
message.warning("Token即将过期,视频可能很快断开");
// 正式环境:请求后端拿新token client.renewToken(newToken)
};
// 注册事件,保存回调引用用于off解绑
client.on("connection-state-change", onConnStateChange);
client.on("user-published", onUserPublished);
client.on("user-unpublished", onUserUnpublished);
client.on("user-left", onUserLeft);
client.on("user-joined", onUserJoined);
client.on("token-privilege-will-expire", onTokenWillExpire);
const init = async () => {
if (joiningRef.current) return;
joiningRef.current = true;
try {
await client.join(APP_ID, CHANNEL, TOKEN, uid);
if (isUnmounted) {
console.log("组件已卸载,丢弃join结果");
return;
}
console.log("加入频道成功");
setJoined(true);
message.success("RTC已加入频道");
// 上位机已经提前推流,手动订阅
for (const remoteUser of client.remoteUsers) {
if (isUnmounted) break;
console.log("发现已有远端用户:", remoteUser.uid);
if (remoteUser.hasVideo) {
await client.subscribe(remoteUser, "video");
remoteVideoTrackRef.current = remoteUser.videoTrack;
remoteUser.videoTrack?.play(remoteVideoRef.current!);
setHasRemoteVideo(true);
}
}
} catch (err: any) {
if (err?.code === "OPERATION_ABORTED") {
console.log("join操作被取消(StrictMode/组件卸载),忽略");
return;
}
console.error("加入频道失败:", err);
if (!isUnmounted) {
message.error("加入频道失败,请检查appid/token/channel");
}
} finally {
joiningRef.current = false;
}
};
init();
// 组件卸载清理
return () => {
isUnmounted = true;
if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
clearRemoteVideo();
const c = clientRef.current;
if (!c) return;
c.off("connection-state-change", onConnStateChange);
c.off("user-published", onUserPublished);
c.off("user-unpublished", onUserUnpublished);
c.off("user-left", onUserLeft);
c.off("user-joined", onUserJoined);
c.off("token-privilege-will-expire", onTokenWillExpire);
c.leave();
clientRef.current = null;
};
}, [uid, CHANNEL]);
return (
<div style={{ width: "100%", height: "100%", display: "flex", flexDirection: "column", borderRadius: 8, overflow: "hidden", background: "#000" }}>
<div style={{ display: "flex", justifyContent: "end", alignItems: "center", gap: 12, padding: "4px 8px", background: "rgba(255,255,255,0.08)", flexShrink: 0 }}>
<Badge
color={connected ? "green" : "red"}
text={connected ? "RTC已连接" : "RTC未连接"}
styles={{ content: { color: '#888' } }}
/>
<Badge
color={joined ? "green" : "orange"}
text={joined ? "已加入频道" : "未加入频道"}
styles={{ content: { color: '#888' } }}
/>
<span style={{ fontSize: 11, color: "#888" }}>频道:{CHANNEL}</span>
</div>
<div style={{ flex: 1, width: "100%", minHeight: 0, position: "relative" }}>
{/* 无视频时显示加载占位 */}
{!hasRemoteVideo && (
<div style={{
position: "absolute",
inset: 0,
display: "flex",
alignItems: "center",
justifyContent: "center",
color: "#aaa",
fontSize: 14,
background: "#000"
}}>
视频加载中,等待远端推流...
</div>
)}
{/* Agora 视频容器,内部会被SDK填充video dom */}
<div ref={remoteVideoRef} style={{
position: "absolute",
inset: 0
}} />
</div>
</div >
);
}

View File

@@ -40,6 +40,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const polygonRef = useRef(null); // coverage 区域多边形
const navLineRef = useRef(null); // 完成点实时轨迹
const markedPointsRef = useRef([]); // 标记点实体
const markedLineRef = useRef(null); // 标记点连线实体
const onMarkPointRef = useRef(onMarkPoint); // 总是指向最新的 onMarkPoint,避免闭包滞后
const onCameraClickRef = useRef(onCameraClick); // 同样处理,避免闭包滞后
const { t } = useTranslation();
@@ -474,19 +477,41 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
}
}, [points]);
// 渲染绿色标记点
// 渲染标记点 + 连线(唯一系统,避免重复标记)
const drawMarkedPoints = (points) => {
const viewer = viewerRef.current;
if (!viewer) return;
// 先清空之前的标记点
// 先清空之前的标记点与连线
markedPointsRef.current.forEach(id => {
viewer.entities.removeById(id);
});
markedPointsRef.current = [];
if (markedLineRef.current) {
try {
viewer.entities.remove(markedLineRef.current);
} catch (e) { }
markedLineRef.current = null;
}
if (!points || points.length === 0) return;
// 先绘制连线:有 2 个及以上打点才连线
if (points.length >= 2) {
const linePositions = points.map(p =>
window.Cesium.Cartesian3.fromDegrees(Number(p.lon), Number(p.lat))
);
markedLineRef.current = viewer.entities.add({
polyline: {
positions: linePositions,
width: 4,
material: window.Cesium.Color.SKYBLUE,
clampToGround: true,
}
});
}
points.forEach((p, i) => {
const id = `marked-point-${i}`;
viewer.entities.add({
@@ -539,8 +564,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
tooltip.innerHTML = `
<div style="font-weight:600;margin-bottom:6px;">🤖 ${robot.deviceAlias || robot.serialNumber || robot.name}</div>
${deviceValuesHTML ? `<div style="margin-top:8px;"><strong>${t('devices.deviceData')}:</strong>${deviceValuesHTML}</div>` : ''}
<div>${t('systemSetting.longitude')}:${Number(robot.lastRunningStatus?.longitude).toFixed(6)}</div>
<div>${t('systemSetting.latitude')}:${Number(robot.lastRunningStatus?.latitude).toFixed(6)}</div>
<div>${t('systemSetting.longitude')}:${Number(robot?.locationMessage?.longitude || robot?.lastRunningStatus?.longitude).toFixed(6)}</div>
<div>${t('systemSetting.latitude')}:${Number(robot?.locationMessage?.latitude || robot?.lastRunningStatus?.latitude).toFixed(6)}</div>
`;
}
@@ -1378,7 +1403,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
devices.forEach((device, index) => {
const raw = device?.lastRunningStatus || {};
const raw = device?.locationMessage || device?.lastRunningStatus || {};
const parsed = parseLngLat(raw.longitude, raw.latitude);
if (!parsed) return;
@@ -1627,6 +1652,10 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
};
}, [points]);
// 每次渲染都更新回调引用,确保单击处理器用最新版本(避免闭包滞后)
onMarkPointRef.current = onMarkPoint;
onCameraClickRef.current = onCameraClick;
useEffect(() => {
const viewer = viewerRef.current;
if (!viewer) return;
@@ -1650,7 +1679,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const picked = viewer.scene.pick(movement.position);
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
const robot = picked.id.properties.robot.getValue();
robot.feStatus == 1 && onCameraClick?.(robot);
robot.feStatus == 1 && onCameraClickRef.current?.(robot);
}
}, window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
@@ -1663,10 +1692,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const lon = window.Cesium.Math.toDegrees(cartographic.longitude);
const lat = window.Cesium.Math.toDegrees(cartographic.latitude);
const newPoint = { lon, lat };
const newPoints = [...drawPoints, newPoint];
setDrawPoints(newPoints);
updateDrawPath(newPoints);
onMarkPoint?.({ lon, lat });
onMarkPointRef.current?.({ lon, lat });
}, window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
if (onClearDraw) {
@@ -1799,7 +1825,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
// ====================================
// 无人机模式:保持原来的逻辑
// ====================================
if (isDroneMode || from == "deviceStatus") {
if (isDroneMode || from == "deviceStatus" || from == "devicesTask") {
// 轨迹点去抖动(防止重复点)
const last = realtimeLastPointRef.current;
let shouldAdd = true;

View File

@@ -50,8 +50,15 @@ interface Robot {
lastRunningStatus?: {
latitude: string | number;
longitude: string | number;
battery: number;
battery: string | number;
};
locationMessage?: {
latitude: string | number;
longitude: string | number;
battery: string | number;
};
drone_callsign?: string;
serialNumber?: string;
}
@@ -1040,8 +1047,8 @@ const RobotControlCenter = ({ setView }) => {
};
const mapFocus = selectedDevice ? {
lat: selectedDevice.lastRunningStatus.latitude,
lon: selectedDevice.lastRunningStatus.longitude,
lat: selectedDevice?.locationMessage?.latitude || selectedDevice?.lastRunningStatus?.latitude,
lon: selectedDevice?.locationMessage?.longitude || selectedDevice?.lastRunningStatus?.longitude,
height: 500
} : { lat: '31.030129089704428', lon: '120.76671769055027', height: 800 };
//手柄数据

View File

@@ -17,15 +17,13 @@ import {
} from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
// 组件内
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
import DroneVideoPlayer from './DroneVideoPlayer';
import AgoraTextTest from '../AgoraRtc.tsx';
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
import VideoPlayer from '../VideoPlayer.tsx';
import AgrtcRoomRobot from '../AgrtcRoomRobot';
import CesiumMap from '../Map.jsx';
import DeviceParamModal from './DeviceParamModal';
import { getUAVState, getSiteDevice, getSiteUAVList, getsinglePlan, getRobotTaskList, getDeviceTotalData, updateDeviceAliasApi, hasPermission } from '@/api/device.ts';
@@ -423,7 +421,7 @@ export default function DeviceOverviewPage() {
// 机器人视频
// 机器人视频:只有 robotPlayActive = true 才真正拉流
const { video: robotVideo, error, ready } = useWebRTCPlayer(
(!isUAV && robotPlayActive) ? (selectedDevice?.serialNumber || '') : '',
(!isUAV && robotPlayActive && !selectedDevice?.hasHost) ? (selectedDevice?.serialNumber || '') : '',
(!isUAV && robotPlayActive)
? `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`
: ''
@@ -878,7 +876,11 @@ export default function DeviceOverviewPage() {
/>
) : (
robotPlayActive ? (
robotVideo ? (
selectedDevice?.hasHost ? (
<div style={{ width: '100%', height: '100%', position: 'relative', overflow: 'hidden', background: '#000', borderRadius: 8 }}>
<AgrtcRoomRobot CHANNEL={selectedDevice?.serialNumber || ''} />
</div>
) : robotVideo ? (
<VideoPlayer
deviceId={selectedDevice?.device_sn || selectedDevice?.serialNumber}
idx={mowerView === 'front' ? 1 : mowerView === 'back' ? 2 : mowerView === 'left' ? 3 : 4}

View File

@@ -53,6 +53,7 @@ import { useSelector } from 'react-redux';
import { RootState } from '@/src/store/index.ts';
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
import VideoPlayer from '../VideoPlayer.tsx';
import AgrtcRoomRobot from '../AgrtcRoomRobot';
import DeviceController from './DeviceController';
import { DatePicker } from 'antd';
import dayjs from 'dayjs';
@@ -66,6 +67,7 @@ const { RangePicker } = DatePicker;
const { Text } = Typography;
export default function DeviceStatusPage() {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
@@ -406,13 +408,14 @@ export default function DeviceStatusPage() {
? base
: {
...base,
...device?.locationMessage,
...wsDeviceInfo,
...locationInfo
};
}, [device, wsDeviceInfo, isUAV, locationInfo]);
const { video: robotVideo, error, ready } = useWebRTCPlayer(
(!isUAV && isVideoPlaying) ? (device?.serialNumber || '') : '',
(!isUAV && isVideoPlaying && !device?.hasHost) ? (device?.serialNumber || '') : '',
(!isUAV && isVideoPlaying)
? `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`
: ''
@@ -680,6 +683,17 @@ export default function DeviceStatusPage() {
messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 }));
};
// 撤回上一个打点
const handleUndoMark = () => {
if (markedPoints.length === 0) {
message.info(t('devices.noPointsToUndo'));
return;
}
const newPoints = markedPoints.slice(0, -1);
setMarkedPoints(newPoints);
messageApi.success(t('devices.pointUndone', { count: newPoints.length }));
};
// 清空标记点
const handleClearPoints = () => {
setMarkedPoints([]);
@@ -924,6 +938,13 @@ export default function DeviceStatusPage() {
>
{t('devices.markPoint')}
</Button>
<Button
type="default"
onClick={handleUndoMark}
disabled={markedPoints?.length === 0}
>
{t('devices.undoMark')}
</Button>
<Button
type="default"
onClick={handleClearPoints}
@@ -1201,25 +1222,41 @@ export default function DeviceStatusPage() {
{/* 视频层:停止时不渲染 / 未播放时为空,不影响状态面板 */}
{robotVideo && isVideoPlaying && (
{isVideoPlaying && (
mowerView === 'all' ? (
<div style={{ width: '100%', height: '100%' }}>
<MowerAllView
serialNumber={device?.serialNumber}
robotVideo={robotVideo}
error={error}
ready={ready}
/>
(
<div style={{ width: '100%', height: '100%' }}>
<MowerAllView
serialNumber={device?.serialNumber}
robotVideo={robotVideo}
error={error}
ready={ready}
/>
</div>
)
) : mowerView === 'front' ? (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
{device?.hasHost ? (
<AgrtcRoomRobot CHANNEL={device?.serialNumber || ''} />
) : (
<VideoPlayer
deviceId={device?.serialNumber}
idx={1}
className="w-full h-full object-contain"
video={robotVideo}
error={error}
ready={ready}
/>
)}
</div>
) : (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
<VideoPlayer
deviceId={device?.serialNumber}
idx={
mowerView === 'front' ? 1
: mowerView === 'back' ? 2
: mowerView === 'left' ? 3
: 4
mowerView === 'back' ? 2
: mowerView === 'left' ? 3
: 4
}
className="w-full h-full object-contain"
video={robotVideo}
@@ -1231,7 +1268,7 @@ export default function DeviceStatusPage() {
)}
{/* 视频未加载 / 停止播放的占位 */}
{(!robotVideo || !isVideoPlaying) && (
{!isVideoPlaying && (
<div style={{
width: '100%', height: '100%',
display: 'flex', alignItems: 'center', justifyContent: 'center',
@@ -1247,7 +1284,6 @@ export default function DeviceStatusPage() {
</div>
</div>
)}
{/* 单视频(非全景)模式状态叠加层:始终渲染,和视频层解耦 */}
{mowerView !== 'all' && (
<div style={{

View File

@@ -25,7 +25,7 @@ import {
import {
getRobotRouteList,
getSingleRouteList,
getPlaneDeviceListAll, saveDeviceTask, getRobotTaskList,
saveDeviceTask, getRobotTaskList,
deleteDeviceTask,
getSiteDevice,
excuetRoute,
@@ -184,15 +184,17 @@ export default function RobotTaskPage() {
if (!taskId) return;
try {
const res = await getRouteByTask({ taskId });
if (res?.code === 200 && res?.data) {
if (res?.code === 200 && res?.data?.jsonData?.path) {
let pathPoints = [];
try {
const data = res.data;
pathPoints = data || [];
pathPoints = data.jsonData.path || [];
setRouteMode(data?.mode || 'coverage'); // 设置路线模式
} catch (err) {
console.error('解析任务路径数据失败:', err);
}
setRouteMode('coverage')
setPolyPoints(pathPoints);
}
} catch (err) {
@@ -304,7 +306,7 @@ export default function RobotTaskPage() {
const runningTask = taskPoolList.find(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus));
if (!runningTask) return;
fetchRouteDetail(runningTask?.id);
//fetchRouteDetail(runningTask?.id);
// 找到对应的设备
const targetDevice = devices.find(d => d.serialNumber === runningTask.deviceId);
@@ -508,6 +510,8 @@ export default function RobotTaskPage() {
if (!runningPoolTask?.id) return;
loadTaskPath(runningPoolTask.id);
fetchRouteDetail(runningPoolTask?.id);
// 只有当任务是执行状态,并且没有连接的设备时,才自动连接
if ((runningPoolTask.taskStaus == 'EXECUTING' || runningPoolTask.taskStaus == 'PAUSE') && !executingRobot) {
@@ -567,30 +571,6 @@ export default function RobotTaskPage() {
setExecuteModalVisible(true);
setSelectedRobotForExecute(null);
// 调用接口检查是否有路径点
const res = await getSingleRouteList({ id: route?.id });
let hasPathPoints = false;
if (res?.code === 200 && res?.data) {
try {
if (res.data.jsonData) {
const data = typeof res.data.jsonData === 'string'
? JSON.parse(res.data.jsonData)
: res.data.jsonData;
hasPathPoints = data?.path && data.path.length > 0;
}
} catch (err) {
console.error('解析路线数据失败:', err);
}
}
//if (!hasPathPoints) {
// utils.message.warning(t('devices.routeExecuteFixed2'));
// return;
//}
} catch (err) {
console.error('检查路线失败:', err);
utils.message.error(t('devices.checkRouteFail'));
@@ -1219,7 +1199,7 @@ export default function RobotTaskPage() {
extra={
<Space size={4} wrap> {/* Space开启自动换行,小屏按钮自动折行 */}
<Button size="small" icon={<DeleteOutlined />} type="primary" style={{ borderRadius: 4 }} onClick={() => setClearNavLine(v => v + 1)}>{t('devices.clearRealtimeTrack')}</Button>
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setRouteMode(""); setClearPlanLine(v => v + 1); }}>{t('devices.clearPlanRoute')}</Button>
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setPolyPoints([]); setRouteMode(""); setClearPlanLine(v => v + 1); }}>{t('devices.clearPlanRoute')}</Button>
{/*<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>{t('common.addNew')}</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>{t('common.import')}</Button>
<Button size="small" icon={<NodeIndexOutlined />} style={{ borderRadius: 4 }}>{t('devices.optimize')}</Button>
@@ -1239,7 +1219,7 @@ export default function RobotTaskPage() {
realtimePosition={realtimePosition}
polyPoints={polyPoints}
realtimeType="robot"
from="deviceStatus"
from="devicesTask"
drawRealTime={execute}
finishPoint={arrivedPoint}
ifClearNavLine={clearNavLine}
@@ -1283,28 +1263,9 @@ export default function RobotTaskPage() {
<span style={{ color: '#9eff9e' }}>{t('devices.remoteMode')}</span>
)}
</span>
{/* const fixStatusMap: Record<string, string> = {
'no_fix': t('devices.noFix'),
'single': t('devices.single'),
'dgnss': t('devices.dgnss'),
'ins': t('devices.ins'),
'rtk_fixed': t('devices.rtkFixed'),
'rtk_float': t('devices.rtkFloat'),
'single_no_heading': t('devices.singleNoHeading'),
'dgnss_no_heading': t('devices.dgnssNoHeading'),
'rtk_fixed_no_heading': t('devices.rtkFixedNoHeading'),
'rtk_float_no_heading': t('devices.rtkFloatNoHeading'),
}
*/}
<span>
{t('devices.heading')}
{robotRealtimePosition?.headingStatus == '1' ? (
<span style={{ color: '#9eff9e' }}>{t('devices.initialized')}</span>
) : (
<span style={{ color: '#ff6f6f' }}>{t('devices.uninitialized')}</span>
)}
</span>
<span>
{t('devices.location')}
@@ -1559,94 +1520,7 @@ export default function RobotTaskPage() {
</div>
</Card>
</Col>
<Col xs={24} xl={10} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.operationSuggestion')}</span>}
variant="borderless"
styles={{ body: { padding: '12px 16px' } }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Timeline
mode="left"
items={[
{
color: 'green',
label: '09:30',
children: (
<>
<Text strong>{t('devices.timelineMow', { robot: 'RBT-01' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMowDetail')}</div>
</>
)
},
{
color: 'blue',
label: '11:00',
children: (
<>
<Text strong>{t('devices.timelineInspect', { robot: 'RBT-02' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineInspectDetail')}</div>
</>
)
},
{
color: 'gray',
label: '14:00',
children: (
<>
<Text strong>{t('devices.timelineMaintenance')}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMaintenanceDetail')}</div>
</>
)
}
]}
/>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>{t('devices.autoGenerateTodayPlan')}</Button>
</Card>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.deviceEnvironment')}</span>}
variant="borderless"
styles={{ body: { padding: '16px' } }}
style={{ ...cardStyle, flex: 1 }}
>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.currentTemp')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>24.5 ℃</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.humidity')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>65 %</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.positionAccuracy')}</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>{t('devices.rtkFixed')}</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.networkLatency')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>45 ms</div>
</div>
</Col>
</Row>
<div style={{ marginTop: 8, padding: 12, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00' }}>{t('devices.waterRiskWarning')}</span>
</div>
</Card>
</Col>
</Row>
<Row gutter={16}>
<Col xs={24} xl={6}>
<Col xs={24} xl={10}>
<Card
title={
<div className="flex justify-between items-center w-full">
@@ -1661,7 +1535,7 @@ export default function RobotTaskPage() {
</div>
}
variant="borderless"
styles={{ body: { padding: '12px', height: 400, overflow: 'auto' } }}
styles={{ body: { padding: '12px', height: 732, overflow: 'auto' } }}
style={cardStyle}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
@@ -1789,16 +1663,105 @@ export default function RobotTaskPage() {
</div>
</Card>
</Col>
<Col xs={24} xl={18}>
</Row>
<Row gutter={16} >
<Col xs={24} xl={6} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.operationSuggestion')}</span>}
variant="borderless"
styles={{ body: { padding: '12px 16px' } }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Timeline
mode="left"
items={[
{
color: 'green',
label: '09:30',
children: (
<>
<Text strong>{t('devices.timelineMow', { robot: 'RBT-01' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMowDetail')}</div>
</>
)
},
{
color: 'blue',
label: '11:00',
children: (
<>
<Text strong>{t('devices.timelineInspect', { robot: 'RBT-02' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineInspectDetail')}</div>
</>
)
},
{
color: 'gray',
label: '14:00',
children: (
<>
<Text strong>{t('devices.timelineMaintenance')}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMaintenanceDetail')}</div>
</>
)
}
]}
/>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>{t('devices.autoGenerateTodayPlan')}</Button>
</Card>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.deviceEnvironment')}</span>}
variant="borderless"
styles={{ body: { padding: '16px' } }}
style={{ ...cardStyle, flex: 1 }}
>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.currentTemp')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>24.5 ℃</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.humidity')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>65 %</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.positionAccuracy')}</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>{t('devices.rtkFixed')}</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.networkLatency')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>45 ms</div>
</div>
</Col>
</Row>
<div style={{ marginTop: 8, padding: 12, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00' }}>{t('devices.waterRiskWarning')}</span>
</div>
</Card>
</Col>
<Col xs={24} xl={18} style={{ display: 'flex', flexDirection: 'column', }}>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.taskBoard')}</span>}
variant="borderless"
styles={{ body: { padding: '12px' } }}
style={{ ...cardStyle, height: '100%' }}
styles={{ body: { padding: '12px', flex: 1 } }}
style={{ ...cardStyle, height: '100%', display: "flex", flexDirection: "column" }}
>
<Row gutter={16}>
<Row gutter={16} style={{ height: "100%" }} >
<Col span={8}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 8, height: 400 }}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 8, height: "100%" }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#86909C" text={t('devices.pending')} /></Title>
{waitList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
@@ -1809,7 +1772,7 @@ export default function RobotTaskPage() {
</div>
</Col>
<Col span={8}>
<div style={{ background: '#E8F3FF', padding: 12, borderRadius: 8, height: 400 }}>
<div style={{ background: '#E8F3FF', padding: 12, borderRadius: 8, height: "100%" }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#165DFF" text={t('devices.statInProgress')} /></Title>
{runList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
@@ -1822,7 +1785,7 @@ export default function RobotTaskPage() {
</div>
</Col>
<Col span={8}>
<div style={{ background: '#F6FFED', padding: 12, borderRadius: 8, height: 400 }}>
<div style={{ background: '#F6FFED', padding: 12, borderRadius: 8, height: "100%" }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#52C41A" text={t('workOrder.completed')} /></Title>
{finishList.slice(0, 3).map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>

View File

@@ -609,6 +609,9 @@ const en = {
lostControlAction: 'Lost Control Action',
lostControlActionLabel: 'Lost Control Action Label',
markPoint: 'Mark Point',
undoMark: 'Undo Mark',
noPointsToUndo: 'No points to undo',
pointUndone: 'Undone, {{count}} points left',
markedPointsCount: 'Marked Points Count',
minBattery: 'Min Battery',
minBatteryLabel: 'Min Battery Label',

View File

@@ -631,6 +631,9 @@ const zh = {
lostControlAction: '丢失控制操作',
lostControlActionLabel: '丢失控制操作标签',
markPoint: '打点',
undoMark: '撤回打点',
noPointsToUndo: '暂无打点可撤回',
pointUndone: '已撤回,剩余 {{count}} 个打点',
markedPointsCount: '已标记点数量',
minBattery: '最小电量',
minBatteryLabel: '最小电量标签',