Compare commits
9 Commits
master
...
a3b2f14620
| Author | SHA1 | Date | |
|---|---|---|---|
| a3b2f14620 | |||
| d6b5c9ad44 | |||
| 36d1517eef | |||
| 30ce706280 | |||
| f22c2bedfe | |||
| be8576b887 | |||
| 5073f64240 | |||
| e363fb2799 | |||
| 81a9ed3dd1 |
10
env.js
10
env.js
@@ -9,17 +9,19 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
|
|||||||
// 环境配置映射
|
// 环境配置映射
|
||||||
const envConfig = {
|
const envConfig = {
|
||||||
[ENV.DEV]: {
|
[ENV.DEV]: {
|
||||||
//baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
|
baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
|
||||||
////baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
////baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||||
//WS_URL: 'ws://192.168.2.59:9002/ws/',
|
//WS_URL: 'ws://192.168.2.59:9002/ws/',
|
||||||
//mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
//mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
||||||
//geoserver_url: "http://192.168.2.59:7000/geoserver"
|
//geoserver_url: "http://192.168.2.59:7000/geoserver"
|
||||||
|
|
||||||
baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
|
//baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
|
||||||
|
//baseURL: 'http://192.168.2.62:8081',//http://192.168.2.56:8081
|
||||||
//baseURL: 'https://serviceri.satabot.com',
|
//baseURL: 'https://serviceri.satabot.com',
|
||||||
WS_URL: 'ws://1.95.137.212:9002/ws/',
|
WS_URL: 'ws://1.95.137.212:9002/ws/',
|
||||||
|
//WS_URL: 'ws://192.168.2.62:9002/ws/',
|
||||||
mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
||||||
geoserver_url: "http://1.95.137.212:59018/geoserver"
|
geoserver_url: "http://1.95.137.212:7900/geoserver"
|
||||||
|
|
||||||
//baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
//baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||||
////baseURL: 'https://serviceri.satabot.com',
|
////baseURL: 'https://serviceri.satabot.com',
|
||||||
@@ -40,7 +42,7 @@ const envConfig = {
|
|||||||
//baseURL: 'https://serviceri.satabot.com',
|
//baseURL: 'https://serviceri.satabot.com',
|
||||||
WS_URL: 'ws://1.95.137.212:9002/ws/',
|
WS_URL: 'ws://1.95.137.212:9002/ws/',
|
||||||
mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
||||||
geoserver_url: "http://1.95.137.212:59018/geoserver"
|
geoserver_url: "http://1.95.137.212:7900/geoserver"
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -61,3 +61,4 @@ export default function App() {
|
|||||||
</I18nextProvider>
|
</I18nextProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -455,6 +455,15 @@ export function hasPermission(params) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///iot/workRecord/getTaskPath?taskId=74 get 获取算法回传的路径
|
||||||
|
export function getTaskPath(params) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/workRecord/getTaskPath',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ export default function AppLayout() {
|
|||||||
src="https://images.unsplash.com/photo-1509391366360-2e959784a276?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80"
|
src="https://images.unsplash.com/photo-1509391366360-2e959784a276?ixlib=rb-1.2.1&auto=format&fit=crop&w=1200&q=80"
|
||||||
/>
|
/>
|
||||||
<div style={{ fontSize: 11, color: '#666', lineHeight: 1.8 }}>
|
<div style={{ fontSize: 11, color: '#666', lineHeight: 1.8 }}>
|
||||||
|
{/*<div>{JSON.stringify(currentStation, null, 2)}</div>*/}
|
||||||
<div>{t('layout.stationAddress')}:{currentStation.address || t('layout.defaultStationAddress')}</div>
|
<div>{t('layout.stationAddress')}:{currentStation.address || t('layout.defaultStationAddress')}</div>
|
||||||
<div>{t('layout.stationType')}:{currentStation.type || t('layout.groundStation')}</div>
|
<div>{t('layout.stationType')}:{currentStation.type || t('layout.groundStation')}</div>
|
||||||
<div style={{ marginTop: 4, display: 'flex', alignItems: 'center', color: '#41ad0a' }}>
|
<div style={{ marginTop: 4, display: 'flex', alignItems: 'center', color: '#41ad0a' }}>
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const planLineRef = useRef(null); // points 规划航线
|
const planLineRef = useRef(null); // points 规划航线
|
||||||
const navLineRef = useRef(null); // 完成点实时轨迹
|
const navLineRef = useRef(null); // 完成点实时轨迹
|
||||||
const markedPointsRef = useRef([]); // 标记点实体
|
const markedPointsRef = useRef([]); // 标记点实体
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
|
||||||
const realtimeEntityRef = useRef(null);
|
const realtimeEntityRef = useRef(null);
|
||||||
const realtimeLineRef = useRef(null);
|
const realtimeLineRef = useRef(null);
|
||||||
@@ -343,8 +345,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
}
|
}
|
||||||
}, [markedPoints]);
|
}, [markedPoints]);
|
||||||
|
|
||||||
function showRobotTooltip(tooltip, robot, position) {
|
function showRobotTooltip(tooltip, robot, position, t) {
|
||||||
const { t } = useTranslation();
|
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
1: { text: t('common.working'), color: "#10b981" },
|
1: { text: t('common.working'), color: "#10b981" },
|
||||||
2: { text: t('devices.idle'), color: "#f59e0b" },
|
2: { text: t('devices.idle'), color: "#f59e0b" },
|
||||||
@@ -498,6 +499,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
if (index == 2 && from == "other") {
|
if (index == 2 && from == "other") {
|
||||||
flyToLayer(layerIdentifier, baseUrl, 100);
|
flyToLayer(layerIdentifier, baseUrl, 100);
|
||||||
}
|
}
|
||||||
|
//if (index == 0 && from == "other") {
|
||||||
|
// flyToLayer(layerIdentifier, baseUrl, 100);
|
||||||
|
//}
|
||||||
//getLayerBoundsAndFit(wmsUrl, layerName);
|
//getLayerBoundsAndFit(wmsUrl, layerName);
|
||||||
|
|
||||||
if (baseUrl.includes('/gwc/service/wms')) {
|
if (baseUrl.includes('/gwc/service/wms')) {
|
||||||
@@ -1397,7 +1401,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
const picked = viewer.scene.pick(movement.endPosition);
|
const picked = viewer.scene.pick(movement.endPosition);
|
||||||
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
|
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
|
||||||
const robot = picked.id.properties.robot.getValue();
|
const robot = picked.id.properties.robot.getValue();
|
||||||
showRobotTooltip(tooltipRef.current, robot, movement.endPosition);
|
showRobotTooltip(tooltipRef.current, robot, movement.endPosition, t);
|
||||||
} else {
|
} else {
|
||||||
tooltipRef.current.style.display = "none";
|
tooltipRef.current.style.display = "none";
|
||||||
}
|
}
|
||||||
@@ -1599,7 +1603,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
|
|
||||||
// 如果有航向角,设置旋转
|
// 如果有航向角,设置旋转
|
||||||
let rotation = 0;
|
let rotation = 0;
|
||||||
console.log('realtimePosition.heading:', realtimePosition.heading);
|
|
||||||
|
|
||||||
|
|
||||||
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ export default function SmartDeviceManagement({
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t('systemSetting.leader')} name="userId" rules={[{ required: true, message: t('systemSetting.fixed2PleaseSelectFixed2LeaderFixed2') }]}>
|
<Form.Item label={t('systemSetting.leader')} name="userId" >
|
||||||
<Select
|
<Select
|
||||||
placeholder={t('systemSetting.leaderFixed2')}
|
placeholder={t('systemSetting.leaderFixed2')}
|
||||||
allowClear
|
allowClear
|
||||||
|
|||||||
@@ -61,44 +61,50 @@ class WebSocketManager {
|
|||||||
// ==================== 连接管理 ====================
|
// ==================== 连接管理 ====================
|
||||||
|
|
||||||
public connect(serialNumber: string, wsUrl: string): void {
|
public connect(serialNumber: string, wsUrl: string): void {
|
||||||
console.log("创建开始");//ws://192.168.2.56:9002/ws/
|
console.log("创建开始");
|
||||||
// 清除之前的重连计时器
|
|
||||||
|
// 清除重连计时器
|
||||||
if (this.reconnectTimer) {
|
if (this.reconnectTimer) {
|
||||||
clearTimeout(this.reconnectTimer);
|
clearTimeout(this.reconnectTimer);
|
||||||
this.reconnectTimer = null;
|
this.reconnectTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serialNumber == null || serialNumber.trim() === "") {
|
||||||
|
console.log("serialNumber 是空/空白,停止执行");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 如果序列号相同且已连接,跳过
|
// 如果序列号相同且已连接,跳过
|
||||||
if (this.ws && this.currentSerialRef === serialNumber && this.status === 'connected') {
|
if (this.ws && this.currentSerialRef === serialNumber && this.status === 'connected') {
|
||||||
console.log('WebSocket already connected for this device');
|
console.log('WebSocket already connected for this device');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果序列号不同,先关闭旧连接
|
// ========== 重点修复:关闭旧连接,并且清空旧ws的事件监听,防止旧消息回调执行 ==========
|
||||||
if (this.ws && this.currentSerialRef !== serialNumber) {
|
if (this.ws) {
|
||||||
|
// 解绑所有事件,阻止旧ws继续触发onmessage/onclose
|
||||||
|
this.ws.onopen = null;
|
||||||
|
this.ws.onmessage = null;
|
||||||
|
this.ws.onerror = null;
|
||||||
|
this.ws.onclose = null;
|
||||||
this.close();
|
this.close();
|
||||||
|
this.ws = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentSerialRef = serialNumber;
|
this.currentSerialRef = serialNumber;
|
||||||
this.setStatus('connecting');
|
this.setStatus('connecting');
|
||||||
this.isManualCloseRef = false;
|
this.isManualCloseRef = false;
|
||||||
|
// 提前赋值,不要等到new WebSocket之后
|
||||||
|
this.wsSerialRef = serialNumber;
|
||||||
|
|
||||||
console.log('Connecting WebSocket for', serialNumber);
|
console.log('Connecting WebSocket for', serialNumber);
|
||||||
|
|
||||||
|
|
||||||
if (serialNumber == null || serialNumber.trim() === "") {
|
|
||||||
console.log("serialNumber 是空/空白,停止执行");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ws = new WebSocket(wsUrl);
|
this.ws = new WebSocket(wsUrl);
|
||||||
this.wsSerialRef = serialNumber;
|
|
||||||
|
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
console.log('WebSocket Connected');
|
console.log('WebSocket Connected');
|
||||||
this.setStatus('connected');
|
this.setStatus('connected');
|
||||||
|
|
||||||
|
|
||||||
const dataStr = localStorage.getItem('userInfo');
|
const dataStr = localStorage.getItem('userInfo');
|
||||||
if (!dataStr) {
|
if (!dataStr) {
|
||||||
console.error('用户信息未找到,无法发送认证包');
|
console.error('用户信息未找到,无法发送认证包');
|
||||||
@@ -109,18 +115,21 @@ class WebSocketManager {
|
|||||||
|
|
||||||
console.log('WebSocket%', token);
|
console.log('WebSocket%', token);
|
||||||
console.log('WebSocket%', parse);
|
console.log('WebSocket%', parse);
|
||||||
console.log("开始发送认证包");//ws://192.168.2.56:9002/ws/
|
console.log("开始发送认证包");
|
||||||
// 发送 AUTH 认证消息
|
|
||||||
this.send({
|
this.send({
|
||||||
type: 'AUTH',
|
type: 'AUTH',
|
||||||
token: token,
|
token: token,
|
||||||
userName: parse.username,
|
userName: parse.username,
|
||||||
deviceId: serialNumber,
|
deviceId: serialNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.ws.onmessage = (event) => {
|
this.ws.onmessage = (event) => {
|
||||||
|
// 【防御二次校验】只有当前活跃serial才处理消息,旧连接残留消息直接丢弃
|
||||||
|
if (this.wsSerialRef !== this.currentSerialRef) {
|
||||||
|
console.log('丢弃过期ws消息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
this.handleMessage(data);
|
this.handleMessage(data);
|
||||||
@@ -137,7 +146,7 @@ class WebSocketManager {
|
|||||||
const { code, reason, wasClean } = event;
|
const { code, reason, wasClean } = event;
|
||||||
console.log('[WebSocket closed]', 'code =', code, 'reason =', reason || '(no reason)', 'wasClean =', wasClean);
|
console.log('[WebSocket closed]', 'code =', code, 'reason =', reason || '(no reason)', 'wasClean =', wasClean);
|
||||||
|
|
||||||
// 如果不是当前设备的 ws,忽略
|
// 不是当前设备直接忽略
|
||||||
if (this.wsSerialRef !== this.currentSerialRef) {
|
if (this.wsSerialRef !== this.currentSerialRef) {
|
||||||
console.log('🟡 ignore old ws close');
|
console.log('🟡 ignore old ws close');
|
||||||
return;
|
return;
|
||||||
@@ -146,15 +155,13 @@ class WebSocketManager {
|
|||||||
this.ws = null;
|
this.ws = null;
|
||||||
this.setStatus('disconnected');
|
this.setStatus('disconnected');
|
||||||
|
|
||||||
// 主动关闭不重连
|
|
||||||
if (this.isManualCloseRef || !this.currentSerialRef) {
|
if (this.isManualCloseRef || !this.currentSerialRef) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5 秒后自动重连
|
|
||||||
this.reconnectTimer = setTimeout(() => {
|
this.reconnectTimer = setTimeout(() => {
|
||||||
if (this.currentSerialRef === this.wsSerialRef) {
|
if (this.currentSerialRef === this.wsSerialRef) {
|
||||||
this.connect(this.currentSerialRef, wsUrl);
|
this.connect(this.currentSerialRef!, wsUrl);
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
};
|
};
|
||||||
@@ -164,21 +171,17 @@ class WebSocketManager {
|
|||||||
|
|
||||||
public close(): void {
|
public close(): void {
|
||||||
this.isManualCloseRef = true;
|
this.isManualCloseRef = true;
|
||||||
|
|
||||||
if (this.reconnectTimer) {
|
if (this.reconnectTimer) {
|
||||||
clearTimeout(this.reconnectTimer);
|
clearTimeout(this.reconnectTimer);
|
||||||
this.reconnectTimer = null;
|
this.reconnectTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
console.log('Closing WebSocket');
|
try {
|
||||||
this.ws.close();
|
this.ws.close(1000, 'manual close');
|
||||||
this.ws = null;
|
} catch (e) {
|
||||||
|
console.warn('ws close exception', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentSerialRef = null;
|
|
||||||
this.wsSerialRef = null;
|
|
||||||
this.setStatus('disconnected');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 消息发送 ====================
|
// ==================== 消息发送 ====================
|
||||||
|
|||||||
@@ -459,8 +459,17 @@ const RobotControlCenter = ({ setView }) => {
|
|||||||
}
|
}
|
||||||
const getControl = (serialnum) => {
|
const getControl = (serialnum) => {
|
||||||
setIsConnecting(true);
|
setIsConnecting(true);
|
||||||
|
let userParse = null;
|
||||||
|
try {
|
||||||
|
const dataStr = localStorage.getItem("userInfo");
|
||||||
|
userParse = dataStr ? JSON.parse(dataStr) : null;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("用户信息解析失败", e);
|
||||||
|
}
|
||||||
|
|
||||||
const data = { platform: "web", deviceId: serialnum };
|
const token = userParse.token || Cookies.get("Admin-Token");
|
||||||
|
|
||||||
|
const data = { platform: "web", deviceId: serialnum, token: token };
|
||||||
getJurisdiction(data).then(res => {
|
getJurisdiction(data).then(res => {
|
||||||
if (res?.data?.code === 200 && res?.data?.data?.remoteControl == true) {
|
if (res?.data?.code === 200 && res?.data?.data?.remoteControl == true) {
|
||||||
console.log("获取远程遥控权限成功");
|
console.log("获取远程遥控权限成功");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, {
|
import React, {
|
||||||
useState,
|
useState,
|
||||||
useEffect,
|
useEffect,
|
||||||
useMemo,
|
useMemo,
|
||||||
@@ -78,6 +78,7 @@ export default function DeviceStatusPage() {
|
|||||||
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
|
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
|
||||||
const [isLoopMode, setIsLoopMode] = useState(true);
|
const [isLoopMode, setIsLoopMode] = useState(true);
|
||||||
const controllerRef = useRef<DeviceController | null>(null);
|
const controllerRef = useRef<DeviceController | null>(null);
|
||||||
|
const isFirstConnect = useRef(true);
|
||||||
const [messageApi, contextHolder] = message.useMessage();
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
|
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ export default function DeviceStatusPage() {
|
|||||||
const [connecting, setConnecting] = useState(false);
|
const [connecting, setConnecting] = useState(false);
|
||||||
const [wsStatus, setWsStatus] = useState('disconnected');
|
const [wsStatus, setWsStatus] = useState('disconnected');
|
||||||
const [wsDeviceInfo, setWsDeviceInfo] = useState({});
|
const [wsDeviceInfo, setWsDeviceInfo] = useState({});
|
||||||
|
const [locationInfo, setLocationInfo] = useState({});
|
||||||
|
|
||||||
|
|
||||||
// 👇 加上这两个
|
// 👇 加上这两个
|
||||||
@@ -388,7 +390,7 @@ export default function DeviceStatusPage() {
|
|||||||
|
|
||||||
const runningStatus = useMemo(() => {
|
const runningStatus = useMemo(() => {
|
||||||
// 判断对象是否为空
|
// 判断对象是否为空
|
||||||
if ((!wsDeviceInfo || Object.keys(wsDeviceInfo).length === 0) && !isUAV) {
|
if ((!wsDeviceInfo || Object.keys(wsDeviceInfo).length === 0) && (!locationInfo || Object.keys(locationInfo).length === 0) && !isUAV) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (isUAV) {
|
if (isUAV) {
|
||||||
@@ -403,8 +405,9 @@ export default function DeviceStatusPage() {
|
|||||||
: {
|
: {
|
||||||
...base,
|
...base,
|
||||||
...wsDeviceInfo,
|
...wsDeviceInfo,
|
||||||
|
...locationInfo
|
||||||
};
|
};
|
||||||
}, [device, wsDeviceInfo, isUAV]);
|
}, [device, wsDeviceInfo, isUAV, locationInfo]);
|
||||||
|
|
||||||
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
||||||
(!isUAV && isVideoPlaying) ? (device?.serialNumber || '') : '',
|
(!isUAV && isVideoPlaying) ? (device?.serialNumber || '') : '',
|
||||||
@@ -433,8 +436,8 @@ export default function DeviceStatusPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 机器人:从 wsDeviceInfo / runningStatus 取实时经纬度
|
// 2. 机器人:从 wsDeviceInfo / runningStatus 取实时经纬度
|
||||||
const robotLon = runningStatus.longitude || wsDeviceInfo.longitude;
|
const robotLon = runningStatus.longitude || locationInfo.longitude;
|
||||||
const robotLat = runningStatus.latitude || wsDeviceInfo.latitude;
|
const robotLat = runningStatus.latitude || locationInfo.latitude;
|
||||||
|
|
||||||
if (robotLon && robotLat) {
|
if (robotLon && robotLat) {
|
||||||
return {
|
return {
|
||||||
@@ -453,6 +456,7 @@ export default function DeviceStatusPage() {
|
|||||||
const controller = new DeviceController(userInfo, messageApi);
|
const controller = new DeviceController(userInfo, messageApi);
|
||||||
|
|
||||||
controller.onDeviceInfoUpdate = setWsDeviceInfo;
|
controller.onDeviceInfoUpdate = setWsDeviceInfo;
|
||||||
|
controller.onLocationInfoUpdate = setLocationInfo;
|
||||||
controller.onControlStatusChange = setIsControlled;
|
controller.onControlStatusChange = setIsControlled;
|
||||||
controller.onHasControlRightChange = setHasControlRight;
|
controller.onHasControlRightChange = setHasControlRight;
|
||||||
controller.onRequestControlStatusChange = setConnecting;
|
controller.onRequestControlStatusChange = setConnecting;
|
||||||
@@ -480,13 +484,19 @@ export default function DeviceStatusPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) {
|
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) {
|
||||||
//controllerRef.current?.destroy();
|
|
||||||
//setWsDeviceInfo({});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setWsDeviceInfo({});
|
setWsDeviceInfo({});
|
||||||
|
setLocationInfo({});
|
||||||
|
|
||||||
controllerRef.current.connectDevice(device);
|
if (isFirstConnect.current) {
|
||||||
|
|
||||||
|
isFirstConnect.current = false;
|
||||||
|
controllerRef.current.connectDevice(device);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
controllerRef.current.switchDevice(device);
|
||||||
|
}
|
||||||
|
|
||||||
}, [device?.serialNumber]);
|
}, [device?.serialNumber]);
|
||||||
|
|
||||||
@@ -656,103 +666,6 @@ export default function DeviceStatusPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 完成功能 - 调用路径规划接口
|
// 完成功能 - 调用路径规划接口
|
||||||
const handleComplete = async () => {
|
|
||||||
//如果时弓子模式
|
|
||||||
if (isLoopMode) {
|
|
||||||
if (markedPoints.length < 3) {
|
|
||||||
messageApi.warning(t('devices.minThreePoints'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 准备路径规划请求参数
|
|
||||||
const positionPoints = [...markedPoints];
|
|
||||||
|
|
||||||
|
|
||||||
const requestParams = {
|
|
||||||
reference: {
|
|
||||||
lat: positionPoints[0].lat,
|
|
||||||
lon: positionPoints[0].lon,
|
|
||||||
},
|
|
||||||
heading: 0,
|
|
||||||
outer: {
|
|
||||||
position: positionPoints.map(point => ({
|
|
||||||
lat: point.lat,
|
|
||||||
lon: point.lon,
|
|
||||||
})),
|
|
||||||
sideWidth: 0.0,
|
|
||||||
},
|
|
||||||
holes: [],
|
|
||||||
workType: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await fetch('https://servicepathplan.satabot.com/api/path', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify(requestParams),
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await response.json();
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
const path = result?.data?.path?.map(p => {
|
|
||||||
return {
|
|
||||||
lng: p.lon,
|
|
||||||
lat: p.lat
|
|
||||||
}
|
|
||||||
})
|
|
||||||
setPoints(path);
|
|
||||||
setSavePath({
|
|
||||||
path: path, // 存储返回的路径结果
|
|
||||||
outer: requestParams?.outer?.position?.map(p => {
|
|
||||||
return {
|
|
||||||
lng: p.lon,
|
|
||||||
lat: p.lat
|
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
planModel: 0,
|
|
||||||
});
|
|
||||||
setCompleteFlag(true);
|
|
||||||
messageApi.success(t('devices.pathPlanDone'));
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('路径规划失败:', error);
|
|
||||||
messageApi.error(t('devices.pathPlanFailRetry'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const positionPoints = [...markedPoints].map(item => {
|
|
||||||
return {
|
|
||||||
lng: item.lon,
|
|
||||||
lat: item.lat
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setPoints(positionPoints);
|
|
||||||
setSavePath({
|
|
||||||
path: positionPoints, // 存储返回的路径结果
|
|
||||||
outer: [],
|
|
||||||
planModel: 2,
|
|
||||||
});
|
|
||||||
setCompleteFlag(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// 打开保存模态框
|
|
||||||
const handleOpenSaveModal = () => {
|
|
||||||
if (!completeFlag) {
|
|
||||||
messageApi.warning(t('devices.completePathFirst'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPlotName('');
|
|
||||||
setIsSaveModalVisible(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 保存功能
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!plotName.trim()) {
|
if (!plotName.trim()) {
|
||||||
messageApi.warning(t('devices.inputPlotName'));
|
messageApi.warning(t('devices.inputPlotName'));
|
||||||
@@ -761,6 +674,15 @@ export default function DeviceStatusPage() {
|
|||||||
|
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
try {
|
try {
|
||||||
|
// ✅重点:接收handleComplete返回的path数据,不再读组件savePath state
|
||||||
|
const pathResult = await handleComplete();
|
||||||
|
if (!pathResult) {
|
||||||
|
messageApi.warning(t('devices.saveFail'));
|
||||||
|
|
||||||
|
// 路径规划失败/校验不通过直接终止
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 1. 获取地图截图
|
// 1. 获取地图截图
|
||||||
let screenshotDataUrl = null;
|
let screenshotDataUrl = null;
|
||||||
if (mapRef.current) {
|
if (mapRef.current) {
|
||||||
@@ -776,18 +698,20 @@ export default function DeviceStatusPage() {
|
|||||||
const file = dataUrlToFile(screenshotDataUrl, "screenshot.jpg");
|
const file = dataUrlToFile(screenshotDataUrl, "screenshot.jpg");
|
||||||
console.log("blob", file)
|
console.log("blob", file)
|
||||||
|
|
||||||
|
|
||||||
if (file instanceof File) {
|
if (file instanceof File) {
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 添加 workRecord
|
// 4. 添加 workRecord,直接使用函数返回的 pathResult,不读取state savePath
|
||||||
const workRecord = {
|
const workRecord = {
|
||||||
workName: plotName,
|
workName: plotName,
|
||||||
siteId: stationId,
|
siteId: stationId,
|
||||||
jsonData: savePath,
|
orgId: currentStation?.orgId,
|
||||||
|
jsonData: pathResult, // 直接用返回值,彻底规避state异步延迟
|
||||||
|
mode: isLoopMode ? "coverage" : "single_point",//"区域还是单点"
|
||||||
};
|
};
|
||||||
|
console.log("workRecord", workRecord)
|
||||||
formData.append(
|
formData.append(
|
||||||
"workRecord",
|
"workRecord",
|
||||||
new Blob([JSON.stringify(workRecord)], {
|
new Blob([JSON.stringify(workRecord)], {
|
||||||
@@ -795,8 +719,6 @@ export default function DeviceStatusPage() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
//formData.append('workRecord', JSON.stringify(workRecord));
|
|
||||||
|
|
||||||
// 5. 调用保存接口
|
// 5. 调用保存接口
|
||||||
const res = await addRoute(formData);
|
const res = await addRoute(formData);
|
||||||
|
|
||||||
@@ -818,6 +740,95 @@ export default function DeviceStatusPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改handleComplete:计算完成后 return路径对象;失败返回null
|
||||||
|
*/
|
||||||
|
const handleComplete = async () => {
|
||||||
|
//如果是闭环模式
|
||||||
|
if (isLoopMode) {
|
||||||
|
if (markedPoints.length < 3) {
|
||||||
|
messageApi.warning(t('devices.minThreePoints'));
|
||||||
|
return null; //校验失败返回null
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 准备路径规划请求参数
|
||||||
|
let positionPoints = [...markedPoints];
|
||||||
|
|
||||||
|
// =========新增:保证闭环,第一个点和最后一个点一致=========
|
||||||
|
const firstPt = positionPoints[0];
|
||||||
|
const lastPt = positionPoints[positionPoints.length - 1];
|
||||||
|
// 判断经纬度是否相等,不相等就把首点追加到末尾
|
||||||
|
if (!(firstPt.lat === lastPt.lat && firstPt.lon === lastPt.lon)) {
|
||||||
|
positionPoints.push({ ...firstPt });
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestParams = {
|
||||||
|
outer: {
|
||||||
|
position: positionPoints.map(point => ({
|
||||||
|
lat: point.lat,
|
||||||
|
lng: point.lon,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const path = requestParams?.outer?.position
|
||||||
|
setPoints(path);
|
||||||
|
|
||||||
|
const resultObj = {
|
||||||
|
path: path,
|
||||||
|
outer: requestParams?.outer?.position?.map(p => {
|
||||||
|
return {
|
||||||
|
lng: p.lon,
|
||||||
|
lat: p.lat
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
setSavePath(resultObj);
|
||||||
|
setCompleteFlag(true);
|
||||||
|
messageApi.success(t('devices.pathPlanDone'));
|
||||||
|
return resultObj; // ✅返回计算好的数据给上层调用
|
||||||
|
} catch (error) {
|
||||||
|
console.error('路径规划失败:', error);
|
||||||
|
messageApi.error(t('devices.pathPlanFailRetry'));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 单点模式
|
||||||
|
const positionPoints = [...markedPoints].map(item => {
|
||||||
|
return {
|
||||||
|
lng: item.lon,
|
||||||
|
lat: item.lat
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setPoints(positionPoints);
|
||||||
|
|
||||||
|
const resultObj = {
|
||||||
|
path: positionPoints,
|
||||||
|
outer: [],
|
||||||
|
};
|
||||||
|
setSavePath(resultObj);
|
||||||
|
setCompleteFlag(true);
|
||||||
|
|
||||||
|
return resultObj; // ✅返回
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 打开保存模态框
|
||||||
|
const handleOpenSaveModal = () => {
|
||||||
|
//if (!completeFlag) {
|
||||||
|
// messageApi.warning(t('devices.completePathFirst'));
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
setPlotName('');
|
||||||
|
setIsSaveModalVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const realtimeType = useMemo(() => {
|
const realtimeType = useMemo(() => {
|
||||||
return isUAV ? 'plane' : 'car';
|
return isUAV ? 'plane' : 'car';
|
||||||
}, [isUAV]);
|
}, [isUAV]);
|
||||||
@@ -856,8 +867,8 @@ export default function DeviceStatusPage() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
||||||
<Text strong>{t('devices.pathPlanning')}:</Text>
|
<Text strong>{t('devices.pathPlanning')}:</Text>
|
||||||
<Text type="secondary">{t('devices.markedPointsCount', { count: markedPoints.length })}</Text>
|
<Text type="secondary">{t('devices.markedPointsCount', { count: markedPoints.length })}</Text>
|
||||||
</div>
|
</div>
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Space>
|
<Space>
|
||||||
@@ -882,18 +893,18 @@ export default function DeviceStatusPage() {
|
|||||||
>
|
>
|
||||||
{t('devices.clearMarks')}
|
{t('devices.clearMarks')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{/*<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
ghost
|
ghost
|
||||||
onClick={handleComplete}
|
onClick={handleComplete}
|
||||||
disabled={markedPoints.length < 2}
|
disabled={markedPoints.length < 2}
|
||||||
>
|
>
|
||||||
{t('devices.complete')}
|
{t('devices.complete')}
|
||||||
</Button>
|
</Button>*/}
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={handleOpenSaveModal}
|
onClick={handleOpenSaveModal}
|
||||||
disabled={!completeFlag}
|
//disabled={!completeFlag}
|
||||||
>
|
>
|
||||||
{t('common.save')}
|
{t('common.save')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -961,7 +972,7 @@ export default function DeviceStatusPage() {
|
|||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
<VideoCameraOutlined />
|
<VideoCameraOutlined />
|
||||||
{t('devices.stationVideo')}
|
{t('devices.stationVideo')}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
bordered={false}
|
bordered={false}
|
||||||
@@ -1039,7 +1050,7 @@ export default function DeviceStatusPage() {
|
|||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
<VideoCameraOutlined />
|
<VideoCameraOutlined />
|
||||||
{t('devices.droneVideo')}
|
{t('devices.droneVideo')}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
bordered={false}
|
bordered={false}
|
||||||
@@ -1103,33 +1114,33 @@ export default function DeviceStatusPage() {
|
|||||||
}}>
|
}}>
|
||||||
<div style={{ marginBottom: 6, fontWeight: 600, color: '#1890ff' }}>{t('devices.robotStatus')}</div>
|
<div style={{ marginBottom: 6, fontWeight: 600, color: '#1890ff' }}>{t('devices.robotStatus')}</div>
|
||||||
<div style={{ display: 'flex', gap: '3px 10px', flexWrap: 'wrap' }}>
|
<div style={{ display: 'flex', gap: '3px 10px', flexWrap: 'wrap' }}>
|
||||||
<span>{t('devices.rtBattery')}</span>
|
<span>{t('devices.rtBattery')}:</span>
|
||||||
<span style={{ color: (runningStatus.battery || 0) < 20 ? '#ff4d4f' : '#52c41a' }}>
|
<span style={{ color: (runningStatus.battery || 0) < 20 ? '#ff4d4f' : '#52c41a' }}>
|
||||||
{runningStatus.battery !== undefined ? `${runningStatus.battery}%` : '-'}
|
{runningStatus.battery !== undefined ? `${runningStatus.battery}%` : '-'}
|
||||||
</span>
|
</span>
|
||||||
<span>{t('devices.rtVoltage')}</span>
|
<span>{t('devices.rtVoltage')}:</span>
|
||||||
<span>{runningStatus.voltage !== undefined ? `${Number(runningStatus.voltage).toFixed(2)}V` : '-'}</span>
|
<span>{runningStatus.voltage !== undefined ? `${Number(runningStatus.voltage).toFixed(2)}V` : '-'}</span>
|
||||||
<span>{t('devices.rtLeftMotor')}</span>
|
<span>{t('devices.rtLeftMotor')}:</span>
|
||||||
<span>{runningStatus.leftCurrent !== undefined ? `${Number(runningStatus.leftCurrent).toFixed(2)}A` : '-'}</span>
|
<span>{runningStatus.leftCurrent !== undefined ? `${Number(runningStatus.leftCurrent).toFixed(2)}A` : '-'}</span>
|
||||||
<span>{t('devices.rtRightMotor')}</span>
|
<span>{t('devices.rtRightMotor')}:</span>
|
||||||
<span>{runningStatus.rightCurrent !== undefined ? `${Number(runningStatus.rightCurrent).toFixed(2)}A` : '-'}</span>
|
<span>{runningStatus.rightCurrent !== undefined ? `${Number(runningStatus.rightCurrent).toFixed(2)}A` : '-'}</span>
|
||||||
<span>{t('devices.rtLeftSpeed')}</span>
|
<span>{t('devices.rtLeftSpeed')}:</span>
|
||||||
<span>{runningStatus.leftMeasureSpeed !== undefined ? `${Number(runningStatus.leftMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
|
<span>{runningStatus.leftMeasureSpeed !== undefined ? `${Number(runningStatus.leftMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
|
||||||
<span>{t('devices.rtRightSpeed')}</span>
|
<span>{t('devices.rtRightSpeed')}:</span>
|
||||||
<span>{runningStatus.rightMeasureSpeed !== undefined ? `${Number(runningStatus.rightMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
|
<span>{runningStatus.rightMeasureSpeed !== undefined ? `${Number(runningStatus.rightMeasureSpeed).toFixed(1)}rpm` : '-'}</span>
|
||||||
<span>{t('devices.rtLeftTemp')}</span>
|
<span>{t('devices.rtLeftTemp')}:</span>
|
||||||
<span>{runningStatus.leftMotorTemp !== undefined ? `${Number(runningStatus.leftMotorTemp).toFixed(1)}℃` : '-'}</span>
|
<span>{runningStatus.leftMotorTemp !== undefined ? `${Number(runningStatus.leftMotorTemp).toFixed(1)}℃` : '-'}</span>
|
||||||
<span>{t('devices.rtRightTemp')}</span>
|
<span>{t('devices.rtRightTemp')}:</span>
|
||||||
<span>{runningStatus.rightMotorTemp !== undefined ? `${Number(runningStatus.rightMotorTemp).toFixed(1)}℃` : '-'}</span>
|
<span>{runningStatus.rightMotorTemp !== undefined ? `${Number(runningStatus.rightMotorTemp).toFixed(1)}℃` : '-'}</span>
|
||||||
<span>{t('devices.rtMainTemp')}</span>
|
<span>{t('devices.rtMainTemp')}:</span>
|
||||||
<span>{runningStatus.chipTemp !== undefined ? `${Number(runningStatus.chipTemp).toFixed(1)}℃` : '-'}</span>
|
<span>{runningStatus.chipTemp !== undefined ? `${Number(runningStatus.chipTemp).toFixed(1)}℃` : '-'}</span>
|
||||||
<span>{t('devices.rtHeadingAngle')}</span>
|
<span>{t('devices.rtHeadingAngle')}:</span>
|
||||||
<span>{runningStatus.yaw !== undefined ? `${Number(runningStatus.yaw).toFixed(1)}°` : '-'}</span>
|
<span>{runningStatus.yaw !== undefined ? `${Number(runningStatus.yaw).toFixed(1)}°` : '-'}</span>
|
||||||
<span>{t('devices.rtPitchAngle')}</span>
|
<span>{t('devices.rtPitchAngle')}:</span>
|
||||||
<span>{runningStatus.pitch !== undefined ? `${Number(runningStatus.pitch).toFixed(1)}°` : '-'}</span>
|
<span>{runningStatus.pitch !== undefined ? `${Number(runningStatus.pitch).toFixed(1)}°` : '-'}</span>
|
||||||
<span>{t('devices.rtHeadingStatus')}</span>
|
<span>{t('devices.rtHeadingStatus')}:</span>
|
||||||
<span>{runningStatus.headingStatus !== undefined ? `${runningStatus.headingStatus == 1 ? t('devices.rtInitialized') : t('devices.uninitialized')}` : '-'}</span>
|
<span>{runningStatus.headingStatus !== undefined ? `${runningStatus.headingStatus == 1 ? t('devices.rtInitialized') : t('devices.uninitialized')}` : '-'}</span>
|
||||||
<span>{t('devices.rtPositioning')}</span>
|
<span>{t('devices.rtPositioning')}:</span>
|
||||||
<span>
|
<span>
|
||||||
{runningStatus.qual == 0 ? t('constants.locationInvalid') :
|
{runningStatus.qual == 0 ? t('constants.locationInvalid') :
|
||||||
runningStatus.qual == 1 ? t('devices.gpsSingle') :
|
runningStatus.qual == 1 ? t('devices.gpsSingle') :
|
||||||
@@ -1137,9 +1148,9 @@ export default function DeviceStatusPage() {
|
|||||||
runningStatus.qual == 4 ? t('devices.rtkFixed2') :
|
runningStatus.qual == 4 ? t('devices.rtkFixed2') :
|
||||||
runningStatus.qual == 5 ? t('devices.rtkFloat') : t('constants.locationUnknown')}
|
runningStatus.qual == 5 ? t('devices.rtkFloat') : t('constants.locationUnknown')}
|
||||||
</span>
|
</span>
|
||||||
<span>{t('devices.rtSatellites')}</span>
|
<span>{t('devices.rtSatellites')}:</span>
|
||||||
<span>{t('devices.satelliteCount', { count: runningStatus.satelliteCnt || 0 })}</span>
|
<span>{t('devices.satelliteCount', { count: runningStatus.satelliteCnt || 0 })}</span>
|
||||||
<span>{t('devices.rtMode')}</span>
|
<span>{t('devices.rtMode')}:</span>
|
||||||
<span>
|
<span>
|
||||||
{runningStatus.controlMode == 1 ? t('devices.localMode') :
|
{runningStatus.controlMode == 1 ? t('devices.localMode') :
|
||||||
runningStatus.controlMode == 3 ? t('devices.remoteMode') : t('constants.locationUnknown')}
|
runningStatus.controlMode == 3 ? t('devices.remoteMode') : t('constants.locationUnknown')}
|
||||||
@@ -1322,7 +1333,7 @@ export default function DeviceStatusPage() {
|
|||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
<ControlOutlined />
|
<ControlOutlined />
|
||||||
{t('devices.remoteControl')}
|
{t('devices.remoteControl')}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
bordered={false}
|
bordered={false}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
|
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
|
||||||
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
|
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
|
||||||
Modal, InputNumber,
|
Modal, InputNumber,
|
||||||
TimePicker,
|
TimePicker,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
App
|
App,
|
||||||
|
Radio
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
PlusOutlined, ImportOutlined, NodeIndexOutlined,
|
PlusOutlined, ImportOutlined, NodeIndexOutlined,
|
||||||
@@ -35,6 +36,7 @@ import {
|
|||||||
getSiteDeviceTaskHistory,
|
getSiteDeviceTaskHistory,
|
||||||
getRouteByTask,
|
getRouteByTask,
|
||||||
deleteRoute,
|
deleteRoute,
|
||||||
|
getTaskPath,
|
||||||
} from '../../api/device';
|
} from '../../api/device';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import DraggableBox from '../Draggable';
|
import DraggableBox from '../Draggable';
|
||||||
@@ -116,6 +118,8 @@ export default function RobotTaskPage() {
|
|||||||
robot: null,
|
robot: null,
|
||||||
dateRange: null,
|
dateRange: null,
|
||||||
});
|
});
|
||||||
|
// 取消任务模式 normal普通取消 force强制取消
|
||||||
|
const [cancelMode, setCancelMode] = useState<'normal' | 'force'>('normal');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -137,6 +141,7 @@ export default function RobotTaskPage() {
|
|||||||
});
|
});
|
||||||
const [messageApi, contextHolder] = message.useMessage();
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
const controllerRef = useRef<DeviceController | null>(null);
|
const controllerRef = useRef<DeviceController | null>(null);
|
||||||
|
const isFirstConnect = useRef(true);
|
||||||
const handleFinish = (data) => {
|
const handleFinish = (data) => {
|
||||||
setExecute(false);
|
setExecute(false);
|
||||||
setShowVideo(false); // 任务完成关闭视频
|
setShowVideo(false); // 任务完成关闭视频
|
||||||
@@ -236,7 +241,7 @@ export default function RobotTaskPage() {
|
|||||||
setExecute(true);
|
setExecute(true);
|
||||||
setExecutingRobot(targetDevice);
|
setExecutingRobot(targetDevice);
|
||||||
setClearNavLine(v => v + 1); // 清空地图轨迹
|
setClearNavLine(v => v + 1); // 清空地图轨迹
|
||||||
controllerRef.current?.connectDevice(targetDevice);
|
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
|
||||||
setShowVideo(true);
|
setShowVideo(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -244,7 +249,7 @@ export default function RobotTaskPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const controller = new DeviceController(userInfo, messageApi);
|
const controller = new DeviceController(userInfo, messageApi);
|
||||||
|
|
||||||
controller.onDeviceInfoUpdate = setRobotRealtimePosition;
|
controller.onLocationInfoUpdate = setRobotRealtimePosition;
|
||||||
controller.onIsFinished = handleFinish;
|
controller.onIsFinished = handleFinish;
|
||||||
controller.handleArrivedPoint = handleFinishEdPoint;
|
controller.handleArrivedPoint = handleFinishEdPoint;
|
||||||
|
|
||||||
@@ -296,7 +301,7 @@ export default function RobotTaskPage() {
|
|||||||
setExecute(true);
|
setExecute(true);
|
||||||
setExecutingRobot(targetDevice);
|
setExecutingRobot(targetDevice);
|
||||||
setClearNavLine(v => v + 1); // 清空地图轨迹
|
setClearNavLine(v => v + 1); // 清空地图轨迹
|
||||||
controllerRef.current?.connectDevice(targetDevice);
|
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
|
||||||
setShowVideo(true);
|
setShowVideo(true);
|
||||||
|
|
||||||
}, [devices, taskPoolList, executingRobot, runningPoolTask]);
|
}, [devices, taskPoolList, executingRobot, runningPoolTask]);
|
||||||
@@ -394,22 +399,14 @@ export default function RobotTaskPage() {
|
|||||||
// 调用接口获取路线详情
|
// 调用接口获取路线详情
|
||||||
const fetchRouteDetail = async () => {
|
const fetchRouteDetail = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getSingleRouteList({ id: selectedPathWork.id });
|
const res = await getTaskPath({ taskId: selectedPathWork.id })
|
||||||
|
//const res = await getSingleRouteList({ id: selectedPathWork.id });
|
||||||
if (res?.code === 200 && res?.data) {
|
if (res?.code === 200 && res?.data) {
|
||||||
let pathPoints = [];
|
let pathPoints = [];
|
||||||
let outerPoints = [];
|
|
||||||
let method = '';//0弓子 2 回子
|
|
||||||
try {
|
try {
|
||||||
// 尝试解析 JSON
|
// 尝试解析 JSON
|
||||||
if (res.data.jsonData) {
|
pathPoints = res.data || [];
|
||||||
const data = typeof res.data.jsonData === 'string'
|
|
||||||
? JSON.parse(res.data.jsonData)
|
|
||||||
: res.data.jsonData;
|
|
||||||
pathPoints = data?.path || [];
|
|
||||||
outerPoints = data?.outer || [];
|
|
||||||
method = data?.planModel;
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('解析路线数据失败:', err);
|
console.error('解析路线数据失败:', err);
|
||||||
}
|
}
|
||||||
@@ -417,15 +414,9 @@ export default function RobotTaskPage() {
|
|||||||
if (pathPoints.length === 0) {
|
if (pathPoints.length === 0) {
|
||||||
utils.message.warning(t('devices.route2'));
|
utils.message.warning(t('devices.route2'));
|
||||||
}
|
}
|
||||||
//if (outerPoints.length === 0 && method == 2) {
|
|
||||||
// utils.message.warning(t('devices.route2'));
|
|
||||||
//}
|
|
||||||
//if (method == 0) {
|
|
||||||
setPoints(pathPoints);
|
|
||||||
//} else {
|
|
||||||
// setPoints(outerPoints);
|
|
||||||
|
|
||||||
//}
|
setPoints(pathPoints);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setPoints([]);
|
setPoints([]);
|
||||||
}
|
}
|
||||||
@@ -460,7 +451,7 @@ export default function RobotTaskPage() {
|
|||||||
setExecute(true);
|
setExecute(true);
|
||||||
setExecutingRobot(targetDevice);
|
setExecutingRobot(targetDevice);
|
||||||
setClearNavLine(v => v + 1); // 清空地图轨迹
|
setClearNavLine(v => v + 1); // 清空地图轨迹
|
||||||
controllerRef.current?.connectDevice(targetDevice);
|
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
|
||||||
setShowVideo(true);
|
setShowVideo(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,7 +557,7 @@ export default function RobotTaskPage() {
|
|||||||
fetchTaskList();
|
fetchTaskList();
|
||||||
fetchTaskPoolList();
|
fetchTaskPoolList();
|
||||||
fetchTaskHistoryList();
|
fetchTaskHistoryList();
|
||||||
controllerRef.current?.connectDevice(selectedRobotForExecute);
|
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(selectedRobotForExecute); } else { controllerRef.current?.switchDevice(selectedRobotForExecute); }
|
||||||
setShowVideo(true); // 连接成功后自动打开视频
|
setShowVideo(true); // 连接成功后自动打开视频
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -653,13 +644,14 @@ export default function RobotTaskPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 取消任务
|
// 取消任务
|
||||||
const handleCancelTask = async (task) => {
|
const handleCancelTask = async (task, mode) => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
taskId: task.id,
|
taskId: task.id,
|
||||||
//deviceId: task.deviceId,
|
//deviceId: task.deviceId,
|
||||||
siteId: stationId,
|
siteId: stationId,
|
||||||
orgId: task.orgId,
|
orgId: task.orgId,
|
||||||
|
forceCancel: mode === 'force' ? true : false,
|
||||||
};
|
};
|
||||||
const res = await cancelRoute(params);
|
const res = await cancelRoute(params);
|
||||||
if (res.code === 200 && res.data == true) {
|
if (res.code === 200 && res.data == true) {
|
||||||
@@ -832,15 +824,17 @@ export default function RobotTaskPage() {
|
|||||||
dataIndex: 'taskStaus',
|
dataIndex: 'taskStaus',
|
||||||
width: 100,
|
width: 100,
|
||||||
render: (status, record) => {
|
render: (status, record) => {
|
||||||
|
console.log('status', status, record);
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
'NEW': { color: 'default', text: t('devices.statusNew') },
|
'NEW': { color: 'default', text: t('devices.statusNew') },
|
||||||
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
|
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
|
||||||
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
||||||
'FINISH': { color: 'success', text: t('devices.statusFinished') },
|
'FINISH': { color: 'success', text: t('devices.statusFinished') },
|
||||||
'FAILED': { color: 'error', text: t('devices.statusFailed') }
|
'FAILED': { color: 'error', text: t('devices.statusFailed') },
|
||||||
|
"CANCELING": { color: 'warning', text: t('devices.statusCanceling') },
|
||||||
};
|
};
|
||||||
const item = statusMap[status] || { color: 'default', text: record.taskStausTranslate || t('constants.locationUnknown') };
|
const item = statusMap[status] || { color: 'default', text: record.taskStausTranslate || t('constants.locationUnknown') };
|
||||||
return <Tag color={item.color}>{item.text}</Tag>;
|
return <Tag color={item.color}>{record.taskStausTranslate}</Tag>;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -889,7 +883,8 @@ export default function RobotTaskPage() {
|
|||||||
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
|
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
|
||||||
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
||||||
'FINISH': { color: 'success', text: t('devices.statusFinished') },
|
'FINISH': { color: 'success', text: t('devices.statusFinished') },
|
||||||
'FAILED': { color: 'error', text: t('devices.statusFailed') }
|
'FAILED': { color: 'error', text: t('devices.statusFailed') },
|
||||||
|
"CANCELING": { color: 'warning', text: t('devices.statusCanceling') },
|
||||||
};
|
};
|
||||||
const item = statusMap[status] || { color: 'default', text: t('constants.locationUnknown') };
|
const item = statusMap[status] || { color: 'default', text: t('constants.locationUnknown') };
|
||||||
return <Tag color={item.color}>{item.text}</Tag>;
|
return <Tag color={item.color}>{item.text}</Tag>;
|
||||||
@@ -909,27 +904,46 @@ export default function RobotTaskPage() {
|
|||||||
|
|
||||||
<>
|
<>
|
||||||
{/*{record.taskStaus === 'NEW' && (*/}
|
{/*{record.taskStaus === 'NEW' && (*/}
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={t('devices.confirmCancelTask')}
|
title={t('devices.confirmCancelTask')}
|
||||||
onConfirm={() => handleCancelTask(record)}
|
description={
|
||||||
okText={t('common.ok')} cancelText={t('common.cancel')}
|
<Radio.Group
|
||||||
>
|
value={cancelMode}
|
||||||
<Button type="text" size="small" danger icon={<CloseOutlined />} onClick={(e) => e.stopPropagation()}>
|
onChange={(e) => setCancelMode(e.target.value)}
|
||||||
{t('common.cancel')}
|
style={{ marginTop: 8 }}
|
||||||
</Button>
|
>
|
||||||
</Popconfirm>
|
<Space direction="vertical">
|
||||||
|
<Radio value="normal">{t('devices.normalCancel')}</Radio>
|
||||||
|
<Radio value="force">{t('devices.forceCancel')}</Radio>
|
||||||
|
</Space>
|
||||||
|
</Radio.Group>
|
||||||
|
}
|
||||||
|
onConfirm={() => handleCancelTask(record, cancelMode)}
|
||||||
|
okText={t('common.ok')}
|
||||||
|
cancelText={t('common.cancel')}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
danger
|
||||||
|
icon={<CloseOutlined />}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{t('common.cancel')}
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>
|
||||||
{/*//)}*/}
|
{/*//)}*/}
|
||||||
|
|
||||||
{/*{record.taskStaus === 'EXECUTING' && (*/}
|
{/*{record.taskStaus === 'EXECUTING' && (*/}
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={t('devices.confirmPauseTask')}
|
title={t('devices.confirmPauseTask')}
|
||||||
onConfirm={() => handlePauseTask(record)}
|
onConfirm={() => handlePauseTask(record)}
|
||||||
okText={t('common.ok')} cancelText={t('common.cancel')}
|
okText={t('common.ok')} cancelText={t('common.cancel')}
|
||||||
>
|
>
|
||||||
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
|
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
|
||||||
{t('video.pause')}
|
{t('video.pause')}
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
{/*)}/*/}
|
{/*)}/*/}
|
||||||
|
|
||||||
{record.taskStaus === 'PAUSE' && (
|
{record.taskStaus === 'PAUSE' && (
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
|
|||||||
return (
|
return (
|
||||||
<div className="relative h-[252px] aspect-[4/3] flex items-center justify-center "
|
<div className="relative h-[252px] aspect-[4/3] flex items-center justify-center "
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (connected && !isControlled && hasControlRight) {
|
if (!isControlled) {
|
||||||
console.log("点击了无控制权限,发起权限请求");
|
console.log("点击了无控制权限,发起权限请求");
|
||||||
// 示例:调用你代码中已有的权限请求弹窗逻辑
|
// 示例:调用你代码中已有的权限请求弹窗逻辑
|
||||||
handleControlModal({ control: true, type: "switchPermission" });
|
handleControlModal({ control: true, type: "switchPermission" });
|
||||||
@@ -125,7 +125,7 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
|
|||||||
{/* Gamepad Status Badge */}
|
{/* Gamepad Status Badge */}
|
||||||
<div
|
<div
|
||||||
className={`absolute top-0 right-0 px-2 py-0.5 rounded text-[8px] font-bold tracking-widest border
|
className={`absolute top-0 right-0 px-2 py-0.5 rounded text-[8px] font-bold tracking-widest border
|
||||||
${connected || !hasControlRight
|
${connected
|
||||||
? isConnecting
|
? isConnecting
|
||||||
? 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30'
|
? 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30'
|
||||||
: isControlled
|
: isControlled
|
||||||
@@ -137,8 +137,6 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
|
|||||||
>
|
>
|
||||||
{!connected ? (
|
{!connected ? (
|
||||||
t('devices.controllerNotConnected')
|
t('devices.controllerNotConnected')
|
||||||
) : !hasControlRight ? (
|
|
||||||
t('devices.otherWebConnected')
|
|
||||||
) : isConnecting ? (
|
) : isConnecting ? (
|
||||||
t('devices.control2')
|
t('devices.control2')
|
||||||
) : isControlled ? (
|
) : isControlled ? (
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import throttle from 'lodash/throttle';
|
import throttle from 'lodash/throttle';
|
||||||
import { wsManager } from '../WebSocketManager.ts';
|
import { wsManager } from '../WebSocketManager.ts';
|
||||||
import {
|
import {
|
||||||
getControlRight,
|
|
||||||
getJurisdiction,
|
getJurisdiction,
|
||||||
|
releaseControl
|
||||||
} from '../../api/device.ts';
|
} from '../../api/device.ts';
|
||||||
|
|
||||||
import envConfig from '../../../env';
|
import envConfig from '../../../env';
|
||||||
@@ -17,7 +17,7 @@ export default class DeviceController {
|
|||||||
envConfig.WS_URL || 'wss://ri.satabot.com/ws/';
|
envConfig.WS_URL || 'wss://ri.satabot.com/ws/';
|
||||||
|
|
||||||
this.connectedDeviceSn = null;
|
this.connectedDeviceSn = null;
|
||||||
this.currentDevice = null; // 保存当前设备
|
this.currentDevice = null;
|
||||||
|
|
||||||
this.requestDeviceId = '';
|
this.requestDeviceId = '';
|
||||||
|
|
||||||
@@ -27,11 +27,14 @@ export default class DeviceController {
|
|||||||
|
|
||||||
this.wsStatus = 'disconnected';
|
this.wsStatus = 'disconnected';
|
||||||
this.wsDeviceInfo = {};
|
this.wsDeviceInfo = {};
|
||||||
|
this.locationInfo = {};
|
||||||
|
|
||||||
this.controlTimeout = null;
|
this.controlTimeout = null;
|
||||||
this.keepAliveInterval = null; // 后台保活定时器
|
this.keepAliveInterval = null;
|
||||||
|
|
||||||
this.onDeviceInfoUpdate = null;
|
this.onDeviceInfoUpdate = null;
|
||||||
|
this.onLocationInfoUpdate = null;
|
||||||
|
|
||||||
this.onControlStatusChange = null;
|
this.onControlStatusChange = null;
|
||||||
this.onWsStatusChange = null;
|
this.onWsStatusChange = null;
|
||||||
this.onHasControlRightChange = null;
|
this.onHasControlRightChange = null;
|
||||||
@@ -43,6 +46,7 @@ export default class DeviceController {
|
|||||||
this.handleWsMessage = this.handleWsMessage.bind(this);
|
this.handleWsMessage = this.handleWsMessage.bind(this);
|
||||||
this.handleWsStatus = this.handleWsStatus.bind(this);
|
this.handleWsStatus = this.handleWsStatus.bind(this);
|
||||||
this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
|
this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
|
||||||
|
this.handleBeforeUnload = this.handleBeforeUnload.bind(this);
|
||||||
|
|
||||||
this.sendGamepad = throttle(
|
this.sendGamepad = throttle(
|
||||||
this.sendGamepad.bind(this),
|
this.sendGamepad.bind(this),
|
||||||
@@ -55,36 +59,38 @@ export default class DeviceController {
|
|||||||
this.unSubMessage = wsManager.onMessage(this.handleWsMessage);
|
this.unSubMessage = wsManager.onMessage(this.handleWsMessage);
|
||||||
this.unSubStatus = wsManager.onStatusChange(this.handleWsStatus);
|
this.unSubStatus = wsManager.onStatusChange(this.handleWsStatus);
|
||||||
|
|
||||||
// ========== 【集成】页面可见性监听 ==========
|
|
||||||
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
||||||
|
document.addEventListener('beforeunload', this.handleBeforeUnload);
|
||||||
|
}
|
||||||
|
levae() {
|
||||||
|
wsManager.close();
|
||||||
|
|
||||||
// ========== 【集成】后台保活定时 ==========
|
|
||||||
//this.startKeepAlive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 【集成】页面切前台重连 ==========
|
|
||||||
handleVisibilityChange() {
|
handleVisibilityChange() {
|
||||||
// 切后台:关闭 WS
|
|
||||||
if (document.visibilityState === 'hidden') {
|
if (document.visibilityState === 'hidden') {
|
||||||
console.log('🔌 页面切后台,关闭 WebSocket');
|
console.log('Page hidden, release control');
|
||||||
//this.release();
|
//this.release();
|
||||||
wsManager.close();
|
wsManager.close();
|
||||||
this.connectedDeviceSn = null;
|
this.connectedDeviceSn = null;
|
||||||
|
|
||||||
|
|
||||||
this.isControlled = false;
|
this.isControlled = false;
|
||||||
this.onControlStatusChange?.(false);
|
this.onControlStatusChange?.(false);
|
||||||
}
|
}
|
||||||
if (document.visibilityState === 'visible' && this.currentDevice) {
|
if (document.visibilityState === 'visible' && this.currentDevice) {
|
||||||
if (!this.currentDevice?.serialNumber) return;
|
if (!this.currentDevice?.serialNumber) return;
|
||||||
console.log('✅ 页面切回前台,自动重连 WebSocket');
|
console.log('Page visible, reconnect WebSocket');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.connectDevice(this.currentDevice);
|
this.connectDevice(this.currentDevice);
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 【集成】后台保活 ==========
|
handleBeforeUnload() {
|
||||||
|
console.log('Browser closing/refreshing, release control');
|
||||||
|
this.release();
|
||||||
|
}
|
||||||
|
|
||||||
startKeepAlive() {
|
startKeepAlive() {
|
||||||
this.keepAliveInterval = setInterval(() => {
|
this.keepAliveInterval = setInterval(() => {
|
||||||
if (
|
if (
|
||||||
@@ -92,47 +98,50 @@ export default class DeviceController {
|
|||||||
this.wsStatus !== 'connected' &&
|
this.wsStatus !== 'connected' &&
|
||||||
this.currentDevice?.serialNumber
|
this.currentDevice?.serialNumber
|
||||||
) {
|
) {
|
||||||
console.log('🔄 后台保活:尝试重连 WebSocket');
|
console.log('Keep alive: reconnect WebSocket');
|
||||||
this.connectDevice(this.currentDevice);
|
this.connectDevice(this.currentDevice);
|
||||||
}
|
}
|
||||||
}, 8000);
|
}, 8000);
|
||||||
}
|
}
|
||||||
release() {
|
|
||||||
if (this.isControlled && this.connectedDeviceSn) {
|
|
||||||
const data = {
|
|
||||||
platform: "web",
|
|
||||||
type: 1
|
|
||||||
};
|
|
||||||
const url = `${envConfig.baseURL}/forward/device/releaseControl`;
|
|
||||||
|
|
||||||
try {
|
async release() {
|
||||||
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });
|
if (!this.connectedDeviceSn) return;
|
||||||
navigator.sendBeacon(url, blob);
|
const data = {
|
||||||
} catch (e) {
|
platform: 'web',
|
||||||
console.error('Failed to send releaseControl beacon:', e);
|
type: 1,
|
||||||
}
|
deviceId: this.connectedDeviceSn,
|
||||||
|
token: this.userInfo.token,
|
||||||
|
};
|
||||||
|
const url = `${envConfig.baseURL}/forward/device/releaseControl`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await releaseControl(data);
|
||||||
|
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });
|
||||||
|
navigator.sendBeacon(url, blob);
|
||||||
|
console.log('releaseControl sent');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to send releaseControl:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.clearControlTimeout();
|
this.clearControlTimeout();
|
||||||
|
|
||||||
// 清理保活
|
|
||||||
if (this.keepAliveInterval) {
|
if (this.keepAliveInterval) {
|
||||||
clearInterval(this.keepAliveInterval);
|
clearInterval(this.keepAliveInterval);
|
||||||
this.keepAliveInterval = null;
|
this.keepAliveInterval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除监听
|
|
||||||
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
||||||
|
document.removeEventListener('beforeunload', this.handleBeforeUnload);
|
||||||
|
|
||||||
|
this.release();
|
||||||
|
this.levae();
|
||||||
|
|
||||||
this.unSubMessage?.();
|
this.unSubMessage?.();
|
||||||
this.unSubStatus?.();
|
this.unSubStatus?.();
|
||||||
//this.release();
|
|
||||||
|
|
||||||
//wsManager.close();
|
|
||||||
this.connectedDeviceSn = null;
|
this.connectedDeviceSn = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleWsStatus(status) {
|
handleWsStatus(status) {
|
||||||
@@ -148,7 +157,6 @@ export default class DeviceController {
|
|||||||
async connectDevice(device) {
|
async connectDevice(device) {
|
||||||
if (!device) return;
|
if (!device) return;
|
||||||
|
|
||||||
// 保存当前设备,用于保活/重连
|
|
||||||
this.currentDevice = device;
|
this.currentDevice = device;
|
||||||
if (!device.serialNumber) return;
|
if (!device.serialNumber) return;
|
||||||
|
|
||||||
@@ -156,31 +164,17 @@ export default class DeviceController {
|
|||||||
|
|
||||||
this.connectedDeviceSn = null;
|
this.connectedDeviceSn = null;
|
||||||
this.wsDeviceInfo = {};
|
this.wsDeviceInfo = {};
|
||||||
|
this.locationInfo = {};
|
||||||
this.isControlled = false;
|
this.isControlled = false;
|
||||||
this.onControlStatusChange?.(false);
|
this.onControlStatusChange?.(false);
|
||||||
|
|
||||||
wsManager.close();
|
wsManager.close();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getControlRight({
|
console.log('Connecting to', this.wsUrl);
|
||||||
userName: this.userInfo.username,
|
|
||||||
sourceType: 1,
|
|
||||||
token: this.userInfo.token,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hasControlRight = res?.code === 200 && res.data == true;
|
|
||||||
this.onHasControlRightChange?.(this.hasControlRight);
|
|
||||||
|
|
||||||
wsManager.connect(sn, this.wsUrl);
|
wsManager.connect(sn, this.wsUrl);
|
||||||
this.connectedDeviceSn = sn;
|
this.connectedDeviceSn = sn;
|
||||||
|
|
||||||
if (!this.hasControlRight) {
|
|
||||||
this.messageApi.warning(i18n.t('devices.fixed2OthersControlFixed2'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await this.getControl(sn);
|
await this.getControl(sn);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -188,11 +182,42 @@ export default class DeviceController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async switchDevice(device) {
|
||||||
|
if (!device) return;
|
||||||
|
if (!device.serialNumber) return;
|
||||||
|
|
||||||
|
const newSn = device.serialNumber;
|
||||||
|
|
||||||
|
if (this.connectedDeviceSn === newSn && this.wsStatus === 'connected') {
|
||||||
|
console.log('switchDevice: same device, skip');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Connecting to switchDevice: switching to', newSn);
|
||||||
|
|
||||||
|
this.currentDevice = device;
|
||||||
|
this.connectedDeviceSn = newSn;
|
||||||
|
this.wsDeviceInfo = {};
|
||||||
|
this.locationInfo = {};
|
||||||
|
this.isControlled = false;
|
||||||
|
this.onControlStatusChange?.(false);
|
||||||
|
|
||||||
|
wsManager.send({
|
||||||
|
type: 'AUTH',
|
||||||
|
token: this.userInfo.token,
|
||||||
|
userName: this.userInfo.username,
|
||||||
|
deviceId: newSn,
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.getControl(newSn);
|
||||||
|
}
|
||||||
|
|
||||||
async getControl(serialnum) {
|
async getControl(serialnum) {
|
||||||
try {
|
try {
|
||||||
const res = await getJurisdiction({
|
const res = await getJurisdiction({
|
||||||
platform: 'web',
|
platform: 'web',
|
||||||
deviceId: serialnum,
|
deviceId: serialnum,
|
||||||
|
token: this.userInfo.token,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.isControlled = res?.code === 200 && res?.data?.remoteControl === true;
|
this.isControlled = res?.code === 200 && res?.data?.remoteControl === true;
|
||||||
@@ -206,10 +231,7 @@ export default class DeviceController {
|
|||||||
|
|
||||||
requestControl() {
|
requestControl() {
|
||||||
if (this.isRequestControl) return;
|
if (this.isRequestControl) return;
|
||||||
if (!this.hasControlRight) {
|
|
||||||
this.messageApi.warning(i18n.t('devices.noneControl'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isRequestControl = true;
|
this.isRequestControl = true;
|
||||||
this.onRequestControlStatusChange?.(true);
|
this.onRequestControlStatusChange?.(true);
|
||||||
@@ -252,7 +274,7 @@ export default class DeviceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleWsMessage(msg) {
|
handleWsMessage(msg) {
|
||||||
console.log('📨 收到消息:', msg);
|
console.log('WS message:', msg);
|
||||||
switch (msg.type) {
|
switch (msg.type) {
|
||||||
case 'deviceInfo': {
|
case 'deviceInfo': {
|
||||||
const data = {};
|
const data = {};
|
||||||
@@ -263,6 +285,15 @@ export default class DeviceController {
|
|||||||
this.onDeviceInfoUpdate?.(data);
|
this.onDeviceInfoUpdate?.(data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'locationInfo': {
|
||||||
|
const data = {};
|
||||||
|
msg.data.forEach((item) => {
|
||||||
|
data[item.name] = item.value;
|
||||||
|
});
|
||||||
|
this.locationInfo = data;
|
||||||
|
this.onLocationInfoUpdate?.(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'AUTH': {
|
case 'AUTH': {
|
||||||
if (msg.isAuth) {
|
if (msg.isAuth) {
|
||||||
@@ -277,7 +308,7 @@ export default class DeviceController {
|
|||||||
this.isRequestControl = false;
|
this.isRequestControl = false;
|
||||||
this.onRequestControlStatusChange?.(false);
|
this.onRequestControlStatusChange?.(false);
|
||||||
|
|
||||||
if (msg.success === false || msg?.respond?.switchResult === false) {
|
if (msg?.success === false || msg?.respond?.switchResult === false) {
|
||||||
this.isControlled = false;
|
this.isControlled = false;
|
||||||
this.onControlStatusChange?.(false);
|
this.onControlStatusChange?.(false);
|
||||||
this.messageApi.error({ key: 'control', content: msg.message || i18n.t('devices.controlFailed') });
|
this.messageApi.error({ key: 'control', content: msg.message || i18n.t('devices.controlFailed') });
|
||||||
@@ -291,19 +322,16 @@ export default class DeviceController {
|
|||||||
case "device_task_change": {
|
case "device_task_change": {
|
||||||
if (msg.deviceId != this.connectedDeviceSn) return;
|
if (msg.deviceId != this.connectedDeviceSn) return;
|
||||||
this.onIsFinished?.(true);
|
this.onIsFinished?.(true);
|
||||||
console.log('🔌 控制结果任务变更,', msg);
|
console.log('task change:', msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//完成点
|
|
||||||
case "device_task_arrive_point": {
|
case "device_task_arrive_point": {
|
||||||
if (msg.deviceId != this.connectedDeviceSn) return;
|
if (msg.deviceId != this.connectedDeviceSn) return;
|
||||||
|
|
||||||
this.handleArrivedPoint?.(msg.entity);
|
this.handleArrivedPoint?.(msg.entity);
|
||||||
console.log('🔌 到达完成点,', msg);
|
console.log('arrive point:', msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case 'switchPermission': {
|
case 'switchPermission': {
|
||||||
const platform = (msg.platform || '').toLowerCase();
|
const platform = (msg.platform || '').toLowerCase();
|
||||||
if (!platform || platform === 'null') return;
|
if (!platform || platform === 'null') return;
|
||||||
|
|||||||
@@ -659,6 +659,8 @@ const en = {
|
|||||||
optimize: 'Optimize',
|
optimize: 'Optimize',
|
||||||
optionalEmpty: 'Optional Empty',
|
optionalEmpty: 'Optional Empty',
|
||||||
otherWebControlling: 'Other Web Controlling',
|
otherWebControlling: 'Other Web Controlling',
|
||||||
|
platformRequestControl: "{{platform}} platformRequestControl",
|
||||||
|
|
||||||
outDock: 'Out Dock',
|
outDock: 'Out Dock',
|
||||||
outdoor: 'Outdoor',
|
outdoor: 'Outdoor',
|
||||||
panorama: 'Panorama',
|
panorama: 'Panorama',
|
||||||
@@ -927,6 +929,8 @@ const en = {
|
|||||||
unitJia: '',
|
unitJia: '',
|
||||||
unitTai: '',
|
unitTai: '',
|
||||||
unitTiao: '',
|
unitTiao: '',
|
||||||
|
normalCancel: "normalCancel",
|
||||||
|
forceCancel: "forceCancel",
|
||||||
unknownDevice: 'Unknown Device',
|
unknownDevice: 'Unknown Device',
|
||||||
unknownDrone: 'Unknown Drone',
|
unknownDrone: 'Unknown Drone',
|
||||||
unknownObject: 'Unknown Object',
|
unknownObject: 'Unknown Object',
|
||||||
@@ -987,6 +991,9 @@ const en = {
|
|||||||
working: 'Working',
|
working: 'Working',
|
||||||
workingCurrent: 'Working Current',
|
workingCurrent: 'Working Current',
|
||||||
zoomLens: 'Zoom Lens',
|
zoomLens: 'Zoom Lens',
|
||||||
|
controllerNotConnected: "controllerNotConnected",
|
||||||
|
otherWebConnected: "otherWebConnected",
|
||||||
|
clickToRequestControl: "clickToRequestControl",
|
||||||
|
|
||||||
fixed2TaskSuspended2: 'Fixed2 Task Suspended2 态势',
|
fixed2TaskSuspended2: 'Fixed2 Task Suspended2 态势',
|
||||||
|
|
||||||
@@ -1280,9 +1287,10 @@ const en = {
|
|||||||
|
|
||||||
failedFixed22: '权限校验 Failed Fixed2',
|
failedFixed22: '权限校验 Failed Fixed2',
|
||||||
|
|
||||||
noneControl: 'None Control 权限',
|
noneControl: 'None Control jurisdiction',
|
||||||
|
|
||||||
fixed2ControlFixed2: 'Fixed2 Control 请求 超时 Fixed2',
|
fixed2ControlFixed2: 'Fixed2 Control 请求 超时 Fixed2',
|
||||||
|
controlFailed:"请求被拒绝",
|
||||||
},
|
},
|
||||||
video: {
|
video: {
|
||||||
onlineVideo: 'Online Video',
|
onlineVideo: 'Online Video',
|
||||||
@@ -3174,7 +3182,6 @@ const en = {
|
|||||||
|
|
||||||
deptRnd: 'R&D Department',
|
deptRnd: 'R&D Department',
|
||||||
|
|
||||||
editMenu: 'Edit Menu',
|
|
||||||
|
|
||||||
editOrganization: 'Edit Organization',
|
editOrganization: 'Edit Organization',
|
||||||
|
|
||||||
@@ -3376,7 +3383,6 @@ const en = {
|
|||||||
abnormal: 'Abnormal',
|
abnormal: 'Abnormal',
|
||||||
addSuccess: 'Add Success',
|
addSuccess: 'Add Success',
|
||||||
confirmDeleteRole: 'Confirm Delete Role',
|
confirmDeleteRole: 'Confirm Delete Role',
|
||||||
editRole: 'Edit Role',
|
|
||||||
editSuccess: 'Edit Success',
|
editSuccess: 'Edit Success',
|
||||||
manageMembers: 'Manage Members',
|
manageMembers: 'Manage Members',
|
||||||
menuPermissionConfig: 'Menu Permission Config',
|
menuPermissionConfig: 'Menu Permission Config',
|
||||||
|
|||||||
@@ -321,10 +321,13 @@ const zh = {
|
|||||||
statusPaused: '暂停中',
|
statusPaused: '暂停中',
|
||||||
statusFinished: '执行成功',
|
statusFinished: '执行成功',
|
||||||
statusFailed: '执行失败',
|
statusFailed: '执行失败',
|
||||||
|
statusCanceling: '取消中',
|
||||||
confirmDeleteTask: '确定要删除该任务吗?',
|
confirmDeleteTask: '确定要删除该任务吗?',
|
||||||
confirmCancelTask: '确定要取消该任务吗?',
|
confirmCancelTask: '确定要取消该任务吗?',
|
||||||
confirmPauseTask: '确定要暂停该任务吗?',
|
confirmPauseTask: '确定要暂停该任务吗?',
|
||||||
confirmResumeTask: '确定要恢复该任务吗?',
|
confirmResumeTask: '确定要恢复该任务吗?',
|
||||||
|
normalCancel: "普通取消",
|
||||||
|
forceCancel: "强制取消",
|
||||||
recover: '恢复',
|
recover: '恢复',
|
||||||
statTodayPlan: '今日机器人计划',
|
statTodayPlan: '今日机器人计划',
|
||||||
unitPlan: '条',
|
unitPlan: '条',
|
||||||
@@ -413,7 +416,8 @@ const zh = {
|
|||||||
selectExecDate: '选择执行日期',
|
selectExecDate: '选择执行日期',
|
||||||
execTime: '执行时间',
|
execTime: '执行时间',
|
||||||
saveTask: '保存任务',
|
saveTask: '保存任务',
|
||||||
abMode: '模式',
|
abMode: '自定义模式',
|
||||||
|
saveFail: '保存失败',
|
||||||
activatedTime: '已激活时间',
|
activatedTime: '已激活时间',
|
||||||
aiAction1: 'AI',
|
aiAction1: 'AI',
|
||||||
aiAction2: 'AI',
|
aiAction2: 'AI',
|
||||||
@@ -444,14 +448,14 @@ const zh = {
|
|||||||
apiRequestException: 'API请求异常',
|
apiRequestException: 'API请求异常',
|
||||||
autoFetch: '自动获取',
|
autoFetch: '自动获取',
|
||||||
autoResumeFromBreakpoint: '自动恢复从断点',
|
autoResumeFromBreakpoint: '自动恢复从断点',
|
||||||
backView: '返回查看',
|
backView: '后视角',
|
||||||
batteryCapacity: '电量容量',
|
batteryCapacity: '电量容量',
|
||||||
batteryWithPercent: '电量带百分比',
|
batteryWithPercent: '电量带百分比',
|
||||||
batteryWithValue: '电量带值',
|
batteryWithValue: '电量带值',
|
||||||
blockUnit: '区块单位',
|
blockUnit: '区块单位',
|
||||||
boardTaskFetchFail: '看板任务获取失败',
|
boardTaskFetchFail: '看板任务获取失败',
|
||||||
boundDrone: '边界无人机',
|
boundDrone: '边界无人机',
|
||||||
bowMode: '船首模式',
|
bowMode: '弓字模式',
|
||||||
canWorkNormally: '可工作正常',
|
canWorkNormally: '可工作正常',
|
||||||
cancelReturnHome: '取消返航首页',
|
cancelReturnHome: '取消返航首页',
|
||||||
chargePoint: '充电点',
|
chargePoint: '充电点',
|
||||||
@@ -554,11 +558,17 @@ const zh = {
|
|||||||
fillRequiredFields: '填写必填字段',
|
fillRequiredFields: '填写必填字段',
|
||||||
firmwareVersion: '固件版本',
|
firmwareVersion: '固件版本',
|
||||||
fixed: '固定',
|
fixed: '固定',
|
||||||
|
controllerNotConnected: "控制器未连接",
|
||||||
|
otherWebConnected: "其他网页已连接",
|
||||||
|
clickToRequestControl: "点击请求控制",
|
||||||
|
|
||||||
|
controlling: "控制中",
|
||||||
|
|
||||||
fixed2: '',
|
fixed2: '',
|
||||||
fixedEnv: '固定环境',
|
fixedEnv: '固定环境',
|
||||||
flightAltitude: '飞行高度',
|
flightAltitude: '飞行高度',
|
||||||
flightWindSpeed: '飞行风速度',
|
flightWindSpeed: '飞行风速度',
|
||||||
frontView: '前查看',
|
frontView: '前视角',
|
||||||
ganttViewTitle: '甘特查看标题',
|
ganttViewTitle: '甘特查看标题',
|
||||||
generateTask: '生成任务',
|
generateTask: '生成任务',
|
||||||
gnssQuality: 'GNSS质量',
|
gnssQuality: 'GNSS质量',
|
||||||
@@ -591,7 +601,7 @@ const zh = {
|
|||||||
issueTaskFirst: '问题任务先',
|
issueTaskFirst: '问题任务先',
|
||||||
landingDockSn: '降落停靠序列号',
|
landingDockSn: '降落停靠序列号',
|
||||||
landingDockSnLabel: '降落停靠序列号标签',
|
landingDockSnLabel: '降落停靠序列号标签',
|
||||||
leftView: '左查看',
|
leftView: '左视角',
|
||||||
leftWheelDrive: '左轮驱动',
|
leftWheelDrive: '左轮驱动',
|
||||||
legendTitle: '图例标题',
|
legendTitle: '图例标题',
|
||||||
levelHigh: '级别高',
|
levelHigh: '级别高',
|
||||||
@@ -610,12 +620,12 @@ const zh = {
|
|||||||
loginInfoExpired: '登录提示已过期',
|
loginInfoExpired: '登录提示已过期',
|
||||||
lostControlAction: '丢失控制操作',
|
lostControlAction: '丢失控制操作',
|
||||||
lostControlActionLabel: '丢失控制操作标签',
|
lostControlActionLabel: '丢失控制操作标签',
|
||||||
markPoint: '标记点',
|
markPoint: '打点',
|
||||||
markedPointsCount: '已标记点数量',
|
markedPointsCount: '已标记点数量',
|
||||||
minBattery: '最小电量',
|
minBattery: '最小电量',
|
||||||
minBatteryLabel: '最小电量标签',
|
minBatteryLabel: '最小电量标签',
|
||||||
minExecBatteryLabel: '最小执行电量标签',
|
minExecBatteryLabel: '最小执行电量标签',
|
||||||
minThreePoints: '最小三点',
|
minThreePoints: '最少三个点',
|
||||||
modeAuto: '模式自动',
|
modeAuto: '模式自动',
|
||||||
modeDebugLocal: '模式调试本地',
|
modeDebugLocal: '模式调试本地',
|
||||||
modeDebugRemote: '模式调试远程',
|
modeDebugRemote: '模式调试远程',
|
||||||
@@ -762,7 +772,7 @@ const zh = {
|
|||||||
returnHomeAltitudeLabel: '返航首页高度标签',
|
returnHomeAltitudeLabel: '返航首页高度标签',
|
||||||
returnHomeMode: '返航首页模式',
|
returnHomeMode: '返航首页模式',
|
||||||
returnHomeModeLabel: '返航首页模式标签',
|
returnHomeModeLabel: '返航首页模式标签',
|
||||||
rightView: '右查看',
|
rightView: '右视角',
|
||||||
rightWheelDrive: '右轮驱动',
|
rightWheelDrive: '右轮驱动',
|
||||||
robotExecutingCount: '机器人执行中数量',
|
robotExecutingCount: '机器人执行中数量',
|
||||||
robotInTaskCount: '机器人内任务数量',
|
robotInTaskCount: '机器人内任务数量',
|
||||||
@@ -804,7 +814,7 @@ const zh = {
|
|||||||
rtkModeDesc: 'RTK模式描述',
|
rtkModeDesc: 'RTK模式描述',
|
||||||
rtkStatus: 'RTK状态',
|
rtkStatus: 'RTK状态',
|
||||||
safeRthBattery: '安全返航电量',
|
safeRthBattery: '安全返航电量',
|
||||||
satelliteCount: '卫星数量',
|
satelliteCount: '卫星数量 {{count}}',
|
||||||
savePathTitle: '保存路径标题',
|
savePathTitle: '保存路径标题',
|
||||||
savePlan: '保存计划',
|
savePlan: '保存计划',
|
||||||
saving: '节省',
|
saving: '节省',
|
||||||
@@ -1292,6 +1302,9 @@ const zh = {
|
|||||||
cancel: "取消",
|
cancel: "取消",
|
||||||
UnitsRobot: "台",
|
UnitsRobot: "台",
|
||||||
UnitsDrone: "架",
|
UnitsDrone: "架",
|
||||||
|
platformRequestControl: "{{platform}} 正在请求控制权限",
|
||||||
|
controlFailed: "controlFailed",
|
||||||
|
|
||||||
},
|
},
|
||||||
video: {
|
video: {
|
||||||
onlineVideo: '在线视频',
|
onlineVideo: '在线视频',
|
||||||
@@ -2641,7 +2654,6 @@ const zh = {
|
|||||||
s36: '用户名',
|
s36: '用户名',
|
||||||
|
|
||||||
s37: '关联产品',
|
s37: '关联产品',
|
||||||
editMenu: '编辑菜单',
|
|
||||||
addMenu: '新增菜单',
|
addMenu: '新增菜单',
|
||||||
editSite: '编辑场站',
|
editSite: '编辑场站',
|
||||||
addSite: '新增场站',
|
addSite: '新增场站',
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ export default function Login() {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name="agreement"
|
name="agreement"
|
||||||
valuePropName="checked"
|
valuePropName="checked"
|
||||||
|
initialValue={true}
|
||||||
|
|
||||||
rules={[{ validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error(t('login.agreeRequired'))) }]}
|
rules={[{ validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error(t('login.agreeRequired'))) }]}
|
||||||
>
|
>
|
||||||
<Checkbox>
|
<Checkbox>
|
||||||
|
|||||||
@@ -1,334 +1,4 @@
|
|||||||
import React, { lazy, Suspense } from 'react';
|
|
||||||
import { createBrowserRouter } from 'react-router-dom';
|
import { createBrowserRouter } from 'react-router-dom';
|
||||||
import type { RouteObject } from 'react-router-dom';
|
import { routes } from './routes';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 🔥 所有组件全部改为懒加载
|
|
||||||
const VideoMonitorPage = lazy(() => import('../pages/VideoMonitorPage'));
|
|
||||||
const AIDiagnosisPage = lazy(() => import('../pages/AIAnalysis'));
|
|
||||||
const CleanOptimizationPage = lazy(() => import('../pages/CleanOptimization'));
|
|
||||||
const WorkOrderPage = lazy(() => import('../pages/WorkOrder'));
|
|
||||||
const ReportCenterPage = lazy(() => import('../pages/ReportCenter'));
|
|
||||||
const RealTimeMonitorPage = lazy(() => import('../pages/RealTimeMonitor'));
|
|
||||||
const Agri = lazy(() => import('../pages/Agri'));
|
|
||||||
|
|
||||||
const Layout = lazy(() => import('../components/Layout'));
|
|
||||||
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
|
|
||||||
const Login = lazy(() => import('../pages/Login'));
|
|
||||||
|
|
||||||
const Home = lazy(() => import('../pages/Home'));
|
|
||||||
|
|
||||||
const Video = lazy(() => import('../pages/Video'));
|
|
||||||
const Alerts = lazy(() => import('../pages/Alerts'));
|
|
||||||
const Downloads = lazy(() => import('../pages/Downloads'));
|
|
||||||
const Roles = lazy(() => import('../pages/Roles'));
|
|
||||||
const Users = lazy(() => import('../pages/Users'));
|
|
||||||
const MenuList = lazy(() => import('../components/SystemSetting/MenuList'));
|
|
||||||
const Organization = lazy(() => import('../components/SystemSetting/Organization'));
|
|
||||||
const StationManage = lazy(() => import('../components/SystemSetting/StationManage'));
|
|
||||||
const SystemSetting = lazy(() => import('../pages/SystemSetting'));
|
|
||||||
const Profile = lazy(() => import('../pages/Profile'));
|
|
||||||
|
|
||||||
|
|
||||||
const DeviceStatus = lazy(() => import('../components/devices/DeviceStatusPage'));
|
|
||||||
const WayLineTask = lazy(() => import('../components/devices/WayLinePage'));
|
|
||||||
const RobotTask = lazy(() => import('../components/devices/RobotTaskPage'));
|
|
||||||
const DevicesOverview = lazy(() => import('../components/devices/DeviceOverviewPage'));
|
|
||||||
|
|
||||||
|
|
||||||
const BasicSettings = lazy(() => import('../components/SystemSetting/BasicSettings'));
|
|
||||||
const UserRolePage = lazy(() => import('../components/SystemSetting/UserPage'));
|
|
||||||
const DeviceAccessPage = lazy(() => import('../components/SystemSetting/DeviceAccessPage'));
|
|
||||||
const OnlineUserPage = lazy(() => import('../components/SystemSetting/OnlineUser'));
|
|
||||||
const DeviceManagementPage = lazy(() => import('../components/SystemSetting/DeviceManagement'));
|
|
||||||
const SystemMaintenancePage = lazy(() => import('../components/SystemSetting/SystemMaintain'));
|
|
||||||
const LogManagement = lazy(() => import('../components/SystemSetting/LogManagement'));
|
|
||||||
const VideoManagement = lazy(() => import('../components/SystemSetting/VideoManagement'));
|
|
||||||
//const ErrorManagement = lazy(() => import('../components/SystemSetting/ErrorManagement'));
|
|
||||||
//const AlarmSettingsManagement = lazy(() => import('../components/SystemSetting/AlarmSettingsManagement'));
|
|
||||||
//const WorkOrderSettingsManagement = lazy(() => import('../components/SystemSetting/WorkOrderSettingsManagement'));
|
|
||||||
|
|
||||||
// 加载中动画
|
|
||||||
function PageFallback() {
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center h-full min-h-[200px]">
|
|
||||||
<div className="w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin" />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 占位页(国际化)
|
|
||||||
const NoticePolicyPlaceholder = () => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return (
|
|
||||||
<div style={{ padding: 20 }}>
|
|
||||||
<h2>{t('router.noticePolicy')}</h2>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const DataSafetyPlaceholder = () => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return (
|
|
||||||
<div style={{ padding: 20 }}>
|
|
||||||
<h2>{t('router.dataSafety')}</h2>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const ModuleDeveloping = () => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center h-full gap-4 text-gray-400 select-none">
|
|
||||||
<span className="text-6xl opacity-20">🚧</span>
|
|
||||||
<p className="text-lg font-medium">{t('router.moduleDeveloping')}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// ====================== 全部懒加载的路由配置 ======================
|
|
||||||
const routes: RouteObject[] = [
|
|
||||||
{
|
|
||||||
path: '/login',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Login />
|
|
||||||
</Suspense>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<ProtectedRoute />
|
|
||||||
</Suspense>
|
|
||||||
),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Layout />
|
|
||||||
</Suspense>
|
|
||||||
),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Home />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'overview',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Home />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'devices/overview',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<DevicesOverview />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'devices/status',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<DeviceStatus />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'devices/wayLineTask',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<WayLineTask />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'devices/robotTask',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<RobotTask />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'video',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Video />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'RealtimeMonitor',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<RealTimeMonitorPage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'monitor',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<VideoMonitorPage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'agri',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Agri />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'alerts/all',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Alerts />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'AIanalysis',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<AIDiagnosisPage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'clean',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<CleanOptimizationPage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'task',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<WorkOrderPage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'table',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<ReportCenterPage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'systemSetting',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<SystemSetting />
|
|
||||||
</Suspense>
|
|
||||||
),
|
|
||||||
children: [
|
|
||||||
{ index: true, element: <Suspense fallback={<PageFallback />}><BasicSettings /></Suspense> },
|
|
||||||
{ path: 'basic', element: <Suspense fallback={<PageFallback />}><BasicSettings /></Suspense> },
|
|
||||||
{ path: 'User', element: <Suspense fallback={<PageFallback />}><UserRolePage /></Suspense> },
|
|
||||||
{ path: 'menu', element: <Suspense fallback={<PageFallback />}><MenuList /></Suspense> },
|
|
||||||
{ path: 'org', element: <Suspense fallback={<PageFallback />}><Organization /></Suspense> },
|
|
||||||
{ path: 'site', element: <Suspense fallback={<PageFallback />}><StationManage /></Suspense> },
|
|
||||||
{ path: 'notice', element: <Suspense fallback={<PageFallback />}><NoticePolicyPlaceholder /></Suspense> },
|
|
||||||
{ path: 'deviceAccess', element: <Suspense fallback={<PageFallback />}><DeviceAccessPage /></Suspense> },
|
|
||||||
{ path: 'dataSafety', element: <Suspense fallback={<PageFallback />}><DataSafetyPlaceholder /></Suspense> },
|
|
||||||
{ path: 'systemMaintenance', element: <Suspense fallback={<PageFallback />}><SystemMaintenancePage /></Suspense> },
|
|
||||||
{ path: 'monitor', element: <Suspense fallback={<PageFallback />}><OnlineUserPage /></Suspense> },
|
|
||||||
{ path: 'devices', element: <Suspense fallback={<PageFallback />}><DeviceManagementPage /></Suspense> },
|
|
||||||
{ path: 'log', element: <Suspense fallback={<PageFallback />}><LogManagement /></Suspense> },
|
|
||||||
{ path: 'videoManage', element: <Suspense fallback={<PageFallback />}><VideoManagement /></Suspense> },
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'downloads',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Downloads />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'manage/users',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Users />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'manage/roles',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Roles />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'manage/menuList',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<MenuList />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'organization',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Organization />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'station',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<StationManage />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'system',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<SystemSetting />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'profile',
|
|
||||||
element: (
|
|
||||||
<Suspense fallback={<PageFallback />}>
|
|
||||||
<Profile />
|
|
||||||
</Suspense>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '*',
|
|
||||||
element: <ModuleDeveloping />,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const router = createBrowserRouter(routes);
|
export const router = createBrowserRouter(routes);
|
||||||
|
|||||||
219
src/router/routes.tsx
Normal file
219
src/router/routes.tsx
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
import React, { lazy, Suspense } from 'react';
|
||||||
|
import type { RouteObject } from 'react-router-dom';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
// 🔥 所有组件全部改为懒加载
|
||||||
|
const VideoMonitorPage = lazy(() => import('../pages/VideoMonitorPage'));
|
||||||
|
const AIDiagnosisPage = lazy(() => import('../pages/AIAnalysis'));
|
||||||
|
const CleanOptimizationPage = lazy(() => import('../pages/CleanOptimization'));
|
||||||
|
const WorkOrderPage = lazy(() => import('../pages/WorkOrder'));
|
||||||
|
const ReportCenterPage = lazy(() => import('../pages/ReportCenter'));
|
||||||
|
const RealTimeMonitorPage = lazy(() => import('../pages/RealTimeMonitor'));
|
||||||
|
const Agri = lazy(() => import('../pages/Agri'));
|
||||||
|
|
||||||
|
const Layout = lazy(() => import('../components/Layout'));
|
||||||
|
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
|
||||||
|
const Login = lazy(() => import('../pages/Login'));
|
||||||
|
|
||||||
|
const Home = lazy(() => import('../pages/Home'));
|
||||||
|
const Video = lazy(() => import('../pages/Video'));
|
||||||
|
const Alerts = lazy(() => import('../pages/Alerts'));
|
||||||
|
const Downloads = lazy(() => import('../pages/Downloads'));
|
||||||
|
const Roles = lazy(() => import('../pages/Roles'));
|
||||||
|
const Users = lazy(() => import('../pages/Users'));
|
||||||
|
const MenuList = lazy(() => import('../components/SystemSetting/MenuList'));
|
||||||
|
const Organization = lazy(() => import('../components/SystemSetting/Organization'));
|
||||||
|
const StationManage = lazy(() => import('../components/SystemSetting/StationManage'));
|
||||||
|
const SystemSetting = lazy(() => import('../pages/SystemSetting'));
|
||||||
|
const Profile = lazy(() => import('../pages/Profile'));
|
||||||
|
|
||||||
|
const DeviceStatus = lazy(() => import('../components/devices/DeviceStatusPage'));
|
||||||
|
const WayLineTask = lazy(() => import('../components/devices/WayLinePage'));
|
||||||
|
const RobotTask = lazy(() => import('../components/devices/RobotTaskPage'));
|
||||||
|
const DevicesOverview = lazy(() => import('../components/devices/DeviceOverviewPage'));
|
||||||
|
|
||||||
|
const BasicSettings = lazy(() => import('../components/SystemSetting/BasicSettings'));
|
||||||
|
const UserRolePage = lazy(() => import('../components/SystemSetting/UserPage'));
|
||||||
|
const DeviceAccessPage = lazy(() => import('../components/SystemSetting/DeviceAccessPage'));
|
||||||
|
const OnlineUserPage = lazy(() => import('../components/SystemSetting/OnlineUser'));
|
||||||
|
const DeviceManagementPage = lazy(() => import('../components/SystemSetting/DeviceManagement'));
|
||||||
|
const SystemMaintenancePage = lazy(() => import('../components/SystemSetting/SystemMaintain'));
|
||||||
|
const LogManagement = lazy(() => import('../components/SystemSetting/LogManagement'));
|
||||||
|
const VideoManagement = lazy(() => import('../components/SystemSetting/VideoManagement'));
|
||||||
|
|
||||||
|
// 加载中动画
|
||||||
|
export function PageFallback() {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center h-full min-h-[200px]">
|
||||||
|
<div className="w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 封装高阶组件,消除重复 Suspense
|
||||||
|
export const withSuspense = (Comp: React.LazyExoticComponent<React.FC>) => {
|
||||||
|
return <Suspense fallback={<PageFallback />}>{<Comp />}</Suspense>;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 占位页(国际化)
|
||||||
|
const NoticePolicyPlaceholder = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<div style={{ padding: 20 }}>
|
||||||
|
<h2>{t('router.noticePolicy')}</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const DataSafetyPlaceholder = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<div style={{ padding: 20 }}>
|
||||||
|
<h2>{t('router.dataSafety')}</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ModuleDeveloping = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center h-full gap-4 text-gray-400 select-none">
|
||||||
|
<span className="text-6xl opacity-20">🚧</span>
|
||||||
|
<p className="text-lg font-medium">{t('router.moduleDeveloping')}</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// ====================== 路由配置数组 ======================
|
||||||
|
export const routes: RouteObject[] = [
|
||||||
|
{
|
||||||
|
path: '/login',
|
||||||
|
element: withSuspense(Login),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
element: withSuspense(ProtectedRoute),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
element: withSuspense(Layout),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
index: true,
|
||||||
|
element: withSuspense(Home)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'overview',
|
||||||
|
element: withSuspense(Home)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'devices/overview',
|
||||||
|
element: withSuspense(DevicesOverview)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'devices/status',
|
||||||
|
element: withSuspense(DeviceStatus)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'devices/wayLineTask',
|
||||||
|
element: withSuspense(WayLineTask)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'devices/robotTask',
|
||||||
|
element: withSuspense(RobotTask)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'video',
|
||||||
|
element: withSuspense(Video)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'RealtimeMonitor',
|
||||||
|
element: withSuspense(RealTimeMonitorPage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'monitor',
|
||||||
|
element: withSuspense(VideoMonitorPage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'agri',
|
||||||
|
element: withSuspense(Agri)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'alerts/all',
|
||||||
|
element: withSuspense(Alerts)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'AIanalysis',
|
||||||
|
element: withSuspense(AIDiagnosisPage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'clean',
|
||||||
|
element: withSuspense(CleanOptimizationPage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'task',
|
||||||
|
element: withSuspense(WorkOrderPage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'table',
|
||||||
|
element: withSuspense(ReportCenterPage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'systemSetting',
|
||||||
|
element: withSuspense(SystemSetting),
|
||||||
|
children: [
|
||||||
|
{ index: true, element: withSuspense(BasicSettings) },
|
||||||
|
{ path: 'basic', element: withSuspense(BasicSettings) },
|
||||||
|
{ path: 'User', element: withSuspense(UserRolePage) },
|
||||||
|
{ path: 'menu', element: withSuspense(MenuList) },
|
||||||
|
{ path: 'org', element: withSuspense(Organization) },
|
||||||
|
{ path: 'site', element: withSuspense(StationManage) },
|
||||||
|
{ path: 'notice', element: <Suspense fallback={<PageFallback />}><NoticePolicyPlaceholder /></Suspense> },
|
||||||
|
{ path: 'deviceAccess', element: withSuspense(DeviceAccessPage) },
|
||||||
|
{ path: 'dataSafety', element: <Suspense fallback={<PageFallback />}><DataSafetyPlaceholder /></Suspense> },
|
||||||
|
{ path: 'systemMaintenance', element: withSuspense(SystemMaintenancePage) },
|
||||||
|
{ path: 'monitor', element: withSuspense(OnlineUserPage) },
|
||||||
|
{ path: 'devices', element: withSuspense(DeviceManagementPage) },
|
||||||
|
{ path: 'log', element: withSuspense(LogManagement) },
|
||||||
|
{ path: 'videoManage', element: withSuspense(VideoManagement) },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'downloads',
|
||||||
|
element: withSuspense(Downloads)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'manage/users',
|
||||||
|
element: withSuspense(Users)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'manage/roles',
|
||||||
|
element: withSuspense(Roles)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'manage/menuList',
|
||||||
|
element: withSuspense(MenuList)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'organization',
|
||||||
|
element: withSuspense(Organization)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'station',
|
||||||
|
element: withSuspense(StationManage)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'system',
|
||||||
|
element: withSuspense(SystemSetting)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'profile',
|
||||||
|
element: withSuspense(Profile)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '*',
|
||||||
|
element: <ModuleDeveloping />,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user