blob: 077f8ed8a8f0a3fd2d20dfdd4f92eb1353d9da34 [file] [log] [blame]
wua80b90d2025-06-15 10:36:02 +08001// src/router/index.jsx
wueb6e6ca2025-06-15 10:35:32 +08002import React from 'react'
3import { Routes, Route, Navigate } from 'react-router-dom'
wua80b90d2025-06-15 10:36:02 +08004
5// 确认这些路径和文件名与你项目里是一一对应的
6import CreatePost from '../components/CreatePost' // src/components/CreatePost.jsx
7import HomeFeed from '../components/HomeFeed' // src/components/HomeFeed.jsx
8import PlaceholderPage from '../components/PlaceholderPage'// src/components/PlaceholderPage.jsx
9import UploadPage from '../components/UploadPage' // src/components/UploadPage.jsx
wueb6e6ca2025-06-15 10:35:32 +080010
11export default function AppRouter() {
12 return (
13 <Routes>
wua80b90d2025-06-15 10:36:02 +080014 {/* 一定要放在最前面,防止被 /* 等 catch-all 覆盖 */}
15 <Route path="/posts/new" element={<CreatePost />} />
wueb6e6ca2025-06-15 10:35:32 +080016
17 <Route path="/home" element={<HomeFeed />} />
wua80b90d2025-06-15 10:36:02 +080018
wueb6e6ca2025-06-15 10:35:32 +080019 <Route path="/notebooks" element={<PlaceholderPage pageId="notebooks" />} />
wua80b90d2025-06-15 10:36:02 +080020 <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" />} />
wueb6e6ca2025-06-15 10:35:32 +080024
25 <Route path="/dashboard/*" element={<UploadPage />} />
26
wua80b90d2025-06-15 10:36:02 +080027 {/* 根路径重定向到 dashboard */}
28 <Route path="/" element={<Navigate to="/dashboard/overview" replace />} />
29
30 {/* 最后一个兜底 */}
wueb6e6ca2025-06-15 10:35:32 +080031 <Route path="*" element={<PlaceholderPage pageId="home" />} />
32 </Routes>
33 )
wua80b90d2025-06-15 10:36:02 +080034}