TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 1 | import React from 'react'; |
| 2 | import { |
| 3 | Routes, |
| 4 | Route, |
| 5 | Navigate, |
| 6 | } from 'react-router-dom'; |
| 7 | import AdminPage from '../components/Admin'; |
| 8 | import UserManagement from '../components/UserManagement'; |
| 9 | import LogsDashboard from '../components/LogsDashboard'; |
| 10 | import SuperAdmin from '../components/SuperAdmin'; |
| 11 | |
| 12 | import CreatePost from '../components/CreatePost' // src/components/CreatePost.jsx |
| 13 | import HomeFeed from '../components/HomeFeed' // src/components/HomeFeed.jsx |
| 14 | import PlaceholderPage from '../components/PlaceholderPage'// src/components/PlaceholderPage.jsx |
| 15 | import UploadPage from '../components/UploadPage' // src/components/UploadPage.jsx |
| 16 | |
TRM-coding | 29174c2 | 2025-06-18 23:56:51 +0800 | [diff] [blame] | 17 | import UserProfile from '../components/UserProfile'; // src/components/UserProfileRoute.jsx |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 18 | |
TRM-coding | c4b4f3d | 2025-06-18 19:02:46 +0800 | [diff] [blame] | 19 | import LoginPage from '../pages/LoginPage/LoginPage'; |
| 20 | import RegisterPage from '../pages/RegisterPage/RegisterPage'; |
| 21 | import ForgotPasswordPage from '../pages/ForgotPasswordPage/ForgotPasswordPage'; |
| 22 | import TestDashboard from '../pages/TestDashboard/TestDashboard'; |
| 23 | |
TRM-coding | 85e5c32 | 2025-06-18 19:49:21 +0800 | [diff] [blame] | 24 | import TransactionLogs from '../components/TransactionLogs'; |
| 25 | import PerformanceLogs from '../components/PerformanceLogs'; |
wu | 90da17b | 2025-06-19 12:45:29 +0800 | [diff] [blame^] | 26 | import NotebookPage from '../components/NotebookPage' |
TRM-coding | 85e5c32 | 2025-06-18 19:49:21 +0800 | [diff] [blame] | 27 | |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 28 | export default function AppRoutes() { |
| 29 | return ( |
| 30 | <Routes> |
| 31 | <Route path="/posts/new" element={<CreatePost />} /> |
| 32 | |
| 33 | <Route path="/home" element={<HomeFeed />} /> |
| 34 | |
wu | 90da17b | 2025-06-19 12:45:29 +0800 | [diff] [blame^] | 35 | <Route path="/notebooks" element={<NotebookPage />} /> |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 36 | <Route path="/activity" element={<PlaceholderPage pageId="activity" />} /> |
| 37 | <Route path="/notes" element={<PlaceholderPage pageId="notes" />} /> |
| 38 | <Route path="/creator" element={<PlaceholderPage pageId="creator" />} /> |
| 39 | <Route path="/journal" element={<PlaceholderPage pageId="journal" />} /> |
TRM-coding | 29174c2 | 2025-06-18 23:56:51 +0800 | [diff] [blame] | 40 | <Route path="/user/:userId" element={<UserProfile />} /> |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 41 | <Route path="/dashboard/*" element={<UploadPage />} /> |
| 42 | |
| 43 | {/* 根路径重定向到 dashboard */} |
TRM-coding | c4b4f3d | 2025-06-18 19:02:46 +0800 | [diff] [blame] | 44 | {/* <Route path="/" element={<Navigate to="/dashboard/overview" replace />} /> */} |
| 45 | |
| 46 | <Route path="/" element={<LoginPage />} /> |
| 47 | <Route path="/login" element={<LoginPage />} /> |
| 48 | <Route path="/register" element={<RegisterPage />} /> |
| 49 | <Route path="/forgot-password" element={<ForgotPasswordPage />} /> |
| 50 | <Route path="/test-dashboard" element={<TestDashboard />} /> |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 51 | |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 52 | {/* 普通管理员,无 header */} |
| 53 | <Route path="admin" element={<AdminPage />} /> |
| 54 | |
| 55 | {/* 超级管理员,只用 SuperAdminLayout */} |
| 56 | <Route path="superadmin" element={<SuperAdmin />}> |
| 57 | <Route index element={<Navigate to="users" replace />} /> |
| 58 | <Route path="users" element={<UserManagement superAdminId={3} />} /> |
TRM-coding | 85e5c32 | 2025-06-18 19:49:21 +0800 | [diff] [blame] | 59 | |
| 60 | {/* dashboard as layout */} |
| 61 | <Route path="dashboard" element={<LogsDashboard />}> |
| 62 | <Route index element={<Navigate to="transactions" replace />} /> |
| 63 | <Route path="transactions" element={<TransactionLogs userId={1} />} /> |
| 64 | <Route path="performance" element={<PerformanceLogs userId={1} />} /> |
| 65 | </Route> |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 66 | </Route> |
TRM-coding | 85e5c32 | 2025-06-18 19:49:21 +0800 | [diff] [blame] | 67 | |
| 68 | {/* 最后一个兜底,放在最末尾 */} |
| 69 | <Route path="*" element={<PlaceholderPage pageId="home" />} /> |
TRM-coding | d1cbf67 | 2025-06-18 15:15:08 +0800 | [diff] [blame] | 70 | </Routes> |
| 71 | ); |
| 72 | } |