|
|
@@ -1,147 +1,179 @@
|
|
|
-import { lazy, Suspense } from 'react';
|
|
|
-import { Routes, Route } from 'react-router-dom';
|
|
|
-import ProtectedRoute from './components/ProtectedRoute';
|
|
|
-import ErrorBoundary from './components/ErrorBoundary';
|
|
|
-import { SkeletonLoader } from './components/SkeletonLoader';
|
|
|
+import React from 'react';
|
|
|
+import { createBrowserRouter, Navigate } from 'react-router-dom';
|
|
|
+import { ProtectedRoute } from './components/ProtectedRoute';
|
|
|
+import { ErrorPage } from './components/ErrorPage';
|
|
|
+import { NotFoundPage } from './components/NotFoundPage';
|
|
|
+import { ErrorBoundary } from './components/ErrorBoundary';
|
|
|
+import { MobileLayout } from './layouts/MobileLayout';
|
|
|
+import { silverPlatformTabs } from './components/BottomTabBar';
|
|
|
|
|
|
-// 页面组件懒加载
|
|
|
-const HomePage = lazy(() => import('./pages/HomePage'));
|
|
|
-const LoginPage = lazy(() => import('./pages/LoginPage'));
|
|
|
-const RegisterPage = lazy(() => import('./pages/RegisterPage'));
|
|
|
-const DashboardPage = lazy(() => import('./pages/DashboardPage'));
|
|
|
-const SilverJobsPage = lazy(() => import('./pages/SilverJobsPage'));
|
|
|
-const JobDetailPage = lazy(() => import('./pages/JobDetailPage'));
|
|
|
-const SilverTalentsPage = lazy(() => import('./pages/SilverTalentsPage'));
|
|
|
-const TalentDetailPage = lazy(() => import('./pages/TalentDetailPage'));
|
|
|
-const SilverWisdomPage = lazy(() => import('./pages/SilverWisdomPage'));
|
|
|
-const SilverWisdomDetailPage = lazy(() => import('./pages/SilverWisdomDetailPage'));
|
|
|
-const ProfilePage = lazy(() => import('./pages/ProfilePage'));
|
|
|
-const ProfileEditPage = lazy(() => import('./pages/ProfileEditPage'));
|
|
|
-const PointsPage = lazy(() => import('./pages/PointsPage'));
|
|
|
-const MyFavoritesPage = lazy(() => import('./pages/MyFavoritesPage'));
|
|
|
-const MyPostsPage = lazy(() => import('./pages/MyPostsPage'));
|
|
|
-const PublishPage = lazy(() => import('./pages/PublishPage'));
|
|
|
-const PolicyNewsPage = lazy(() => import('./pages/PolicyNewsPage'));
|
|
|
-const PolicyNewsDetailPage = lazy(() => import('./pages/PolicyNewsDetailPage'));
|
|
|
-const CompanyProfilePage = lazy(() => import('./pages/CompanyProfilePage'));
|
|
|
-const TimeBankPage = lazy(() => import('./pages/TimeBankPage'));
|
|
|
-const ElderlyCarePage = lazy(() => import('./pages/ElderlyCarePage'));
|
|
|
-const ElderlyUniversityPage = lazy(() => import('./pages/ElderlyUniversityPage'));
|
|
|
-const FontSettingsPage = lazy(() => import('./pages/FontSettingsPage'));
|
|
|
-const AIAgentsPage = lazy(() => import('./pages/AIAgentsPage'));
|
|
|
+// 页面组件导入
|
|
|
+import HomePage from './pages/HomePage';
|
|
|
+import SilverJobsPage from './pages/SilverJobsPage';
|
|
|
+import JobDetailPage from './pages/JobDetailPage';
|
|
|
+import SilverTalentsPage from './pages/SilverTalentsPage';
|
|
|
+import TalentDetailPage from './pages/TalentDetailPage';
|
|
|
+import SilverWisdomPage from './pages/SilverWisdomPage';
|
|
|
+import SilverWisdomDetailPage from './pages/SilverWisdomDetailPage';
|
|
|
+import ElderlyUniversityPage from './pages/ElderlyUniversityPage';
|
|
|
+import TimeBankPage from './pages/TimeBankPage';
|
|
|
+import PolicyNewsPage from './pages/PolicyNewsPage';
|
|
|
+import PolicyNewsDetailPage from './pages/PolicyNewsDetailPage';
|
|
|
+import PublishPage from './pages/PublishPage';
|
|
|
+import ProfilePage from './pages/ProfilePage';
|
|
|
+import ProfileEditPage from './pages/ProfileEditPage';
|
|
|
+import CompanyProfilePage from './pages/CompanyProfilePage';
|
|
|
+import PointsPage from './pages/PointsPage';
|
|
|
+import MyPostsPage from './pages/MyPostsPage';
|
|
|
+import MyFavoritesPage from './pages/MyFavoritesPage';
|
|
|
+import SkillsPage from './pages/SkillsPage';
|
|
|
+import FontSettingsPage from './pages/FontSettingsPage';
|
|
|
+import LoginPage from './pages/LoginPage';
|
|
|
+import RegisterPage from './pages/RegisterPage';
|
|
|
+import AIAgentsPage from './pages/AIAgentsPage';
|
|
|
|
|
|
-// 加载骨架屏
|
|
|
-const LoadingSkeleton = () => (
|
|
|
- <div className="min-h-screen flex items-center justify-center">
|
|
|
- <SkeletonLoader />
|
|
|
- </div>
|
|
|
-);
|
|
|
-
|
|
|
-const MobileRoutes = () => {
|
|
|
- return (
|
|
|
- <ErrorBoundary>
|
|
|
- <Suspense fallback={<LoadingSkeleton />}>
|
|
|
- <Routes>
|
|
|
- {/* 公开路由 */}
|
|
|
- <Route path="/" element={<HomePage />} />
|
|
|
- <Route path="/login" element={<LoginPage />} />
|
|
|
- <Route path="/register" element={<RegisterPage />} />
|
|
|
-
|
|
|
- {/* 银龄岗位相关路由 */}
|
|
|
- <Route path="/silver-jobs" element={<SilverJobsPage />} />
|
|
|
- <Route path="/silver-jobs/:id" element={<JobDetailPage />} />
|
|
|
-
|
|
|
- {/* 银龄人才相关路由 */}
|
|
|
- <Route path="/silver-talents" element={<SilverTalentsPage />} />
|
|
|
- <Route path="/silver-talents/:id" element={<TalentDetailPage />} />
|
|
|
-
|
|
|
- {/* 银龄智库相关路由 */}
|
|
|
- <Route path="/silver-wisdom" element={<SilverWisdomPage />} />
|
|
|
- <Route path="/silver-wisdom/:id" element={<SilverWisdomDetailPage />} />
|
|
|
-
|
|
|
- {/* 政策资讯相关路由 */}
|
|
|
- <Route path="/policy-news" element={<PolicyNewsPage />} />
|
|
|
- <Route path="/policy-news/:id" element={<PolicyNewsDetailPage />} />
|
|
|
-
|
|
|
- {/* 养老机构相关路由 */}
|
|
|
- <Route path="/elderly-care" element={<ElderlyCarePage />} />
|
|
|
- <Route path="/elderly-universities" element={<ElderlyUniversityPage />} />
|
|
|
-
|
|
|
- {/* 时间银行相关路由 */}
|
|
|
- <Route path="/time-bank" element={<TimeBankPage />} />
|
|
|
-
|
|
|
- {/* 智能体相关路由 */}
|
|
|
- <Route path="/ai-agents" element={<AIAgentsPage />} />
|
|
|
-
|
|
|
- {/* 需要认证的路由 */}
|
|
|
- <Route path="/dashboard" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <DashboardPage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/profile" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <ProfilePage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/profile/edit" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <ProfileEditPage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/points" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <PointsPage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/favorites" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <MyFavoritesPage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/my-posts" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <MyPostsPage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/publish" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <PublishPage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/company-profile" element={
|
|
|
- <ProtectedRoute>
|
|
|
- <CompanyProfilePage />
|
|
|
- </ProtectedRoute>
|
|
|
- } />
|
|
|
-
|
|
|
- <Route path="/font-settings" element={<FontSettingsPage />} />
|
|
|
-
|
|
|
- {/* 404页面 */}
|
|
|
- <Route path="*" element={
|
|
|
- <div className="min-h-screen flex items-center justify-center">
|
|
|
- <div className="text-center">
|
|
|
- <h1 className="text-2xl font-bold mb-4">页面不存在</h1>
|
|
|
- <button
|
|
|
- onClick={() => window.history.back()}
|
|
|
- className="text-blue-600 underline"
|
|
|
- >
|
|
|
- 返回上一页
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- } />
|
|
|
- </Routes>
|
|
|
- </Suspense>
|
|
|
- </ErrorBoundary>
|
|
|
- );
|
|
|
-};
|
|
|
-
|
|
|
-export default MobileRoutes;
|
|
|
+export const router = createBrowserRouter([
|
|
|
+ {
|
|
|
+ path: '/',
|
|
|
+ element: <MobileLayout tabs={silverPlatformTabs} />,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ index: true,
|
|
|
+ element: <Navigate to="/home" replace />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'home',
|
|
|
+ element: <HomePage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'silver-jobs',
|
|
|
+ element: <SilverJobsPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'silver-jobs/:id',
|
|
|
+ element: <JobDetailPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'silver-talents',
|
|
|
+ element: <SilverTalentsPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'silver-talents/:id',
|
|
|
+ element: <TalentDetailPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'silver-wisdom',
|
|
|
+ element: <SilverWisdomPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'silver-wisdom/:id',
|
|
|
+ element: <SilverWisdomDetailPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'elderly-university',
|
|
|
+ element: <ElderlyUniversityPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'time-bank',
|
|
|
+ element: <TimeBankPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'ai-agents',
|
|
|
+ element: <AIAgentsPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'policy-news',
|
|
|
+ element: <PolicyNewsPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'policy-news/:id',
|
|
|
+ element: <PolicyNewsDetailPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'publish',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <PublishPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <ProfilePage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/edit',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <ProfileEditPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/company',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <CompanyProfilePage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/points',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <PointsPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/posts',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <MyPostsPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/favorites',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <MyFavoritesPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/skills',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <SkillsPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: 'profile/font-settings',
|
|
|
+ element: (
|
|
|
+ <ProtectedRoute>
|
|
|
+ <FontSettingsPage />
|
|
|
+ </ProtectedRoute>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: '/login',
|
|
|
+ element: <LoginPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: '/register',
|
|
|
+ element: <RegisterPage />
|
|
|
+ },
|
|
|
+ {
|
|
|
+ path: '*',
|
|
|
+ element: <NotFoundPage />,
|
|
|
+ errorElement: <ErrorPage />
|
|
|
+ }
|
|
|
+]);
|