47 2 months ago
parent
commit
9bd547b2d7
2 changed files with 17 additions and 18 deletions
  1. 4 1
      src/router/modules/remaining.ts
  2. 13 17
      src/views/Login/components/LoginForm.vue

+ 4 - 1
src/router/modules/remaining.ts

@@ -102,7 +102,10 @@ const remainingRouter: AppRouteRecordRaw[] = [
         path: '/system/Home/index',
         name: 'SystemHome',
         component: () => import('@/views/system/Home/Index.vue'),
-        meta: {}
+        meta: {
+          icon: 'ep:apple',
+          title: '首页',
+        }
       }
     ]
   },

+ 13 - 17
src/views/Login/components/LoginForm.vue

@@ -264,23 +264,19 @@ const handleLogin = async (params) => {
       authUtil.removeLoginForm()
     }
     authUtil.setToken(res)
-    try {
-      const userType = await LoginApi.getInfo();
-      console.log(userType,"我在这里");
-      console.log(userType);  // 查看 userType 的结构  
-      if (userType && Array.isArray(userType.roles)) {
-          if (userType.roles.indexOf("student") !== -1) {
-              console.log("我是学生");
-              window.location.href = '/system/studentSelf/index';
-          } else {
-              console.log("我不是学生");
-              window.location.href = '/system/Home/index';
-          }
-      } else {
-          console.error("userType 或 roles 格式错误");
-      }
-    } catch (error) {
-      console.error("获取用户信息时发生错误:", error);
+    const userType = await LoginApi.getInfo()
+    console.log(userType,"我在这里")
+    console.log(userType);  // 查看 userType 的结构
+    if (userType && Array.isArray(userType.roles)) {
+        if (userType.roles.indexOf("student") !== -1) {
+            console.log("我是学生");
+            window.location.href = '/system/studentSelf/index';
+        } else {
+            console.log("我不是学生");
+            window.location.href = '/system/Home/index';
+        }
+    } else {
+        console.error("userType 或 roles 格式错误");
     }
   } finally {
     loginLoading.value = false