{t('devices.mapEditor.routePoints')}
- 已选 {currentList.length} 个
+ {t('devices.mapEditor.selectedCount', { count: currentList.length })}
{currentList.length === 0 ? (
@@ -1328,9 +1302,9 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
size="small"
title={
- {activeType === 'returnPoint' ? '返航点列表' : activeType === 'obstaclePoint' ? '障碍物点列表' : '分区列表'}
+ {activeType === 'returnPoint' ? t('devices.mapEditor.returnPointList') : activeType === 'obstaclePoint' ? t('devices.mapEditor.configuredObstaclePoints') : t('devices.mapEditor.regionList')}
- 已选 {currentList.length} 个
+ {t('devices.mapEditor.selectedCount', { count: currentList.length })}
}
@@ -1354,7 +1328,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
{currentList.length === 0 ? (
) : (
@@ -1395,8 +1369,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
}}
style={{ marginBottom: 4 }}
>
- 矩形
- {/*圆形*/}
+ {t('devices.mapEditor.shapeRect')}
+ {/*{t('devices.mapEditor.shapeCircle')}*/}
{p.shapeType === 'circle' ? (
{
const val = parseFloat(e.target.value);
@@ -1453,7 +1427,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
size="small"
value={p.deviceId}
allowClear
- placeholder="未绑定"
+ placeholder={t('devices.mapEditor.unbound')}
onChange={(v) => bindRobot(p.id, v)}
style={{ width: '100%', marginTop: 4 }}
options={robots.map(r => ({
@@ -1487,7 +1461,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
{t('devices.presetRoutes')}
- 共 {presetRoutes.length} 条
+ {t('devices.mapEditor.totalCountWithUnit', { count: presetRoutes.length })}
}
@@ -1524,8 +1498,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
{t('devices.mapEditor.mode')}: {route.mode === 'coverage' || route.mode === 'coverage_area'
- ? t('devices.coverageMode')
- : t('devices.singleMode')}
+ ? t('devices.coverageMode') : route.mode === 'predefined_path' ? t('devices.predefinedPathMode')
+ : t('devices.singleMode')}
{route.routeType && (
· {route.routeType === 'MOWING_TASK' ? t('devices.mapEditor.typeMowing')
@@ -1563,7 +1537,7 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
{activeType === 'returnPoint'
? t('devices.mapEditor.configuredReturnPoints')
: activeType === 'obstaclePoint'
- ? '已配置障碍物点'
+ ? t('devices.mapEditor.configuredObstaclePoints')
: t('devices.mapEditor.configuredRegions')}
e.stopPropagation()} style={{ fontSize: 13, fontWeight: 500, padding: '4px 0' }}>
{isReturnPoint
- ? ((item.alias || '').trim() || `返航点-${String(idx + 1).padStart(2, '0')}`)
+ ? ((item.alias || '').trim() || `${t('devices.mapEditor.returnPoint')}-${String(idx + 1).padStart(2, '0')}`)
: isObstaclePoint
- ? (item.name || item.alias || `障碍物点-${idx + 1}`)
- : (item.regionName || `分区-${idx + 1}`)}
+ ? (item.name || item.alias || `${t('devices.mapEditor.obstaclePoint')}-${idx + 1}`)
+ : (item.regionName || `${t('devices.mapEditor.restArea')}-${idx + 1}`)}
{/* 已配置障碍物点:展示类型、尺寸与坐标 */}
@@ -1707,29 +1681,29 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
marginTop: 2,
}}
>
- 类型: {item.shapeType === 'circle' ? '圆形' : '矩形'}
+ {t('common.type')}: {item.shapeType === 'circle' ? t('devices.mapEditor.shapeCircle') : t('devices.mapEditor.shapeRect')}
{item.shapeType === 'circle' ? (
- 半径: {item.radius}m
+ {t('devices.mapEditor.radiusLabel')}: {item.radius}m
) : (
- 尺寸: {item.size_x}m x {item.size_y}m
+ {t('devices.mapEditor.sizeLabel')}: {item.size_x}m x {item.size_y}m
)}
- 经度: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
- 纬度: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
+ {t('devices.mapEditor.longitude')}: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
+ {t('devices.mapEditor.latitude')}: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
)}
{isReturnPoint && (
- 经度: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
- 纬度: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
+ {t('devices.mapEditor.longitude')}: {Number(item.lon ?? item.position?.lng ?? item.position?.lon ?? 0).toFixed(6)}
+ {t('devices.mapEditor.latitude')}: {Number(item.lat ?? item.position?.lat ?? 0).toFixed(6)}
)}
{/* 已配置返航点:展示绑定信息 */}
{isReturnPoint && item.bindDeviceId && (
- 绑定设备: {(() => {
+ {t('devices.mapEditor.bindDevice')}: {(() => {
const r = robots.find((x: any) => x.serialNumber === item.bindDeviceId);
return r ? `${r.deviceAlias || r.deviceName || r.serialNumber}(${r.serialNumber})` : item.bindDeviceId;
})()}
diff --git a/src/components/devices/TaskPlanningView.tsx b/src/components/devices/TaskPlanningView.tsx
index fbecf2a..71e1637 100644
--- a/src/components/devices/TaskPlanningView.tsx
+++ b/src/components/devices/TaskPlanningView.tsx
@@ -824,7 +824,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskPoolList();
fetchTaskHistoryList();
} else {
- utils.message.error(res.msg || '暂停失败');
+ utils.message.error(res.msg || t('devices.pauseFailed'));
}
} catch (err) {
console.error('暂停任务失败:', err);
@@ -846,7 +846,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskPoolList();
fetchTaskHistoryList();
} else {
- utils.message.error(res.msg || '恢复失败');
+ utils.message.error(res.msg || t('devices.resumeFailed'));
}
} catch (err) {
console.error('恢复任务失败:', err);
@@ -1627,7 +1627,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
}}
>
- 任务规划
+ {t('devices.mapEditor.taskPlan')}
@@ -2031,7 +2031,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
rowKey="id"
columns={taskHistoryColumns}
dataSource={taskHistoryList}
- pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => '共 ' + total + ' 条' }}
+ pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => t('devices.mapEditor.totalCountWithUnit', { count: total }) }}
scroll={{ x: 800, y: 140 }}
/>
@@ -2097,7 +2097,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
]}
dataSource={consecutiveTaskList ?? []}
loading={consecutiveLoading}
- pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => '共 ' + total + ' 条' }}
+ pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => t('devices.mapEditor.totalCountWithUnit', { count: total }) }}
scroll={{ x: 760, y: 140 }}
empty={
}
/>
@@ -2112,17 +2112,17 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
{/* 机器人任务规划:地图编辑能力入口 */}
机器人任务规划}
+ title={{t('devices.mapEditor.robotTaskPlam')}}
variant="borderless"
styles={{ body: { padding: 12 } }}
style={{ ...cardStyle, marginBottom: 10 }}
>
{([
- { type: 'returnPoint' as const, label: '返航点', desc: '任务结束返回点', icon: },
- { type: 'restArea' as const, label: '分区', desc: '绑定规划路线', icon: },
- { type: 'obstaclePoint' as const, label: '障碍点', desc: '标记障碍区域', icon: },
- { type: 'routeGen' as const, label: '路径生成', desc: '生成规划路径', icon: },
+ { type: 'returnPoint' as const, label: t('devices.mapEditor.returnPoint'), desc: t('devices.mapEditor.returnPointDesc'), icon: },
+ { type: 'restArea' as const, label: t('devices.mapEditor.restArea'), desc: t('devices.mapEditor.restAreaDesc'), icon: },
+ { type: 'obstaclePoint' as const, label: t('devices.mapEditor.obstaclePointLabel'), desc: t('devices.mapEditor.obstaclePointDesc'), icon: },
+ { type: 'routeGen' as const, label: t('devices.mapEditor.routeGen'), desc: t('devices.mapEditor.routeGenDesc'), icon: },
]).map((item) => {
const selected = editorType === item.type;
return (
@@ -2258,7 +2258,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
lineHeight: '16px',
}}
>
- 选择需要执行任务的区域(可多选)
+ {t('devices.selectDispatchRegions')}
{/* 区域选择卡片 */}
@@ -2408,7 +2408,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
lineHeight: '16px',
}}
>
- 选择需要执行任务的路线(可多选)
+ {t('devices.selectDispatchRoutes')}
{/* 路线选择卡片 */}
@@ -2532,8 +2532,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
>
-
调节执行顺序 (拖拽排序)
-
+ {t('devices.adjustExecutionOrder')}
+
diff --git a/src/components/devices/deviceController.js b/src/components/devices/deviceController.js
index 6d74e34..8bf656b 100644
--- a/src/components/devices/deviceController.js
+++ b/src/components/devices/deviceController.js
@@ -30,6 +30,9 @@ export default class DeviceController {
this.wsStatus = 'disconnected';
this.wsDeviceInfo = {};
this.locationInfo = {};
+ // 切换设备后的实时数据门禁:AUTH 确认前丢弃无设备标识的遗留消息
+ this.authConfirmed = true;
+ this.switchAt = 0;
this.controlTimeout = null;
this.keepAliveInterval = null;
@@ -360,6 +363,9 @@ export default class DeviceController {
this.connectedDeviceSn = newSn;
this.wsDeviceInfo = {};
this.locationInfo = {};
+ // 切换设备:AUTH 确认前丢弃旧设备遗留的实时数据
+ this.authConfirmed = false;
+ this.switchAt = Date.now();
this.isControlled = false;
this.onControlStatusChange?.(false);
@@ -437,6 +443,20 @@ export default class DeviceController {
});
}
+ // 判断实时消息是否属于当前连接设备;设备切换过程中旧设备的遗留消息返回 true
+ isStaleRealtimeMessage(msg, data) {
+ const msgSn = data?.deviceId ?? data?.device_id ?? data?.deviceSn
+ ?? msg?.deviceId ?? msg?.device_id ?? msg?.deviceSn ?? msg?.sn;
+ if (msgSn != null && String(msgSn) !== '') {
+ if (String(msgSn) !== String(this.connectedDeviceSn)) return true;
+ this.authConfirmed = true;
+ return false;
+ }
+ // 无设备标识:切换后 AUTH 确认前一律视为遗留数据(兜底 2 秒防止永久丢弃)
+ if (!this.authConfirmed) return Date.now() - (this.switchAt || 0) < 2000;
+ return false;
+ }
+
handleWsMessage(msg) {
console.log('WS message:', msg);
switch (msg.type) {
@@ -446,7 +466,7 @@ export default class DeviceController {
data[item.name] = item.value;
});
// 切换任务/切换设备时,忽略上一个设备遗留的实时数据
- if (data?.deviceId && data.deviceId !== this.connectedDeviceSn) {
+ if (this.isStaleRealtimeMessage(msg, data)) {
break;
}
this.wsDeviceInfo = data;
@@ -459,7 +479,7 @@ export default class DeviceController {
data[item.name] = item.value;
});
// 切换任务/切换设备时,忽略上一个设备遗留的实时经纬度,只显示当前连接设备的实时轨迹
- if (data?.deviceId && data.deviceId !== this.connectedDeviceSn) {
+ if (this.isStaleRealtimeMessage(msg, data)) {
break;
}
this.locationInfo = data;
@@ -469,6 +489,7 @@ export default class DeviceController {
case 'AUTH': {
if (msg.isAuth) {
+ this.authConfirmed = true;
this.getControl(this.connectedDeviceSn);
}
break;
diff --git a/src/components/taskRadio/taskRadio.tsx b/src/components/taskRadio/taskRadio.tsx
index 518841c..4615238 100644
--- a/src/components/taskRadio/taskRadio.tsx
+++ b/src/components/taskRadio/taskRadio.tsx
@@ -6,6 +6,8 @@ import {
CheckCircleFilled,
} from '@ant-design/icons';
import './TaskTypeRadio.css'
+import { useTranslation } from 'react-i18next';
+
type DispatchMode = 'immediate' | 'scheduled';
interface TaskTypeRadioProps {
@@ -17,6 +19,8 @@ const TaskTypeRadio: React.FC
= ({
value,
onChange,
}) => {
+ const { t } = useTranslation();
+
const options: {
value: DispatchMode;
title: string;
@@ -25,22 +29,24 @@ const TaskTypeRadio: React.FC = ({
}[] = [
{
value: 'immediate',
- title: '立即执行任务',
- description: '下发后机器人立即开始执行',
+ title: t('devices.taskTypeRadio.immediate'),
+ description: t('devices.taskTypeRadio.immediateDescription'),
icon: ,
},
{
value: 'scheduled',
- title: '定时任务',
- description: '设置开始时间和重复周期',
+ title: t('devices.taskTypeRadio.scheduled'),
+ description: t('devices.taskTypeRadio.scheduledDescription'),
icon: ,
},
];
+
+
return (
- 选择任务类型
+ {t('devices.taskTypeRadio.taskType')}