优化机器人任务 界面 匹配和实时经纬度

This commit is contained in:
mmc
2026-09-21 15:13:28 +08:00
parent 0e95bb0c96
commit 1e516414d7
4 changed files with 93 additions and 53 deletions

View File

@@ -265,7 +265,7 @@ export default function RobotTaskPage() {
setExecutingRobot(targetDevice);
setClearNavLine(v => v + 1); // 清空地图轨迹
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
setShowVideo(true);
//setShowVideo(true);
};
@@ -336,7 +336,7 @@ export default function RobotTaskPage() {
console.log('🔄 检测到正在执行任务的新设备,开始连接', targetDevice);
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
setShowVideo(true);
//setShowVideo(true);
}, [devices, taskPoolList, executingRobot, runningPoolTask]);
useEffect(() => {
@@ -540,7 +540,7 @@ export default function RobotTaskPage() {
setExecutingRobot(targetDevice);
setClearNavLine(v => v + 1); // 清空地图轨迹
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
setShowVideo(true);
//setShowVideo(true);
}
}
@@ -1879,7 +1879,7 @@ export default function RobotTaskPage() {
</div>
</Modal>
{showVideo && executingRobot && execute && taskPoolList.length > 0 && (
{/*{showVideo && executingRobot && execute && taskPoolList.length > 0 && (
<DraggableBox
defaultPosition={{ x: 50, y: 50 }}
title={t('devices.robotPanoramaVideo', { robot: executingRobot.deviceAlias || executingRobot.serialNumber })}
@@ -1894,7 +1894,7 @@ export default function RobotTaskPage() {
/>
</div>
</DraggableBox>
)}
)}*/}
</div >
);
}

View File

@@ -279,12 +279,15 @@ export default class DeviceController {
this.isControlled = false;
this.onControlStatusChange?.(false);
// 切换任务/设备:先清掉上一个设备的实时坐标,避免轨迹残留到新设备
this.onLocationInfoUpdate?.(null);
wsManager.close();
try {
console.log('Connecting to', this.wsUrl);
wsManager.connect(sn, this.wsUrl);
this.connectedDeviceSn = sn;
wsManager.connect(sn, this.wsUrl);
await this.getControl(sn);
} catch (err) {
@@ -313,6 +316,9 @@ export default class DeviceController {
this.isControlled = false;
this.onControlStatusChange?.(false);
// 切换设备:清掉上一个设备的实时坐标,避免轨迹残留
this.onLocationInfoUpdate?.(null);
wsManager.send({
type: 'AUTH',
token: this.userInfo.token,
@@ -392,6 +398,10 @@ export default class DeviceController {
msg.data.forEach((item) => {
data[item.name] = item.value;
});
// 切换任务/切换设备时,忽略上一个设备遗留的实时数据
if (data?.deviceId && data.deviceId !== this.connectedDeviceSn) {
break;
}
this.wsDeviceInfo = data;
this.onDeviceInfoUpdate?.(data);
break;
@@ -401,6 +411,10 @@ export default class DeviceController {
msg.data.forEach((item) => {
data[item.name] = item.value;
});
// 切换任务/切换设备时,忽略上一个设备遗留的实时经纬度,只显示当前连接设备的实时轨迹
if (data?.deviceId && data.deviceId !== this.connectedDeviceSn) {
break;
}
this.locationInfo = data;
this.onLocationInfoUpdate?.(data);
break;