急停 发送ws 遥感控制 避免 raf循环闭包

This commit is contained in:
mmc
2026-10-15 14:02:02 +08:00
parent 4e1356b8af
commit 652dbdcc78
6 changed files with 46 additions and 3 deletions

View File

@@ -1,5 +1,8 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { RootState } from '@/store';
import { sendEmergencyStop } from './emergencyStopControl';
import {
ShieldAlert,
Zap,
@@ -48,6 +51,7 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
className = '',
}) => {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
const [active, setActive] = useState<Set<RobotFeature>>(new Set(activeFeatures));
const handleClick = (feature: RobotFeature) => {
@@ -56,6 +60,8 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
if (next) nextSet.add(feature);
else nextSet.delete(feature);
setActive(nextSet);
// 急停:点击时直接下发 button7(绕过控制权限校验)
if (feature === 'emergencyStop') sendEmergencyStop(userInfo);
onToggle?.(feature, next);
};