Browse Source

修改登陆逻辑

Liuzhenyu 4 days ago
parent
commit
56ca0a2c56
1 changed files with 32 additions and 30 deletions
  1. 32 30
      src/permission.ts

+ 32 - 30
src/permission.ts

@@ -32,36 +32,38 @@ router.beforeEach((to, from, next) => {
             next({ path: '/' });
             NProgress.done();
         } else {
-            if (useUserStore().roles.length === 0) {
-                isRelogin.show = true;
-                // 判断当前用户是否已拉取完user_info信息
-                useUserStore()
-                    .getInfo()
-                    .then(() => {
-                        isRelogin.show = false;
-                        usePermissionStore()
-                            .generateRoutes()
-                            .then(accessRoutes => {
-                                // 根据roles权限生成可访问的路由表
-                                accessRoutes.forEach(route => {
-                                    if (!isHttp(route.path)) {
-                                        router.addRoute(route); // 动态添加可访问路由表
-                                    }
-                                });
-                                next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
-                            });
-                    })
-                    .catch(err => {
-                        useUserStore()
-                            .logOut()
-                            .then(() => {
-                                ElMessage.error(err);
-                                next({ path: '/' });
-                            });
-                    });
-            } else {
-                next();
-            }
+            /* TODO 暂时隐藏登陆逻辑 */
+            // if (useUserStore().roles.length === 0) {
+            //     isRelogin.show = true;
+            //     // 判断当前用户是否已拉取完user_info信息
+            //     useUserStore()
+            //         .getInfo()
+            //         .then(() => {
+            //             isRelogin.show = false;
+            //             usePermissionStore()
+            //                 .generateRoutes()
+            //                 .then(accessRoutes => {
+            //                     // 根据roles权限生成可访问的路由表
+            //                     accessRoutes.forEach(route => {
+            //                         if (!isHttp(route.path)) {
+            //                             router.addRoute(route); // 动态添加可访问路由表
+            //                         }
+            //                     });
+            //                     next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
+            //                 });
+            //         })
+            //         .catch(err => {
+            //             useUserStore()
+            //                 .logOut()
+            //                 .then(() => {
+            //                     ElMessage.error(err);
+            //                     next({ path: '/' });
+            //                 });
+            //         });
+            // } else {
+            //     next();
+            // }
+            next();
         }
     } else {
         // 没有token