From 9e749785a244e88e8abef3bf42ee6da3bdfafe4b Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Thu, 19 Nov 2026 14:01:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=20=E4=BD=8D=E7=BD=AE=20?= =?UTF-8?q?=E5=81=8F=E7=A7=BB=E4=BF=AE=E5=A4=8D=20=20=20=E6=80=A5=E5=81=9C?= =?UTF-8?q?=E5=89=B2=E5=88=80=E5=8A=A0=E7=A1=AE=E8=AE=A4=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Map.jsx | 12 +- .../SystemSetting/ErrorManagement.tsx | 44 +++--- src/components/devices/DeviceOverviewPage.tsx | 32 ++--- src/components/devices/DeviceStatusPage.tsx | 130 +++++++++++++++--- .../devices/RobotFeatureButtons.tsx | 13 +- src/components/devices/TaskPlanningView.tsx | 41 +++--- src/components/devices/deviceController.js | 2 + src/locales/en/index.ts | 14 +- src/locales/zh/index.ts | 14 +- 9 files changed, 216 insertions(+), 86 deletions(-) diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 8cc1482..7b9e244 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -961,7 +961,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, width: 2, // 规划航线用橙色,和实时轨迹区分 material: Cesium.Color.ORANGE.withAlpha(0.8), - clampToGround: true, + clampToGround: false, disableDepthTestDistance: Number.POSITIVE_INFINITY, }, }); @@ -1085,7 +1085,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, outline: true, outlineColor: Cesium.Color.ORANGE.withAlpha(0.8), height: 0, - clampToGround: true, + clampToGround: false, disableDepthTestDistance: Number.POSITIVE_INFINITY, }, }); @@ -1096,7 +1096,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, width: 2, material: Cesium.Color.ORANGE.withAlpha(0.8), - clampToGround: true, + clampToGround: false, disableDepthTestDistance: Number.POSITIVE_INFINITY, }, }); @@ -1346,7 +1346,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, positions: linePositions, width: 4, material: Cesium.Color.SKYBLUE, - clampToGround: true, + clampToGround: false, } }); } @@ -2116,7 +2116,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, outline: true, outlineColor: Cesium.Color.fromCssColorString('#13C2C2').withAlpha(0.9), height: 0, - clampToGround: true, + clampToGround: false, }, label: region?.regionName ? { text: region.regionName, @@ -2977,7 +2977,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, positions: positions, width: 2, material: Cesium.Color.BLUE.withAlpha(0.9), - clampToGround: true, + clampToGround: false, disableDepthTestDistance: Number.POSITIVE_INFINITY, }, }); diff --git a/src/components/SystemSetting/ErrorManagement.tsx b/src/components/SystemSetting/ErrorManagement.tsx index a96fa46..62cbec6 100644 --- a/src/components/SystemSetting/ErrorManagement.tsx +++ b/src/components/SystemSetting/ErrorManagement.tsx @@ -292,30 +292,30 @@ export default function ErrorManagement() { return {severityObj?.label || text}; }, }, - { - title: t('systemSetting.checkField'), - dataIndex: 'field', - key: 'field', - width: 130, - }, - { - title: t('systemSetting.compareRule'), - dataIndex: 'compareType', - key: 'compareType', - width: 140, - render: (val) => { - const item = CompareEnumOptions.find(o => o.value === val); - return item?.label || val; - }, - }, + //{ + // title: t('systemSetting.checkField'), + // dataIndex: 'field', + // key: 'field', + // width: 130, + //}, + //{ + // title: t('systemSetting.compareRule'), + // dataIndex: 'compareType', + // key: 'compareType', + // width: 140, + // render: (val) => { + // const item = CompareEnumOptions.find(o => o.value === val); + // return item?.label || val; + // }, + //}, - { - title: t('systemSetting.compareValueCol'), - dataIndex: 'compareValues', - key: 'compareValues', - width: 140, + //{ + // title: t('systemSetting.compareValueCol'), + // dataIndex: 'compareValues', + // key: 'compareValues', + // width: 140, - }, + //}, { title: t('common.description'), dataIndex: 'errorDescription', diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index d2b12d3..7b118f5 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -631,12 +631,12 @@ export default function DeviceOverviewPage() { // 机器人视频 // 机器人视频:只有 robotPlayActive = true 才真正拉流 - const { video: robotVideo, error, ready } = useWebRTCPlayer( - (!isUAV && robotPlayActive && !selectedDevice?.hasHost) ? (selectedDevice?.serialNumber || '') : '', - (!isUAV && robotPlayActive) - ? `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}` - : '' - ); + //const { video: robotVideo, error, ready } = useWebRTCPlayer( + // (!isUAV && robotPlayActive && !selectedDevice?.hasHost) ? (selectedDevice?.serialNumber || '') : '', + // (!isUAV && robotPlayActive) + // ? `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}` + // : '' + //); const getDevivePermisstion = (data) => { const params = { @@ -1320,22 +1320,10 @@ export default function DeviceOverviewPage() { /> ) : ( robotPlayActive ? ( - selectedDevice?.hasHost ? ( -
- -
- ) : robotVideo ? ( - - ) : ( -
{t('video.videoLoading')}
- ) +
+ +
+ ) : ( // ========== 未点击播放时:显示播放大按钮 ==========
{ syncEmergencyStop(runningStatus?.emergency_stop); }, [runningStatus?.emergency_stop]); + // 急停当前状态(用于确认弹窗区分「触发急停」还是「解除急停」) + const [eStopActive, setEStopActive] = useState(false); + useEffect(() => subscribeEmergencyStop(setEStopActive), []); // 统一在线状态判断:优先实时数据,兜底接口数据 const isDeviceOnline = useMemo(() => { // 1. 优先检查实时数据源(WebSocket 推送的 wsDeviceInfo / locationInfo) @@ -481,12 +487,12 @@ export default function DeviceStatusPage() { // 3. 兜底用接口返回的 onlineStatus return device?.onlineStatus == 1; }, [device, wsDeviceInfo, locationInfo,]); - const { video: robotVideo, error, ready } = useWebRTCPlayer( - (!isUAV && isVideoPlaying && !device?.hasHost) ? (device?.serialNumber || '') : '', - (!isUAV && isVideoPlaying) - ? `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}` - : '' - ); + //const { video: robotVideo, error, ready } = useWebRTCPlayer( + // (!isUAV && isVideoPlaying && !device?.hasHost) ? (device?.serialNumber || '') : '', + // (!isUAV && isVideoPlaying) + // ? `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}` + // : '' + //); //const { video: robotVideo, error, ready } = useWebRTCPlayer( // !isUAV ? device?.serialNumber : '', // `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`, @@ -697,7 +703,7 @@ export default function DeviceStatusPage() { return; } //console.log(runningStatus,controlMode, "现在的控制controlmode") - if ((controlMode == 3 && runningStatus?.control_mode == 3) || runningStatus?.systemMode == 3) { + if ((controlMode == 3 && runningStatus?.control_mode == 3)) { messageApi.warning(t('devices.onRemoteControl')); return; } @@ -744,8 +750,12 @@ export default function DeviceStatusPage() { warned = true; } - if ((currentStatus?.control_mode != 3 || currentStatus?.controlMode != 3) && - currentStatus?.systemMode != 3) { + if ( + currentStatus?.controlMode != 3 && + currentStatus?.control_mode != 3 && + currentStatus?.systemMode != 3 && + currentStatus?.system_mode != 3 + ) { messageApi.warning(t('devices.switchControl')); warned = true; } @@ -835,11 +845,87 @@ export default function DeviceStatusPage() { }, [buildSteerButtons, handleGamepadUpdate]); // 点击:未激活→激活;再次点击→取消;切换同组另一个按钮时自动互斥 - const toggleSteerGroup = useCallback((group: SteerGroup, value: string) => { - if (blockIfGamepadConnected()) return; - const prev = steerStateRef.current; - sendSteerState({ ...prev, [group]: prev[group] === value ? null : value } as Record); - }, [blockIfGamepadConnected, sendSteerState]); + const isConfirmingRef = useRef(false); + + const toggleSteerGroup = useCallback( + (group: SteerGroup, value: string) => { + if (blockIfGamepadConnected()) return; + + // 防止重复打开确认框 + if (isConfirmingRef.current) return; + + const prev = steerStateRef.current; + const isActivating = prev[group] !== value; + + // 需要二次确认的危险操作 + const DANGEROUS_ACTIONS: Record< + string, + Record + > = { + blade: { + start: { + title: t('devices.steer.confirmCutterStart'), + content: t('devices.steer.confirmCutterStartDesc'), + }, + }, + power: { + ignition: { + title: t('devices.steer.confirmIgnition'), + content: t('devices.steer.confirmIgnitionDesc'), + }, + shutdown: { + title: t('devices.steer.confirmShutdown'), + content: t('devices.steer.confirmShutdownDesc'), + }, + }, + }; + + const danger = isActivating + ? DANGEROUS_ACTIONS[group]?.[value] + : undefined; + + // 真正执行操作时读取最新状态 + const doToggle = () => { + const latest = steerStateRef.current; + + sendSteerState({ + ...latest, + [group]: latest[group] === value ? null : value, + }); + }; + + if (danger) { + isConfirmingRef.current = true; + + modal.confirm({ + title: danger.title, + content: danger.content, + okText: t('common.confirm'), + cancelText: t('common.cancel'), + okButtonProps: { danger: true }, + + onOk: () => { + try { + doToggle(); + } finally { + isConfirmingRef.current = false; + } + }, + + onCancel: () => { + isConfirmingRef.current = false; + }, + + afterClose: () => { + isConfirmingRef.current = false; + }, + }); + } else { + doToggle(); + } + }, + [blockIfGamepadConnected, sendSteerState, t, modal] + ); // 锁存期间每 100ms 持续发送,保持"按住"语义 useEffect(() => { @@ -1558,7 +1644,17 @@ export default function DeviceStatusPage() { { if (blockIfGamepadConnected()) return; handleGamepadUpdate(state); }} onSpeedChange={() => { }} - onEmergencyStop={() => sendEmergencyStop(selectedSn)} + onEmergencyStop={() => { + const isRelease = eStopActive; + modal.confirm({ + title: isRelease ? t('devices.steer.confirmEmergencyRelease') : t('devices.steer.confirmEmergencyStop'), + content: isRelease ? t('devices.steer.confirmEmergencyReleaseDesc') : t('devices.steer.confirmEmergencyStopDesc'), + okText: t('common.confirm'), + cancelText: t('common.cancel'), + okButtonProps: { danger: !isRelease }, + onOk: () => sendEmergencyStop(selectedSn), + }); + }} />
diff --git a/src/components/devices/RobotFeatureButtons.tsx b/src/components/devices/RobotFeatureButtons.tsx index ce6d494..b89b3c2 100644 --- a/src/components/devices/RobotFeatureButtons.tsx +++ b/src/components/devices/RobotFeatureButtons.tsx @@ -10,6 +10,7 @@ import { BatteryWarning, MoveVertical, } from 'lucide-react'; +import { App } from 'antd'; export type RobotFeature = | 'emergencyStop' @@ -75,6 +76,8 @@ const RobotFeatureButtons: React.FC = ({ const { t } = useTranslation(); const { userInfo } = useSelector((state: RootState) => state.user); const [active, setActive] = useState>(new Set(activeFeatures)); + const { modal } = App.useApp(); + // 临时按压闪烁标记 const [flashKey, setFlashKey] = useState(null); // 急停锁存状态:与 DPad / 手柄共用同一份状态,点击后保持按下态 @@ -97,7 +100,15 @@ const RobotFeatureButtons: React.FC = ({ // 一次性按钮:只发指令,不切换active状态 if (oneShotKeys.includes(feature)) { if (feature === 'emergencyStop') { - sendEmergencyStop(deviceId || ""); + const isRelease = eStopActive; + modal.confirm({ + title: isRelease ? t('devices.steer.confirmEmergencyRelease') : t('devices.steer.confirmEmergencyStop'), + content: isRelease ? t('devices.steer.confirmEmergencyReleaseDesc') : t('devices.steer.confirmEmergencyStopDesc'), + okText: t('common.confirm'), + cancelText: t('common.cancel'), + okButtonProps: { danger: !isRelease }, + onOk: () => sendEmergencyStop(deviceId || ""), + }); onToggle?.(feature, true); return; } diff --git a/src/components/devices/TaskPlanningView.tsx b/src/components/devices/TaskPlanningView.tsx index 5485db2..8b780d8 100644 --- a/src/components/devices/TaskPlanningView.tsx +++ b/src/components/devices/TaskPlanningView.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useRef, useMemo } from 'react'; -import { Row, Col, Card, Button, Space, Table, Tag, Typography, Badge, Tabs, Input, Switch, Tooltip, Timeline, Select, message, DatePicker, TimePicker, Popconfirm, App, Radio, Empty, Collapse } from 'antd'; +import { Row, Col, Card, Button, Space, Table, Tag, Typography, Badge, Tabs, Input, Switch, Tooltip, Timeline, Select, message, DatePicker, TimePicker, Popconfirm, App, Radio, Empty, Collapse, Modal } from 'antd'; import { PlusOutlined, ImportOutlined, NodeIndexOutlined, SaveOutlined, DeleteOutlined, CloseOutlined, ReloadOutlined, ExclamationCircleOutlined, EnvironmentOutlined, EnvironmentFilled } from '@ant-design/icons'; import { Car, Navigation, MapPinned, Route, Satellite, LayoutGrid, CheckCircle2, AlertCircle, TrendingUp, Maximize2 } from 'lucide-react'; import TaskTypeRadio from '../taskRadio/taskRadio'; @@ -123,10 +123,10 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC robot: null, planId: null, }); - const { video: robotVideo, error, ready } = useWebRTCPlayer( - executingRobot?.serialNumber ? executingRobot?.serialNumber : '', - `webrtc://1.95.137.212/live/livestream/${executingRobot?.serialNumber}`, - ); + //const { video: robotVideo, error, ready } = useWebRTCPlayer( + // executingRobot?.serialNumber ? executingRobot?.serialNumber : '', + // `webrtc://1.95.137.212/live/livestream/${executingRobot?.serialNumber}`, + //); const [historyFilterForm, setHistoryFilterForm] = useState({ taskStatus: null, robot: null, @@ -900,10 +900,10 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC const res = await cancelRoute(params); if (res.code === 200 && res.data == true) { utils.message.success(t('devices.fixed2TaskSuspended2Fixed2CancelledFixed2')); - fetchTaskPoolList(); - fetchTaskHistoryList(); - fetchStatsTaskHistoryList(); - fetchConsecutiveTaskList(); + //fetchTaskPoolList(); + //fetchTaskHistoryList(); + //fetchStatsTaskHistoryList(); + //fetchConsecutiveTaskList(); setExecute(false); //if (controllerRef.current) { // controllerRef.current.destroy?.(); @@ -934,9 +934,9 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC const res = await pauseRoute(params); if (res.code === 200) { utils.message.success(t('devices.taskPaused')); - fetchTaskPoolList(); - fetchTaskHistoryList(); - fetchStatsTaskHistoryList(); + //fetchTaskPoolList(); + //fetchTaskHistoryList(); + //fetchStatsTaskHistoryList(); } else { utils.message.error(res.msg || t('devices.pauseFailed')); } @@ -957,9 +957,9 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC const res = await recoverRoute(params); if (res.code === 200) { utils.message.success(t('devices.taskResumed')); - fetchTaskPoolList(); - fetchTaskHistoryList(); - fetchStatsTaskHistoryList(); + //fetchTaskPoolList(); + //fetchTaskHistoryList(); + //fetchStatsTaskHistoryList(); } else { utils.message.error(res.msg || t('devices.resumeFailed')); } @@ -1621,7 +1621,16 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC // 急停:与 DPad 保持一致,调用共享锁存接口(再次点击解除) const handleEmergencyStop = () => { - sendEmergencyStop(selectedMachineSn || targetRobot?.serialNumber || ''); + // 已急停 -> 再次点击是解除;未急停 -> 点击是触发 + const isRelease = eStopActive; + modal.confirm({ + title: isRelease ? t('devices.steer.confirmEmergencyRelease') : t('devices.steer.confirmEmergencyStop'), + content: isRelease ? t('devices.steer.confirmEmergencyReleaseDesc') : t('devices.steer.confirmEmergencyStopDesc'), + okText: t('common.confirm'), + cancelText: t('common.cancel'), + okButtonProps: { danger: !isRelease }, + onOk: () => sendEmergencyStop(selectedMachineSn || targetRobot?.serialNumber || ''), + }); }; // 选中的路径对象列表(用于拖拽排序显示) diff --git a/src/components/devices/deviceController.js b/src/components/devices/deviceController.js index 8048825..6878d83 100644 --- a/src/components/devices/deviceController.js +++ b/src/components/devices/deviceController.js @@ -160,6 +160,8 @@ export default class DeviceController { this.onMapPush?.(next); } if (msg?.type == 'device_task_change') { + console.log('task change:', msg); + if (msg.status == "FINISH") { console.log('task finish'); this.onIsFinished?.(msg); diff --git a/src/locales/en/index.ts b/src/locales/en/index.ts index 1bec274..3e31a40 100644 --- a/src/locales/en/index.ts +++ b/src/locales/en/index.ts @@ -697,7 +697,19 @@ chassisDownHint: 'Chassis down', cutterControl: 'Cutter Control', cutterAccel: 'Cutter Faster', - cutterDecel: 'Cutter Slower', + cutterDecel: "Cutter Stop", + confirmEmergencyStop: "Confirm Emergency Stop?", + confirmEmergencyStopDesc: "Triggering emergency stop will immediately halt all robot motion. This action cannot be undone.", + confirmEmergencyRelease: "Confirm Release Emergency Stop?", + confirmEmergencyReleaseDesc: "Releasing emergency stop will restore robot control. Ensure the surrounding area is safe.", + confirmCutterStart: "Confirm Cutter Start?", + confirmCutterStartDesc: "The cutter will start working. Ensure the surrounding area is clear.", + confirmCutterStop: "Confirm Cutter Stop?", + confirmCutterStopDesc: "The cutter will stop.", + confirmIgnition: "Confirm Ignition?", + confirmIgnitionDesc: "The robot chassis will start. Watch for people and obstacles around.", + confirmShutdown: "Confirm Shutdown?", + confirmShutdownDesc: "The robot chassis will shut down and all motion will stop.", }, features: { title: 'Feature Control', diff --git a/src/locales/zh/index.ts b/src/locales/zh/index.ts index debd973..f182e77 100644 --- a/src/locales/zh/index.ts +++ b/src/locales/zh/index.ts @@ -730,7 +730,19 @@ const zh = { chassisDownHint: '底盘下降', cutterControl: '割刀控制', cutterAccel: '割刀启动', - cutterDecel: '割刀停止', + cutterDecel: "割刀停止", + confirmEmergencyStop: "确认触发急停?", + confirmEmergencyStopDesc: "触发急停后机器人所有运动将立即停止,此操作不可撤销。", + confirmEmergencyRelease: "确认解除急停?", + confirmEmergencyReleaseDesc: "解除急停后机器人将恢复可控状态,请确认周围环境安全。", + confirmCutterStart: "确认启动割刀?", + confirmCutterStartDesc: "割刀启动后将进入持续工作状态,请确保周围环境安全。", + confirmCutterStop: "确认停止割刀?", + confirmCutterStopDesc: "割刀将停止工作。", + confirmIgnition: "确认点火启动?", + confirmIgnitionDesc: "机器人底盘将启动,请注意周围人员与障碍物。", + confirmShutdown: "确认熄火?", + confirmShutdownDesc: "机器人底盘将熄火,当前所有运动将停止。", }, features: { title: '功能控制',