Browse Source

no message

zhujindu 7 hours ago
parent
commit
eeec334663
1 changed files with 19 additions and 26 deletions
  1. 19 26
      src/permission.js

+ 19 - 26
src/permission.js

@@ -9,35 +9,28 @@ router.beforeEach((to, from, next) => {
     localStorage.setItem('loginName', queryLoginName);
     localStorage.setItem('loginName', queryLoginName);
   }
   }
   const username = localStorage.getItem('loginName');
   const username = localStorage.getItem('loginName');
-  if (username) {
-    /* has token*/
-    if (!store.state.user.userInfo) {
-      // 获取移动端获取用户信息接口
-      store
-        .dispatch('getUserInfo')
-        .then(() => {
-          next();
-        })
-        .catch(() => {
-          next();
-        });
-    } else {
-      next();
-    }
+  // 测试使用 账户密码登录页面,正式环境禁用
+  if (to.path == '/logincs' && process.env.NODE_ENV == 'production') {
+    next('/');
   } else {
   } else {
-    // 测试使用 账户密码登录页面,正式环境禁用
-    if (to.path == '/logincs' && process.env.NODE_ENV == 'production') {
-      next('/');
+    if (username) {
+      /* has token*/
+      if (!store.state.user.userInfo) {
+        // 获取移动端获取用户信息接口
+        store
+          .dispatch('getUserInfo')
+          .then(() => {
+            next();
+          })
+          .catch(() => {
+            next();
+          });
+      } else {
+        next();
+      }
     } else {
     } else {
+      alert('获取签名失败');
       next();
       next();
     }
     }
-    // // 没有token
-    // if (whiteList.indexOf(to.path) !== -1) {
-    //   // 在免登录白名单,直接进入
-    //   next();
-    // } else {
-    //     next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
-    //     NProgress.done();
-    // }
   }
   }
 });
 });