doctor-mail/apps/web/src/routes/index.tsx

87 lines
2.7 KiB
TypeScript
Raw Normal View History

2024-07-11 11:00:51 +08:00
import {
2024-09-10 10:31:24 +08:00
createBrowserRouter,
IndexRouteObject,
NonIndexRouteObject
2024-07-11 11:00:51 +08:00
} from "react-router-dom";
import MainPage from "../app/main/page";
2024-07-22 10:07:05 +08:00
import ErrorPage from "../app/error";
import LayoutPage from "../app/layout";
2024-09-09 18:48:07 +08:00
import LoginPage from "../app/login";
2024-09-10 10:31:24 +08:00
import DepartmentAdminPage from "../app/admin/department/page";
import RoleAdminPage from "../app/admin/role/page";
import StaffAdminPage from "../app/admin/staff/page";
import TermAdminPage from "../app/admin/term/page";
import WithAuth from "../components/utilities/with-auth";
interface CustomIndexRouteObject extends IndexRouteObject {
name?: string;
breadcrumb?: string;
}
2024-07-22 10:07:05 +08:00
2024-09-10 10:31:24 +08:00
interface CustomNonIndexRouteObject extends NonIndexRouteObject {
name?: string;
children?: CustomRouteObject[];
breadcrumb?: string;
}
type CustomRouteObject = CustomIndexRouteObject | CustomNonIndexRouteObject;
export const routes = [
2024-07-11 11:00:51 +08:00
{
path: "/",
2024-07-22 10:07:05 +08:00
element: <LayoutPage></LayoutPage>,
2024-07-11 11:00:51 +08:00
errorElement: <ErrorPage></ErrorPage>,
children: [
{
index: true,
2024-09-09 18:48:07 +08:00
element: <WithAuth><MainPage></MainPage></WithAuth>
2024-09-10 10:31:24 +08:00
},
{
path: "admin",
children: [
{
path: "department",
breadcrumb: "单位管理",
element: (
<WithAuth>
<DepartmentAdminPage></DepartmentAdminPage>
</WithAuth>
),
},
{
path: "staff",
breadcrumb: "人员管理",
element: (
<WithAuth>
<StaffAdminPage></StaffAdminPage>
</WithAuth>
),
},
{
path: "term",
breadcrumb: "术语管理",
element: (
<WithAuth>
<TermAdminPage></TermAdminPage>
</WithAuth>
),
},
{
path: "role",
breadcrumb: "角色管理",
element: (
<WithAuth>
<RoleAdminPage></RoleAdminPage>
</WithAuth>
),
}
],
},
2024-09-09 18:48:07 +08:00
],
2024-07-11 11:00:51 +08:00
},
2024-09-09 18:48:07 +08:00
{
path: '/login',
element: <LoginPage></LoginPage>
}
2024-09-10 10:31:24 +08:00
]
export const router = createBrowserRouter(routes);