Compare commits
10 Commits
62b03bba03
...
a3b2f14620
| Author | SHA1 | Date | |
|---|---|---|---|
| a3b2f14620 | |||
| d6b5c9ad44 | |||
| 36d1517eef | |||
| 30ce706280 | |||
| f22c2bedfe | |||
| be8576b887 | |||
| 5073f64240 | |||
| e363fb2799 | |||
| 81a9ed3dd1 | |||
| 027455272b |
10
env.js
10
env.js
@@ -9,17 +9,19 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
|
||||
// 环境配置映射
|
||||
const envConfig = {
|
||||
[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
|
||||
//WS_URL: 'ws://192.168.2.59:9002/ws/',
|
||||
//mqtt_url: "ws://1.95.137.212:8083/mqtt",
|
||||
//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',
|
||||
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",
|
||||
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: 'https://serviceri.satabot.com',
|
||||
@@ -40,7 +42,7 @@ const envConfig = {
|
||||
//baseURL: 'https://serviceri.satabot.com',
|
||||
WS_URL: 'ws://1.95.137.212:9002/ws/',
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<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.stationType')}:{currentStation.type || t('layout.groundStation')}</div>
|
||||
<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 navLineRef = useRef(null); // 完成点实时轨迹
|
||||
const markedPointsRef = useRef([]); // 标记点实体
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
const realtimeEntityRef = useRef(null);
|
||||
const realtimeLineRef = useRef(null);
|
||||
@@ -343,8 +345,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}
|
||||
}, [markedPoints]);
|
||||
|
||||
function showRobotTooltip(tooltip, robot, position) {
|
||||
const { t } = useTranslation();
|
||||
function showRobotTooltip(tooltip, robot, position, t) {
|
||||
const statusMap = {
|
||||
1: { text: t('common.working'), color: "#10b981" },
|
||||
2: { text: t('devices.idle'), color: "#f59e0b" },
|
||||
@@ -498,6 +499,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
if (index == 2 && from == "other") {
|
||||
flyToLayer(layerIdentifier, baseUrl, 100);
|
||||
}
|
||||
//if (index == 0 && from == "other") {
|
||||
// flyToLayer(layerIdentifier, baseUrl, 100);
|
||||
//}
|
||||
//getLayerBoundsAndFit(wmsUrl, layerName);
|
||||
|
||||
if (baseUrl.includes('/gwc/service/wms')) {
|
||||
@@ -1397,7 +1401,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
const picked = viewer.scene.pick(movement.endPosition);
|
||||
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
|
||||
const robot = picked.id.properties.robot.getValue();
|
||||
showRobotTooltip(tooltipRef.current, robot, movement.endPosition);
|
||||
showRobotTooltip(tooltipRef.current, robot, movement.endPosition, t);
|
||||
} else {
|
||||
tooltipRef.current.style.display = "none";
|
||||
}
|
||||
@@ -1599,7 +1603,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
// 如果有航向角,设置旋转
|
||||
let rotation = 0;
|
||||
console.log('realtimePosition.heading:', realtimePosition.heading);
|
||||
|
||||
|
||||
if (realtimePosition?.heading !== undefined && !isNaN(Number(realtimePosition.heading))) {
|
||||
|
||||
@@ -161,11 +161,11 @@ const BasicSettings = () => {
|
||||
const deviceStatuses = [
|
||||
{ name: t('home.inverter'), count: '5/5', status: t('roles.normal') },
|
||||
{ name: t('home.combinerBox'), count: '20/20', status: t('roles.normal') },
|
||||
{ name: '气象站', count: '1/1', status: t('roles.normal') },
|
||||
{ name: t('home.WeatherStation'), count: '1/1', status: t('roles.normal') },
|
||||
{ name: t('devices.camera'), count: '12/12', status: t('roles.normal') },
|
||||
{ name: t('constants.uav'), count: '2/2', status: t('roles.normal') },
|
||||
{ name: t('devices.robot'), count: '5/5', status: t('roles.normal') },
|
||||
{ name: 'API接口', count: t('roles.normal'), status: t('roles.normal') },
|
||||
{ name: t('systemSetting.api'), count: t('roles.normal'), status: t('roles.normal') },
|
||||
{ name: 'Modbus', count: t('roles.normal'), status: t('roles.normal') },
|
||||
];
|
||||
|
||||
@@ -204,7 +204,7 @@ const BasicSettings = () => {
|
||||
<Col xs={24} xl={17}>
|
||||
{/* 基础配置 */}
|
||||
<AntdCard
|
||||
title={<Space><SettingOutlined style={{ color: '#1677ff' }} /><b>{t('systemSetting.s02')}</b></Space>}
|
||||
title={<Space><SettingOutlined style={{ color: '#1677ff' }} /><b>{t('systemSetting.basicSettings')}</b></Space>}
|
||||
bordered={false}
|
||||
style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
@@ -292,10 +292,10 @@ const BasicSettings = () => {
|
||||
>
|
||||
<Row gutter={[12, 12]} style={{ marginBottom: 8 }}>
|
||||
{[
|
||||
{ label: t('alerts.sms'), icon: <Smartphone size={16} />, color: '#52c41a', status: '已启用' },
|
||||
{ label: t('alerts.email'), icon: <Mail size={16} />, color: '#1677ff', status: '已启用' },
|
||||
{ label: 'Telegram', icon: <Send size={16} />, color: '#13c2c2', status: '已启用' },
|
||||
{ label: t('report.systemNotification'), icon: <BellOutlined style={{ fontSize: 16 }} />, color: '#fa8c16', status: '已启用' },
|
||||
{ label: t('alerts.sms'), icon: <Smartphone size={16} />, color: '#52c41a', status: `${t('alerts.enabled')}` },
|
||||
{ label: t('alerts.email'), icon: <Mail size={16} />, color: '#1677ff', status: `${t('alerts.enabled')}` },
|
||||
{ label: 'Telegram', icon: <Send size={16} />, color: '#13c2c2', status: `${t('alerts.enabled')}` },
|
||||
{ label: t('report.systemNotification'), icon: <BellOutlined style={{ fontSize: 16 }} />, color: '#fa8c16', status: `${t('alerts.enabled')}` },
|
||||
].map((item, idx) => (
|
||||
<Col xs={24} sm={12} lg={6} key={idx}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', padding: '10px 12px', background: '#f8fafc', borderRadius: 8, border: '1px solid #f1f5f9' }}>
|
||||
@@ -315,10 +315,10 @@ const BasicSettings = () => {
|
||||
<Col xs={24} sm={12} md={8}><Space size={8}><span style={{ fontSize: fontSmall }}>{t('systemSetting.fixed2CriticalAlert')}</span><Switch size="small" defaultChecked /></Space></Col>
|
||||
<Col xs={24} sm={12} md={8}><Space size={8}><span style={{ fontSize: fontSmall }}>{t('systemSetting.fixed2GenerationFixed2Descend15')}</span><Switch size="small" defaultChecked /></Space></Col>
|
||||
<Col xs={24} sm={12} md={8}><Space size={8}><span style={{ fontSize: fontSmall }}>{t('systemSetting.fixed2Communicating')}</span><Switch size="small" defaultChecked /></Space></Col>
|
||||
<Col xs={24} sm={12} md={8}><Space size={8}><span style={{ fontSize: fontSmall }}>{t('systemSetting.s122')}</span><Switch size="small" defaultChecked /></Space></Col>
|
||||
<Col xs={24} sm={12} md={8}><Space size={8}><span style={{ fontSize: fontSmall }}>{t('systemSetting.everydayPush')}</span><Switch size="small" defaultChecked /></Space></Col>
|
||||
<Col xs={24} md={16}>
|
||||
<Space size="middle" style={{ flexWrap: 'wrap' }}>
|
||||
<span style={{ fontSize: fontSmall }}>{t('systemSetting.s132')}</span>
|
||||
<span style={{ fontSize: fontSmall }}>{t('systemSetting.Nighttime')}</span>
|
||||
<TimePicker.RangePicker size="small" defaultValue={[dayjs('23:00', 'HH:mm'), dayjs('07:00', 'HH:mm')]} format="HH:mm" style={{ width: 140 }} />
|
||||
<Switch size="small" />
|
||||
</Space>
|
||||
@@ -328,7 +328,7 @@ const BasicSettings = () => {
|
||||
|
||||
{/* 用户与权限预览 */}
|
||||
<AntdCard
|
||||
title={<Space><Users size={16} style={{ color: '#1677ff' }} /><b>{t('systemSetting.s142')}</b></Space>}
|
||||
title={<Space><Users size={16} style={{ color: '#1677ff' }} /><b>{t('systemSetting.fixed2RolePermissionFixed2OverviewFixed2')}</b></Space>}
|
||||
bordered={false}
|
||||
style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)', marginBottom: 0 }}
|
||||
bodyStyle={{ padding: '12px' }}
|
||||
@@ -466,7 +466,7 @@ const BasicSettings = () => {
|
||||
{[
|
||||
{ x: 60, y: 40, icon: <Cpu size={10} />, label: t('home.inverter') },
|
||||
{ x: 140, y: 40, icon: <Box size={10} />, label: t('home.combinerBox') },
|
||||
{ x: 160, y: 80, icon: <Wind size={10} />, label: t('video.s0') },
|
||||
{ x: 160, y: 80, icon: <Wind size={10} />, label: t('video.WeatherStation') },
|
||||
{ x: 140, y: 120, icon: <Camera size={10} />, label: t('devices.camera') },
|
||||
{ x: 60, y: 120, icon: <Activity size={10} />, label: t('devices.robot') },
|
||||
{ x: 40, y: 80, icon: <Zap size={10} />, label: t('systemSetting.s38') },
|
||||
|
||||
@@ -356,7 +356,7 @@ export default function DroneManagement({
|
||||
pageSize: droneParams.pageSize,
|
||||
total: droneTotal,
|
||||
showSizeChanger: true,
|
||||
showTotal: t => `${t('common.total')} ${t} ${t('common.items')}`,
|
||||
showTotal: r => `${t('common.total')} ${r} ${t('common.items')}`,
|
||||
onChange: (page, pageSize) => {
|
||||
setDroneParams({ ...droneParams, pageNum: page, pageSize });
|
||||
},
|
||||
|
||||
@@ -171,7 +171,7 @@ export default function MenuList() {
|
||||
)}
|
||||
<Button type="text" icon={<EditOutlined />} onClick={() => handleEdit(record)}>{t('roles.edit')}</Button>
|
||||
<Popconfirm title={t('common.confirmDelete')} onConfirm={() => handleDelete(record.menuId)}>
|
||||
<Button type="text" danger>roles.delete</Button>
|
||||
<Button type="text" danger>{t('roles.delete')}</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
@@ -212,7 +212,7 @@ export default function MenuList() {
|
||||
|
||||
{/* 菜单弹窗 */}
|
||||
<Modal
|
||||
title={editMenu ? '编辑菜单' : '新增菜单'}
|
||||
title={editMenu ? t('systemSetting.editMenu') : t('systemSetting.addMenu')}
|
||||
open={menuModal}
|
||||
width={600}
|
||||
onCancel={() => setMenuModal(false)}
|
||||
|
||||
@@ -115,7 +115,7 @@ const OnlineUserPage = () => {
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span>profile.username</span>
|
||||
<span>{t('profile.username')}</span>
|
||||
<Input
|
||||
placeholder={t('systemSetting.fixed2PleaseEnterFixed2UsernameFixed2')}
|
||||
value={searchParams.userName}
|
||||
|
||||
@@ -404,7 +404,7 @@ export default function SmartDeviceManagement({
|
||||
pageSize: smartParams.pageSize,
|
||||
total: smartTotal,
|
||||
showSizeChanger: true,
|
||||
showTotal: (t) => `${t('common.total')} ${t} ${t('common.items')}`,
|
||||
showTotal: (r) => `${t('common.total')} ${r} ${t('common.items')}`,
|
||||
onChange: (page, pageSize) => {
|
||||
setSmartParams({ pageNum: page, pageSize });
|
||||
},
|
||||
@@ -484,7 +484,7 @@ export default function SmartDeviceManagement({
|
||||
))}
|
||||
</Select>
|
||||
</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
|
||||
placeholder={t('systemSetting.leaderFixed2')}
|
||||
allowClear
|
||||
|
||||
@@ -264,7 +264,7 @@ export default function StationManage() {
|
||||
<Button icon={<BgColorsOutlined />} onClick={() => handleOpenArea(record)}>{t('systemSetting.settingsFixed2')}</Button>
|
||||
<Button onClick={() => handleOpenMap(record)}>{t('systemSetting.s110')}</Button>
|
||||
<Popconfirm title={t('common.confirmDelete')} onConfirm={() => handleDelete(record.id)}>
|
||||
<Button danger>roles.delete</Button>
|
||||
<Button danger>{t('roles.delete')}</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
@@ -319,7 +319,7 @@ export default function StationManage() {
|
||||
|
||||
{/* 场站弹窗 */}
|
||||
<Modal
|
||||
title={editRecord ? '编辑场站' : '新增场站'}
|
||||
title={editRecord ? t('systemSetting.editSite') : t('systemSetting.addSite')}
|
||||
open={modalVisible}
|
||||
width={680}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
@@ -497,9 +497,9 @@ export default function StationManage() {
|
||||
footer={null}
|
||||
>
|
||||
<div style={{ height: 400, background: '#f5f5f5', borderRadius: 8, display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>{t('systemSetting.area')}<Space style={{ marginTop: 20 }}>
|
||||
<Button type="primary">{t('systemSetting.s8')}</Button>
|
||||
<Button>{t('systemSetting.fixed2Save')}</Button>
|
||||
</Space>
|
||||
<Button type="primary">{t('systemSetting.s8')}</Button>
|
||||
<Button>{t('systemSetting.fixed2Save')}</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Modal>
|
||||
</div>
|
||||
|
||||
@@ -410,7 +410,7 @@ export default function UserRolePage() {
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||
{selectedUserIds.length > 0 && (
|
||||
<Button danger onClick={handleBatchDeleteUsers}>
|
||||
批量删除(已选 {selectedUserIds.length} 项)
|
||||
{t('systemSetting.batchDelete')} {selectedUserIds.length} {t('systemSetting.deleteUnit')}
|
||||
</Button>
|
||||
)}
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAddUser}>{t('users.addUser')}</Button>
|
||||
@@ -498,7 +498,7 @@ export default function UserRolePage() {
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
|
||||
{selectedRoleIds.length > 0 && (
|
||||
<Button danger onClick={handleBatchDeleteRoles}>
|
||||
批量删除(已选 {selectedRoleIds.length} 项)
|
||||
{t("systemSetting.batchDelete")}{selectedRoleIds.length}{t("systemSetting.deleteunit")}
|
||||
</Button>
|
||||
)}
|
||||
<Button type="primary" icon={<PlusOutlined />} onClick={handleAddRole}>{t('roles.addRole')}</Button>
|
||||
@@ -512,7 +512,7 @@ export default function UserRolePage() {
|
||||
actions={[
|
||||
<Button type="text" icon={<EditOutlined />} onClick={() => handleEditRole(r)}>{t('roles.edit')}</Button>,
|
||||
<Popconfirm onConfirm={() => handleDeleteRole(r.roleId)} title={t('common.confirmDelete')}>
|
||||
<Button type="text" danger>roles.delete</Button>
|
||||
<Button type="text" danger>{t('roles.delete')}</Button>
|
||||
</Popconfirm>
|
||||
]}
|
||||
>
|
||||
@@ -532,8 +532,8 @@ export default function UserRolePage() {
|
||||
title={<strong>{r.roleName}</strong>}
|
||||
description={
|
||||
<Space direction="vertical" size={2}>
|
||||
<span>权限:{r.roleKey}</span>
|
||||
<span>等级:{r.roleLevel || '-'}</span>
|
||||
<span>{t('systemSetting.permission')}:{r.roleKey}</span>
|
||||
<span>{t('systemSetting.level')}:{r.roleLevel || '-'}</span>
|
||||
{/*{r.roleKey == "admin1" && <Tag color="red">{t('roles.superAdmin')}</Tag>}*/}
|
||||
</Space>
|
||||
}
|
||||
@@ -566,7 +566,7 @@ export default function UserRolePage() {
|
||||
|
||||
{/* 角色弹窗 */}
|
||||
<Modal
|
||||
title={editRole ? '编辑角色' : t('roles.addRole')}
|
||||
title={editRole ? t('roles.editRole') : t('roles.addRole')}
|
||||
open={roleModalVisible}
|
||||
onCancel={() => setRoleModalVisible(false)}
|
||||
onOk={handleSaveRole}
|
||||
@@ -600,7 +600,7 @@ export default function UserRolePage() {
|
||||
|
||||
{userInfo?.roleId == 23 && (
|
||||
<>
|
||||
<Divider>roles.menuPermissions</Divider>
|
||||
<Divider>{t("roles.menuPermissions")}</Divider>
|
||||
<Tree
|
||||
checkable
|
||||
treeData={menuTree}
|
||||
|
||||
@@ -182,9 +182,7 @@ const VideoManagement = () => {
|
||||
<div style={{ padding: '8px 0px', background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.1vw, 18px)' }}>{t('router.videoManage')}</Title>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
录像通道与回放管理 · 共 {channels.length} 个通道
|
||||
</Text>
|
||||
|
||||
</div>
|
||||
|
||||
<Card bordered={false} style={{ borderRadius: 10, marginBottom: 8 }} bodyStyle={{ padding: 12 }}>
|
||||
|
||||
@@ -178,7 +178,6 @@ const WorkOrderModelManagement: React.FC = () => {
|
||||
}, [stationId]);
|
||||
|
||||
const handleAdd = () => {
|
||||
const { t } = useTranslation();
|
||||
setEditingItem(null);
|
||||
form.resetFields();
|
||||
setSelectedDeviceType(null);
|
||||
|
||||
@@ -61,44 +61,50 @@ class WebSocketManager {
|
||||
// ==================== 连接管理 ====================
|
||||
|
||||
public connect(serialNumber: string, wsUrl: string): void {
|
||||
console.log("创建开始");//ws://192.168.2.56:9002/ws/
|
||||
// 清除之前的重连计时器
|
||||
console.log("创建开始");
|
||||
|
||||
// 清除重连计时器
|
||||
if (this.reconnectTimer) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
this.reconnectTimer = null;
|
||||
}
|
||||
|
||||
if (serialNumber == null || serialNumber.trim() === "") {
|
||||
console.log("serialNumber 是空/空白,停止执行");
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果序列号相同且已连接,跳过
|
||||
if (this.ws && this.currentSerialRef === serialNumber && this.status === 'connected') {
|
||||
console.log('WebSocket already connected for this device');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果序列号不同,先关闭旧连接
|
||||
if (this.ws && this.currentSerialRef !== serialNumber) {
|
||||
// ========== 重点修复:关闭旧连接,并且清空旧ws的事件监听,防止旧消息回调执行 ==========
|
||||
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.ws = null;
|
||||
}
|
||||
|
||||
this.currentSerialRef = serialNumber;
|
||||
this.setStatus('connecting');
|
||||
this.isManualCloseRef = false;
|
||||
// 提前赋值,不要等到new WebSocket之后
|
||||
this.wsSerialRef = serialNumber;
|
||||
|
||||
console.log('Connecting WebSocket for', serialNumber);
|
||||
|
||||
|
||||
if (serialNumber == null || serialNumber.trim() === "") {
|
||||
console.log("serialNumber 是空/空白,停止执行");
|
||||
return;
|
||||
}
|
||||
|
||||
this.ws = new WebSocket(wsUrl);
|
||||
this.wsSerialRef = serialNumber;
|
||||
|
||||
this.ws.onopen = () => {
|
||||
console.log('WebSocket Connected');
|
||||
this.setStatus('connected');
|
||||
|
||||
|
||||
const dataStr = localStorage.getItem('userInfo');
|
||||
if (!dataStr) {
|
||||
console.error('用户信息未找到,无法发送认证包');
|
||||
@@ -109,18 +115,21 @@ class WebSocketManager {
|
||||
|
||||
console.log('WebSocket%', token);
|
||||
console.log('WebSocket%', parse);
|
||||
console.log("开始发送认证包");//ws://192.168.2.56:9002/ws/
|
||||
// 发送 AUTH 认证消息
|
||||
console.log("开始发送认证包");
|
||||
this.send({
|
||||
type: 'AUTH',
|
||||
token: token,
|
||||
userName: parse.username,
|
||||
deviceId: serialNumber,
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
this.ws.onmessage = (event) => {
|
||||
// 【防御二次校验】只有当前活跃serial才处理消息,旧连接残留消息直接丢弃
|
||||
if (this.wsSerialRef !== this.currentSerialRef) {
|
||||
console.log('丢弃过期ws消息');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
this.handleMessage(data);
|
||||
@@ -137,7 +146,7 @@ class WebSocketManager {
|
||||
const { code, reason, wasClean } = event;
|
||||
console.log('[WebSocket closed]', 'code =', code, 'reason =', reason || '(no reason)', 'wasClean =', wasClean);
|
||||
|
||||
// 如果不是当前设备的 ws,忽略
|
||||
// 不是当前设备直接忽略
|
||||
if (this.wsSerialRef !== this.currentSerialRef) {
|
||||
console.log('🟡 ignore old ws close');
|
||||
return;
|
||||
@@ -146,15 +155,13 @@ class WebSocketManager {
|
||||
this.ws = null;
|
||||
this.setStatus('disconnected');
|
||||
|
||||
// 主动关闭不重连
|
||||
if (this.isManualCloseRef || !this.currentSerialRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 5 秒后自动重连
|
||||
this.reconnectTimer = setTimeout(() => {
|
||||
if (this.currentSerialRef === this.wsSerialRef) {
|
||||
this.connect(this.currentSerialRef, wsUrl);
|
||||
this.connect(this.currentSerialRef!, wsUrl);
|
||||
}
|
||||
}, 5000);
|
||||
};
|
||||
@@ -164,21 +171,17 @@ class WebSocketManager {
|
||||
|
||||
public close(): void {
|
||||
this.isManualCloseRef = true;
|
||||
|
||||
if (this.reconnectTimer) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
this.reconnectTimer = null;
|
||||
}
|
||||
|
||||
if (this.ws) {
|
||||
console.log('Closing WebSocket');
|
||||
this.ws.close();
|
||||
this.ws = null;
|
||||
try {
|
||||
this.ws.close(1000, 'manual close');
|
||||
} 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) => {
|
||||
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 => {
|
||||
if (res?.data?.code === 200 && res?.data?.data?.remoteControl == true) {
|
||||
console.log("获取远程遥控权限成功");
|
||||
|
||||
@@ -474,31 +474,31 @@ export default function DeviceOverviewPage() {
|
||||
title: t('devices.fixed2DroneAirportFixed2StatusFixed2'),
|
||||
icon: <EnvironmentOutlined style={{ color: '#165DFF', fontSize: 24 }} />,
|
||||
value: `${onlineDrones} / ${totalDrones}`,
|
||||
sub: `可调度 ${onlineDrones} 架`,
|
||||
sub: `${t('devices.distributable')} ${onlineDrones} ${t('devices.UnitsDrone')}`,
|
||||
color: '#165DFF',
|
||||
iconBg: '#E8F3FF'
|
||||
},
|
||||
{
|
||||
title: t('home.inspectionRobot'),
|
||||
icon: <RobotOutlined style={{ color: '#13c2c2', fontSize: 24 }} />,
|
||||
value: `${totalRobots} 台`,
|
||||
sub: `执行中 ${activeRobots}`,
|
||||
value: `${totalRobots} ${t('devices.UnitsRobot')}`,
|
||||
sub: `${t('devices.executing')} ${activeRobots}`,
|
||||
color: '#13c2c2',
|
||||
iconBg: '#E6FFFA'
|
||||
},
|
||||
{
|
||||
title: t('devices.mowingRobot'),
|
||||
icon: <CarOutlined style={{ color: '#722ED1', fontSize: 24 }} />,
|
||||
value: `${totalMowers} 台`,
|
||||
sub: `任务中 ${activeMowers}`,
|
||||
value: `${totalMowers} ${t('devices.UnitsRobot')}`,
|
||||
sub: `${t('devices.executing')} ${activeMowers}`,
|
||||
color: '#722ED1',
|
||||
iconBg: '#F9F0FF'
|
||||
},
|
||||
{
|
||||
title: t('devices.washDrone'),
|
||||
icon: <CloudOutlined style={{ color: '#eb2f96', fontSize: 24 }} />,
|
||||
value: `${totalDrones} 架`,
|
||||
sub: `待命 ${washDroneStandby}`,
|
||||
value: `${totalDrones} ${t('devices.UnitsDrone')}`,
|
||||
sub: `${t('devices.waiting')} ${washDroneStandby}`,
|
||||
color: '#eb2f96',
|
||||
iconBg: '#FFF1F3'
|
||||
},
|
||||
@@ -514,7 +514,7 @@ export default function DeviceOverviewPage() {
|
||||
title: t('devices.todayTaskExecute'),
|
||||
icon: <CheckCircleOutlined style={{ color: '#2f54eb', fontSize: 24 }} />,
|
||||
value: `${completedTasks} / ${totalTasks}`,
|
||||
sub: `完成率 ${completionRate}%`,
|
||||
sub: `${t('devices.completionRate')} ${completionRate}%`,
|
||||
color: '#2f54eb',
|
||||
iconBg: '#E8F3FF'
|
||||
},
|
||||
@@ -779,7 +779,7 @@ export default function DeviceOverviewPage() {
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||
<span style={{ color: '#52c41a' }}><ThunderboltOutlined /></span>
|
||||
<span style={{ fontSize: 12 }}>电量 {fix2(realtimeDevice?.capacity_percent || realtimeDevice?.lastRunningStatus?.battery || 100)}%</span>
|
||||
<span style={{ fontSize: 12 }}>{t('devices.batteryLevel')}: {fix2(realtimeDevice?.capacity_percent || realtimeDevice?.lastRunningStatus?.battery || 100)}%</span>
|
||||
</div>
|
||||
{realtimeDevice?.environment_temperature && (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {
|
||||
import React, {
|
||||
useState,
|
||||
useEffect,
|
||||
useMemo,
|
||||
@@ -78,6 +78,7 @@ export default function DeviceStatusPage() {
|
||||
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
|
||||
const [isLoopMode, setIsLoopMode] = useState(true);
|
||||
const controllerRef = useRef<DeviceController | null>(null);
|
||||
const isFirstConnect = useRef(true);
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
|
||||
@@ -95,6 +96,7 @@ export default function DeviceStatusPage() {
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
const [wsStatus, setWsStatus] = useState('disconnected');
|
||||
const [wsDeviceInfo, setWsDeviceInfo] = useState({});
|
||||
const [locationInfo, setLocationInfo] = useState({});
|
||||
|
||||
|
||||
// 👇 加上这两个
|
||||
@@ -388,7 +390,7 @@ export default function DeviceStatusPage() {
|
||||
|
||||
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 {};
|
||||
}
|
||||
if (isUAV) {
|
||||
@@ -403,8 +405,9 @@ export default function DeviceStatusPage() {
|
||||
: {
|
||||
...base,
|
||||
...wsDeviceInfo,
|
||||
...locationInfo
|
||||
};
|
||||
}, [device, wsDeviceInfo, isUAV]);
|
||||
}, [device, wsDeviceInfo, isUAV, locationInfo]);
|
||||
|
||||
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
||||
(!isUAV && isVideoPlaying) ? (device?.serialNumber || '') : '',
|
||||
@@ -433,8 +436,8 @@ export default function DeviceStatusPage() {
|
||||
}
|
||||
|
||||
// 2. 机器人:从 wsDeviceInfo / runningStatus 取实时经纬度
|
||||
const robotLon = runningStatus.longitude || wsDeviceInfo.longitude;
|
||||
const robotLat = runningStatus.latitude || wsDeviceInfo.latitude;
|
||||
const robotLon = runningStatus.longitude || locationInfo.longitude;
|
||||
const robotLat = runningStatus.latitude || locationInfo.latitude;
|
||||
|
||||
if (robotLon && robotLat) {
|
||||
return {
|
||||
@@ -453,6 +456,7 @@ export default function DeviceStatusPage() {
|
||||
const controller = new DeviceController(userInfo, messageApi);
|
||||
|
||||
controller.onDeviceInfoUpdate = setWsDeviceInfo;
|
||||
controller.onLocationInfoUpdate = setLocationInfo;
|
||||
controller.onControlStatusChange = setIsControlled;
|
||||
controller.onHasControlRightChange = setHasControlRight;
|
||||
controller.onRequestControlStatusChange = setConnecting;
|
||||
@@ -480,13 +484,19 @@ export default function DeviceStatusPage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) {
|
||||
//controllerRef.current?.destroy();
|
||||
//setWsDeviceInfo({});
|
||||
return;
|
||||
}
|
||||
setWsDeviceInfo({});
|
||||
setLocationInfo({});
|
||||
|
||||
controllerRef.current.connectDevice(device);
|
||||
if (isFirstConnect.current) {
|
||||
|
||||
isFirstConnect.current = false;
|
||||
controllerRef.current.connectDevice(device);
|
||||
} else {
|
||||
|
||||
controllerRef.current.switchDevice(device);
|
||||
}
|
||||
|
||||
}, [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 () => {
|
||||
if (!plotName.trim()) {
|
||||
messageApi.warning(t('devices.inputPlotName'));
|
||||
@@ -761,6 +674,15 @@ export default function DeviceStatusPage() {
|
||||
|
||||
setIsSaving(true);
|
||||
try {
|
||||
// ✅重点:接收handleComplete返回的path数据,不再读组件savePath state
|
||||
const pathResult = await handleComplete();
|
||||
if (!pathResult) {
|
||||
messageApi.warning(t('devices.saveFail'));
|
||||
|
||||
// 路径规划失败/校验不通过直接终止
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 获取地图截图
|
||||
let screenshotDataUrl = null;
|
||||
if (mapRef.current) {
|
||||
@@ -776,18 +698,20 @@ export default function DeviceStatusPage() {
|
||||
const file = dataUrlToFile(screenshotDataUrl, "screenshot.jpg");
|
||||
console.log("blob", file)
|
||||
|
||||
|
||||
if (file instanceof File) {
|
||||
formData.append('file', file);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 添加 workRecord
|
||||
// 4. 添加 workRecord,直接使用函数返回的 pathResult,不读取state savePath
|
||||
const workRecord = {
|
||||
workName: plotName,
|
||||
siteId: stationId,
|
||||
jsonData: savePath,
|
||||
orgId: currentStation?.orgId,
|
||||
jsonData: pathResult, // 直接用返回值,彻底规避state异步延迟
|
||||
mode: isLoopMode ? "coverage" : "single_point",//"区域还是单点"
|
||||
};
|
||||
console.log("workRecord", workRecord)
|
||||
formData.append(
|
||||
"workRecord",
|
||||
new Blob([JSON.stringify(workRecord)], {
|
||||
@@ -795,8 +719,6 @@ export default function DeviceStatusPage() {
|
||||
})
|
||||
);
|
||||
|
||||
//formData.append('workRecord', JSON.stringify(workRecord));
|
||||
|
||||
// 5. 调用保存接口
|
||||
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(() => {
|
||||
return isUAV ? 'plane' : 'car';
|
||||
}, [isUAV]);
|
||||
@@ -856,8 +867,8 @@ export default function DeviceStatusPage() {
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
|
||||
<Text strong>{t('devices.pathPlanning')}:</Text>
|
||||
<Text type="secondary">{t('devices.markedPointsCount', { count: markedPoints.length })}</Text>
|
||||
<Text strong>{t('devices.pathPlanning')}:</Text>
|
||||
<Text type="secondary">{t('devices.markedPointsCount', { count: markedPoints.length })}</Text>
|
||||
</div>
|
||||
<Space size="middle">
|
||||
<Space>
|
||||
@@ -882,18 +893,18 @@ export default function DeviceStatusPage() {
|
||||
>
|
||||
{t('devices.clearMarks')}
|
||||
</Button>
|
||||
<Button
|
||||
{/*<Button
|
||||
type="primary"
|
||||
ghost
|
||||
onClick={handleComplete}
|
||||
disabled={markedPoints.length < 2}
|
||||
>
|
||||
{t('devices.complete')}
|
||||
</Button>
|
||||
</Button>*/}
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={handleOpenSaveModal}
|
||||
disabled={!completeFlag}
|
||||
//disabled={!completeFlag}
|
||||
>
|
||||
{t('common.save')}
|
||||
</Button>
|
||||
@@ -961,7 +972,7 @@ export default function DeviceStatusPage() {
|
||||
title={
|
||||
<>
|
||||
<VideoCameraOutlined />
|
||||
{t('devices.stationVideo')}
|
||||
{t('devices.stationVideo')}
|
||||
</>
|
||||
}
|
||||
bordered={false}
|
||||
@@ -1039,7 +1050,7 @@ export default function DeviceStatusPage() {
|
||||
title={
|
||||
<>
|
||||
<VideoCameraOutlined />
|
||||
{t('devices.droneVideo')}
|
||||
{t('devices.droneVideo')}
|
||||
</>
|
||||
}
|
||||
bordered={false}
|
||||
@@ -1103,33 +1114,33 @@ export default function DeviceStatusPage() {
|
||||
}}>
|
||||
<div style={{ marginBottom: 6, fontWeight: 600, color: '#1890ff' }}>{t('devices.robotStatus')}</div>
|
||||
<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' }}>
|
||||
{runningStatus.battery !== undefined ? `${runningStatus.battery}%` : '-'}
|
||||
</span>
|
||||
<span>{t('devices.rtVoltage')}</span>
|
||||
<span>{t('devices.rtVoltage')}:</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>{t('devices.rtRightMotor')}</span>
|
||||
<span>{t('devices.rtRightMotor')}:</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>{t('devices.rtRightSpeed')}</span>
|
||||
<span>{t('devices.rtRightSpeed')}:</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>{t('devices.rtRightTemp')}</span>
|
||||
<span>{t('devices.rtRightTemp')}:</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>{t('devices.rtHeadingAngle')}</span>
|
||||
<span>{t('devices.rtHeadingAngle')}:</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>{t('devices.rtHeadingStatus')}</span>
|
||||
<span>{t('devices.rtHeadingStatus')}:</span>
|
||||
<span>{runningStatus.headingStatus !== undefined ? `${runningStatus.headingStatus == 1 ? t('devices.rtInitialized') : t('devices.uninitialized')}` : '-'}</span>
|
||||
<span>{t('devices.rtPositioning')}</span>
|
||||
<span>{t('devices.rtPositioning')}:</span>
|
||||
<span>
|
||||
{runningStatus.qual == 0 ? t('constants.locationInvalid') :
|
||||
runningStatus.qual == 1 ? t('devices.gpsSingle') :
|
||||
@@ -1137,9 +1148,9 @@ export default function DeviceStatusPage() {
|
||||
runningStatus.qual == 4 ? t('devices.rtkFixed2') :
|
||||
runningStatus.qual == 5 ? t('devices.rtkFloat') : t('constants.locationUnknown')}
|
||||
</span>
|
||||
<span>{t('devices.rtSatellites')}</span>
|
||||
<span>{t('devices.rtSatellites')}:</span>
|
||||
<span>{t('devices.satelliteCount', { count: runningStatus.satelliteCnt || 0 })}</span>
|
||||
<span>{t('devices.rtMode')}</span>
|
||||
<span>{t('devices.rtMode')}:</span>
|
||||
<span>
|
||||
{runningStatus.controlMode == 1 ? t('devices.localMode') :
|
||||
runningStatus.controlMode == 3 ? t('devices.remoteMode') : t('constants.locationUnknown')}
|
||||
@@ -1322,7 +1333,7 @@ export default function DeviceStatusPage() {
|
||||
title={
|
||||
<>
|
||||
<ControlOutlined />
|
||||
{t('devices.remoteControl')}
|
||||
{t('devices.remoteControl')}
|
||||
</>
|
||||
}
|
||||
bordered={false}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import {
|
||||
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
|
||||
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
|
||||
Modal, InputNumber,
|
||||
TimePicker,
|
||||
Popconfirm,
|
||||
App
|
||||
App,
|
||||
Radio
|
||||
} from 'antd';
|
||||
import {
|
||||
PlusOutlined, ImportOutlined, NodeIndexOutlined,
|
||||
@@ -35,6 +36,7 @@ import {
|
||||
getSiteDeviceTaskHistory,
|
||||
getRouteByTask,
|
||||
deleteRoute,
|
||||
getTaskPath,
|
||||
} from '../../api/device';
|
||||
import dayjs from 'dayjs';
|
||||
import DraggableBox from '../Draggable';
|
||||
@@ -116,6 +118,8 @@ export default function RobotTaskPage() {
|
||||
robot: 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 controllerRef = useRef<DeviceController | null>(null);
|
||||
const isFirstConnect = useRef(true);
|
||||
const handleFinish = (data) => {
|
||||
setExecute(false);
|
||||
setShowVideo(false); // 任务完成关闭视频
|
||||
@@ -236,7 +241,7 @@ export default function RobotTaskPage() {
|
||||
setExecute(true);
|
||||
setExecutingRobot(targetDevice);
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -244,7 +249,7 @@ export default function RobotTaskPage() {
|
||||
useEffect(() => {
|
||||
const controller = new DeviceController(userInfo, messageApi);
|
||||
|
||||
controller.onDeviceInfoUpdate = setRobotRealtimePosition;
|
||||
controller.onLocationInfoUpdate = setRobotRealtimePosition;
|
||||
controller.onIsFinished = handleFinish;
|
||||
controller.handleArrivedPoint = handleFinishEdPoint;
|
||||
|
||||
@@ -296,7 +301,7 @@ export default function RobotTaskPage() {
|
||||
setExecute(true);
|
||||
setExecutingRobot(targetDevice);
|
||||
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);
|
||||
|
||||
}, [devices, taskPoolList, executingRobot, runningPoolTask]);
|
||||
@@ -394,22 +399,14 @@ export default function RobotTaskPage() {
|
||||
// 调用接口获取路线详情
|
||||
const fetchRouteDetail = async () => {
|
||||
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) {
|
||||
let pathPoints = [];
|
||||
let outerPoints = [];
|
||||
let method = '';//0弓子 2 回子
|
||||
|
||||
try {
|
||||
// 尝试解析 JSON
|
||||
if (res.data.jsonData) {
|
||||
const data = typeof res.data.jsonData === 'string'
|
||||
? JSON.parse(res.data.jsonData)
|
||||
: res.data.jsonData;
|
||||
pathPoints = data?.path || [];
|
||||
outerPoints = data?.outer || [];
|
||||
method = data?.planModel;
|
||||
|
||||
}
|
||||
pathPoints = res.data || [];
|
||||
} catch (err) {
|
||||
console.error('解析路线数据失败:', err);
|
||||
}
|
||||
@@ -417,15 +414,9 @@ export default function RobotTaskPage() {
|
||||
if (pathPoints.length === 0) {
|
||||
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 {
|
||||
setPoints([]);
|
||||
}
|
||||
@@ -460,7 +451,7 @@ export default function RobotTaskPage() {
|
||||
setExecute(true);
|
||||
setExecutingRobot(targetDevice);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -566,7 +557,7 @@ export default function RobotTaskPage() {
|
||||
fetchTaskList();
|
||||
fetchTaskPoolList();
|
||||
fetchTaskHistoryList();
|
||||
controllerRef.current?.connectDevice(selectedRobotForExecute);
|
||||
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(selectedRobotForExecute); } else { controllerRef.current?.switchDevice(selectedRobotForExecute); }
|
||||
setShowVideo(true); // 连接成功后自动打开视频
|
||||
|
||||
} else {
|
||||
@@ -653,13 +644,14 @@ export default function RobotTaskPage() {
|
||||
};
|
||||
|
||||
// 取消任务
|
||||
const handleCancelTask = async (task) => {
|
||||
const handleCancelTask = async (task, mode) => {
|
||||
try {
|
||||
const params = {
|
||||
taskId: task.id,
|
||||
//deviceId: task.deviceId,
|
||||
siteId: stationId,
|
||||
orgId: task.orgId,
|
||||
forceCancel: mode === 'force' ? true : false,
|
||||
};
|
||||
const res = await cancelRoute(params);
|
||||
if (res.code === 200 && res.data == true) {
|
||||
@@ -832,15 +824,17 @@ export default function RobotTaskPage() {
|
||||
dataIndex: 'taskStaus',
|
||||
width: 100,
|
||||
render: (status, record) => {
|
||||
console.log('status', status, record);
|
||||
const statusMap = {
|
||||
'NEW': { color: 'default', text: t('devices.statusNew') },
|
||||
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
|
||||
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
||||
'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') };
|
||||
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') },
|
||||
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
||||
'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') };
|
||||
return <Tag color={item.color}>{item.text}</Tag>;
|
||||
@@ -909,27 +904,46 @@ export default function RobotTaskPage() {
|
||||
|
||||
<>
|
||||
{/*{record.taskStaus === 'NEW' && (*/}
|
||||
<Popconfirm
|
||||
title={t('devices.confirmCancelTask')}
|
||||
onConfirm={() => handleCancelTask(record)}
|
||||
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>
|
||||
<Popconfirm
|
||||
title={t('devices.confirmCancelTask')}
|
||||
description={
|
||||
<Radio.Group
|
||||
value={cancelMode}
|
||||
onChange={(e) => setCancelMode(e.target.value)}
|
||||
style={{ marginTop: 8 }}
|
||||
>
|
||||
<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' && (*/}
|
||||
<Popconfirm
|
||||
title={t('devices.confirmPauseTask')}
|
||||
onConfirm={() => handlePauseTask(record)}
|
||||
okText={t('common.ok')} cancelText={t('common.cancel')}
|
||||
>
|
||||
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
|
||||
{t('video.pause')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
title={t('devices.confirmPauseTask')}
|
||||
onConfirm={() => handlePauseTask(record)}
|
||||
okText={t('common.ok')} cancelText={t('common.cancel')}
|
||||
>
|
||||
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
|
||||
{t('video.pause')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
{/*)}/*/}
|
||||
|
||||
{record.taskStaus === 'PAUSE' && (
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isConnecting, hasControlRight }) => {
|
||||
const { t } = useTranslation();
|
||||
const [gamepadState, setGamepadState] = useState<{
|
||||
buttons: boolean[];
|
||||
axes: number[];
|
||||
@@ -115,7 +116,7 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
|
||||
return (
|
||||
<div className="relative h-[252px] aspect-[4/3] flex items-center justify-center "
|
||||
onClick={() => {
|
||||
if (connected && !isControlled && hasControlRight) {
|
||||
if (!isControlled) {
|
||||
console.log("点击了无控制权限,发起权限请求");
|
||||
// 示例:调用你代码中已有的权限请求弹窗逻辑
|
||||
handleControlModal({ control: true, type: "switchPermission" });
|
||||
@@ -124,7 +125,7 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
|
||||
{/* Gamepad Status Badge */}
|
||||
<div
|
||||
className={`absolute top-0 right-0 px-2 py-0.5 rounded text-[8px] font-bold tracking-widest border
|
||||
${connected || !hasControlRight
|
||||
${connected
|
||||
? isConnecting
|
||||
? 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30'
|
||||
: isControlled
|
||||
@@ -135,15 +136,13 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
|
||||
`}
|
||||
>
|
||||
{!connected ? (
|
||||
'未连接设备'
|
||||
) : !hasControlRight ? (
|
||||
'其他 Web 端已连接'
|
||||
t('devices.controllerNotConnected')
|
||||
) : isConnecting ? (
|
||||
'请求控制中...'
|
||||
t('devices.control2')
|
||||
) : isControlled ? (
|
||||
'控制中'
|
||||
t('devices.controlling')
|
||||
) : (
|
||||
'点击获取控制权限'
|
||||
t('devices.clickToRequestControl')
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import throttle from 'lodash/throttle';
|
||||
import { wsManager } from '../WebSocketManager.ts';
|
||||
import {
|
||||
getControlRight,
|
||||
getJurisdiction,
|
||||
releaseControl
|
||||
} from '../../api/device.ts';
|
||||
|
||||
import envConfig from '../../../env';
|
||||
@@ -17,7 +17,7 @@ export default class DeviceController {
|
||||
envConfig.WS_URL || 'wss://ri.satabot.com/ws/';
|
||||
|
||||
this.connectedDeviceSn = null;
|
||||
this.currentDevice = null; // 保存当前设备
|
||||
this.currentDevice = null;
|
||||
|
||||
this.requestDeviceId = '';
|
||||
|
||||
@@ -27,11 +27,14 @@ export default class DeviceController {
|
||||
|
||||
this.wsStatus = 'disconnected';
|
||||
this.wsDeviceInfo = {};
|
||||
this.locationInfo = {};
|
||||
|
||||
this.controlTimeout = null;
|
||||
this.keepAliveInterval = null; // 后台保活定时器
|
||||
this.keepAliveInterval = null;
|
||||
|
||||
this.onDeviceInfoUpdate = null;
|
||||
this.onLocationInfoUpdate = null;
|
||||
|
||||
this.onControlStatusChange = null;
|
||||
this.onWsStatusChange = null;
|
||||
this.onHasControlRightChange = null;
|
||||
@@ -43,6 +46,7 @@ export default class DeviceController {
|
||||
this.handleWsMessage = this.handleWsMessage.bind(this);
|
||||
this.handleWsStatus = this.handleWsStatus.bind(this);
|
||||
this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
|
||||
this.handleBeforeUnload = this.handleBeforeUnload.bind(this);
|
||||
|
||||
this.sendGamepad = throttle(
|
||||
this.sendGamepad.bind(this),
|
||||
@@ -55,36 +59,38 @@ export default class DeviceController {
|
||||
this.unSubMessage = wsManager.onMessage(this.handleWsMessage);
|
||||
this.unSubStatus = wsManager.onStatusChange(this.handleWsStatus);
|
||||
|
||||
// ========== 【集成】页面可见性监听 ==========
|
||||
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
||||
document.addEventListener('beforeunload', this.handleBeforeUnload);
|
||||
}
|
||||
levae() {
|
||||
wsManager.close();
|
||||
|
||||
// ========== 【集成】后台保活定时 ==========
|
||||
//this.startKeepAlive();
|
||||
}
|
||||
|
||||
// ========== 【集成】页面切前台重连 ==========
|
||||
handleVisibilityChange() {
|
||||
// 切后台:关闭 WS
|
||||
if (document.visibilityState === 'hidden') {
|
||||
console.log('🔌 页面切后台,关闭 WebSocket');
|
||||
console.log('Page hidden, release control');
|
||||
//this.release();
|
||||
wsManager.close();
|
||||
this.connectedDeviceSn = null;
|
||||
|
||||
|
||||
this.isControlled = false;
|
||||
this.onControlStatusChange?.(false);
|
||||
}
|
||||
if (document.visibilityState === 'visible' && this.currentDevice) {
|
||||
if (!this.currentDevice?.serialNumber) return;
|
||||
console.log('✅ 页面切回前台,自动重连 WebSocket');
|
||||
console.log('Page visible, reconnect WebSocket');
|
||||
setTimeout(() => {
|
||||
this.connectDevice(this.currentDevice);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 【集成】后台保活 ==========
|
||||
handleBeforeUnload() {
|
||||
console.log('Browser closing/refreshing, release control');
|
||||
this.release();
|
||||
}
|
||||
|
||||
startKeepAlive() {
|
||||
this.keepAliveInterval = setInterval(() => {
|
||||
if (
|
||||
@@ -92,47 +98,50 @@ export default class DeviceController {
|
||||
this.wsStatus !== 'connected' &&
|
||||
this.currentDevice?.serialNumber
|
||||
) {
|
||||
console.log('🔄 后台保活:尝试重连 WebSocket');
|
||||
console.log('Keep alive: reconnect WebSocket');
|
||||
this.connectDevice(this.currentDevice);
|
||||
}
|
||||
}, 8000);
|
||||
}
|
||||
release() {
|
||||
if (this.isControlled && this.connectedDeviceSn) {
|
||||
const data = {
|
||||
platform: "web",
|
||||
type: 1
|
||||
};
|
||||
const url = `${envConfig.baseURL}/forward/device/releaseControl`;
|
||||
|
||||
try {
|
||||
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });
|
||||
navigator.sendBeacon(url, blob);
|
||||
} catch (e) {
|
||||
console.error('Failed to send releaseControl beacon:', e);
|
||||
}
|
||||
async release() {
|
||||
if (!this.connectedDeviceSn) return;
|
||||
const data = {
|
||||
platform: 'web',
|
||||
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() {
|
||||
this.clearControlTimeout();
|
||||
|
||||
// 清理保活
|
||||
if (this.keepAliveInterval) {
|
||||
clearInterval(this.keepAliveInterval);
|
||||
this.keepAliveInterval = null;
|
||||
}
|
||||
|
||||
// 移除监听
|
||||
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
||||
document.removeEventListener('beforeunload', this.handleBeforeUnload);
|
||||
|
||||
this.release();
|
||||
this.levae();
|
||||
|
||||
this.unSubMessage?.();
|
||||
this.unSubStatus?.();
|
||||
//this.release();
|
||||
|
||||
//wsManager.close();
|
||||
this.connectedDeviceSn = null;
|
||||
|
||||
}
|
||||
|
||||
handleWsStatus(status) {
|
||||
@@ -148,7 +157,6 @@ export default class DeviceController {
|
||||
async connectDevice(device) {
|
||||
if (!device) return;
|
||||
|
||||
// 保存当前设备,用于保活/重连
|
||||
this.currentDevice = device;
|
||||
if (!device.serialNumber) return;
|
||||
|
||||
@@ -156,31 +164,17 @@ export default class DeviceController {
|
||||
|
||||
this.connectedDeviceSn = null;
|
||||
this.wsDeviceInfo = {};
|
||||
this.locationInfo = {};
|
||||
this.isControlled = false;
|
||||
this.onControlStatusChange?.(false);
|
||||
|
||||
wsManager.close();
|
||||
|
||||
try {
|
||||
const res = await getControlRight({
|
||||
userName: this.userInfo.username,
|
||||
sourceType: 1,
|
||||
token: this.userInfo.token,
|
||||
});
|
||||
|
||||
this.hasControlRight = res?.code === 200 && res.data == true;
|
||||
this.onHasControlRightChange?.(this.hasControlRight);
|
||||
|
||||
console.log('Connecting to', this.wsUrl);
|
||||
wsManager.connect(sn, this.wsUrl);
|
||||
this.connectedDeviceSn = sn;
|
||||
|
||||
if (!this.hasControlRight) {
|
||||
this.messageApi.warning(i18n.t('devices.fixed2OthersControlFixed2'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
await this.getControl(sn);
|
||||
} catch (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) {
|
||||
try {
|
||||
const res = await getJurisdiction({
|
||||
platform: 'web',
|
||||
deviceId: serialnum,
|
||||
token: this.userInfo.token,
|
||||
});
|
||||
|
||||
this.isControlled = res?.code === 200 && res?.data?.remoteControl === true;
|
||||
@@ -206,10 +231,7 @@ export default class DeviceController {
|
||||
|
||||
requestControl() {
|
||||
if (this.isRequestControl) return;
|
||||
if (!this.hasControlRight) {
|
||||
this.messageApi.warning(i18n.t('devices.noneControl'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.isRequestControl = true;
|
||||
this.onRequestControlStatusChange?.(true);
|
||||
@@ -252,7 +274,7 @@ export default class DeviceController {
|
||||
}
|
||||
|
||||
handleWsMessage(msg) {
|
||||
console.log('📨 收到消息:', msg);
|
||||
console.log('WS message:', msg);
|
||||
switch (msg.type) {
|
||||
case 'deviceInfo': {
|
||||
const data = {};
|
||||
@@ -263,6 +285,15 @@ export default class DeviceController {
|
||||
this.onDeviceInfoUpdate?.(data);
|
||||
break;
|
||||
}
|
||||
case 'locationInfo': {
|
||||
const data = {};
|
||||
msg.data.forEach((item) => {
|
||||
data[item.name] = item.value;
|
||||
});
|
||||
this.locationInfo = data;
|
||||
this.onLocationInfoUpdate?.(data);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'AUTH': {
|
||||
if (msg.isAuth) {
|
||||
@@ -277,7 +308,7 @@ export default class DeviceController {
|
||||
this.isRequestControl = false;
|
||||
this.onRequestControlStatusChange?.(false);
|
||||
|
||||
if (msg.success === false || msg?.respond?.switchResult === false) {
|
||||
if (msg?.success === false || msg?.respond?.switchResult === false) {
|
||||
this.isControlled = false;
|
||||
this.onControlStatusChange?.(false);
|
||||
this.messageApi.error({ key: 'control', content: msg.message || i18n.t('devices.controlFailed') });
|
||||
@@ -291,19 +322,16 @@ export default class DeviceController {
|
||||
case "device_task_change": {
|
||||
if (msg.deviceId != this.connectedDeviceSn) return;
|
||||
this.onIsFinished?.(true);
|
||||
console.log('🔌 控制结果任务变更,', msg);
|
||||
|
||||
console.log('task change:', msg);
|
||||
break;
|
||||
}
|
||||
//完成点
|
||||
case "device_task_arrive_point": {
|
||||
if (msg.deviceId != this.connectedDeviceSn) return;
|
||||
|
||||
this.handleArrivedPoint?.(msg.entity);
|
||||
console.log('🔌 到达完成点,', msg);
|
||||
|
||||
console.log('arrive point:', msg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 'switchPermission': {
|
||||
const platform = (msg.platform || '').toLowerCase();
|
||||
if (!platform || platform === 'null') return;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
import WeatherRainy from "@/src/components/Weather/WeatherRainy";
|
||||
|
||||
const zh = {
|
||||
common: {
|
||||
// 按钮
|
||||
@@ -188,7 +190,7 @@ const zh = {
|
||||
|
||||
'3': '3天内',
|
||||
|
||||
fixed2MoreGt: '更多 >',
|
||||
fixed2MoreGt: '更多',
|
||||
|
||||
taskSuspended2Fixed2: '总任务',
|
||||
|
||||
@@ -208,7 +210,7 @@ const zh = {
|
||||
|
||||
generationDeviationFixed2: '整体发电偏差',
|
||||
|
||||
gt: '详细 >',
|
||||
gt: '详细',
|
||||
|
||||
cleaningFixed2Time: '建议清洗时间:',
|
||||
|
||||
@@ -224,17 +226,21 @@ const zh = {
|
||||
|
||||
a05HotspotPvA05018PvA05020StatusAbnormal: 'A05阵列热斑处置建议:建议现场复核PV-A05-018至PV-A05-020组件接线和旁路二极管状态,必要时更换异常组件。',
|
||||
|
||||
fixed2InspectionFixed2TypeFixed2: '巡检类型',
|
||||
InspectionType: '巡检类型',
|
||||
|
||||
fixed2InspectionFixed2TimeFixed2: '巡检时间',
|
||||
|
||||
fixed2Inspection: '巡检人员',
|
||||
InspectionTime: '巡检时间',
|
||||
|
||||
InspectionPerson: '巡检人员',
|
||||
fixed2Battery: '预计提升发电量:',
|
||||
|
||||
cleaningOrderGeneratedSuccessfullyFixed2: '✅ 清洗工单生成成功',
|
||||
|
||||
failedFixed2: '❌ 工单生成接口调用失败',
|
||||
solarPanel: "组件阵列",
|
||||
weatherStation: "气象站",
|
||||
environmentalSensor: "环境传感器",
|
||||
distributable: "可调度",
|
||||
|
||||
},
|
||||
devices: {
|
||||
deviceManagement: '设备管理',
|
||||
@@ -315,10 +321,13 @@ const zh = {
|
||||
statusPaused: '暂停中',
|
||||
statusFinished: '执行成功',
|
||||
statusFailed: '执行失败',
|
||||
statusCanceling: '取消中',
|
||||
confirmDeleteTask: '确定要删除该任务吗?',
|
||||
confirmCancelTask: '确定要取消该任务吗?',
|
||||
confirmPauseTask: '确定要暂停该任务吗?',
|
||||
confirmResumeTask: '确定要恢复该任务吗?',
|
||||
normalCancel: "普通取消",
|
||||
forceCancel: "强制取消",
|
||||
recover: '恢复',
|
||||
statTodayPlan: '今日机器人计划',
|
||||
unitPlan: '条',
|
||||
@@ -407,7 +416,8 @@ const zh = {
|
||||
selectExecDate: '选择执行日期',
|
||||
execTime: '执行时间',
|
||||
saveTask: '保存任务',
|
||||
abMode: '模式',
|
||||
abMode: '自定义模式',
|
||||
saveFail: '保存失败',
|
||||
activatedTime: '已激活时间',
|
||||
aiAction1: 'AI',
|
||||
aiAction2: 'AI',
|
||||
@@ -438,14 +448,14 @@ const zh = {
|
||||
apiRequestException: 'API请求异常',
|
||||
autoFetch: '自动获取',
|
||||
autoResumeFromBreakpoint: '自动恢复从断点',
|
||||
backView: '返回查看',
|
||||
backView: '后视角',
|
||||
batteryCapacity: '电量容量',
|
||||
batteryWithPercent: '电量带百分比',
|
||||
batteryWithValue: '电量带值',
|
||||
blockUnit: '区块单位',
|
||||
boardTaskFetchFail: '看板任务获取失败',
|
||||
boundDrone: '边界无人机',
|
||||
bowMode: '船首模式',
|
||||
bowMode: '弓字模式',
|
||||
canWorkNormally: '可工作正常',
|
||||
cancelReturnHome: '取消返航首页',
|
||||
chargePoint: '充电点',
|
||||
@@ -481,7 +491,7 @@ const zh = {
|
||||
coverClosed: '覆盖已关闭',
|
||||
coverOpen: '覆盖打开',
|
||||
coverageEquipment: '覆盖设备',
|
||||
coverageValue: '覆盖值',
|
||||
coverageValue: '{{types}}/{{units}}',
|
||||
createSuccess: '创建成功',
|
||||
createTaskException: '创建任务异常',
|
||||
createTaskFail: '创建任务失败',
|
||||
@@ -548,11 +558,17 @@ const zh = {
|
||||
fillRequiredFields: '填写必填字段',
|
||||
firmwareVersion: '固件版本',
|
||||
fixed: '固定',
|
||||
controllerNotConnected: "控制器未连接",
|
||||
otherWebConnected: "其他网页已连接",
|
||||
clickToRequestControl: "点击请求控制",
|
||||
|
||||
controlling: "控制中",
|
||||
|
||||
fixed2: '',
|
||||
fixedEnv: '固定环境',
|
||||
flightAltitude: '飞行高度',
|
||||
flightWindSpeed: '飞行风速度',
|
||||
frontView: '前查看',
|
||||
frontView: '前视角',
|
||||
ganttViewTitle: '甘特查看标题',
|
||||
generateTask: '生成任务',
|
||||
gnssQuality: 'GNSS质量',
|
||||
@@ -570,7 +586,7 @@ const zh = {
|
||||
horizontalSpeed: '水平速度',
|
||||
hotspotSuspect: '热斑疑似',
|
||||
inDock: '内停靠',
|
||||
inProgressDesc: '内进度描述',
|
||||
inProgressDesc: '进行中',
|
||||
indoor: '室内',
|
||||
inputCustomAlias: '输入自定义别名',
|
||||
inputPlotName: '输入区域名称',
|
||||
@@ -585,7 +601,7 @@ const zh = {
|
||||
issueTaskFirst: '问题任务先',
|
||||
landingDockSn: '降落停靠序列号',
|
||||
landingDockSnLabel: '降落停靠序列号标签',
|
||||
leftView: '左查看',
|
||||
leftView: '左视角',
|
||||
leftWheelDrive: '左轮驱动',
|
||||
legendTitle: '图例标题',
|
||||
levelHigh: '级别高',
|
||||
@@ -604,12 +620,12 @@ const zh = {
|
||||
loginInfoExpired: '登录提示已过期',
|
||||
lostControlAction: '丢失控制操作',
|
||||
lostControlActionLabel: '丢失控制操作标签',
|
||||
markPoint: '标记点',
|
||||
markPoint: '打点',
|
||||
markedPointsCount: '已标记点数量',
|
||||
minBattery: '最小电量',
|
||||
minBatteryLabel: '最小电量标签',
|
||||
minExecBatteryLabel: '最小执行电量标签',
|
||||
minThreePoints: '最小三点',
|
||||
minThreePoints: '最少三个点',
|
||||
modeAuto: '模式自动',
|
||||
modeDebugLocal: '模式调试本地',
|
||||
modeDebugRemote: '模式调试远程',
|
||||
@@ -709,7 +725,7 @@ const zh = {
|
||||
pathPlanFailRetry: '路径计划失败重试',
|
||||
pathPlanning: '路径规划',
|
||||
pauseTask: '暂停任务',
|
||||
pendingApprovalTasks: '待处理审批任务',
|
||||
pendingApprovalTasks: '待处理任务',
|
||||
pendingExec: '待处理执行',
|
||||
permissionObtained: '权限已获取',
|
||||
permissionRequestTitle: '权限请求标题',
|
||||
@@ -756,7 +772,7 @@ const zh = {
|
||||
returnHomeAltitudeLabel: '返航首页高度标签',
|
||||
returnHomeMode: '返航首页模式',
|
||||
returnHomeModeLabel: '返航首页模式标签',
|
||||
rightView: '右查看',
|
||||
rightView: '右视角',
|
||||
rightWheelDrive: '右轮驱动',
|
||||
robotExecutingCount: '机器人执行中数量',
|
||||
robotInTaskCount: '机器人内任务数量',
|
||||
@@ -798,7 +814,7 @@ const zh = {
|
||||
rtkModeDesc: 'RTK模式描述',
|
||||
rtkStatus: 'RTK状态',
|
||||
safeRthBattery: '安全返航电量',
|
||||
satelliteCount: '卫星数量',
|
||||
satelliteCount: '卫星数量 {{count}}',
|
||||
savePathTitle: '保存路径标题',
|
||||
savePlan: '保存计划',
|
||||
saving: '节省',
|
||||
@@ -912,7 +928,7 @@ const zh = {
|
||||
todayWaylinePlan: '今日航线计划',
|
||||
totalCount: '总数量',
|
||||
trendFlat: '趋势持平',
|
||||
trendYesterday: '趋势昨日',
|
||||
trendYesterday: '较昨日 {{diff}}',
|
||||
typeAIRecheck: '类型AI复检',
|
||||
typeArrayMow: '类型阵列除草',
|
||||
typeComponentClean: '类型组件清洗',
|
||||
@@ -920,10 +936,10 @@ const zh = {
|
||||
typeFenceInspect: '类型围栏巡检',
|
||||
typeHotspotInspect: '类型热斑巡检',
|
||||
typeRecheck: '类型复检',
|
||||
unitGe: '单位地理',
|
||||
unitJia: '单位',
|
||||
unitTai: '单位台',
|
||||
unitTiao: '单位条',
|
||||
unitGe: '个',
|
||||
unitJia: '架',
|
||||
unitTai: '台',
|
||||
unitTiao: '条',
|
||||
unknownDevice: '未知设备',
|
||||
unknownDrone: '未知无人机',
|
||||
unknownObject: '未知对象',
|
||||
@@ -1000,6 +1016,7 @@ const zh = {
|
||||
s6: '遥控接管',
|
||||
|
||||
s7: '规划态势',
|
||||
waiting: '待命',
|
||||
|
||||
taskSuspended2Fixed2: '连续任务',
|
||||
|
||||
@@ -1280,6 +1297,14 @@ const zh = {
|
||||
noneControl: '无控制权限',
|
||||
|
||||
fixed2ControlFixed2: '控制请求超时',
|
||||
executing: "执行中",
|
||||
failed: "失败",
|
||||
cancel: "取消",
|
||||
UnitsRobot: "台",
|
||||
UnitsDrone: "架",
|
||||
platformRequestControl: "{{platform}} 正在请求控制权限",
|
||||
controlFailed: "controlFailed",
|
||||
|
||||
},
|
||||
video: {
|
||||
onlineVideo: '在线视频',
|
||||
@@ -1569,7 +1594,9 @@ const zh = {
|
||||
trendUp: '趋势上升',
|
||||
trendZero: '趋势零',
|
||||
triggerCondition: '触发条件',
|
||||
yesterdayValue: '昨日值',
|
||||
yesterdayValue: '昨日值 {{value}}',
|
||||
enabled: '已启用',
|
||||
|
||||
},
|
||||
aiAnalysis: {
|
||||
title: 'AI诊断分析',
|
||||
@@ -1619,6 +1646,7 @@ const zh = {
|
||||
clickHotspotHint: '点击热斑提示',
|
||||
default: '默认',
|
||||
detect: '检测',
|
||||
algoCountUnit: "检测 + 分割",
|
||||
detectAndSeg: '检测与分割',
|
||||
detectDesc: '检测描述',
|
||||
detectModel: '检测模型',
|
||||
@@ -2008,6 +2036,12 @@ const zh = {
|
||||
orderStatus: '工单状态',
|
||||
priority: '优先级',
|
||||
source: '来源',
|
||||
today: '今天',
|
||||
notitle: '暂无标题',
|
||||
noRelatedArea: '无',
|
||||
|
||||
|
||||
|
||||
execStartTime: '执行开始时间',
|
||||
relatedDevice: '关联设备',
|
||||
relatedArea: '关联区域',
|
||||
@@ -2349,6 +2383,13 @@ const zh = {
|
||||
videoCodecMseNotSupported: '当前浏览器 MSE 不支持该视频编码格式',
|
||||
mediaSourceNotSupported: '当前浏览器不支持 MediaSource 扩展',
|
||||
flvMseHint: '提示:播放 FLV 需要浏览器支持 MSE',
|
||||
everydayPush: '每日推送',
|
||||
Nighttime: '夜间免打扰',
|
||||
WeatherStation: "气象站",
|
||||
batchDelete: '批量删除(已选择',
|
||||
deleteUnit: "项)",
|
||||
level: "等级",
|
||||
|
||||
|
||||
exportLogFileName: '系统日志',
|
||||
exportLogSuccess: '成功导出 {count} 条日志',
|
||||
@@ -2613,6 +2654,9 @@ const zh = {
|
||||
s36: '用户名',
|
||||
|
||||
s37: '关联产品',
|
||||
addMenu: '新增菜单',
|
||||
editSite: '编辑场站',
|
||||
addSite: '新增场站',
|
||||
|
||||
s38: '接口',
|
||||
|
||||
@@ -3355,6 +3399,7 @@ const zh = {
|
||||
roleName: '角色名称',
|
||||
roleKey: '权限字符',
|
||||
roleSort: '排序',
|
||||
editRole: '编辑角色',
|
||||
status: '状态',
|
||||
remark: '备注',
|
||||
actions: '操作',
|
||||
@@ -3369,7 +3414,7 @@ const zh = {
|
||||
abnormal: '异常',
|
||||
addSuccess: '新增成功',
|
||||
confirmDeleteRole: '确认删除角色',
|
||||
editRole: '编辑角色',
|
||||
|
||||
editSuccess: '编辑成功',
|
||||
manageMembers: '管理成员',
|
||||
menuPermissionConfig: '菜单权限配置',
|
||||
@@ -3491,8 +3536,11 @@ const zh = {
|
||||
page: {
|
||||
|
||||
uploadThermal: '请上传热成像文件',
|
||||
stationTopology: '场站拓扑图',
|
||||
|
||||
s0: '外部系统',
|
||||
inverterPowerCompare: '逆变器功率对比',
|
||||
stringCurrentHeatmap: '组串电流热力图(单位:A)',
|
||||
|
||||
|
||||
'2': '已接入 2 套',
|
||||
@@ -3514,6 +3562,11 @@ const zh = {
|
||||
geojson: '面板 GeoJSON',
|
||||
|
||||
s15: '结果展示',
|
||||
online: '在线',
|
||||
offline: '离线',
|
||||
alerts: '告警',
|
||||
all: '总数',
|
||||
|
||||
|
||||
jsonViewFixed2: '原始预览、结果图与完整 JSON 同屏查看',
|
||||
|
||||
|
||||
@@ -4449,7 +4449,7 @@ export default function Agri() {
|
||||
{
|
||||
title: t('aiAnalysis.algoCount'),
|
||||
value: '2',
|
||||
unit: '检测 + 分割',
|
||||
unit: `${t('aiAnalysis.algoCountUnit')}`,
|
||||
icon: <AppstoreOutlined />,
|
||||
color: '#165DFF',
|
||||
bg: '#E8F3FF',
|
||||
|
||||
@@ -384,9 +384,9 @@ export default function StationDashboard() {
|
||||
pagination={false}
|
||||
size="small"
|
||||
columns={[
|
||||
{ title: t('home.fixed2InspectionFixed2TypeFixed2'), dataIndex: 'name', key: 'name', ellipsis: true },
|
||||
{ title: t('home.fixed2InspectionFixed2TimeFixed2'), dataIndex: 'time', key: 'time' },
|
||||
{ title: t('home.fixed2Inspection'), dataIndex: 'person', key: 'person', render: (t) => t.substring(0, 10) },
|
||||
{ title: t('home.InspectionType'), dataIndex: 'name', key: 'name', ellipsis: true },
|
||||
{ title: t('home.InspectionTime'), dataIndex: 'time', key: 'time' },
|
||||
{ title: t('home.InspectionPerson'), dataIndex: 'person', key: 'person', render: (t) => t.substring(0, 10) },
|
||||
{ title: t('roles.status'), dataIndex: 'status', key: 'status', render: () => <span style={{ color: '#52c41a', fontSize: 12 }}>{t('home.completedFixed2')}</span> },
|
||||
]}
|
||||
/>
|
||||
@@ -468,12 +468,12 @@ export default function StationDashboard() {
|
||||
<Card title={<span style={{ fontWeight: 800 }}>{t('home.deviceOnlineStatus')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<Row gutter={[16, 16]}>
|
||||
{[
|
||||
{ name: '组件阵列', count: '320/320', icon: <AppstoreOutlined /> },
|
||||
{ name: t('home.solarPanel'), count: '320/320', icon: <AppstoreOutlined /> },
|
||||
{ name: t('home.inverter'), count: '5/5', icon: <ThunderboltOutlined /> },
|
||||
{ name: t('home.combinerBox'), count: '20/20', icon: <BranchesOutlined /> },
|
||||
{ name: '气象站', count: '1/1', icon: <CloudOutlined /> },
|
||||
{ name: t('home.weatherStation'), count: '1/1', icon: <CloudOutlined /> },
|
||||
{ name: t('devices.camera'), count: '12/12', icon: <VideoCameraOutlined /> },
|
||||
{ name: '环境传感器', count: '8/8', icon: <ExperimentOutlined /> },
|
||||
{ name: t('home.environmentalSensor'), count: '8/8', icon: <ExperimentOutlined /> },
|
||||
{ name: t('constants.uav'), count: '1/1', icon: <RocketOutlined /> },
|
||||
{ name: t('home.inspectionRobot'), count: '1/1', icon: <RobotOutlined /> },
|
||||
].map((item, idx) => (
|
||||
|
||||
@@ -113,6 +113,8 @@ export default function Login() {
|
||||
<Form.Item
|
||||
name="agreement"
|
||||
valuePropName="checked"
|
||||
initialValue={true}
|
||||
|
||||
rules={[{ validator: (_, value) => value ? Promise.resolve() : Promise.reject(new Error(t('login.agreeRequired'))) }]}
|
||||
>
|
||||
<Checkbox>
|
||||
|
||||
@@ -112,7 +112,7 @@ const RealTimeMonitorPage = () => {
|
||||
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||
{/* 电站拓扑图 */}
|
||||
<Card
|
||||
title={<span style={{ fontWeight: 800, fontSize: 13 }}>电站拓扑图 (实时)</span>}
|
||||
title={<span style={{ fontWeight: 800, fontSize: 13 }}>{t('page.stationTopology')}</span>}
|
||||
extra={
|
||||
<div style={{ display: 'flex', gap: 12, fontSize: 11 }}>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#52c41a', marginRight: 4 }}></span>{t('roles.normal')}</span>
|
||||
@@ -232,7 +232,7 @@ const RealTimeMonitorPage = () => {
|
||||
</Card>
|
||||
|
||||
{/* 逆变器功率对比 */}
|
||||
<Card title={<span style={{ fontWeight: 800 }}>逆变器功率对比 (实时)</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<Card title={<span style={{ fontWeight: 800 }}>{t('page.inverterPowerCompare')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<UniversalBarChart
|
||||
height={180}
|
||||
data={inverterPowerData}
|
||||
@@ -253,7 +253,7 @@ const RealTimeMonitorPage = () => {
|
||||
{/* 热力图与在线率 */}
|
||||
<Row gutter={8}>
|
||||
<Col span={12}>
|
||||
<Card title={<span style={{ fontWeight: 800 }}>组串电流热力图 (单位: A)</span>} extra={<Select defaultValue="a" size="small" style={{ width: 60 }}><Option value="a">{t('page.s12')}</Option></Select>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<Card title={<span style={{ fontWeight: 800 }}>{t('page.stringCurrentHeatmap')}</span>} extra={<Select defaultValue="a" size="small" style={{ width: 60 }}><Option value="a">{t('page.s12')}</Option></Select>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||
{['INV-01', 'INV-02', 'INV-03', 'INV-04', 'INV-05'].map((name, i) => (
|
||||
<div key={i} style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||
@@ -325,10 +325,10 @@ const RealTimeMonitorPage = () => {
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ fontSize: 10, display: 'flex', flexWrap: 'wrap', gap: 8, marginTop: 8 }}>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#52c41a', marginRight: 4 }}></span>在线 52 (92.1%)</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#f5f5f5', marginRight: 4 }}></span>离线 3 (5.3%)</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#faad14', marginRight: 4 }}></span>告警 1 (1.8%)</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#999', marginRight: 4 }}></span>{t('page.56')}</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#52c41a', marginRight: 4 }}></span>{t('pages.online')} 52 (92.1%)</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#f5f5f5', marginRight: 4 }}></span>{t('pages.offline')} 3 (5.3%)</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#faad14', marginRight: 4 }}></span>{t('pages.alerts')} 1 (1.8%)</span>
|
||||
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ width: 6, height: 6, borderRadius: '50%', background: '#999', marginRight: 4 }}></span>{t('pages.all')} 56</span>
|
||||
</div>
|
||||
<div style={{ width: '100%', height: '100%', background: `url(${bgMain}) center/cover no-repeat`, position: 'relative' }}>
|
||||
{/* 简易地图点位 */}
|
||||
|
||||
@@ -221,7 +221,7 @@ export default function ReportCenterPage() {
|
||||
}}
|
||||
>
|
||||
{overviewCards.map((card, idx) => (
|
||||
<Col key={idx} style={{ minWidth: '180px', flex: '1 0 auto', maxWidth: "240px" }}>
|
||||
<Col key={idx} style={{ minWidth: '180px', flex: '1 0 auto', }}>
|
||||
<Card
|
||||
bordered={false}
|
||||
bodyStyle={{ padding: '20px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
|
||||
|
||||
@@ -452,7 +452,7 @@ const WorkOrderPage = () => {
|
||||
{
|
||||
title: t('workOrder.handle'),
|
||||
value: orderStat.avgHandleHour,
|
||||
unit: '小时',
|
||||
unit: t('workOrder.hour'),
|
||||
subValue: orderStat.avgDiff,
|
||||
subText: '较上周',
|
||||
icon: <Timer size={24} color="#1890ff" />,
|
||||
@@ -461,7 +461,7 @@ const WorkOrderPage = () => {
|
||||
{
|
||||
title: t('workOrder.fixed2Ai'),
|
||||
value: orderStat.aiCreate,
|
||||
unit: '单',
|
||||
unit: t('workOrder.workorderUnit'),
|
||||
subValue: '',
|
||||
subText: '今日自动生成',
|
||||
icon: <Cpu size={24} color="#722ed1" />,
|
||||
@@ -1078,7 +1078,7 @@ const WorkOrderPage = () => {
|
||||
<Button size="small" icon={<ChevronRight style={{ transform: 'rotate(180deg)' }} size={14} />} onClick={prevScheduleDay} />
|
||||
<Text strong style={{ fontSize: 13 }}>
|
||||
{scheduleDate}
|
||||
{scheduleDate === dayjs().format('YYYY-MM-DD') ? ' (今天)' : ''}
|
||||
{scheduleDate === dayjs().format('YYYY-MM-DD') ? ' (' + t('workOrder.today') + ')' : ''}
|
||||
</Text>
|
||||
<Button size="small" icon={<ChevronRight size={14} />} onClick={nextScheduleDay} />
|
||||
</Space>
|
||||
@@ -1098,7 +1098,7 @@ const WorkOrderPage = () => {
|
||||
{/* 单一行时间画布,不再区分人员 */}
|
||||
<div style={{ height: 220, position: 'relative', padding: '10px 0', overflow: 'hidden' }}>
|
||||
{getScheduleOrderList().length === 0 ? (
|
||||
<Empty description={`${scheduleDate} 暂无设置计划执行时间的工单`} style={{ padding: "60px 0" }} />
|
||||
<Empty description={`${scheduleDate} ${t('workOrder.noScheduledOrders')}`} style={{ padding: "60px 0" }} />
|
||||
) : (
|
||||
<>
|
||||
{getScheduleOrderList().map((order, index) => {
|
||||
@@ -1214,7 +1214,7 @@ const WorkOrderPage = () => {
|
||||
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8, flexWrap: 'wrap', gap: 12 }}>
|
||||
<span level={4} style={{ margin: 0, fontSize: 18, fontWeight: 800 }}>{currentDetail?.orderTitle || '暂无标题'}</span>
|
||||
<span level={4} style={{ margin: 0, fontSize: 18, fontWeight: 800 }}>{currentDetail?.orderTitle || t('workOrder.notitle')}</span>
|
||||
{currentDetail?.priorityLevel && (
|
||||
<Tag style={{ color: priorityConfig[currentDetail.priorityLevel]?.color, background: priorityConfig[currentDetail.priorityLevel]?.bg, border: `1px solid ${priorityConfig[currentDetail.priorityLevel]?.color}`, borderRadius: 4, fontWeight: 600 }}>
|
||||
{currentDetail.priorityLevel}
|
||||
@@ -1239,11 +1239,11 @@ const WorkOrderPage = () => {
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<span style={{ fontSize: 12 }}>{t('workOrder.fixed2RelatedDevice')}</span>
|
||||
<span style={{ fontSize: 12, color: '#165DFF', fontWeight: 600 }}>{currentDetail?.deviceName || '无'}</span>
|
||||
<span style={{ fontSize: 12, color: '#165DFF', fontWeight: 600 }}>{currentDetail?.deviceName || t('workOrder.noRelatedDevice')}</span>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<span style={{ fontSize: 12 }}>{t('workOrder.fixed2RelatedArea')}</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.siteName || '无'}</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.siteName || t('workOrder.noRelatedArea')}</span>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<span style={{ fontSize: 12 }}>{t('workOrder.fixed2CurrentStatus')}</span>
|
||||
|
||||
@@ -1,334 +1,4 @@
|
||||
import React, { lazy, Suspense } from 'react';
|
||||
import { createBrowserRouter } from 'react-router-dom';
|
||||
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'));
|
||||
//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 />,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
import { routes } from './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