Compare commits
13 Commits
feat-suanf
...
ac60263a6c
| Author | SHA1 | Date | |
|---|---|---|---|
| ac60263a6c | |||
| ce924ddf66 | |||
| f342bc7648 | |||
| f318cba0b3 | |||
| 60583074bf | |||
| 2b887270b9 | |||
| 46c5236731 | |||
| 2d30219a49 | |||
| 54eebdfd15 | |||
| 4710b24ef3 | |||
| 6b527bc316 | |||
| 98500d14ff | |||
| c611b2a2dc |
4
env.js
4
env.js
@@ -19,7 +19,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"
|
||||
|
||||
//baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
|
||||
////baseURL: 'https://serviceri.satabot.com',
|
||||
@@ -40,7 +40,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"
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
Layout, Menu, Button, Space, Select, Avatar, Card, Tag
|
||||
@@ -86,7 +86,6 @@ export default function AppLayout() {
|
||||
|
||||
list.forEach(item => {
|
||||
map.set(item.menuId, {
|
||||
...item,
|
||||
key: item.path,
|
||||
label: item.menuName,
|
||||
icon: getIcon(item.path),
|
||||
@@ -240,6 +239,11 @@ export default function AppLayout() {
|
||||
/>
|
||||
)}
|
||||
<span style={{ fontSize: 'clamp(12px, 1vw, 14px)' }}>{userInfo?.nickName || userInfo?.username}</span>
|
||||
{userInfo?.roleKey === "admin" && <Tag color="red">管理员</Tag>}
|
||||
{userInfo?.roleKey === "manager" && <Tag color="orange">组织管理员</Tag>}
|
||||
{userInfo?.roleKey === "siteManager" && <Tag color="blue">场站管理员</Tag>}
|
||||
|
||||
|
||||
</Space>
|
||||
<Button type="text" danger icon={<LogoutOutlined />} onClick={handleLogout} style={{ fontSize: 'clamp(12px, 1vw, 14px)' }}>
|
||||
{t('layout.logout')}
|
||||
@@ -295,6 +299,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' }}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react';
|
||||
import carImg from '../assets/images/carplane.png';
|
||||
import inspectImg from "../assets/images/inspectCar.png"
|
||||
import planeImg from '../assets/images/planeicon.png';
|
||||
@@ -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);
|
||||
@@ -200,7 +202,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}
|
||||
return;
|
||||
}
|
||||
const validPoints = points.filter(p => {
|
||||
const validPoints = points?.filter(p => {
|
||||
|
||||
const lon = Number(p.lng);
|
||||
const lat = Number(p.lat);
|
||||
@@ -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" },
|
||||
@@ -484,7 +485,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
!isNaN(Number(realtimePosition.lon)) &&
|
||||
!isNaN(Number(realtimePosition.lat));
|
||||
|
||||
const hasTrack = points && points.length > 0;
|
||||
const hasTrack = (points && points.length > 0);
|
||||
|
||||
if (hasRealtime) return "realtime";
|
||||
if (hasTrack) return "track";
|
||||
@@ -495,9 +496,12 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
const layerIdentifier = `${workspace}:${layerName}`;
|
||||
let baseUrl = wmsUrl;
|
||||
const cesiumLayers = [];
|
||||
if (index == 2 && from == "other") {
|
||||
flyToLayer(layerIdentifier, baseUrl, 100);
|
||||
}
|
||||
//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')) {
|
||||
@@ -1027,7 +1031,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
return;
|
||||
}
|
||||
|
||||
const validPoints = tracePoints.filter(p => {
|
||||
const validPoints = tracePoints?.filter(p => {
|
||||
const lng = Number(p.lng);
|
||||
const lat = Number(p.lat);
|
||||
return !isNaN(lng) && !isNaN(lat) && Math.abs(lng) < 180 && Math.abs(lat) < 90 && lng !== 0 && lat !== 0;
|
||||
@@ -1087,8 +1091,12 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
if (viewer) {
|
||||
if (planLineRef.current) {
|
||||
viewer.entities.remove(planLineRef.current);
|
||||
|
||||
|
||||
planLineRef.current = null;
|
||||
}
|
||||
|
||||
|
||||
viewer.scene.requestRender();
|
||||
}
|
||||
prevIfClearPlanLine.current = ifClearPlanLine;
|
||||
@@ -1397,7 +1405,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 +1607,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))) {
|
||||
@@ -1854,17 +1861,27 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
captureScreenshot
|
||||
}));
|
||||
|
||||
return <>
|
||||
<div ref={containerRef} className="w-full h-full bg-slate-900 overflow-hidden" />
|
||||
<div
|
||||
ref={tooltipRef}
|
||||
style={{
|
||||
position: "absolute", display: "none", pointerEvents: "none",
|
||||
background: "rgba(0,0,0,0.75)", color: "#fff", padding: "8px 10px",
|
||||
borderRadius: "4px", fontSize: "12px", zIndex: 9999, whiteSpace: "nowrap"
|
||||
}}
|
||||
/>
|
||||
</>;
|
||||
return (
|
||||
<div className="w-full h-full bg-slate-900 overflow-hidden relative">
|
||||
<div ref={containerRef} className="w-full h-full overflow-hidden" />
|
||||
<div
|
||||
ref={tooltipRef}
|
||||
style={{
|
||||
position: "absolute",
|
||||
display: "none",
|
||||
pointerEvents: "none",
|
||||
background: "rgba(0,0,0,0.75)",
|
||||
color: "#fff",
|
||||
padding: "8px 10px",
|
||||
borderRadius: "4px",
|
||||
fontSize: "12px",
|
||||
zIndex: 99999,
|
||||
whiteSpace: "nowrap",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
export default CesiumMap;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Form,
|
||||
Input,
|
||||
@@ -58,12 +58,22 @@ import {
|
||||
} from 'lucide-react';
|
||||
import dayjs from 'dayjs';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getRoleList } from '@/api/role';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import { getUser } from '@/api/user';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
const BasicSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
const [roles, setRoles] = useState<any[]>([]);
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { currentStation, stationId } = useSelector((state: RootState) => state.station);
|
||||
const [userList, setUserList] = useState<any[]>([]);
|
||||
|
||||
|
||||
|
||||
// 响应式字体大小
|
||||
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
|
||||
@@ -119,6 +129,7 @@ const BasicSettings = () => {
|
||||
|
||||
// 角色权限概览
|
||||
const roleOverview = [
|
||||
//平台管理员
|
||||
{
|
||||
title: t('roles.superAdmin'),
|
||||
users: 2,
|
||||
@@ -128,34 +139,68 @@ const BasicSettings = () => {
|
||||
bg: '#e6f4ff',
|
||||
icon: <ShieldCheck size={20} color="#1677ff" />
|
||||
},
|
||||
//普通用户
|
||||
{
|
||||
title: t('systemSetting.fixed2OM'),
|
||||
users: 5,
|
||||
perms: 18,
|
||||
tags: [t('router.devices'), '工单管理'],
|
||||
tags: ["处理工单", "处理任务"],
|
||||
color: '#52c41a',
|
||||
bg: '#f6ffed',
|
||||
icon: <Wrench size={20} color="#52c41a" />
|
||||
},
|
||||
//机构管理员
|
||||
{
|
||||
title: t('systemSetting.fixed2Inspection2'),
|
||||
users: 8,
|
||||
perms: 12,
|
||||
tags: ['巡检管理', '告警处理'],
|
||||
tags: ['管理机构下所有场站', '告警处理'],
|
||||
color: '#fa8c16',
|
||||
bg: '#fff7e6',
|
||||
icon: <Users size={20} color="#fa8c16" />
|
||||
},
|
||||
//场站管理员
|
||||
{
|
||||
title: t('systemSetting.s322'),
|
||||
users: 3,
|
||||
perms: 15,
|
||||
tags: ['数据分析', '报表查看'],
|
||||
tags: ['管理自己场站', '报表查看', '告警处理'],
|
||||
color: '#722ed1',
|
||||
bg: '#f9f0ff',
|
||||
icon: <LineChart size={20} color="#722ed1" />
|
||||
},
|
||||
];
|
||||
const matchRoleStyle = (roleName: string) => {
|
||||
const found = roleOverview.find(item => item.title === roleName);
|
||||
if (found) return found;
|
||||
// 兜底默认样式
|
||||
return {
|
||||
color: '#8c8c8c',
|
||||
bg: '#f5f5f5',
|
||||
icon: null,
|
||||
tags: []
|
||||
};
|
||||
};
|
||||
|
||||
const getUserData = () => {
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
orgId: userInfo?.roleKey == "manager" ? userInfo?.orgId : currentStation?.orgId,
|
||||
...(userInfo?.roleKey == "manager"
|
||||
? {}
|
||||
: { siteId: stationId }
|
||||
)
|
||||
};
|
||||
|
||||
getUser(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setUserList(res.rows || []);
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 设备状态
|
||||
const deviceStatuses = [
|
||||
@@ -168,6 +213,21 @@ const BasicSettings = () => {
|
||||
{ name: t('systemSetting.api'), count: t('roles.normal'), status: t('roles.normal') },
|
||||
{ name: 'Modbus', count: t('roles.normal'), status: t('roles.normal') },
|
||||
];
|
||||
const getRoleData = () => {
|
||||
const params = { pageNum: 1, pageSize: 9999 };
|
||||
getRoleList(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
let sortedRoles = (res.data || []).sort((a, b) => (a.roleSort || 999) - (b.roleSort || 999));
|
||||
setRoles(sortedRoles);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getRoleData();
|
||||
getUserData();
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<div className="normal-spacing" style={{ padding: '8px 0px', background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
@@ -182,9 +242,9 @@ const BasicSettings = () => {
|
||||
<Col key={idx} style={{ minWidth: '168px', flex: '1 0 auto', maxWidth: "250px" }}>
|
||||
<AntdCard bordered={false} bodyStyle={{ padding: '12px 16px' }} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
|
||||
<div style={{ width: 40, height: 40, borderRadius: 10, background: item.bg, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
{/*<div style={{ width: 40, height: 40, borderRadius: 10, background: item.bg, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
{React.cloneElement(item.icon as React.ReactElement, { size: 20, style: item.icon.props.style ? { ...item.icon.props.style, fontSize: 20 } : { fontSize: 20 } })}
|
||||
</div>
|
||||
</div>*/}
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ color: '#8c8c8c', fontSize: fontSmall, marginBottom: 2 }}>{item.title}</div>
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6 }}>
|
||||
@@ -300,7 +360,7 @@ const BasicSettings = () => {
|
||||
<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' }}>
|
||||
<div style={{ width: 32, height: 32, borderRadius: '50%', background: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: '0 1px 4px rgba(0,0,0,0.04)', marginRight: 10 }}>
|
||||
{React.cloneElement(item.icon as React.ReactElement, { style: { color: item.color } })}
|
||||
{/*{React.cloneElement(item.icon as React.ReactElement, { style: { color: item.color } })}*/}
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ fontSize: 10, color: '#8c8c8c' }}>{item.label}</div>
|
||||
@@ -342,39 +402,37 @@ const BasicSettings = () => {
|
||||
|
||||
pagination={{ size: 'small', total: 4, pageSize: 4, showTotal: (total) => `共 ${total} 条` }}
|
||||
columns={[
|
||||
{ title: t('systemSetting.s36'), dataIndex: 'name', key: 'name', fixed: 'left', width: 80 },
|
||||
{ title: t('systemSetting.s36'), dataIndex: 'userName', key: 'userName', fixed: 'left', },
|
||||
{
|
||||
title: t('users.role'),
|
||||
dataIndex: 'role',
|
||||
key: 'role',
|
||||
width: 100,
|
||||
render: (role) => {
|
||||
const config: any = {
|
||||
'超级管理员': { color: '#1677ff', bg: '#e6f4ff' },
|
||||
'运维工程师': { color: '#52c41a', bg: '#f6ffed' },
|
||||
'巡检主管': { color: '#fa8c16', bg: '#fff7e6' },
|
||||
'数据分析师': { color: '#722ed1', bg: '#f9f0ff' },
|
||||
};
|
||||
const s = config[role] || { color: '#8c8c8c', bg: '#f5f5f5' };
|
||||
return <Tag bordered={false} style={{ color: s.color, background: s.bg, fontSize: 10, margin: 0 }}>{role}</Tag>;
|
||||
render: (_val, record) => {
|
||||
const roleList = record.roles || [];
|
||||
return <>
|
||||
{roleList.map((rItem: any) => {
|
||||
//const conf = getRoleConfByKey(rItem.roleKey);
|
||||
return <Tag key={rItem.roleId}>{rItem.roleKey == "manager" ? t('systemSetting.fixed2Inspection2') : rItem.roleKey == "siteManager" ? t('systemSetting.s322') : t('systemSetting.fixed2OM')}</Tag>
|
||||
})}
|
||||
</>
|
||||
}
|
||||
},
|
||||
{ title: t('users.phone'), dataIndex: 'phone', key: 'phone', width: 110 },
|
||||
{ title: t('users.phone'), dataIndex: 'phonenumber', key: 'phonenumber', },
|
||||
{ title: t('users.email'), dataIndex: 'email', key: 'email', ellipsis: true },
|
||||
{
|
||||
title: t('roles.status'),
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 70,
|
||||
render: (status) => (
|
||||
<Space size={4}>
|
||||
<div style={{ width: 6, height: 6, borderRadius: '50%', background: status === t('devices.online') ? '#52c41a' : '#bfbfbf' }} />
|
||||
<span style={{ fontSize: 10 }}>{status}</span>
|
||||
<span style={{ fontSize: 10 }}>{status == 1 ? "在线" : "离线"}</span>
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: t('roles.actions'), key: 'action', width: 60, render: () => <Button
|
||||
title: t('roles.actions'), key: 'action', render: () => <Button
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<EyeOutlined />}
|
||||
@@ -382,12 +440,7 @@ const BasicSettings = () => {
|
||||
>{t('common.view')}</Button>, fixed: 'right'
|
||||
},
|
||||
]}
|
||||
dataSource={[
|
||||
{ name: '张运维', role: '超级管理员', phone: '138****0001', email: 'zhangyw@pvsmart.com', status: t('devices.online') },
|
||||
{ name: '李工程师', role: '运维工程师', phone: '139****0002', email: 'li.gongcheng@pvsmart.com', status: t('devices.online') },
|
||||
{ name: '王班长', role: '巡检主管', phone: '137****0003', email: 'wang.banzhang@pvsmart.com', status: t('devices.online') },
|
||||
{ name: '赵分析师', role: '数据分析师', phone: '136****0004', email: 'zhao.fx@pvsmart.com', status: t('devices.online') },
|
||||
]}
|
||||
dataSource={userList}
|
||||
/>
|
||||
</AntdCard>
|
||||
</Col>
|
||||
@@ -402,25 +455,41 @@ const BasicSettings = () => {
|
||||
bodyStyle={{ padding: '10px' }}
|
||||
>
|
||||
<Row gutter={[8, 8]}>
|
||||
{roleOverview.map((role, idx) => (
|
||||
<Col xs={24} sm={12} key={idx}>
|
||||
<div style={{ background: role.bg, borderRadius: 8, padding: 8, height: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
|
||||
{React.cloneElement(role.icon as React.ReactElement, { size: 16 })}
|
||||
<RightOutlined style={{ fontSize: 9, color: role.color }} />
|
||||
{roles.map((role, idx) => {
|
||||
const styleConf = matchRoleStyle(role.roleName);
|
||||
return (
|
||||
<Col xs={24} sm={12} key={idx}>
|
||||
<div style={{ background: styleConf.bg, borderRadius: 8, padding: 8, height: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4, alignItems: 'center' }}>
|
||||
{styleConf.icon}
|
||||
</div>
|
||||
<div style={{ fontWeight: 600, fontSize: 11, color: styleConf.color, marginBottom: 2 }}>
|
||||
{role.roleName}
|
||||
</div>
|
||||
<div style={{ fontSize: 9, color: '#8c8c8c', marginBottom: 6 }}>
|
||||
用户 {role.users} | 菜单权限 {role.menuIds?.length ?? 0}
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
|
||||
{styleConf.tags.map((tag, tidx) => (
|
||||
<span
|
||||
key={tidx}
|
||||
style={{
|
||||
fontSize: 8,
|
||||
padding: '0 4px',
|
||||
background: '#fff',
|
||||
color: styleConf.color,
|
||||
borderRadius: 2,
|
||||
border: `1px solid ${styleConf.color}20`
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ fontWeight: 600, fontSize: 11, color: role.color, marginBottom: 2 }}>{role.title}</div>
|
||||
<div style={{ fontSize: 9, color: '#8c8c8c', marginBottom: 6 }}>
|
||||
用户 {role.users} | 权限 {role.perms}
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
|
||||
{role.tags.map((tag, tidx) => (
|
||||
<span key={tidx} style={{ fontSize: 8, padding: '0 4px', background: '#fff', color: role.color, borderRadius: 2, border: `1px solid ${role.color}20` }}>{tag}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Col>
|
||||
))}
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
</AntdCard>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Layout, Tabs, Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message,
|
||||
Input, Popconfirm, Divider, InputNumber, Pagination, Table, Select,
|
||||
@@ -130,12 +130,13 @@ export default function UserRolePage() {
|
||||
const params = {
|
||||
pageNum: userPagination.pageNum,
|
||||
pageSize: userPagination.pageSize,
|
||||
orgId: userInfo?.roleKey == "manager" ? userInfo?.orgId : currentStation?.orgId,
|
||||
...(userInfo?.roleKey == "manager"
|
||||
orgId: userInfo?.roleKey === "manager" ? userInfo?.orgId : currentStation?.orgId,
|
||||
...(userInfo?.roleKey === "admin" && stationId
|
||||
? {}
|
||||
: { siteId: stationId }
|
||||
)
|
||||
};
|
||||
console.log(userInfo?.roleKey)
|
||||
|
||||
getUser(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
@@ -171,7 +172,7 @@ export default function UserRolePage() {
|
||||
useEffect(() => {
|
||||
getUserData();
|
||||
getRoleForSelect();
|
||||
}, [userPagination.pageNum, userPagination.pageSize,]);
|
||||
}, [userPagination.pageNum, userPagination.pageSize, stationId]);
|
||||
|
||||
// ====================== 角色操作 ======================
|
||||
const handleAddRole = () => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
ResponsiveContainer,
|
||||
LineChart,
|
||||
Line,
|
||||
XAxis,
|
||||
@@ -15,8 +14,10 @@ import {
|
||||
Bar,
|
||||
} from 'recharts';
|
||||
|
||||
|
||||
// =========================
|
||||
// 默认颜色池
|
||||
// =========================
|
||||
|
||||
const DEFAULT_COLORS = [
|
||||
'#1677ff',
|
||||
'#52c41a',
|
||||
@@ -29,11 +30,114 @@ const DEFAULT_COLORS = [
|
||||
];
|
||||
|
||||
|
||||
// =========================
|
||||
// 通用自适应容器
|
||||
// =========================
|
||||
//
|
||||
// 不再使用 ResponsiveContainer。
|
||||
// 通过 ResizeObserver 获取真实尺寸,
|
||||
// 只有 width / height > 0 时才渲染 Recharts。
|
||||
// 这样可以彻底避免:
|
||||
//
|
||||
// width(-1) and height(-1)
|
||||
//
|
||||
// =========================
|
||||
|
||||
const ChartResizeContainer = ({
|
||||
children,
|
||||
width = '100%',
|
||||
height = 360,
|
||||
className,
|
||||
style,
|
||||
}) => {
|
||||
const containerRef = useRef(null);
|
||||
|
||||
const [size, setSize] = useState({
|
||||
width: 0,
|
||||
height: 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const element = containerRef.current;
|
||||
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
const updateSize = () => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
|
||||
const nextWidth = Math.floor(rect.width);
|
||||
const nextHeight = Math.floor(rect.height);
|
||||
|
||||
// 非法尺寸直接忽略
|
||||
if (nextWidth <= 0 || nextHeight <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSize((prev) => {
|
||||
if (
|
||||
prev.width === nextWidth &&
|
||||
prev.height === nextHeight
|
||||
) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
return {
|
||||
width: nextWidth,
|
||||
height: nextHeight,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
// 首次主动测量
|
||||
updateSize();
|
||||
|
||||
// 后续监听尺寸变化
|
||||
const observer = new ResizeObserver(() => {
|
||||
updateSize();
|
||||
});
|
||||
|
||||
observer.observe(element);
|
||||
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={className}
|
||||
style={{
|
||||
width,
|
||||
height,
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
boxSizing: 'border-box',
|
||||
overflow: 'hidden',
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
{size.width > 0 && size.height > 0
|
||||
? React.cloneElement(children, {
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
})
|
||||
: null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// =========================
|
||||
// Universal Line Chart
|
||||
// =========================
|
||||
|
||||
export const UniversalLineChart = ({
|
||||
data,
|
||||
data = [],
|
||||
xKey,
|
||||
series,
|
||||
series = [],
|
||||
width = '100%',
|
||||
height = 360,
|
||||
showGrid = true,
|
||||
@@ -43,6 +147,7 @@ export const UniversalLineChart = ({
|
||||
smooth = true,
|
||||
dot = false,
|
||||
className,
|
||||
style,
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
@@ -50,48 +155,80 @@ export const UniversalLineChart = ({
|
||||
style={{
|
||||
width,
|
||||
height,
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
boxSizing: 'border-box',
|
||||
background: backgroundColor,
|
||||
borderRadius: 12,
|
||||
padding: 12,
|
||||
overflow: 'hidden',
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<ChartResizeContainer
|
||||
width="100%"
|
||||
height="100%"
|
||||
>
|
||||
<LineChart data={data}>
|
||||
{showGrid && (
|
||||
<CartesianGrid strokeDasharray="3 3" opacity={0.25} />
|
||||
<CartesianGrid
|
||||
strokeDasharray="3 3"
|
||||
opacity={0.25}
|
||||
/>
|
||||
)}
|
||||
|
||||
<XAxis dataKey={xKey} />
|
||||
|
||||
<YAxis />
|
||||
|
||||
{showTooltip && <Tooltip />}
|
||||
|
||||
{showLegend && <Legend />}
|
||||
|
||||
{series.map((item, index) => (
|
||||
<Line
|
||||
key={item.key}
|
||||
type={smooth ? 'monotone' : 'linear'}
|
||||
type={
|
||||
smooth
|
||||
? 'monotone'
|
||||
: 'linear'
|
||||
}
|
||||
dataKey={item.key}
|
||||
name={item.name}
|
||||
stroke={item.color || DEFAULT_COLORS[index % DEFAULT_COLORS.length]}
|
||||
strokeWidth={item.strokeWidth || 2}
|
||||
strokeDasharray={item.dashed ? '6 6' : undefined}
|
||||
stroke={
|
||||
item.color ||
|
||||
DEFAULT_COLORS[
|
||||
index %
|
||||
DEFAULT_COLORS.length
|
||||
]
|
||||
}
|
||||
strokeWidth={
|
||||
item.strokeWidth || 2
|
||||
}
|
||||
strokeDasharray={
|
||||
item.dashed
|
||||
? '6 6'
|
||||
: undefined
|
||||
}
|
||||
dot={dot}
|
||||
activeDot={{ r: 6 }}
|
||||
/>
|
||||
))}
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</ChartResizeContainer>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// =========================
|
||||
// Universal Bar Chart
|
||||
// =========================
|
||||
|
||||
export const UniversalBarChart = ({
|
||||
data,
|
||||
data = [],
|
||||
xKey,
|
||||
series,
|
||||
series = [],
|
||||
width = '100%',
|
||||
height = 360,
|
||||
showGrid = true,
|
||||
@@ -102,6 +239,7 @@ export const UniversalBarChart = ({
|
||||
radius = 6,
|
||||
stack = false,
|
||||
className,
|
||||
style,
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
@@ -109,21 +247,34 @@ export const UniversalBarChart = ({
|
||||
style={{
|
||||
width,
|
||||
height,
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
boxSizing: 'border-box',
|
||||
background: backgroundColor,
|
||||
borderRadius: 12,
|
||||
padding: 12,
|
||||
overflow: 'hidden',
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<ChartResizeContainer
|
||||
width="100%"
|
||||
height="100%"
|
||||
>
|
||||
<BarChart data={data}>
|
||||
{showGrid && (
|
||||
<CartesianGrid strokeDasharray="3 3" opacity={0.25} />
|
||||
<CartesianGrid
|
||||
strokeDasharray="3 3"
|
||||
opacity={0.25}
|
||||
/>
|
||||
)}
|
||||
|
||||
<XAxis dataKey={xKey} />
|
||||
|
||||
<YAxis />
|
||||
|
||||
{showTooltip && <Tooltip />}
|
||||
|
||||
{showLegend && <Legend />}
|
||||
|
||||
{series.map((item, index) => (
|
||||
@@ -131,22 +282,35 @@ export const UniversalBarChart = ({
|
||||
key={item.key}
|
||||
dataKey={item.key}
|
||||
name={item.name}
|
||||
fill={item.color || DEFAULT_COLORS[index % DEFAULT_COLORS.length]}
|
||||
fill={
|
||||
item.color ||
|
||||
DEFAULT_COLORS[
|
||||
index %
|
||||
DEFAULT_COLORS.length
|
||||
]
|
||||
}
|
||||
barSize={barSize}
|
||||
radius={radius}
|
||||
stackId={stack ? 'stack' : undefined}
|
||||
stackId={
|
||||
stack
|
||||
? 'stack'
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</ChartResizeContainer>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// =========================
|
||||
// Universal Pie Chart
|
||||
// =========================
|
||||
|
||||
export const UniversalPieChart = ({
|
||||
data,
|
||||
data = [],
|
||||
width = '100%',
|
||||
height = 360,
|
||||
showLegend = true,
|
||||
@@ -157,7 +321,7 @@ export const UniversalPieChart = ({
|
||||
paddingAngle = 2,
|
||||
showLabel = true,
|
||||
className,
|
||||
style
|
||||
style,
|
||||
}) => {
|
||||
return (
|
||||
<div
|
||||
@@ -165,15 +329,23 @@ export const UniversalPieChart = ({
|
||||
style={{
|
||||
width,
|
||||
height,
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
boxSizing: 'border-box',
|
||||
background: backgroundColor,
|
||||
borderRadius: 12,
|
||||
padding: 12,
|
||||
...style
|
||||
overflow: 'hidden',
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<ChartResizeContainer
|
||||
width="100%"
|
||||
height="100%"
|
||||
>
|
||||
<PieChart>
|
||||
{showTooltip && <Tooltip />}
|
||||
|
||||
{showLegend && <Legend />}
|
||||
|
||||
<Pie
|
||||
@@ -190,37 +362,86 @@ export const UniversalPieChart = ({
|
||||
{data.map((entry, index) => (
|
||||
<Cell
|
||||
key={`cell-${index}`}
|
||||
fill={entry.color || DEFAULT_COLORS[index % DEFAULT_COLORS.length]}
|
||||
fill={
|
||||
entry.color ||
|
||||
DEFAULT_COLORS[
|
||||
index %
|
||||
DEFAULT_COLORS.length
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</Pie>
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
</ChartResizeContainer>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// =========================
|
||||
// 使用示例
|
||||
// =========================
|
||||
|
||||
export const DemoCharts = () => {
|
||||
const lineData = [
|
||||
{ month: '1月', uv: 400, pv: 240, amt: 240 },
|
||||
{ month: '2月', uv: 300, pv: 456, amt: 300 },
|
||||
{ month: '3月', uv: 500, pv: 139, amt: 200 },
|
||||
{ month: '4月', uv: 278, pv: 390, amt: 278 },
|
||||
{ month: '5月', uv: 189, pv: 480, amt: 189 },
|
||||
{
|
||||
month: '1月',
|
||||
uv: 400,
|
||||
pv: 240,
|
||||
amt: 240,
|
||||
},
|
||||
{
|
||||
month: '2月',
|
||||
uv: 300,
|
||||
pv: 456,
|
||||
amt: 300,
|
||||
},
|
||||
{
|
||||
month: '3月',
|
||||
uv: 500,
|
||||
pv: 139,
|
||||
amt: 200,
|
||||
},
|
||||
{
|
||||
month: '4月',
|
||||
uv: 278,
|
||||
pv: 390,
|
||||
amt: 278,
|
||||
},
|
||||
{
|
||||
month: '5月',
|
||||
uv: 189,
|
||||
pv: 480,
|
||||
amt: 189,
|
||||
},
|
||||
];
|
||||
|
||||
const pieData = [
|
||||
{ name: 'Vue', value: 40 },
|
||||
{ name: 'React', value: 35 },
|
||||
{ name: 'Angular', value: 25 },
|
||||
{
|
||||
name: 'Vue',
|
||||
value: 40,
|
||||
},
|
||||
{
|
||||
name: 'React',
|
||||
value: 35,
|
||||
},
|
||||
{
|
||||
name: 'Angular',
|
||||
value: 25,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 gap-6 p-6">
|
||||
<div
|
||||
className="
|
||||
grid
|
||||
grid-cols-1
|
||||
gap-6
|
||||
p-6
|
||||
min-w-0
|
||||
"
|
||||
>
|
||||
<UniversalLineChart
|
||||
data={lineData}
|
||||
xKey="month"
|
||||
|
||||
@@ -927,6 +927,8 @@ const en = {
|
||||
unitJia: '',
|
||||
unitTai: '',
|
||||
unitTiao: '',
|
||||
normalCancel: "normalCancel",
|
||||
forceCancel: "forceCancel",
|
||||
unknownDevice: 'Unknown Device',
|
||||
unknownDrone: 'Unknown Drone',
|
||||
unknownObject: 'Unknown Object',
|
||||
@@ -3174,7 +3176,6 @@ const en = {
|
||||
|
||||
deptRnd: 'R&D Department',
|
||||
|
||||
editMenu: 'Edit Menu',
|
||||
|
||||
editOrganization: 'Edit Organization',
|
||||
|
||||
@@ -3376,7 +3377,6 @@ const en = {
|
||||
abnormal: 'Abnormal',
|
||||
addSuccess: 'Add Success',
|
||||
confirmDeleteRole: 'Confirm Delete Role',
|
||||
editRole: 'Edit Role',
|
||||
editSuccess: 'Edit Success',
|
||||
manageMembers: 'Manage Members',
|
||||
menuPermissionConfig: 'Menu Permission Config',
|
||||
|
||||
@@ -237,7 +237,7 @@ const zh = {
|
||||
|
||||
failedFixed2: '❌ 工单生成接口调用失败',
|
||||
solarPanel: "组件阵列",
|
||||
weatherStation: "气象站",
|
||||
WeatherStation: "气象站",
|
||||
environmentalSensor: "环境传感器",
|
||||
distributable: "可调度",
|
||||
|
||||
@@ -321,10 +321,13 @@ const zh = {
|
||||
statusPaused: '暂停中',
|
||||
statusFinished: '执行成功',
|
||||
statusFailed: '执行失败',
|
||||
statusCanceling: '取消中',
|
||||
confirmDeleteTask: '确定要删除该任务吗?',
|
||||
confirmCancelTask: '确定要取消该任务吗?',
|
||||
confirmPauseTask: '确定要暂停该任务吗?',
|
||||
confirmResumeTask: '确定要恢复该任务吗?',
|
||||
normalCancel: "普通取消",
|
||||
forceCancel: "强制取消",
|
||||
recover: '恢复',
|
||||
statTodayPlan: '今日机器人计划',
|
||||
unitPlan: '条',
|
||||
@@ -413,7 +416,8 @@ const zh = {
|
||||
selectExecDate: '选择执行日期',
|
||||
execTime: '执行时间',
|
||||
saveTask: '保存任务',
|
||||
abMode: '模式',
|
||||
abMode: '自定义模式',
|
||||
saveFail: '保存失败',
|
||||
activatedTime: '已激活时间',
|
||||
aiAction1: 'AI',
|
||||
aiAction2: 'AI',
|
||||
@@ -444,14 +448,14 @@ const zh = {
|
||||
apiRequestException: 'API请求异常',
|
||||
autoFetch: '自动获取',
|
||||
autoResumeFromBreakpoint: '自动恢复从断点',
|
||||
backView: '返回查看',
|
||||
backView: '后视角',
|
||||
batteryCapacity: '电量容量',
|
||||
batteryWithPercent: '电量带百分比',
|
||||
batteryWithValue: '电量带值',
|
||||
blockUnit: '区块单位',
|
||||
boardTaskFetchFail: '看板任务获取失败',
|
||||
boundDrone: '边界无人机',
|
||||
bowMode: '船首模式',
|
||||
bowMode: '弓字模式',
|
||||
canWorkNormally: '可工作正常',
|
||||
cancelReturnHome: '取消返航首页',
|
||||
chargePoint: '充电点',
|
||||
@@ -484,8 +488,8 @@ const zh = {
|
||||
controlLogTitle: '控制日志标题',
|
||||
controlRequestContent: '控制请求内容',
|
||||
countUnit: '数量单位',
|
||||
coverClosed: '覆盖已关闭',
|
||||
coverOpen: '覆盖打开',
|
||||
coverClosed: '已关闭',
|
||||
coverOpen: '打开',
|
||||
coverageEquipment: '覆盖设备',
|
||||
coverageValue: '{{types}}/{{units}}',
|
||||
createSuccess: '创建成功',
|
||||
@@ -558,7 +562,7 @@ const zh = {
|
||||
fixedEnv: '固定环境',
|
||||
flightAltitude: '飞行高度',
|
||||
flightWindSpeed: '飞行风速度',
|
||||
frontView: '前查看',
|
||||
frontView: '前视角',
|
||||
ganttViewTitle: '甘特查看标题',
|
||||
generateTask: '生成任务',
|
||||
gnssQuality: 'GNSS质量',
|
||||
@@ -575,7 +579,7 @@ const zh = {
|
||||
headingAngle: '航向角度',
|
||||
horizontalSpeed: '水平速度',
|
||||
hotspotSuspect: '热斑疑似',
|
||||
inDock: '内停靠',
|
||||
inDock: '舱内',
|
||||
inProgressDesc: '进行中',
|
||||
indoor: '室内',
|
||||
inputCustomAlias: '输入自定义别名',
|
||||
@@ -591,7 +595,7 @@ const zh = {
|
||||
issueTaskFirst: '问题任务先',
|
||||
landingDockSn: '降落停靠序列号',
|
||||
landingDockSnLabel: '降落停靠序列号标签',
|
||||
leftView: '左查看',
|
||||
leftView: '左视角',
|
||||
leftWheelDrive: '左轮驱动',
|
||||
legendTitle: '图例标题',
|
||||
levelHigh: '级别高',
|
||||
@@ -610,12 +614,12 @@ const zh = {
|
||||
loginInfoExpired: '登录提示已过期',
|
||||
lostControlAction: '丢失控制操作',
|
||||
lostControlActionLabel: '丢失控制操作标签',
|
||||
markPoint: '标记点',
|
||||
markPoint: '打点',
|
||||
markedPointsCount: '已标记点数量',
|
||||
minBattery: '最小电量',
|
||||
minBatteryLabel: '最小电量标签',
|
||||
minExecBatteryLabel: '最小执行电量标签',
|
||||
minThreePoints: '最小三点',
|
||||
minThreePoints: '最少三个点',
|
||||
modeAuto: '模式自动',
|
||||
modeDebugLocal: '模式调试本地',
|
||||
modeDebugRemote: '模式调试远程',
|
||||
@@ -662,7 +666,7 @@ const zh = {
|
||||
optimize: '优化',
|
||||
optionalEmpty: '可选空',
|
||||
otherWebControlling: '其他网页控制中',
|
||||
outDock: '外停靠',
|
||||
outDock: '舱外',
|
||||
outdoor: '室外',
|
||||
panorama: '全景',
|
||||
paramArmChannel: '参数布防渠道',
|
||||
@@ -762,7 +766,7 @@ const zh = {
|
||||
returnHomeAltitudeLabel: '返航首页高度标签',
|
||||
returnHomeMode: '返航首页模式',
|
||||
returnHomeModeLabel: '返航首页模式标签',
|
||||
rightView: '右查看',
|
||||
rightView: '右视角',
|
||||
rightWheelDrive: '右轮驱动',
|
||||
robotExecutingCount: '机器人执行中数量',
|
||||
robotInTaskCount: '机器人内任务数量',
|
||||
@@ -804,7 +808,7 @@ const zh = {
|
||||
rtkModeDesc: 'RTK模式描述',
|
||||
rtkStatus: 'RTK状态',
|
||||
safeRthBattery: '安全返航电量',
|
||||
satelliteCount: '卫星数量',
|
||||
satelliteCount: '卫星数量 {{count}}',
|
||||
savePathTitle: '保存路径标题',
|
||||
savePlan: '保存计划',
|
||||
saving: '节省',
|
||||
@@ -2632,7 +2636,7 @@ const zh = {
|
||||
|
||||
s28: '开启钉钉推送时必须填写加密密钥',
|
||||
|
||||
fixed2OM: '运维工程师',
|
||||
fixed2OM: '普通用户',
|
||||
|
||||
fixed2Inspection: '巡检区',
|
||||
|
||||
@@ -2641,7 +2645,6 @@ const zh = {
|
||||
s36: '用户名',
|
||||
|
||||
s37: '关联产品',
|
||||
editMenu: '编辑菜单',
|
||||
addMenu: '新增菜单',
|
||||
editSite: '编辑场站',
|
||||
addSite: '新增场站',
|
||||
@@ -3074,9 +3077,9 @@ const zh = {
|
||||
|
||||
s282: '最近更新',
|
||||
|
||||
fixed2Inspection2: '巡检主管',
|
||||
fixed2Inspection2: '机构管理员',
|
||||
|
||||
s322: '数据分析师',
|
||||
s322: '场站管理员',
|
||||
|
||||
fixed2Login2: '登录审计',
|
||||
|
||||
@@ -3412,7 +3415,7 @@ const zh = {
|
||||
roleNamePlaceholder: '角色名称占位',
|
||||
rolePermission: '角色权限',
|
||||
roleSortLabel: '角色排序标签',
|
||||
superAdmin: '超级管理员',
|
||||
superAdmin: '平台管理员',
|
||||
},
|
||||
constants: {
|
||||
// 工单类型
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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