فهرست منبع

地灾小浪底

sujunling 1 سال پیش
والد
کامیت
fcd0fe05eb
1فایلهای تغییر یافته به همراه16 افزوده شده و 4 حذف شده
  1. 16 4
      src/router/guard/permissionGuard.ts

+ 16 - 4
src/router/guard/permissionGuard.ts

@@ -23,9 +23,21 @@ export async function createPermissionGuard(router: Router) {
   var tokenV2 = session.getItem('tokenV2')
   if ((location.href.indexOf('refreshToken') > -1) && (!token || !tokenV2)) {
     var o = session.getItem('loginParams');
-    await userStore2.login({ password: 'Tofly@028', username: o.username.toUpperCase(), mode: 'modal' })//地灾使用这个
-    //修改地址栏链接
-    window.history.pushState('', '', location.href.split('?')[0]);
+    if (o && o.username) {
+      await userStore2.login({
+        password: 'Tofly@028',
+        username: o.username.toUpperCase(),
+        mode: 'modal'
+      })//地灾使用这个
+      //修改地址栏链接
+      window.history.pushState('', '', location.href.split('?')[0]);
+      window.location.reload();
+      return;
+    } else {
+      sessionStorage.clear();
+      localStorage.clear();
+      window.location.href = '/admin/index.html';
+    }
   }
 
   router.beforeEach(async (to, from, next) => {
@@ -53,7 +65,7 @@ export async function createPermissionGuard(router: Router) {
             return;
           }
         } catch { }
-      } else if (to.path == LOGIN_PATH) {
+      } else if (to.path == LOGIN_PATH && !(location.href.indexOf('127.0.0.1') > -1) && !(location.href.indexOf('localhost') > -1)) {
         sessionStorage.clear();//地灾项目使用这个
         localStorage.clear();//地灾项目使用这个
         window.location.href = '/admin/index.html';//地灾项目使用这个