机器状态页面 样式优化 对接新的 设备状态数据 ,xbox和 方向盘 需要 互斥控制 中英文优化,方向盘加入 点火熄火等功能,等待对接状态和远程控制和倒车影像

This commit is contained in:
mmc
2026-10-21 14:51:27 +08:00
parent 1034b6dbf8
commit 2758dd9643
8 changed files with 2312 additions and 617 deletions

View File

@@ -20,7 +20,6 @@ export type RobotFeature =
| 'findCar'
| 'autoback';
export interface FeatureConfig {
key: RobotFeature;
icon: React.ReactNode;
@@ -28,71 +27,86 @@ export interface FeatureConfig {
inactiveColor: string;
}
// 功能方块:方块样式展示,不再包含急停(急停已移至方向盘中键)
const FEATURES: FeatureConfig[] = [
{ key: 'emergencyStop', icon: <ShieldAlert className="w-5 h-5" />, activeColor: '#ef4444', inactiveColor: '#94a3b8' },
{ key: 'obstacleAvoidance', icon: <Siren className="w-5 h-5" />, activeColor: '#3b82f6', inactiveColor: '#94a3b8' },
{ key: 'lowBatteryReturn', icon: <BatteryWarning className="w-5 h-5" />, activeColor: '#f59e0b', inactiveColor: '#94a3b8' },
{ key: 'tiltProtection', icon: <MoveVertical className="w-5 h-5" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
//{ key: 'findCar', icon: <Zap className="w-5 h-5" />, activeColor: '#22c55e', inactiveColor: '#c4158c' },
{ key: 'autoback', icon: <Zap className="w-5 h-5" />, activeColor: '#22c55e', inactiveColor: '#133c75' },
{ 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' },
{ key: 'autoback', icon: <Zap className="w-6 h-6" />, activeColor: '#22c55e', inactiveColor: '#94a3b8' },
{ 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" />,
activeColor: '#ef4444',
inactiveColor: '#ef4444',
};
interface RobotFeatureButtonsProps {
activeFeatures?: RobotFeature[];
onToggle?: (feature: RobotFeature, enabled: boolean) => void;
className?: string;
showEmergencyStop?: boolean;
sendFindCar: () => {}
}
const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
activeFeatures = [],
onToggle,
className = '',
showEmergencyStop = true,
sendFindCar,
}) => {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
const [active, setActive] = useState<Set<RobotFeature>>(new Set(activeFeatures));
const list = showEmergencyStop ? [EMERGENCY, ...FEATURES] : FEATURES;
const handleClick = (feature: RobotFeature) => {
// 急停:点击时直接下发 button7(绕过控制权限校验)
if (feature === 'emergencyStop') {
sendEmergencyStop(userInfo);
onToggle?.(feature, true);
return;
}
// 寻车:下发指令的同时,与其他功能一样切换选中状态(toggle 效果)
if (feature === 'findCar') {
sendFindCar?.();
}
const next = !active.has(feature);
const nextSet = new Set(active);
if (next) nextSet.add(feature);
else nextSet.delete(feature);
setActive(nextSet);
// 急停:点击时直接下发 button7(绕过控制权限校验)
if (feature === 'emergencyStop') sendEmergencyStop(userInfo);
onToggle?.(feature, next);
};
return (
<div className={`flex flex-wrap gap-2 ${className}`}>
{FEATURES.map((f) => {
<div className={`flex gap-2 w-full ${className}`}>
{list.map((f) => {
const isActive = active.has(f.key);
return (
<button
key={f.key}
onClick={() => handleClick(f.key)}
className={`flex items-center gap-1 px-1 py-1 rounded-lg border transition-all duration-200 select-none
${isActive
? 'border-current shadow-lg'
: 'border-slate-700 hover:border-slate-500'
}`}
className="flex flex-col items-center justify-center gap-1.5 rounded-lg border transition-all duration-200 select-none hover:shadow-md"
style={{
aspectRatio: '1 / 1',
height: 64,
color: isActive ? f.activeColor : f.inactiveColor,
backgroundColor: isActive ? `${f.activeColor}1a` : 'transparent',
backgroundColor: isActive ? `${f.activeColor}1a` : '#fafafa',
borderColor: isActive ? f.activeColor : '#e5e7eb',
boxShadow: isActive ? `0 0 12px ${f.activeColor}33` : 'none',
}}
title={t(`devices.features.${f.key}`)}
>
<span className="flex items-center justify-center">{f.icon}</span>
<span className="text-xs font-medium whitespace-nowrap">
<span className="text-xs font-medium text-center leading-tight px-1" style={{ color: isActive ? f.activeColor : '#595959' }}>
{t(`devices.features.${f.key}`)}
</span>
<span
className="ml-1 w-2 h-2 rounded-full transition-all"
style={{ backgroundColor: isActive ? f.activeColor : '#475569' }}
/>
</button>
);
})}