2024-07-11 11:00:51 +08:00
|
|
|
import {
|
2024-12-30 08:26:40 +08:00
|
|
|
createBrowserRouter,
|
|
|
|
IndexRouteObject,
|
|
|
|
NonIndexRouteObject,
|
2024-07-11 11:00:51 +08:00
|
|
|
} from "react-router-dom";
|
2024-07-22 10:07:05 +08:00
|
|
|
import ErrorPage from "../app/error";
|
2025-04-09 11:40:44 +08:00
|
|
|
import LoginPage from "../app/login";
|
2025-05-20 10:29:13 +08:00
|
|
|
import { MainLayout } from "../app/main/layout/MainLayout";
|
|
|
|
import DeviceMessage from "../app/main/devicepage/page";
|
|
|
|
import AdminLayout from "../components/layout/admin/AdminLayout";
|
|
|
|
import { adminRoute } from "./admin-route";
|
2025-05-20 11:49:59 +08:00
|
|
|
import WithAuth from "../components/utils/with-auth";
|
|
|
|
import DashboardPage from "../app/main/devicepage/dashboard/page";
|
2024-09-10 10:31:24 +08:00
|
|
|
interface CustomIndexRouteObject extends IndexRouteObject {
|
2024-12-30 08:26:40 +08:00
|
|
|
name?: string;
|
|
|
|
breadcrumb?: string;
|
2024-09-10 10:31:24 +08:00
|
|
|
}
|
2024-12-30 08:26:40 +08:00
|
|
|
interface CustomIndexRouteObject extends IndexRouteObject {
|
|
|
|
name?: string;
|
|
|
|
breadcrumb?: string;
|
2024-09-10 10:31:24 +08:00
|
|
|
}
|
|
|
|
|
2024-12-30 08:26:40 +08:00
|
|
|
export interface CustomNonIndexRouteObject extends NonIndexRouteObject {
|
|
|
|
name?: string;
|
|
|
|
children?: CustomRouteObject[];
|
|
|
|
breadcrumb?: string;
|
|
|
|
handle?: {
|
|
|
|
crumb: (data?: any) => void;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
export type CustomRouteObject =
|
|
|
|
| CustomIndexRouteObject
|
|
|
|
| CustomNonIndexRouteObject;
|
|
|
|
export const routes: CustomRouteObject[] = [
|
2025-05-20 10:29:13 +08:00
|
|
|
{
|
2024-12-30 08:26:40 +08:00
|
|
|
errorElement: <ErrorPage />,
|
2025-05-20 10:29:13 +08:00
|
|
|
path: "/",
|
|
|
|
element: <MainLayout/>,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
children: [
|
2025-05-20 11:49:59 +08:00
|
|
|
{
|
2025-05-20 10:29:13 +08:00
|
|
|
index: true,
|
2025-05-20 11:49:59 +08:00
|
|
|
element: <WithAuth><DashboardPage></DashboardPage></WithAuth>,
|
2025-05-20 10:29:13 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/device",
|
2025-05-20 11:49:59 +08:00
|
|
|
element: <WithAuth><DeviceMessage></DeviceMessage></WithAuth>,
|
2025-05-20 10:29:13 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: "/admin",
|
2025-05-20 11:49:59 +08:00
|
|
|
element: <WithAuth><AdminLayout></AdminLayout></WithAuth>,
|
2025-05-20 10:29:13 +08:00
|
|
|
children: adminRoute.children,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
},]
|
2025-04-02 21:59:19 +08:00
|
|
|
},
|
2025-05-20 11:49:59 +08:00
|
|
|
{
|
|
|
|
path: "/dashboard",
|
|
|
|
element: <WithAuth><DashboardPage/></WithAuth>,
|
|
|
|
},
|
2025-04-09 11:40:44 +08:00
|
|
|
{
|
|
|
|
path: "/login",
|
|
|
|
breadcrumb: "登录",
|
|
|
|
element: <LoginPage></LoginPage>,
|
|
|
|
},
|
2025-04-21 22:52:10 +08:00
|
|
|
|
2024-12-30 08:26:40 +08:00
|
|
|
];
|
2024-09-09 18:48:07 +08:00
|
|
|
|
2024-09-10 10:31:24 +08:00
|
|
|
export const router = createBrowserRouter(routes);
|