22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 1 | // src/routes/routes.ts |
| 2 | |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 3 | import { createBrowserRouter } from "react-router"; |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 4 | import Home from "../feature/home/Home"; |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 5 | import AuthLayout from "../feature/auth/AuthLayout"; |
| 6 | import Login from "../feature/auth/Login"; |
| 7 | import Register from "../feature/auth/Register"; |
| 8 | import Forget from "../feature/auth/Forget"; |
| 9 | import AppLayout from "../AppLayout"; |
| 10 | import withProtect from "./withProtect"; |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 11 | import Work from "../feature/work/Work"; |
| 12 | import CreateWork from "../feature/work/CreateWork"; |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 13 | |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 14 | // 创建受保护的组件 |
| 15 | const ProtectedHome = withProtect(Home); |
| 16 | const ProtectedWork = withProtect(Work); |
| 17 | const ProtectedCreatWork = withProtect(CreateWork) |
22301014 | 3d96630 | 2025-06-07 22:54:40 +0800 | [diff] [blame^] | 18 | import FilmCategory from '../feature/categories/MovieCategory'; |
| 19 | import MusicCategory from '../feature/categories/MusicCategory'; |
| 20 | import GameCategory from '../feature/categories/GameCategory'; |
| 21 | import OtherCategory from '../feature/categories/OtherCategory'; |
| 22 | import WorkPage from '../feature/work/WorkPage'; |
| 23 | |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 24 | export default createBrowserRouter([ |
| 25 | { |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 26 | path: "/", |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 27 | Component: AppLayout, |
| 28 | children: [ |
| 29 | { |
| 30 | path: "/", |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 31 | Component: ProtectedHome, |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 32 | }, |
22301014 | 3d96630 | 2025-06-07 22:54:40 +0800 | [diff] [blame^] | 33 | {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, }, |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 38 | { |
| 39 | Component: AuthLayout, |
| 40 | children: [ |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 41 | { path: "/login", Component: Login }, |
| 42 | { path: "/register", Component: Register }, |
| 43 | { path: "/forget", Component: Forget }, |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 44 | ], |
| 45 | }, |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 46 | { |
| 47 | path: "/work/:work_id", |
| 48 | Component: ProtectedWork, |
| 49 | }, |
| 50 | { |
| 51 | path:"/work/creat", |
| 52 | Component: ProtectedCreatWork |
| 53 | } |
22301014 | b1477f7 | 2025-06-07 22:54:40 +0800 | [diff] [blame] | 54 | ], |
| 55 | }, |
22301014 | 4ce0587 | 2025-06-08 22:33:28 +0800 | [diff] [blame] | 56 | ]); |