72 lines
1.7 KiB
TypeScript
Executable File
72 lines
1.7 KiB
TypeScript
Executable File
import {
|
|
createBrowserRouter,
|
|
IndexRouteObject,
|
|
NonIndexRouteObject,
|
|
} from "react-router-dom";
|
|
import ErrorPage from "../app/error";
|
|
import LoginPage from "../app/login";
|
|
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";
|
|
import WithAuth from "../components/utils/with-auth";
|
|
import DashboardPage from "../app/main/devicepage/dashboard/page";
|
|
interface CustomIndexRouteObject extends IndexRouteObject {
|
|
name?: string;
|
|
breadcrumb?: string;
|
|
}
|
|
interface CustomIndexRouteObject extends IndexRouteObject {
|
|
name?: string;
|
|
breadcrumb?: string;
|
|
}
|
|
|
|
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[] = [
|
|
{
|
|
errorElement: <ErrorPage />,
|
|
path: "/",
|
|
element: <MainLayout/>,
|
|
children: [
|
|
{
|
|
children: [
|
|
{
|
|
index: true,
|
|
element: <WithAuth><DashboardPage></DashboardPage></WithAuth>,
|
|
},
|
|
{
|
|
path: "/device",
|
|
element: <WithAuth><DeviceMessage></DeviceMessage></WithAuth>,
|
|
},
|
|
{
|
|
path: "/admin",
|
|
element: <WithAuth><AdminLayout></AdminLayout></WithAuth>,
|
|
children: adminRoute.children,
|
|
},
|
|
{
|
|
path: "/dashboard",
|
|
element: <WithAuth><DashboardPage/></WithAuth>,
|
|
},
|
|
],
|
|
},]
|
|
},
|
|
|
|
{
|
|
path: "/login",
|
|
breadcrumb: "登录",
|
|
element: <LoginPage></LoginPage>,
|
|
},
|
|
|
|
];
|
|
|
|
export const router = createBrowserRouter(routes);
|