wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 1 | // src/router/index.jsx |
wu | eb6e6ca | 2025-06-15 10:35:32 +0800 | [diff] [blame] | 2 | import React from 'react' |
| 3 | import { Routes, Route, Navigate } from 'react-router-dom' |
wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 4 | |
| 5 | // 确认这些路径和文件名与你项目里是一一对应的 |
| 6 | import CreatePost from '../components/CreatePost' // src/components/CreatePost.jsx |
| 7 | import HomeFeed from '../components/HomeFeed' // src/components/HomeFeed.jsx |
| 8 | import PlaceholderPage from '../components/PlaceholderPage'// src/components/PlaceholderPage.jsx |
| 9 | import UploadPage from '../components/UploadPage' // src/components/UploadPage.jsx |
wu | eb6e6ca | 2025-06-15 10:35:32 +0800 | [diff] [blame] | 10 | |
| 11 | export default function AppRouter() { |
| 12 | return ( |
| 13 | <Routes> |
wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 14 | {/* 一定要放在最前面,防止被 /* 等 catch-all 覆盖 */} |
| 15 | <Route path="/posts/new" element={<CreatePost />} /> |
wu | eb6e6ca | 2025-06-15 10:35:32 +0800 | [diff] [blame] | 16 | |
| 17 | <Route path="/home" element={<HomeFeed />} /> |
wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 18 | |
wu | eb6e6ca | 2025-06-15 10:35:32 +0800 | [diff] [blame] | 19 | <Route path="/notebooks" element={<PlaceholderPage pageId="notebooks" />} /> |
wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 20 | <Route path="/activity" element={<PlaceholderPage pageId="activity" />} /> |
| 21 | <Route path="/notes" element={<PlaceholderPage pageId="notes" />} /> |
| 22 | <Route path="/creator" element={<PlaceholderPage pageId="creator" />} /> |
| 23 | <Route path="/journal" element={<PlaceholderPage pageId="journal" />} /> |
wu | eb6e6ca | 2025-06-15 10:35:32 +0800 | [diff] [blame] | 24 | |
| 25 | <Route path="/dashboard/*" element={<UploadPage />} /> |
| 26 | |
wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 27 | {/* 根路径重定向到 dashboard */} |
| 28 | <Route path="/" element={<Navigate to="/dashboard/overview" replace />} /> |
| 29 | |
| 30 | {/* 最后一个兜底 */} |
wu | eb6e6ca | 2025-06-15 10:35:32 +0800 | [diff] [blame] | 31 | <Route path="*" element={<PlaceholderPage pageId="home" />} /> |
| 32 | </Routes> |
| 33 | ) |
wu | a80b90d | 2025-06-15 10:36:02 +0800 | [diff] [blame^] | 34 | } |