2026-04-24 16:18:24 +08:00
|
|
|
import React, { lazy, Suspense } from 'react';
|
2026-04-28 11:01:54 +08:00
|
|
|
import { createBrowserRouter } from 'react-router-dom';
|
2026-04-24 16:18:24 +08:00
|
|
|
import type { RouteObject } from 'react-router-dom';
|
2026-05-06 17:17:36 +08:00
|
|
|
import VideoMonitorPage from '../pages/VideoMonitorPage';
|
2026-04-17 17:20:41 +08:00
|
|
|
|
2026-04-24 16:18:24 +08:00
|
|
|
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 Devices = lazy(() => import('../pages/Devices'));
|
|
|
|
|
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'));
|
2026-05-07 14:13:26 +08:00
|
|
|
const MenuList = lazy(() => import('../components/SystemSetting/MenuList'));
|
|
|
|
|
const Organization = lazy(() => import('../components/SystemSetting/Organization'));
|
|
|
|
|
const StationManage = lazy(() => import('../components/SystemSetting/StationManage'));
|
2026-04-24 16:18:24 +08:00
|
|
|
const SerialNumGenerate = lazy(() => import('../pages/SerialNumGenerate'));
|
2026-04-29 14:26:01 +08:00
|
|
|
const SystemSetting = lazy(() => import('../pages/SystemSetting'));
|
|
|
|
|
|
2026-04-24 16:18:24 +08:00
|
|
|
function PageFallback() {
|
2026-04-28 11:01:54 +08:00
|
|
|
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>
|
|
|
|
|
);
|
2026-04-24 16:18:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const routeMeta: Record<string, {
|
2026-04-28 11:01:54 +08:00
|
|
|
title: string;
|
|
|
|
|
roles: string[];
|
|
|
|
|
requiresAuth: boolean;
|
2026-04-24 16:18:24 +08:00
|
|
|
}> = {
|
2026-04-28 11:01:54 +08:00
|
|
|
'/': { title: '总览首页', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
2026-04-29 15:01:00 +08:00
|
|
|
'/overview': { title: '总览首页', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
2026-04-28 11:01:54 +08:00
|
|
|
'/devices': { title: '设备管理', roles: ['admin', 'operator'], requiresAuth: true },
|
|
|
|
|
'/video': { title: '在线视频', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
2026-04-29 15:01:00 +08:00
|
|
|
'/monitor': { title: '实时监控', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
|
2026-04-28 11:01:54 +08:00
|
|
|
'/alerts': { title: '告警中心', roles: ['admin', 'operator'], requiresAuth: true },
|
2026-04-29 15:01:00 +08:00
|
|
|
'/AIanalysis': { title: 'AI诊断分析', roles: ['admin', 'operator'], requiresAuth: true },
|
|
|
|
|
'/clean': { title: '清洗优化', roles: ['admin', 'operator'], requiresAuth: true },
|
|
|
|
|
'/task': { title: '工单任务', roles: ['admin', 'operator'], requiresAuth: true },
|
|
|
|
|
'/table': { title: '报表中心', roles: ['admin', 'operator'], requiresAuth: true },
|
|
|
|
|
'/systemSetting': { title: '系统设置', roles: ['admin'], requiresAuth: true },
|
2026-04-28 11:01:54 +08:00
|
|
|
'/downloads': { title: '视频下载', roles: ['admin', 'operator'], requiresAuth: true },
|
|
|
|
|
'/serialNumGenerate': { title: '序列号生成', roles: ['admin'], requiresAuth: true },
|
2026-04-29 15:01:00 +08:00
|
|
|
'/manage/users': { title: '用户管理', roles: ['admin'], requiresAuth: true },
|
|
|
|
|
'/manage/roles': { title: '角色管理', roles: ['admin'], requiresAuth: true },
|
|
|
|
|
'/manage/menuList': { title: '菜单管理', roles: ['admin'], requiresAuth: true },
|
2026-04-28 11:01:54 +08:00
|
|
|
'/organization': { title: '组织管理', roles: ['admin'], requiresAuth: true },
|
|
|
|
|
'/station': { title: '场站管理', roles: ['admin'], requiresAuth: true },
|
2026-04-24 16:18:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const routes: RouteObject[] = [
|
2026-04-28 11:01:54 +08:00
|
|
|
{
|
|
|
|
|
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: <Home /> },
|
2026-04-29 15:01:00 +08:00
|
|
|
{ path: 'overview', element: <Home /> },
|
2026-04-28 11:01:54 +08:00
|
|
|
{ path: 'devices', element: <Devices /> },
|
|
|
|
|
{ path: 'video', element: <Video /> },
|
2026-05-06 17:17:36 +08:00
|
|
|
{ path: 'monitor', element: <VideoMonitorPage /> },
|
2026-04-28 11:01:54 +08:00
|
|
|
{ path: 'alerts', element: <Alerts /> },
|
2026-04-29 15:01:00 +08:00
|
|
|
{ path: 'AIanalysis', element: <div>AI诊断分析</div> },
|
|
|
|
|
{ path: 'clean', element: <div>清洗优化</div> },
|
|
|
|
|
{ path: 'task', element: <div>工单任务</div> },
|
|
|
|
|
{ path: 'table', element: <div>报表中心</div> },
|
|
|
|
|
{ path: 'systemSetting', element: <SystemSetting /> },
|
2026-04-28 11:01:54 +08:00
|
|
|
{ path: 'downloads', element: <Downloads /> },
|
|
|
|
|
{ path: 'serialNumGenerate', element: <SerialNumGenerate /> },
|
2026-04-29 15:01:00 +08:00
|
|
|
{ path: 'manage/users', element: <Users /> },
|
|
|
|
|
{ path: 'manage/roles', element: <Roles /> },
|
|
|
|
|
{ path: 'manage/menuList', element: <MenuList /> },
|
2026-04-28 11:01:54 +08:00
|
|
|
{ path: 'organization', element: <Organization /> },
|
|
|
|
|
{ path: 'station', element: <StationManage /> },
|
2026-04-29 14:26:01 +08:00
|
|
|
{ path: 'system', element: <SystemSetting /> },
|
2026-04-28 11:01:54 +08:00
|
|
|
{
|
|
|
|
|
path: '*',
|
|
|
|
|
element: (
|
|
|
|
|
<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">模块开发中</p>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-04-24 16:18:24 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const router = createBrowserRouter(routes);
|