2
0
Переглянути джерело

✨ feat(mobile): 添加新路由并优化用户信息展示

- 重构移动端路由结构,将classroom、stock和xunlian路由整合到member路由下
- 优化导航栏用户信息展示,简化用户头像按钮样式,仅保留图标
- 调整用户名显示位置,直接展示在导航栏右侧

✨ refactor(routes): 优化移动端路由配置

- 将多个路由从根路径移至member路由下,优化路由层级结构
- 保持原有功能不变,提升路由组织清晰度和可维护性
yourname 6 місяців тому
батько
коміт
b375abdbb8
2 змінених файлів з 41 додано та 41 видалено
  1. 13 13
      src/client/mobile/layouts/MainLayout.tsx
  2. 28 28
      src/client/mobile/routes.tsx

+ 13 - 13
src/client/mobile/layouts/MainLayout.tsx

@@ -143,24 +143,24 @@ export const MainLayout = () => {
                   <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
                   <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
                 </svg>
                 </svg>
               </button>
               </button>
+              {user && (
+                <button
+                  onClick={() => navigate('/mobile/member')}
+                  className="w-8 h-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center mr-3"
+                >
+                  <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
+                    <path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />
+                  </svg>
+                </button>
+              )}
               <h1 className="text-xl font-semibold text-foreground">股票训练系统</h1>
               <h1 className="text-xl font-semibold text-foreground">股票训练系统</h1>
             </div>
             </div>
 
 
             <div className="flex items-center space-x-4">
             <div className="flex items-center space-x-4">
               {user ? (
               {user ? (
-                <button
-                  onClick={() => navigate('/mobile/member')}
-                  className="flex items-center space-x-2 p-2 rounded-md hover:bg-muted"
-                >
-                  <div className="w-8 h-8 rounded-full bg-primary text-primary-foreground flex items-center justify-center">
-                    <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
-                      <path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />
-                    </svg>
-                  </div>
-                  <span className="hidden sm:inline text-sm text-muted-foreground">
-                    {user.username}
-                  </span>
-                </button>
+                <span className="text-sm text-muted-foreground">
+                  {user.username}
+                </span>
               ) : (
               ) : (
                 <div className="flex space-x-2">
                 <div className="flex space-x-2">
                   <button
                   <button

+ 28 - 28
src/client/mobile/routes.tsx

@@ -53,6 +53,34 @@ export const router = createBrowserRouter([
         path: 'member',
         path: 'member',
         element: <MemberPage />
         element: <MemberPage />
       },
       },
+      {
+        path: 'classroom/:classId/:role',
+        element: <ProtectedRoute><ClassroomPage /></ProtectedRoute>,
+        errorElement: <ErrorPage />
+      },
+      {
+        path: 'classroom/:role',
+        element: <ProtectedRoute><ClassroomPage /></ProtectedRoute>,
+        errorElement: <ErrorPage />
+      },
+      {
+        path: 'classroom',
+        element: <ProtectedRoute><ClassroomPage /></ProtectedRoute>,
+        errorElement: <ErrorPage />
+      },
+      {
+        path: 'stock',
+        element: <ProtectedRoute><StockMain /></ProtectedRoute>,
+        errorElement: <ErrorPage />
+      },
+      {
+        path: 'xunlian',
+        element: (
+          <ProtectedRoute>
+            <XunlianPage />
+          </ProtectedRoute>
+        ),
+      },
       {
       {
         path: '*',
         path: '*',
         element: <NotFoundPage />,
         element: <NotFoundPage />,
@@ -68,34 +96,6 @@ export const router = createBrowserRouter([
   //     </ProtectedRoute>
   //     </ProtectedRoute>
   //   ),
   //   ),
   // },
   // },
-  {
-    path: '/mobile/xunlian',
-    element: (
-      <ProtectedRoute>
-        <XunlianPage />
-      </ProtectedRoute>
-    ),
-  },
-  {
-    path: '/mobile/classroom/:classId/:role',
-    element: <ProtectedRoute><ClassroomPage /></ProtectedRoute>,
-    errorElement: <ErrorPage />
-  },
-  {
-    path: '/mobile/classroom/:role',
-    element: <ProtectedRoute><ClassroomPage /></ProtectedRoute>,
-    errorElement: <ErrorPage />
-  },
-  {
-    path: '/mobile/classroom',
-    element: <ProtectedRoute><ClassroomPage /></ProtectedRoute>,
-    errorElement: <ErrorPage />
-  },
-  {
-    path: '/mobile/stock',
-    element: <ProtectedRoute><StockMain /></ProtectedRoute>,
-    errorElement: <ErrorPage />
-  },
   {
   {
     path: '/mobile/exam/card',
     path: '/mobile/exam/card',
     element: <ProtectedRoute><ExamCard /></ProtectedRoute>,
     element: <ProtectedRoute><ExamCard /></ProtectedRoute>,