blob: 401b6bb1f2b4a17baf6d7e029595dfd14079a12e [file] [log] [blame]
223010144ce05872025-06-08 22:33:28 +08001// src/routes/routes.ts
2
22301014b1477f72025-06-07 22:54:40 +08003import { createBrowserRouter } from "react-router";
223010144ce05872025-06-08 22:33:28 +08004import Home from "../feature/home/Home";
22301014b1477f72025-06-07 22:54:40 +08005import AuthLayout from "../feature/auth/AuthLayout";
6import Login from "../feature/auth/Login";
7import Register from "../feature/auth/Register";
8import Forget from "../feature/auth/Forget";
9import AppLayout from "../AppLayout";
10import withProtect from "./withProtect";
223010144ce05872025-06-08 22:33:28 +080011import Work from "../feature/work/Work";
12import CreateWork from "../feature/work/CreateWork";
22301014b1477f72025-06-07 22:54:40 +080013
223010144ce05872025-06-08 22:33:28 +080014// 创建受保护的组件
15const ProtectedHome = withProtect(Home);
16const ProtectedWork = withProtect(Work);
17const ProtectedCreatWork = withProtect(CreateWork)
223010143d966302025-06-07 22:54:40 +080018import FilmCategory from '../feature/categories/MovieCategory';
19import MusicCategory from '../feature/categories/MusicCategory';
20import GameCategory from '../feature/categories/GameCategory';
21import OtherCategory from '../feature/categories/OtherCategory';
22import WorkPage from '../feature/work/WorkPage';
23
22301014b1477f72025-06-07 22:54:40 +080024export default createBrowserRouter([
25 {
223010144ce05872025-06-08 22:33:28 +080026 path: "/",
22301014b1477f72025-06-07 22:54:40 +080027 Component: AppLayout,
28 children: [
29 {
30 path: "/",
223010144ce05872025-06-08 22:33:28 +080031 Component: ProtectedHome,
22301014b1477f72025-06-07 22:54:40 +080032 },
223010143d966302025-06-07 22:54:40 +080033 {path: 'categories/film', Component: FilmCategory,},
34 {path: 'categories/music', Component: MusicCategory,},
35 {path: 'categories/game', Component: GameCategory,},
36 {path: 'categories/other', Component: OtherCategory,},
37 {path: '/works/:id', Component: WorkPage, },
22301014b1477f72025-06-07 22:54:40 +080038 {
39 Component: AuthLayout,
40 children: [
223010144ce05872025-06-08 22:33:28 +080041 { path: "/login", Component: Login },
42 { path: "/register", Component: Register },
43 { path: "/forget", Component: Forget },
22301014b1477f72025-06-07 22:54:40 +080044 ],
45 },
223010144ce05872025-06-08 22:33:28 +080046 {
47 path: "/work/:work_id",
48 Component: ProtectedWork,
49 },
50 {
51 path:"/work/creat",
52 Component: ProtectedCreatWork
53 }
22301014b1477f72025-06-07 22:54:40 +080054 ],
55 },
223010144ce05872025-06-08 22:33:28 +080056]);