blob: d380bde143ba7dc8bcd0c1e81e4f77bc318f5a94 [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
22301021313d1b22025-06-09 01:13:46 +080014import UserHome from "../feature/user/UserHome";
15
223010144ce05872025-06-08 22:33:28 +080016// 创建受保护的组件
17const ProtectedHome = withProtect(Home);
18const ProtectedWork = withProtect(Work);
19const ProtectedCreatWork = withProtect(CreateWork)
223010143d966302025-06-07 22:54:40 +080020import FilmCategory from '../feature/categories/MovieCategory';
21import MusicCategory from '../feature/categories/MusicCategory';
22import GameCategory from '../feature/categories/GameCategory';
23import OtherCategory from '../feature/categories/OtherCategory';
24import WorkPage from '../feature/work/WorkPage';
25
22301014b1477f72025-06-07 22:54:40 +080026export default createBrowserRouter([
27 {
223010144ce05872025-06-08 22:33:28 +080028 path: "/",
22301014b1477f72025-06-07 22:54:40 +080029 Component: AppLayout,
30 children: [
31 {
32 path: "/",
223010144ce05872025-06-08 22:33:28 +080033 Component: ProtectedHome,
22301014b1477f72025-06-07 22:54:40 +080034 },
223010143d966302025-06-07 22:54:40 +080035 {path: 'categories/film', Component: FilmCategory,},
36 {path: 'categories/music', Component: MusicCategory,},
37 {path: 'categories/game', Component: GameCategory,},
38 {path: 'categories/other', Component: OtherCategory,},
39 {path: '/works/:id', Component: WorkPage, },
22301014b1477f72025-06-07 22:54:40 +080040 {
22301021313d1b22025-06-09 01:13:46 +080041 path: "user",
42 Component: UserHome,
43 },
44 {
22301014b1477f72025-06-07 22:54:40 +080045 Component: AuthLayout,
46 children: [
223010144ce05872025-06-08 22:33:28 +080047 { path: "/login", Component: Login },
48 { path: "/register", Component: Register },
49 { path: "/forget", Component: Forget },
22301014b1477f72025-06-07 22:54:40 +080050 ],
51 },
223010144ce05872025-06-08 22:33:28 +080052 {
53 path: "/work/:work_id",
54 Component: ProtectedWork,
55 },
56 {
57 path:"/work/creat",
58 Component: ProtectedCreatWork
59 }
22301014b1477f72025-06-07 22:54:40 +080060 ],
61 },
223010144ce05872025-06-08 22:33:28 +080062]);