路由懒加载 还要取消暂停路径规划接口 接入
This commit is contained in:
@@ -289,4 +289,24 @@ export function excuetRoute(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//取消任务
|
||||||
|
|
||||||
|
export function cancelRoute(data) {
|
||||||
|
return request({
|
||||||
|
url: `/iot/deviceTask/cancelTask`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pauseRoute(data) {
|
||||||
|
return request({
|
||||||
|
url: `/iot/deviceTask/pauseTask`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,9 @@ export default function DeviceStatusPage({
|
|||||||
controllerRef.current = controller;
|
controllerRef.current = controller;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
controller.destroy();
|
controller?.destroy();
|
||||||
|
controllerRef.current?.destroy();
|
||||||
|
|
||||||
controllerRef.current = null;
|
controllerRef.current = null;
|
||||||
};
|
};
|
||||||
}, [userInfo, messageApi]);
|
}, [userInfo, messageApi]);
|
||||||
@@ -376,11 +378,7 @@ export default function DeviceStatusPage({
|
|||||||
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) return;
|
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) return;
|
||||||
|
|
||||||
controllerRef.current.connectDevice(device);
|
controllerRef.current.connectDevice(device);
|
||||||
return () => {
|
|
||||||
controllerRef.current.destroy();
|
|
||||||
controllerRef.current = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
}, [device?.serialNumber]);
|
}, [device?.serialNumber]);
|
||||||
|
|
||||||
// 定时获取无人机状态
|
// 定时获取无人机状态
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default function RobotTaskPage() {
|
|||||||
const controller = new DeviceController(userInfo, messageApi);
|
const controller = new DeviceController(userInfo, messageApi);
|
||||||
controllerRef.current = controller;
|
controllerRef.current = controller;
|
||||||
return () => {
|
return () => {
|
||||||
controllerRef.current.destroy();
|
controllerRef.current?.destroy();
|
||||||
controllerRef.current = null;
|
controllerRef.current = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import React, { lazy, Suspense } from 'react';
|
import React, { lazy, Suspense } from 'react';
|
||||||
import { createBrowserRouter } from 'react-router-dom';
|
import { createBrowserRouter } from 'react-router-dom';
|
||||||
import type { RouteObject } from 'react-router-dom';
|
import type { RouteObject } from 'react-router-dom';
|
||||||
import VideoMonitorPage from '../pages/VideoMonitorPage';
|
|
||||||
import AIDiagnosisPage from '../pages/AIAnalysis';
|
// 🔥 所有组件全部改为懒加载
|
||||||
import CleanOptimizationPage from '../pages/CleanOptimization';
|
const VideoMonitorPage = lazy(() => import('../pages/VideoMonitorPage'));
|
||||||
import WorkOrderPage from '../pages/WorkOrder';
|
const AIDiagnosisPage = lazy(() => import('../pages/AIAnalysis'));
|
||||||
import ReportCenterPage from '../pages/ReportCenter';
|
const CleanOptimizationPage = lazy(() => import('../pages/CleanOptimization'));
|
||||||
import RealTimeMonitorPage from '../pages/RealTimeMonitor';
|
const WorkOrderPage = lazy(() => import('../pages/WorkOrder'));
|
||||||
import Agri from '../pages/Agri';
|
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 Layout = lazy(() => import('../components/Layout'));
|
||||||
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
|
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
|
||||||
@@ -26,6 +28,7 @@ const StationManage = lazy(() => import('../components/SystemSetting/StationMana
|
|||||||
const SystemSetting = lazy(() => import('../pages/SystemSetting'));
|
const SystemSetting = lazy(() => import('../pages/SystemSetting'));
|
||||||
const Profile = lazy(() => import('../pages/Profile'));
|
const Profile = lazy(() => import('../pages/Profile'));
|
||||||
|
|
||||||
|
// 加载中动画
|
||||||
function PageFallback() {
|
function PageFallback() {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center h-full min-h-[200px]">
|
<div className="flex items-center justify-center h-full min-h-[200px]">
|
||||||
@@ -60,6 +63,7 @@ export const routeMeta: Record<string, {
|
|||||||
'/profile': { title: '个人中心', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
'/profile': { title: '个人中心', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ====================== 全部懒加载的路由配置 ======================
|
||||||
const routes: RouteObject[] = [
|
const routes: RouteObject[] = [
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
@@ -83,28 +87,174 @@ const routes: RouteObject[] = [
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
{ index: true, element: <Home /> },
|
{
|
||||||
{ path: 'overview', element: <Home /> },
|
index: true,
|
||||||
{ path: 'devices', element: <Devices /> },
|
element: (
|
||||||
{ path: 'video', element: <Video /> },
|
<Suspense fallback={<PageFallback />}>
|
||||||
{ path: 'RealtimeMonitor', element: <RealTimeMonitorPage /> },
|
<Home />
|
||||||
{ path: 'monitor', element: <VideoMonitorPage /> },
|
</Suspense>
|
||||||
{ path: 'agri', element: <Agri /> },
|
)
|
||||||
{ path: 'alerts', element: <Alerts /> },
|
},
|
||||||
{ path: 'AIanalysis', element: <AIDiagnosisPage /> },
|
{
|
||||||
{ path: 'clean', element: <CleanOptimizationPage /> },
|
path: 'overview',
|
||||||
{ path: 'task', element: <WorkOrderPage /> },
|
element: (
|
||||||
{ path: 'table', element: <ReportCenterPage /> },
|
<Suspense fallback={<PageFallback />}>
|
||||||
{ path: 'systemSetting', element: <SystemSetting /> },
|
<Home />
|
||||||
{ path: 'downloads', element: <Downloads /> },
|
</Suspense>
|
||||||
|
)
|
||||||
{ path: 'manage/users', element: <Users /> },
|
},
|
||||||
{ path: 'manage/roles', element: <Roles /> },
|
{
|
||||||
{ path: 'manage/menuList', element: <MenuList /> },
|
path: 'devices',
|
||||||
{ path: 'organization', element: <Organization /> },
|
element: (
|
||||||
{ path: 'station', element: <StationManage /> },
|
<Suspense fallback={<PageFallback />}>
|
||||||
{ path: 'system', element: <SystemSetting /> },
|
<Devices />
|
||||||
{ path: 'profile', element: <Profile /> },
|
</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',
|
||||||
|
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>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: '*',
|
path: '*',
|
||||||
element: (
|
element: (
|
||||||
|
|||||||
Reference in New Issue
Block a user