连续任务下发列表 取消连续任务 增加模式切换 方向盘手柄 加一个提示 切换模式控件 加一个高亮效果 任务监控界面 数据完善
This commit is contained in:
@@ -18,7 +18,8 @@ export type RobotFeature =
|
||||
| 'lowBatteryReturn'
|
||||
| 'tiltProtection'
|
||||
| 'findCar'
|
||||
| 'autoback';
|
||||
| 'autoback'
|
||||
| 'controlMode';
|
||||
|
||||
export interface FeatureConfig {
|
||||
key: RobotFeature;
|
||||
@@ -27,8 +28,10 @@ export interface FeatureConfig {
|
||||
inactiveColor: string;
|
||||
}
|
||||
|
||||
// 功能方块:方块样式展示,不再包含急停(急停已移至方向盘中键)
|
||||
// 功能方块
|
||||
const FEATURES: FeatureConfig[] = [
|
||||
{ key: 'controlMode', icon: <ShieldAlert className="w-6 h-6" />, activeColor: '#0dab2d', inactiveColor: '#94a3b8' },
|
||||
|
||||
{ key: 'obstacleAvoidance', icon: <Siren className="w-6 h-6" />, activeColor: '#3b82f6', inactiveColor: '#94a3b8' },
|
||||
{ key: 'lowBatteryReturn', icon: <BatteryWarning className="w-6 h-6" />, activeColor: '#f59e0b', inactiveColor: '#94a3b8' },
|
||||
{ key: 'tiltProtection', icon: <MoveVertical className="w-6 h-6" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
|
||||
@@ -36,7 +39,7 @@ const FEATURES: FeatureConfig[] = [
|
||||
{ key: 'findCar', icon: <ShieldAlert className="w-6 h-6" />, activeColor: '#ef4444', inactiveColor: '#94a3b8' },
|
||||
];
|
||||
|
||||
// 急停方块(仅在 showEmergencyStop 时展示,兼容其他页面)
|
||||
// 急停方块
|
||||
const EMERGENCY: FeatureConfig = {
|
||||
key: 'emergencyStop',
|
||||
icon: <ShieldAlert className="w-6 h-6" />,
|
||||
@@ -49,8 +52,10 @@ interface RobotFeatureButtonsProps {
|
||||
onToggle?: (feature: RobotFeature, enabled: boolean) => void;
|
||||
className?: string;
|
||||
showEmergencyStop?: boolean;
|
||||
sendFindCar: () => {};
|
||||
sendAutoBack?: () => {};
|
||||
sendFindCar?: () => void;
|
||||
sendAutoBack?: () => void;
|
||||
sendControlMode?: () => void;
|
||||
controlMode?: number | string;
|
||||
}
|
||||
|
||||
const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
@@ -59,28 +64,48 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
className = '',
|
||||
showEmergencyStop = true,
|
||||
sendFindCar,
|
||||
sendAutoBack
|
||||
sendAutoBack,
|
||||
sendControlMode,
|
||||
controlMode
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const [active, setActive] = useState<Set<RobotFeature>>(new Set(activeFeatures));
|
||||
// 临时按压闪烁标记
|
||||
const [flashKey, setFlashKey] = useState<RobotFeature | null>(null);
|
||||
|
||||
// 一次性触发,不toggle的按钮列表
|
||||
const oneShotKeys: RobotFeature[] = ['emergencyStop', 'findCar', 'autoback', 'controlMode'];
|
||||
|
||||
const list = showEmergencyStop ? [EMERGENCY, ...FEATURES] : FEATURES;
|
||||
|
||||
const handleClick = (feature: RobotFeature) => {
|
||||
// 急停:点击时直接下发 button7(绕过控制权限校验)
|
||||
if (feature === 'emergencyStop') {
|
||||
sendEmergencyStop(userInfo);
|
||||
onToggle?.(feature, true);
|
||||
// 触发按压反馈
|
||||
setFlashKey(feature);
|
||||
setTimeout(() => {
|
||||
setFlashKey(null);
|
||||
}, 200);
|
||||
|
||||
// 一次性按钮:只发指令,不切换active状态
|
||||
if (oneShotKeys.includes(feature)) {
|
||||
if (feature === 'emergencyStop') {
|
||||
sendEmergencyStop(userInfo);
|
||||
onToggle?.(feature, true);
|
||||
return;
|
||||
}
|
||||
if (feature === 'findCar') {
|
||||
sendFindCar?.();
|
||||
}
|
||||
if (feature === 'autoback') {
|
||||
sendAutoBack?.();
|
||||
}
|
||||
if (feature === 'controlMode') {
|
||||
sendControlMode?.();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 寻车:下发指令的同时,与其他功能一样切换选中状态(toggle 效果)
|
||||
if (feature === 'findCar') {
|
||||
sendFindCar?.();
|
||||
}
|
||||
if (feature === 'autoback') {
|
||||
sendAutoBack?.();
|
||||
}
|
||||
|
||||
// 开关类:保留toggle
|
||||
const next = !active.has(feature);
|
||||
const nextSet = new Set(active);
|
||||
if (next) nextSet.add(feature);
|
||||
@@ -91,26 +116,56 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
|
||||
return (
|
||||
<div className={`flex w-full ${className} flex-wrap content-start items-start gap-x-2 gap-y-2 justify-start self-start`}>
|
||||
<style>
|
||||
{`
|
||||
@keyframes controlModeGlow {
|
||||
0% { box-shadow: 0 0 5px rgba(13, 171, 45, 0.4); border-color: rgba(13, 171, 45, 0.4); }
|
||||
50% { box-shadow: 0 0 15px rgba(13, 171, 45, 0.8); border-color: rgba(13, 171, 45, 0.8); }
|
||||
100% { box-shadow: 0 0 5px rgba(13, 171, 45, 0.4); border-color: rgba(13, 171, 45, 0.4); }
|
||||
}
|
||||
.control-mode-glow {
|
||||
animation: controlModeGlow 1.5s infinite ease-in-out;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
{list.map((f) => {
|
||||
const isOneShot = oneShotKeys.includes(f.key);
|
||||
const isActive = active.has(f.key);
|
||||
const isFlashing = flashKey === f.key;
|
||||
const shouldGlow = f.key === 'controlMode' && controlMode != 3;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={f.key}
|
||||
onClick={() => handleClick(f.key)}
|
||||
className="flex flex-col items-center justify-center gap-1.5 rounded-lg border transition-all duration-200 select-none hover:shadow-md"
|
||||
className={`flex flex-col items-center justify-center gap-1.5 rounded-lg border transition-all duration-150 select-none hover:shadow-md ${shouldGlow ? 'control-mode-glow' : ''}`}
|
||||
style={{
|
||||
aspectRatio: '1 / 1',
|
||||
height: 64,
|
||||
color: isActive ? f.activeColor : f.inactiveColor,
|
||||
backgroundColor: isActive ? `${f.activeColor}1a` : '#fafafa',
|
||||
borderColor: isActive ? f.activeColor : '#e5e7eb',
|
||||
boxShadow: isActive ? `0 0 12px ${f.activeColor}33` : 'none',
|
||||
// 一次性按钮基础样式 + 按压变暗
|
||||
color: isOneShot
|
||||
? (isFlashing ? '#333' : f.inactiveColor)
|
||||
: (isActive ? f.activeColor : f.inactiveColor),
|
||||
backgroundColor: isOneShot
|
||||
? (isFlashing ? '#eaeaea' : '#fafafa')
|
||||
: (isActive ? `${f.activeColor}1a` : '#fafafa'),
|
||||
borderColor: isOneShot
|
||||
? (isFlashing ? '#ccc' : (shouldGlow ? f.activeColor : '#e5e7eb'))
|
||||
: (isActive ? f.activeColor : '#e5e7eb'),
|
||||
boxShadow: isOneShot
|
||||
? (isFlashing ? 'inset 0 1px 3px rgba(0,0,0,0.15)' : (shouldGlow ? `0 0 10px ${f.activeColor}66` : 'none'))
|
||||
: (isActive ? `0 0 12px ${f.activeColor}33` : 'none'),
|
||||
cursor: 'pointer',
|
||||
transform: isFlashing ? 'scale(0.97)' : 'scale(1)',
|
||||
}}
|
||||
title={t(`devices.features.${f.key}`)}
|
||||
>
|
||||
<span className="flex items-center justify-center">{f.icon}</span>
|
||||
<span className="text-xs font-medium text-center leading-tight px-1" style={{ color: isActive ? f.activeColor : '#595959' }}>
|
||||
<span className="text-xs font-medium text-center leading-tight px-1" style={{
|
||||
color: isOneShot
|
||||
? (isFlashing ? '#222' : '#595959')
|
||||
: (isActive ? f.activeColor : '#595959')
|
||||
}}>
|
||||
{t(`devices.features.${f.key}`)}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user