Compare commits

...

4 Commits

13 changed files with 740 additions and 2651 deletions

View File

@@ -8,6 +8,10 @@ import utils from './lib/utils';
import { useTranslation } from 'react-i18next';
import { I18nextProvider } from 'react-i18next';
import i18n from './i18n';
import { useEffect } from 'react';
import { useAppDispatch } from './store';
import { setSettingField, setGlobalParams } from './store/basicSettingsSlice';
import { getSystemParam } from './api/global';
// 用于静态注入 message/modal/notification
const StaticAntd = () => {
@@ -50,6 +54,28 @@ const AntdConfigWrapper = ({ children }: { children: React.ReactNode }) => {
};
export default function App() {
const dispatch = useAppDispatch();
useEffect(() => {
getSystemParam()
.then((res: any) => {
if (res?.code === 200 && res?.data?.global) {
const globalArr = res.data.global;
// 存储完整数组,保存时基于此结构更新 paramValue
dispatch(setGlobalParams(globalArr));
// 同时提取 systemName 用于登录页和平台头部显示
const systemNameItem = globalArr.find((item: any) => item.paramKey === 'systemName');
if (systemNameItem?.paramValue) {
dispatch(setSettingField({ systemName: systemNameItem.paramValue }));
}
console.log('[System] global config loaded:', globalArr);
}
})
.catch((err: any) => {
console.error('[System] Failed to load global config:', err);
});
}, [dispatch]);
return (
<I18nextProvider i18n={i18n}>
<AntdConfigWrapper>

18
src/api/global.ts Normal file
View File

@@ -0,0 +1,18 @@
import request from './request';
//新增物模型
export function getSystemParam() {
return request({
url: '/system/param/list',
method: 'get',
});
}
//保存系统参数
export function saveSystemParam(data: any[]) {
return request({
url: '/system/param/save',
method: 'post',
data,
});
}

View File

@@ -1,4 +1,4 @@
import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import envConfig from '../../env';
import Cookies from 'js-cookie';
import utils from '../lib/utils';
@@ -21,8 +21,10 @@ const api = axios.create({
api.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
const token = localStorage.getItem('token');
if (token && config.headers) {
config.headers['Authorization'] = `Bearer ${token}`;
const lang = localStorage.getItem('i18nextLng') || 'zh';
if (config.headers) {
if (token) config.headers['Authorization'] = `Bearer ${token}`;
config.headers['language'] = lang;
}
if (!(config.data instanceof FormData)) {

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import {
Form,
Input,
@@ -61,6 +61,7 @@ import {
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
import { getRoleList } from '@/api/role';
import { saveSystemParam } from '@/api/global';
import { useSelector } from 'react-redux';
import { RootState } from '@/src/store';
import { getUser } from '@/api/user';
@@ -87,8 +88,23 @@ const BasicSettings = () => {
const [userPage, setUserPage] = useState(1);
const [rolePage, setRolePage] = useState(1);
const [devicePage, setDevicePage] = useState(1);
// 本地临时状态,保存时才 dispatch
const [localLocale, setLocalLocale] = useState(locale);
const [localTimezone, setLocalTimezone] = useState(timezone);
const [localUnitSystem, setLocalUnitSystem] = useState(unitSystem);
const [localDateFormat, setLocalDateFormat] = useState(dateFormat);
// Redux 值变化时同步到本地(如保存后、重置后)
useEffect(() => {
setLocalLocale(locale);
setLocalTimezone(timezone);
setLocalUnitSystem(unitSystem);
setLocalDateFormat(dateFormat);
}, [locale, timezone, unitSystem, dateFormat]);
const tzOptions = getTimezoneOptions();
const dstActive = isDST(timezone);
const dstActive = isDST(localTimezone);
// 响应式字体大小
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
@@ -97,26 +113,73 @@ const BasicSettings = () => {
const fontLarge = 'clamp(18px, 1.1vw, 22px)';
const handleSave = () => {
const systemName = form.getFieldValue('systemName') || basicSettings.systemName;
const defaultSite = form.getFieldValue('defaultSite') || basicSettings.defaultSite;
dispatch(saveAllSettings({
systemName: form.getFieldValue('systemName') || basicSettings.systemName,
defaultSite,
defaultPage: form.getFieldValue('defaultPage') || basicSettings.defaultPage,
refreshRate: form.getFieldValue('refreshRate') || basicSettings.refreshRate,
}));
// 查找默认场站名称
let defaultStationName = '';
if (defaultSite && stationList && stationList.length > 0) {
const target = stationList.find((s: any) => s.id === defaultSite);
if (target) {
dispatch(setCurrentStation(target));
defaultStationName = target.siteName || target.name || '';
}
}
if (defaultSite && stationList && stationList.length > 0) {
const target = stationList.find((s: any) => s.id === defaultSite);
if (target) {
dispatch(setCurrentStation(target));
// 基于 getSystemParam 返回的完整数组结构,只更新 paramValue
const paramsToSave = (basicSettings.globalParams || []).map((item: any) => {
const updated = { ...item };
switch (item.paramKey) {
case 'systemName':
updated.paramValue = systemName;
break;
case 'defaultStationName':
updated.paramValue = defaultStationName;
break;
case 'defaultLanguage':
updated.paramValue = localLocale === 'en' ? 'en_US' : 'zh_CN';
break;
case 'defaultZoneId':
updated.paramValue = localTimezone;
break;
case 'defaultUnit':
updated.paramValue = localUnitSystem === 'imperial' ? '英制' : '公制';
break;
case 'defaultDateFormat':
updated.paramValue = localDateFormat;
break;
}
}
utils.message.success(t('systemSetting.fixed2SettingsSaveFixed2'));
return updated;
});
saveSystemParam(paramsToSave).then((res: any) => {
if (res.code === 200) {
// 同步到 Redux/localStorage
dispatch(saveAllSettings({
systemName,
defaultSite,
defaultPage: form.getFieldValue('defaultPage') || basicSettings.defaultPage,
refreshRate: form.getFieldValue('refreshRate') || basicSettings.refreshRate,
}));
// 同步偏好设置
dispatch(setLocale(localLocale));
i18n.changeLanguage(localLocale);
dispatch(setTimezone(localTimezone));
dispatch(setUnitSystem(localUnitSystem));
dispatch(setDateFormat(localDateFormat));
// 同步默认场站
if (defaultSite && stationList && stationList.length > 0) {
const target = stationList.find((s: any) => s.id === defaultSite);
if (target) {
dispatch(setCurrentStation(target));
}
}
utils.message.success(t('systemSetting.fixed2SettingsSaveFixed2'));
} else {
utils.message.error(res.msg || t('common.saveFailed'));
}
}).catch((err: any) => {
utils.message.error(err?.message || t('common.saveFailed'));
});
};
// 顶部统计卡片数据
@@ -319,15 +382,15 @@ const BasicSettings = () => {
<Row gutter={16}>
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.systemName')} name="systemName" style={{ marginBottom: 12 }}>
<Input size="small" value={basicSettings.systemName} />
<Input size="small" />
</Form.Item>
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.fixed2Default2')} name="defaultSite" style={{ marginBottom: 12 }}>
<Select size="small" value={basicSettings.defaultSite} onChange={(v) => dispatch(saveAllSettings({ defaultSite: v }))}>
<Select size="small">
{(stationList || []).slice().sort((a, b) => (a.id || 0) - (b.id || 0)).map((s, idx) => (
<Select.Option key={s.id} value={s.id}>
{idx + 1}. {s.siteName || s.name || s.id}
{s.siteName || s.name || s.id}
</Select.Option>
))}
</Select>
@@ -335,7 +398,7 @@ const BasicSettings = () => {
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.defaultLanguage')} style={{ marginBottom: 12 }}>
<Select size="small" value={locale} onChange={(v) => { dispatch(setLocale(v)); i18n.changeLanguage(v); }}>
<Select size="small" value={localLocale} onChange={(v) => setLocalLocale(v)}>
<Select.Option value="zh">{t('users.chinese')}</Select.Option>
<Select.Option value="en">English</Select.Option>
</Select>
@@ -343,7 +406,7 @@ const BasicSettings = () => {
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.timezoneSelect')} style={{ marginBottom: 12 }}>
<Select size="small" value={timezone} onChange={(v) => dispatch(setTimezone(v))} showSearch optionFilterProp="label">
<Select size="small" value={localTimezone} onChange={(v) => setLocalTimezone(v)} showSearch optionFilterProp="label">
{tzOptions.map(opt => <Select.Option key={opt.value} value={opt.value}>{opt.label}</Select.Option>)}
</Select>
</Form.Item>
@@ -351,13 +414,13 @@ const BasicSettings = () => {
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.daylightSavingTime')} style={{ marginBottom: 12 }}>
<Tag color={dstActive ? 'green' : 'default'}>
{dstActive ? t('systemSetting.dstActive') : t('systemSetting.dstInactive')} ({getTimezoneOffsetLabel(timezone)})
{dstActive ? t('systemSetting.dstActive') : t('systemSetting.dstInactive')} ({getTimezoneOffsetLabel(localTimezone)})
</Tag>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.unitSystem')} style={{ marginBottom: 12 }}>
<Radio.Group size="small" value={unitSystem} onChange={(e) => dispatch(setUnitSystem(e.target.value))}>
<Radio.Group size="small" value={localUnitSystem} onChange={(e) => setLocalUnitSystem(e.target.value)}>
<Radio value="metric" style={{ fontSize: fontSmall }}>{t('systemSetting.metric')}</Radio>
<Radio value="imperial" style={{ fontSize: fontSmall }}>{t('systemSetting.imperial')}</Radio>
</Radio.Group>
@@ -365,7 +428,7 @@ const BasicSettings = () => {
</Col>
<Col xs={24} sm={12} md={8}>
<Form.Item label={t('systemSetting.dateFormat')} style={{ marginBottom: 12 }}>
<Select size="small" value={dateFormat} onChange={(v) => dispatch(setDateFormat(v))}>
<Select size="small" value={localDateFormat} onChange={(v) => setLocalDateFormat(v)}>
<Select.Option value="YYYY-MM-DD HH:mm:ss">YYYY-MM-DD HH:mm:ss</Select.Option>
<Select.Option value="YYYY-MM-DD HH:mm">YYYY-MM-DD HH:mm</Select.Option>
<Select.Option value="MM/DD/YYYY HH:mm:ss">MM/DD/YYYY HH:mm:ss</Select.Option>
@@ -401,18 +464,19 @@ const BasicSettings = () => {
<div style={{ marginTop: 12 }}>
<Button type="primary" size="small" onClick={handleSave} style={{ width: 100, borderRadius: 6 }}>{t('systemSetting.fixed2SaveFixed2SettingsFixed2')}</Button>
<Button size="small" style={{ marginLeft: 8, borderRadius: 6 }} onClick={() => {
dispatch(resetBasicSettings());
dispatch(setLocale('zh'));
i18n.changeLanguage('zh');
dispatch(setTimezone('Asia/Shanghai'));
dispatch(setUnitSystem('metric'));
dispatch(setDateFormat('YYYY-MM-DD HH:mm:ss'));
if (stationList && stationList.length > 0) {
const sorted = [...stationList].sort((a, b) => (a.id || 0) - (b.id || 0));
const first = sorted[0];
dispatch(saveAllSettings({ defaultSite: first.id }));
dispatch(setCurrentStation(first));
}
// 只重置本地视图,不 dispatch;需点击保存才会生效
form.setFieldsValue({
systemName: '光伏机器人环境感知服务平台',
defaultSite: stationList && stationList.length > 0
? [...stationList].sort((a, b) => (a.id || 0) - (b.id || 0))[0]?.id
: '',
defaultPage: 'dashboard',
refreshRate: '5min',
});
setLocalLocale('zh');
setLocalTimezone('Asia/Shanghai');
setLocalUnitSystem('metric');
setLocalDateFormat('YYYY-MM-DD HH:mm:ss');
}}>{t('systemSetting.fixed2ResumeFixed2DefaultFixed2')}</Button>
</div>
</Form>

View File

@@ -0,0 +1,157 @@
import React, { useCallback, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ChevronUp, ChevronDown, ChevronLeft, ChevronRight, Circle } from 'lucide-react';
export interface GamepadState {
buttons: boolean[];
axes: number[];
connected: boolean;
ts?: number;
}
interface DPadControlProps {
onGamepadUpdate?: (state: GamepadState) => void;
onSpeedChange?: (speed: number) => void;
disabled?: boolean;
}
const DPadControl: React.FC<DPadControlProps> = ({ onGamepadUpdate, onSpeedChange, disabled = false }) => {
const { t } = useTranslation();
const [pressed, setPressed] = useState<Record<string, boolean>>({});
const [speed, setSpeed] = useState(0.5);
const pressTimer = useRef<number | null>(null);
// 用 ref 存储最新状态,避免 setInterval 闭包捕获旧值
const pressedRef = useRef<Record<string, boolean>>({});
const speedRef = useRef(0.5);
// 构建状态:只传输 xy 坐标(axes),buttons 全部为 false
const buildState = useCallback(
(overrides: Record<string, boolean> = {}): GamepadState => {
const btnMap = { ...pressedRef.current, ...overrides };
// 方向键映射到左摇杆 axes[0] X, axes[1] Y
let axisX = 0;
let axisY = 0;
const spd = speedRef.current;
if (btnMap.left) axisX -= spd;
if (btnMap.right) axisX += spd;
if (btnMap.up) axisY -= spd;
if (btnMap.down) axisY += spd;
return {
buttons: new Array(17).fill(false),
axes: [axisX, axisY, 0, 0],
connected: true,
ts: Date.now(),
};
},
[],
);
const emit = useCallback(
(overrides?: Record<string, boolean>) => {
if (disabled) return;
const state = overrides ? buildState(overrides) : buildState();
onGamepadUpdate?.(state);
},
[buildState, disabled, onGamepadUpdate],
);
const startPress = useCallback(
(key: string) => {
if (disabled) return;
pressedRef.current = { ...pressedRef.current, [key]: true };
setPressed(pressedRef.current);
emit({ [key]: true });
// 持续发送(模拟手柄按住)
if (pressTimer.current) window.clearInterval(pressTimer.current);
pressTimer.current = window.setInterval(() => {
emit();
}, 100);
},
[disabled, emit],
);
const endPress = useCallback(
(key: string) => {
if (disabled) return;
if (pressTimer.current) {
window.clearInterval(pressTimer.current);
pressTimer.current = null;
}
pressedRef.current = { ...pressedRef.current, [key]: false };
setPressed(pressedRef.current);
emit({ [key]: false });
},
[disabled, emit],
);
const btnBase =
'flex items-center justify-center w-8 h-8 rounded-xl border transition-all duration-150 select-none active:scale-95';
const btnActive = 'border-cyan-400 bg-cyan-500/30 text-cyan-300 shadow-[0_0_16px_rgba(34,211,238,0.4)]';
const btnIdle = 'border-slate-600 bg-slate-800/60 text-slate-300 hover:border-cyan-500/60 hover:text-cyan-300';
const renderBtn = (key: string, icon: React.ReactNode, ariaLabel: string) => (
<button
aria-label={ariaLabel}
disabled={disabled}
className={`${btnBase} ${pressed[key] ? btnActive : btnIdle} ${disabled ? 'opacity-40 cursor-not-allowed' : 'cursor-pointer'}`}
onMouseDown={() => startPress(key)}
onMouseUp={() => endPress(key)}
onMouseLeave={() => pressed[key] && endPress(key)}
onTouchStart={(e) => { e.preventDefault(); startPress(key); }}
onTouchEnd={(e) => { e.preventDefault(); endPress(key); }}
>
{icon}
</button>
);
return (
<div className="flex flex-col items-center gap-5 w-full">
{/* 十字方向键 */}
<div className="grid grid-cols-3 grid-rows-3 gap-2.5">
<div />
{renderBtn('up', <ChevronUp className="w-6 h-6" />, t('devices.dpad.up'))}
<div />
{renderBtn('left', <ChevronLeft className="w-6 h-6" />, t('devices.dpad.left'))}
{renderBtn('center', <Circle className="w-5 h-5 fill-current" />, t('devices.dpad.center'))}
{renderBtn('right', <ChevronRight className="w-6 h-6" />, t('devices.dpad.right'))}
<div />
{renderBtn('down', <ChevronDown className="w-6 h-6" />, t('devices.dpad.down'))}
<div />
</div>
{/* 速度滑块 */}
<div className="w-full px-3">
<div className="flex items-center justify-between mb-2">
<span className="text-sm text-slate-400 font-medium">{t('devices.dpad.speed')}</span>
<span className="text-sm font-bold text-cyan-300">{Math.round(speed * 100)}%</span>
</div>
<input
type="range"
min={0}
max={1}
step={0.01}
value={speed}
onChange={(e) => {
const v = parseFloat(e.target.value);
setSpeed(v);
speedRef.current = v;
onSpeedChange?.(v);
}}
className="w-full h-2.5 rounded-full appearance-none cursor-pointer bg-slate-700 accent-cyan-400"
style={{
background: `linear-gradient(to right, #22d3ee 0%, #22d3ee ${speed * 100}%, #334155 ${speed * 100}%, #334155 100%)`,
}}
/>
<div className="flex justify-between mt-1.5 text-[11px] text-slate-500">
<span>0%</span>
<span>50%</span>
<span>100%</span>
</div>
</div>
</div>
);
};
export default DPadControl;

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,7 @@ import {
ThunderboltOutlined,
EnvironmentOutlined,
DeleteOutlined,
SafetyOutlined,
} from '@ant-design/icons';
import {
@@ -47,6 +48,8 @@ import {
import { useLocation } from 'react-router-dom';
import XboxController from './XboxController';
import RobotFeatureButtons from './RobotFeatureButtons';
import DPadControl from './DPadControl';
import DroneVideoPlayer from './DroneVideoPlayer';
import CesiumMap from '../Map.jsx';
import { useSelector } from 'react-redux';
@@ -628,6 +631,7 @@ export default function DeviceStatusPage() {
}, [device, uavState, currentDroneData]);
const handleGamepadUpdate = useCallback((state) => {
console.log('Gamepad state updated:', state);
controllerRef.current?.sendGamepad(state);
}, []);
@@ -897,7 +901,11 @@ export default function DeviceStatusPage() {
return (
<div style={{ background: '#f5f7fa', minHeight: '100%', padding: 0 }}>
<div style={{ background: 'linear-gradient(180deg, #f0f4f8 0%, #e8eef5 100%)', minHeight: '100%', padding: 0 }}>
<style>{`
.ds-card { box-shadow: 0 2px 12px rgba(0,0,0,0.06) !important; border: 1px solid #e8edf3 !important; }
.ds-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1) !important; transition: box-shadow 0.3s ease; }
`}</style>
<div style={{ padding: '4px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('devices.deviceStatus')}</Typography.Title>
</div>
@@ -1027,7 +1035,7 @@ export default function DeviceStatusPage() {
{/* 左侧:机场视频 + 地图 */}
<Col xs={24} lg={8}>
{/* 无人机场视频 + 机场状态 */}
<Card
<Card className="ds-card"
title={
<>
<VideoCameraOutlined />
@@ -1052,7 +1060,7 @@ export default function DeviceStatusPage() {
</Card>
{/* 地图 */}
<Card
<Card className="ds-card"
title={
<>
<GlobalOutlined />
@@ -1107,7 +1115,7 @@ export default function DeviceStatusPage() {
{/* 右侧:无人机视频 + 无人机状态 */}
<Col xs={24} lg={16}>
{/* 无人机视频 + 无人机状态 */}
<Card
<Card className="ds-card"
title={
<>
<VideoCameraOutlined />
@@ -1136,7 +1144,7 @@ export default function DeviceStatusPage() {
// 机器人原布局
<Row gutter={[16, 16]} align="stretch">
<Col xs={24} lg={16}>
<Card
<Card className="ds-card"
title={
<>
<VideoCameraOutlined />
@@ -1144,8 +1152,8 @@ export default function DeviceStatusPage() {
</>
}
variant="borderless"
style={{ borderRadius: 12, marginBottom: 8 }}
styles={{ body: { padding: 12, height: 'calc(100vh - 220px)', minHeight: 500 } }}
style={{ borderRadius: 12, marginBottom: 8, height: '100%' }}
styles={{ body: { padding: 12, height: 'calc(100vh - 240px)', minHeight: 380, display: 'flex', flexDirection: 'column' } }}
extra={
<Button
@@ -1157,7 +1165,7 @@ export default function DeviceStatusPage() {
</Button>
}
>
<Space style={{ marginBottom: 8, }} align="start" >
<Space style={{ marginBottom: 8, flexShrink: 0 }} align="start" >
<Button type={mowerView === 'front' ? 'primary' : 'default'} onClick={() => setMowerView('front')}>{t('devices.frontView')}</Button>
<Button type={mowerView === 'back' ? 'primary' : 'default'} onClick={() => setMowerView('back')}>{t('devices.backView')}</Button>
<Button type={mowerView === 'left' ? 'primary' : 'default'} onClick={() => setMowerView('left')}>{t('devices.leftView')}</Button>
@@ -1221,200 +1229,253 @@ export default function DeviceStatusPage() {
</> : null}
</Space>
{/* 视频容器:剩余空间 */}
<div style={{ position: 'relative', flex: 1, minHeight: 0, borderRadius: 8, overflow: 'hidden', background: '#0a0e1a' }}>
{/* 视频层:停止时不渲染 / 未播放时为空,不影响状态面板 */}
{isVideoPlaying && (
mowerView === 'all' ? (
(
<div style={{ width: '100%', height: '100%' }}>
<MowerAllView
serialNumber={device?.serialNumber}
robotVideo={robotVideo}
error={error}
ready={ready}
/>
</div>
)
) : mowerView === 'front' ? (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
{/*<AgrtcRoomRobot CHANNEL={device?.serialNumber || ''} />*/}
<AgrtcRoomRobot CHANNEL={"41-thream03"} />
{/* 视频层:停止时不渲染 / 未播放时为空,不影响状态面板 */}
{isVideoPlaying && (
mowerView === 'all' ? (
(
<div style={{ width: '100%', height: '100%' }}>
<MowerAllView
serialNumber={device?.serialNumber}
robotVideo={robotVideo}
</div>
) : (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
<VideoPlayer
deviceId={device?.serialNumber}
idx={
mowerView === 'back' ? 2
: mowerView === 'left' ? 3
: 4
}
className="w-full h-full object-contain"
video={robotVideo}
error={error}
ready={ready}
/>
</div>
)
) : mowerView === 'front' ? (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
{/*<AgrtcRoomRobot CHANNEL={device?.serialNumber || ''} />*/}
<AgrtcRoomRobot CHANNEL={"41-thream03"} />
)}
{/* 视频未加载 / 停止播放的占位 */}
{!isVideoPlaying && (
<div style={{
width: '100%', height: '100%',
display: 'flex', alignItems: 'center', justifyContent: 'center',
flexDirection: 'column', gap: 12,
color: 'rgba(14, 78, 198, 0.35)',
}}>
<VideoCameraOutlined style={{ fontSize: 56, opacity: 0.6 }} />
<div style={{ fontSize: 15 }}>
{!isVideoPlaying ? t('devices.videoStopped') : t('video.videoLoading')}
</div>
<div style={{ fontSize: 12, opacity: 0.7 }}>
{!isVideoPlaying ? t('devices.clickPlayHint') : ''}
</div>
</div>
) : (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
<VideoPlayer
deviceId={device?.serialNumber}
idx={
mowerView === 'back' ? 2
: mowerView === 'left' ? 3
: 4
}
className="w-full h-full object-contain"
video={robotVideo}
error={error}
ready={ready}
/>
)}
{/* 单视频(非全景)模式状态叠加层:始终渲染,和视频层解耦 */}
{mowerView !== 'all' && (
<div style={{
position: 'absolute',
top: 8,
left: 8,
background: 'rgba(0,0,0,0.7)',
color: '#fff',
padding: '10px 12px',
borderRadius: 8,
fontSize: 11,
zIndex: 10,
backdropFilter: 'blur(4px)',
boxShadow: '0 4px 16px rgba(0,0,0,0.4)',
border: '1px solid rgba(24,144,255,0.2)',
}}>
<div style={{ marginBottom: 6, fontWeight: 600, color: '#1890ff' }}>{t('devices.robotStatus')}</div>
<div style={{ display: 'grid', gridTemplateColumns: 'auto auto', gap: '3px 10px' }}>
<span>{t('devices.rtBattery')}</span>
<span style={{ color: (runningStatus?.battery || 0) < 20 ? '#ff4d4f' : '#52c41a' }}>
{runningStatus?.battery !== undefined ? `${runningStatus?.battery}%` : '-'}
</span>
<span>{t('devices.rtVoltage')}</span>
<span>{runningStatus?.voltage !== undefined ? `${Number(runningStatus?.voltage).toFixed(2)}V` : '-'}</span>
<span>{t('devices.rtLeftMotor')}</span>
<span>{runningStatus?.leftCurrent !== undefined ? `${Number(runningStatus?.leftCurrent).toFixed(2)}A` : '-'}</span>
<span>{t('devices.rtRightMotor')}</span>
<span>{runningStatus?.rightCurrent !== undefined ? `${Number(runningStatus?.rightCurrent).toFixed(2)}A` : '-'}</span>
<span>{t('devices.rtLeftSpeed')}</span>
<span>{runningStatus?.leftMeasureSpeed !== undefined ? `${Number(runningStatus?.leftMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
<span>{t('devices.rtRightSpeed')}</span>
<span>{runningStatus?.rightMeasureSpeed !== undefined ? `${Number(runningStatus?.rightMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
<span>{t('devices.rtLeftTemp')}</span>
<span>{runningStatus?.leftMotorTemp !== undefined ? formatTemperature(Number(runningStatus?.leftMotorTemp), 1).label : '-'}</span>
<span>{t('devices.rtRightTemp')}</span>
<span>{runningStatus?.rightMotorTemp !== undefined ? formatTemperature(Number(runningStatus?.rightMotorTemp), 1).label : '-'}</span>
<span>{t('devices.rtMainTemp')}</span>
<span>{runningStatus?.chipTemp !== undefined ? formatTemperature(Number(runningStatus?.chipTemp), 1).label : '-'}</span>
<span>{t('devices.rtHeadingAngle')}</span>
<span>{runningStatus?.yaw !== undefined ? `${Number(runningStatus?.yaw).toFixed(1)}°` : '-'}</span>
<span>{t('devices.rtPitchAngle')}</span>
<span>{runningStatus?.pitch !== undefined ? `${Number(runningStatus?.pitch).toFixed(1)}°` : '-'}</span>
<span>{t('devices.rtHeadingStatus')}</span>
<span>{runningStatus?.headingStatus !== undefined ? `${runningStatus?.headingStatus == 1 ? t('devices.rtInitialized') : t('devices.uninitialized')}` : '-'}</span>
<span>{t('devices.rtPositioning')}</span>
<span>
{runningStatus?.fix_status ? fixStatusMap[runningStatus?.fix_status] : t('constants.locationUnknown')}
</span>
<span>{t('devices.rtSatellites')}</span>
<span>{t('devices.satelliteCount', { count: runningStatus?.satelliteCnt || 0 })}</span>
<span>{t('devices.rtMode')}</span>
<span>
{runningStatus?.controlMode == 1 ? t('devices.localMode') :
runningStatus?.controlMode == 3 ? t('devices.remoteMode') : t('constants.locationUnknown')}
</span>
</div>
</div>
)
)}
{/* 视频未加载 / 停止播放的占位 */}
{!isVideoPlaying && (
<div style={{
width: '100%', height: '100%',
display: 'flex', alignItems: 'center', justifyContent: 'center',
flexDirection: 'column', gap: 12,
color: 'rgba(14, 78, 198, 0.35)',
}}>
<VideoCameraOutlined style={{ fontSize: 56, opacity: 0.6 }} />
<div style={{ fontSize: 15 }}>
{!isVideoPlaying ? t('devices.videoStopped') : t('video.videoLoading')}
</div>
<div style={{ fontSize: 12, opacity: 0.7 }}>
{!isVideoPlaying ? t('devices.clickPlayHint') : ''}
</div>
</div>
)}
{/* 单视频(非全景)模式状态叠加层:始终渲染,和视频层解耦 */}
{mowerView !== 'all' && (
<div style={{
position: 'absolute',
top: 106,
left: 20,
background: 'rgba(0,0,0,0.7)',
color: '#fff',
padding: '10px 12px',
borderRadius: 8,
fontSize: 11,
zIndex: 10,
backdropFilter: 'blur(4px)',
boxShadow: '0 4px 16px rgba(0,0,0,0.4)',
border: '1px solid rgba(24,144,255,0.2)',
}}>
<div style={{ marginBottom: 6, fontWeight: 600, color: '#1890ff' }}>{t('devices.robotStatus')}</div>
<div style={{ display: 'grid', gridTemplateColumns: 'auto auto', gap: '3px 10px' }}>
<span>{t('devices.rtBattery')}</span>
<span style={{ color: (runningStatus?.battery || 0) < 20 ? '#ff4d4f' : '#52c41a' }}>
{runningStatus?.battery !== undefined ? `${runningStatus?.battery}%` : '-'}
</span>
<span>{t('devices.rtVoltage')}</span>
<span>{runningStatus?.voltage !== undefined ? `${Number(runningStatus?.voltage).toFixed(2)}V` : '-'}</span>
<span>{t('devices.rtLeftMotor')}</span>
<span>{runningStatus?.leftCurrent !== undefined ? `${Number(runningStatus?.leftCurrent).toFixed(2)}A` : '-'}</span>
<span>{t('devices.rtRightMotor')}</span>
<span>{runningStatus?.rightCurrent !== undefined ? `${Number(runningStatus?.rightCurrent).toFixed(2)}A` : '-'}</span>
<span>{t('devices.rtLeftSpeed')}</span>
<span>{runningStatus?.leftMeasureSpeed !== undefined ? `${Number(runningStatus?.leftMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
<span>{t('devices.rtRightSpeed')}</span>
<span>{runningStatus?.rightMeasureSpeed !== undefined ? `${Number(runningStatus?.rightMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
<span>{t('devices.rtLeftTemp')}</span>
<span>{runningStatus?.leftMotorTemp !== undefined ? formatTemperature(Number(runningStatus?.leftMotorTemp), 1).label : '-'}</span>
<span>{t('devices.rtRightTemp')}</span>
<span>{runningStatus?.rightMotorTemp !== undefined ? formatTemperature(Number(runningStatus?.rightMotorTemp), 1).label : '-'}</span>
<span>{t('devices.rtMainTemp')}</span>
<span>{runningStatus?.chipTemp !== undefined ? formatTemperature(Number(runningStatus?.chipTemp), 1).label : '-'}</span>
<span>{t('devices.rtHeadingAngle')}</span>
<span>{runningStatus?.yaw !== undefined ? `${Number(runningStatus?.yaw).toFixed(1)}°` : '-'}</span>
<span>{t('devices.rtPitchAngle')}</span>
<span>{runningStatus?.pitch !== undefined ? `${Number(runningStatus?.pitch).toFixed(1)}°` : '-'}</span>
<span>{t('devices.rtHeadingStatus')}</span>
<span>{runningStatus?.headingStatus !== undefined ? `${runningStatus?.headingStatus == 1 ? t('devices.rtInitialized') : t('devices.uninitialized')}` : '-'}</span>
<span>{t('devices.rtPositioning')}</span>
<span>
{runningStatus?.fix_status ? fixStatusMap[runningStatus?.fix_status] : t('constants.locationUnknown')}
</span>
<span>{t('devices.rtSatellites')}</span>
<span>{t('devices.satelliteCount', { count: runningStatus?.satelliteCnt || 0 })}</span>
<span>{t('devices.rtMode')}</span>
<span>
{runningStatus?.controlMode == 1 ? t('devices.localMode') :
runningStatus?.controlMode == 3 ? t('devices.remoteMode') : t('constants.locationUnknown')}
</span>
</div>
</div>
)
}
}
</div>
</Card>
</Col>
{/* 右边 - 占1格,上部地图,下部远程控制 */}
<Col xs={24} lg={8} style={{ display: 'flex', flexDirection: 'column', }}>
{/* 地图 */}
<Card
title={
<>
<GlobalOutlined />
{t('devices.situationMap')}
</>
}
extra={
<Space size={4}>
<Button
size="small"
type="primary"
icon={<DeleteOutlined />}
onClick={() => setClearNavLine((v) => v + 1)}
>
{t('devices.clearRealtimeTrack')}
</Button>
<Button
size="small"
danger
icon={<DeleteOutlined />}
onClick={() => {
setPoints([]);
setClearPlanLine((v) => v + 1);
}}
>
{t('devices.clearPlanRoute')}
</Button>
</Space>
}
variant="borderless"
style={{ borderRadius: 12, marginBottom: 8, flex: 1, minHeight: 280 }}
styles={{ body: { padding: 12, height: 'calc((100vh - 260px) / 2)', minHeight: 280 } }}
>
<CesiumMap
ref={mapRef}
devices={[mapDevices]}
points={points}
markedPoints={markedPoints}
realtimePosition={realtimePosition}
realtimeType={realtimeType}
drawRealTime={true}
finishPoint={arrivedPoint}
ifClearNavLine={clearNavLine}
ifClearPlanLine={clearPlanLine}
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
/>
</Card>
{/* 右边 - 地图 + 控制手柄方向盘 + 功能按钮 三个面板,高度与左侧视频对齐 */}
<Col xs={24} lg={8}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, height: 'calc(100vh - 240px)', minHeight: 380 }}>
{/* 地图 */}
<Card
title={
<>
<GlobalOutlined />
{t('devices.situationMap')}
</>
}
extra={
<Space size={4}>
<Button
size="small"
type="primary"
icon={<DeleteOutlined />}
onClick={() => setClearNavLine((v) => v + 1)}
>
{t('devices.clearRealtimeTrack')}
</Button>
<Button
size="small"
danger
icon={<DeleteOutlined />}
onClick={() => {
setPoints([]);
setClearPlanLine((v) => v + 1);
}}
>
{t('devices.clearPlanRoute')}
</Button>
</Space>
}
variant="borderless"
className="ds-card"
style={{ borderRadius: 12, flex: 1, minHeight: 0 }}
styles={{ body: { padding: 12, height: 'calc(100% - 57px)' } }}
>
<CesiumMap
ref={mapRef}
devices={[mapDevices]}
points={points}
markedPoints={markedPoints}
realtimePosition={realtimePosition}
realtimeType={realtimeType}
drawRealTime={true}
finishPoint={arrivedPoint}
ifClearNavLine={clearNavLine}
ifClearPlanLine={clearPlanLine}
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
/>
</Card>
{/* 远程控制面板 */}
<Card
title={
<>
<ControlOutlined />
{t('devices.remoteControl')}
</>
}
variant="borderless"
style={{ borderRadius: 12, background: '#0f172a', flex: 1, minHeight: 280, }}
styles={{
header: { color: '#fff', },
body: { display: 'flex', justifyContent: 'center', alignItems: 'center', height: 'calc(100% - 57px)' },
}}
>
<XboxController
onGamepadUpdate={handleGamepadUpdate}
handleControlModal={handleControlModal}
isControlled={isControlled}
hasControlRight={hasControlRight}
isConnecting={connecting}
/>
</Card>
{/* 手柄 + 方向盘 一个面板 */}
<Card
title={
<>
<ControlOutlined />
{t('devices.remoteControl')}
</>
}
variant="borderless"
className="ds-card"
style={{ borderRadius: 12, background: '#0f172a', flex: 1, minHeight: 0 }}
styles={{
header: { color: '#fff' },
body: { padding: 12, display: 'flex', flexDirection: 'row', gap: 12, height: 'calc(100% - 57px)', overflow: 'hidden' },
}}
>
{/* Xbox 手柄 - 左侧,缩小显示 */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', flex: '0 0 auto', transform: 'scale(0.82)', transformOrigin: 'left center' }}>
<XboxController
onGamepadUpdate={handleGamepadUpdate}
handleControlModal={handleControlModal}
isControlled={isControlled}
hasControlRight={hasControlRight}
isConnecting={connecting}
/>
</div>
{/* 方向盘 + 滑块 - 右侧,居中不挤压 */}
<div style={{ flex: '1 1 auto', minWidth: 0, display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }}>
{/*<p style={{ color: '#94a3b8', fontSize: 12, fontWeight: 600, marginBottom: 12, textAlign: 'center' }}>
{t('devices.dpad.title')}
</p>*/}
<DPadControl
onGamepadUpdate={(state) => {
handleGamepadUpdate(state);
//console.log('[DeviceStatusPage] DPad state:', {
// buttons: state.buttons.map((b, i) => ({ idx: i, pressed: b })).filter(b => b.pressed),
// axes: state.axes,
// ts: state.ts,
//});
}}
onSpeedChange={(speed) => {
//console.log(`[DeviceStatusPage] Speed slider: ${Math.round(speed * 100)}%`);
}}
//disabled={!isControlled}
/>
</div>
</Card>
{/* 功能按钮 单独一个面板 */}
<Card
title={
<>
<SafetyOutlined style={{ color: '#fa541c' }} />
{t('devices.features.title')}
</>
}
variant="borderless"
style={{ borderRadius: 12, flex: '0 0 auto' }}
styles={{
header: { color: '#fff' },
body: { padding: 12 },
}}
>
<RobotFeatureButtons
activeFeatures={['response', 'obstacleAvoidance', 'lowBatteryReturn', 'tiltProtection']}
onToggle={(feature, enabled) => {
console.log(`[DeviceStatusPage] Feature toggled: ${feature} = ${enabled}`);
}}
/>
</Card>
</div>
</Col>
</Row>
)}

View File

@@ -0,0 +1,90 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
ShieldAlert,
Zap,
Siren,
BatteryWarning,
MoveVertical,
} from 'lucide-react';
export type RobotFeature =
| 'emergencyStop'
| 'response'
| 'obstacleAvoidance'
| 'lowBatteryReturn'
| 'tiltProtection';
export interface FeatureConfig {
key: RobotFeature;
icon: React.ReactNode;
activeColor: string;
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' },
];
interface RobotFeatureButtonsProps {
activeFeatures?: RobotFeature[];
onToggle?: (feature: RobotFeature, enabled: boolean) => void;
className?: string;
}
const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
activeFeatures = [],
onToggle,
className = '',
}) => {
const { t } = useTranslation();
const [active, setActive] = useState<Set<RobotFeature>>(new Set(activeFeatures));
const handleClick = (feature: RobotFeature) => {
const next = !active.has(feature);
const nextSet = new Set(active);
if (next) nextSet.add(feature);
else nextSet.delete(feature);
setActive(nextSet);
onToggle?.(feature, next);
};
return (
<div className={`flex flex-wrap gap-2 ${className}`}>
{FEATURES.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'
}`}
style={{
color: isActive ? f.activeColor : f.inactiveColor,
backgroundColor: isActive ? `${f.activeColor}1a` : 'transparent',
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">
{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>
);
})}
</div>
);
};
export default RobotFeatureButtons;

View File

@@ -600,6 +600,8 @@
gnssQuality: 'Gnss Quality',
gpsMode: 'Gps Mode',
gpsModeDesc: 'Gps Mode Desc',
devicecontreol: 'Device Control',
gpsPlanning: 'Gps Planning',
gpsSingle: 'Gps Single',
gpsTaskIssued: 'Gps Task Issued',
@@ -629,6 +631,23 @@
landingDockSnLabel: 'Landing Dock Sn Label',
leftView: 'Left View',
leftWheelDrive: 'Left Wheel Drive',
features: {
title: 'Feature Control',
emergencyStop: 'Emergency Stop',
response: 'Response',
obstacleAvoidance: 'Obstacle Avoidance',
lowBatteryReturn: 'Low Battery Return',
tiltProtection: 'Tilt Protection',
},
dpad: {
title: 'Direction Control',
up: 'Forward',
down: 'Backward',
left: 'Turn Left',
right: 'Turn Right',
center: 'Confirm',
speed: 'Speed',
},
legendTitle: 'Legend Title',
levelHigh: 'Level High',
levelLow: 'Level Low',
@@ -666,6 +685,10 @@
mowRobotGr: 'Mow Robot Gr',
mowRoute: 'Mow Route',
mowingRobot: 'Mowing Robot',
robotStation: 'Robot Station',
inspectionRobot: "Inspection Robot",
cleaningRobot: "Cleaning Robot",
networkErrorRetry: 'Network Error Retry',
nightFlightLimit: 'Night Flight Limit',
noData: 'no Data',
@@ -818,22 +841,22 @@
routeLoadedWithName: 'Route Loaded with Name',
routeNoPathPoints: 'Route No Path Points',
routeSavedLocal: 'Route Saved Local',
rtBattery: 'rt Battery',
rtBattery: 'Battery',
rtHeadingAngle: 'rt Heading Angle',
rtHeadingStatus: 'rt Heading Status',
rtInitialized: 'rt Initialized',
rtLeftMotor: 'rt Left Motor',
rtLeftSpeed: 'rt Left Speed',
rtLeftTemp: 'rt Left Temp',
rtMainTemp: 'rt Main Temp',
rtLeftMotor: 'Left Motor',
rtLeftSpeed: 'Left Wheel Speed',
rtLeftTemp: 'Left Motor Temp',
rtMainTemp: 'Main Motor Temp',
rtMode: 'rt Mode',
rtPitchAngle: 'rt Pitch Angle',
rtPositioning: 'rt Positioning',
rtRightMotor: 'rt Right Motor',
rtRightSpeed: 'rt Right Speed',
rtRightTemp: 'rt Right Temp',
rtRightMotor: 'Right Motor',
rtRightSpeed: 'Right Wheel Speed',
rtRightTemp: 'Right Motor Temp',
rtSatellites: 'rt Satellites',
rtVoltage: 'rt Voltage',
rtVoltage: 'Voltage',
rthMode: 'Rth Mode',
rthOptimal: 'Rth Optimal',
rthPreset: 'Rth Preset',

View File

@@ -265,6 +265,7 @@ const zh = {
deviceManagement: '设备管理',
distributable: '可调度',
deviceOverview: '设备总览',
devicecontreol: '设备控制',
deviceStatus: '设备状态',
waylineTask: '航线任务',
robotTask: '机器人任务',
@@ -653,6 +654,23 @@ const zh = {
landingDockSnLabel: '降落停靠序列号标签',
leftView: '左视角',
leftWheelDrive: '左轮驱动',
features: {
title: '功能控制',
emergencyStop: '急停',
response: '响应',
obstacleAvoidance: '避障',
lowBatteryReturn: '低电量自动返航',
tiltProtection: '倾斜保护',
},
dpad: {
title: '方向控制',
up: '前进',
down: '后退',
left: '左转',
right: '右转',
center: '确认',
speed: '速度',
},
legendTitle: '图例标题',
levelHigh: '级别高',
levelLow: '级别低',
@@ -690,6 +708,10 @@ const zh = {
mowRobotGr: '除草机器人电网',
mowRoute: '除草路线',
mowingRobot: '除草机器人',
inspectionRobot: "巡检机器人",
robotStation: '机器人机场',
cleaningRobot: "清洗机器人",
networkErrorRetry: '网络错误重试',
nightFlightLimit: '夜间飞行限制',
noData: '无数据',

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import {
Form,
@@ -17,7 +17,8 @@ import { motion } from 'motion/react';
import bgcImg from '../assets/bgc2.png';
import logincard from '../assets/logincard.png';
import { userLogin } from '../store/userSlice';
import { useAppDispatch } from '../store';
import { useSelector } from 'react-redux';
import { useAppDispatch, RootState } from '../store';
import Cookies from 'js-cookie';
import { useTranslation } from 'react-i18next';
@@ -31,6 +32,7 @@ export default function Login() {
const { message } = App.useApp();
// 登录 loading 状态
const [loading, setLoading] = useState(false);
const { systemName } = useSelector((state: RootState) => state.basicSettings);
// 账号密码登录
const onFinish = async (values: any) => {
@@ -89,7 +91,7 @@ export default function Login() {
<div className="md:w-1/2 bg-white p-10 md:p-16 flex flex-col justify-center relative z-10">
<motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.2 }}>
<Title level={2} style={{ marginBottom: 40, color: '#111', fontWeight: 700 }}>
{t('login.systemName')}
{systemName || t('login.systemName')}
</Title>
<Form name="login" layout="vertical" onFinish={onFinish} autoComplete="off" size="large">

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect, useMemo, useRef, useCallback } from 'react';
import React, { useState, useEffect, useMemo, useRef, useCallback } from 'react';
import {
Card, Row, Col, Table, Select, Input, Tag,
Typography, Button, Space, Avatar, Pagination,
@@ -17,7 +17,7 @@ import {
PauseCircleOutlined, StopOutlined, InfoCircleOutlined,
ClockCircleOutlined, EnvironmentOutlined, PlusOutlined,
SettingOutlined, ExclamationCircleOutlined, FileTextOutlined,
DeleteOutlined, AimOutlined, SendOutlined, LockOutlined,
DeleteOutlined, AimOutlined, SendOutlined, LockOutlined, SafetyOutlined,
NodeIndexOutlined, SaveOutlined, MaximizeOutlined, ReloadOutlined
} from '@ant-design/icons';
import { Line, Bar, Pie } from '@ant-design/charts';
@@ -28,6 +28,7 @@ import { useSelector } from 'react-redux';
import dayjs from 'dayjs';
import envConfig from '../../env';
import { useMqtt } from '../hooks/useMqtt';
import RobotFeatureButtons from '../components/devices/RobotFeatureButtons';
import DeviceController from '../components/devices/deviceController';
import {
@@ -369,19 +370,19 @@ const RealTimeMonitorPage = () => {
const lat = rt.lat;
//if (!isFinite(lon) || !isFinite(lat) || (lon === 0 && lat === 0)) return d;
return {
...d,
longitude: lon,
latitude: lat,
heading: rt.yaw,
batteryLevel: rt.battery,
feStatus: rt.status,
taskId: rt.taskId,
updateTime: rt.updateTime || d.updateTime,
// 同步写入 locationMessage / lastRunningStatus,确保 Map.jsx 设备渲染 useEffect 能读到实时坐标
locationMessage: { longitude: lon, latitude: lat, heading: rt.yaw, batteryLevel: rt.battery },
lastRunningStatus: { longitude: lon, latitude: lat, heading: rt.yaw, batteryLevel: rt.battery },
raw: { ...(d.raw || d), heading: rt.yaw, batteryLevel: rt.b, longitude: lon, latitude: lat },
};
...d,
longitude: lon,
latitude: lat,
heading: rt.yaw,
batteryLevel: rt.battery,
feStatus: rt.status,
taskId: rt.taskId,
updateTime: rt.updateTime || d.updateTime,
// 同步写入 locationMessage / lastRunningStatus,确保 Map.jsx 设备渲染 useEffect 能读到实时坐标
locationMessage: { longitude: lon, latitude: lat, heading: rt.yaw, batteryLevel: rt.battery },
lastRunningStatus: { longitude: lon, latitude: lat, heading: rt.yaw, batteryLevel: rt.battery },
raw: { ...(d.raw || d), heading: rt.yaw, batteryLevel: rt.b, longitude: lon, latitude: lat },
};
});
}, [devices, realtimeMap]);
@@ -1383,6 +1384,19 @@ const RealTimeMonitorPage = () => {
)}
</Card>
<Card size="small" style={{ borderRadius: 10, marginBottom: 0 }}>
<p style={{ fontWeight: 600, fontSize: 13, marginBottom: 8 }}>
<SafetyOutlined style={{ color: '#fa541c', marginRight: 6 }} />
{t('devices.features.title')}
</p>
<RobotFeatureButtons
activeFeatures={['response', 'obstacleAvoidance', 'lowBatteryReturn', 'tiltProtection']}
onToggle={(feature, enabled) => {
console.log('[RTMonitor Feature]', feature, enabled);
}}
/>
</Card>
{/* ============== 【中部】预设路径列表 ============== */}
<Card
size="small"

View File

@@ -1,4 +1,4 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
export interface BasicSettingsState {
systemName: string;
@@ -19,6 +19,7 @@ export interface BasicSettingsState {
nightModeStart: string;
nightModeEnd: string;
enableNightMode: boolean;
globalParams: any[];
}
const STORAGE_KEY = 'basicSettings';
@@ -42,6 +43,7 @@ const defaultState: BasicSettingsState = {
nightModeStart: '23:00',
nightModeEnd: '07:00',
enableNightMode: false,
globalParams: [],
};
const loadFromStorage = (): BasicSettingsState => {
@@ -91,6 +93,10 @@ const basicSettingsSlice = createSlice({
Object.assign(state, action.payload);
persist(state);
},
setGlobalParams: (state, action: PayloadAction<any[]>) => {
state.globalParams = action.payload;
persist(state);
},
saveAllSettings: (state, action: PayloadAction<Partial<BasicSettingsState>>) => {
Object.assign(state, action.payload);
persist(state);
@@ -108,6 +114,7 @@ export const {
setDefaultPage,
setRefreshRate,
setSettingField,
setGlobalParams,
saveAllSettings,
resetBasicSettings,
} = basicSettingsSlice.actions;