import { createBrowserRouter, IndexRouteObject, Link, NonIndexRouteObject, } from "react-router-dom"; import { RolePerms } from "@nicestack/common"; import ErrorPage from "../app/error"; import DepartmentAdminPage from "../app/admin/department/page"; import TermAdminPage from "../app/admin/term/page"; import StaffAdminPage from "../app/admin/staff/page"; import RoleAdminPage from "../app/admin/role/page"; import WithAuth from "../components/utils/with-auth"; import LoginPage from "../app/login"; import BaseSettingPage from "../app/admin/base-setting/page"; import { CoursePage } from "../app/main/course/page"; import { CourseEditorPage } from "../app/main/course/editor/page"; import { MainLayout } from "../components/layout/main/MainLayout"; import StudentCoursesPage from "../app/main/courses/student/page"; import InstructorCoursesPage from "../app/main/courses/instructor/page"; import HomePage from "../app/main/home/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[] = [ { path: "/", errorElement: , handle: { crumb() { return 主页; }, }, children: [ { element: , children: [ { index: true, element: }, { path: "courses", children: [ { path: "student", element: }, { path: "instructor", element: } ] } ] }, { path: "course", children: [{ path: ":id?/manage", // 使用 ? 表示 id 参数是可选的 element: }] }, { path: "admin", children: [ { path: "base-setting", element: ( ), handle: { crumb() { return ( 基本设置 ); }, }, }, { path: "department", breadcrumb: "单位管理", element: ( ), handle: { crumb() { return ( 组织架构 ); }, }, }, { path: "staff", element: ( ), handle: { crumb() { return ( 用户管理 ); }, }, }, { path: "term", breadcrumb: "分类配置", element: ( ), handle: { crumb() { return 分类配置; }, }, }, { path: "role", breadcrumb: "角色管理", element: ( ), handle: { crumb() { return 角色管理; }, }, }, ], }, ], }, { path: "/login", breadcrumb: "登录", element: , }, ]; export const router = createBrowserRouter(routes);