import { createBrowserRouter, IndexRouteObject, Link, NonIndexRouteObject, useParams, } from "react-router-dom"; import ErrorPage from "../app/error"; import WithAuth from "../components/utils/with-auth"; import LoginPage from "../app/login"; import HomePage from "../app/main/home/page"; import { CourseDetailPage } from "../app/main/course/detail/page"; import { CourseBasicForm } from "../components/models/course/editor/form/CourseBasicForm"; import CourseContentForm from "../components/models/course/editor/form/CourseContentForm/CourseContentForm"; import CourseEditorLayout from "../components/models/course/editor/layout/CourseEditorLayout"; import { MainLayout } from "../app/main/layout/MainLayout"; import CoursesPage from "../app/main/courses/page"; import PathsPage from "../app/main/paths/page"; import { adminRoute } from "./admin-route"; import { CoursePreview } from "../app/main/course/preview/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: "paths", element: , }, { path: "courses", element: , }, { path: "profiles", }, // // 课程预览页面 // { // path: "coursePreview/:id?", // element: , // }, ], }, { path: "course", children: [ { path: ":id?/editor", element: ( ), children: [ { index: true, element: ( ), }, { path: "content", element: ( ), }, // { // path: "setting", // element: ( // // ), // }, ], }, { path: ":id?/detail/:lectureId?", // 使用 ? 表示 id 参数是可选的 element: , }, ], }, adminRoute, ], }, { path: "/login", breadcrumb: "登录", element: , }, ]; export const router = createBrowserRouter(routes);