jwyu 6 сар өмнө
parent
commit
99ed6656f1
2 өөрчлөгдсөн 5 нэмэгдсэн , 3 устгасан
  1. 4 2
      src/api/http.js
  2. 1 1
      src/main.js

+ 4 - 2
src/api/http.js

@@ -1,6 +1,7 @@
 "use strict";
 import axios from "axios";
 import bus from "./bus.js";
+import {router} from '../main'
 let store=null
 // 异步加载store模块 不异步加载的话,@/api/modules/oldApi.js的导入导出写法会有问题
 import('@/vuex/index.js')
@@ -77,14 +78,15 @@ function checkStatus(response,closableErrMsg) {
     } else if (res.Ret == 403) {
       errorMsgShow(closableErrMsg,res.Msg)
     } else if (res.Ret === 408) {
-      localStorage.setItem("auth", "")
+      // localStorage.setItem("auth", "")
       localStorage.setItem("loginTime", "")
       bus
         .$alert(res.Msg, "提示", {
           showClose: false,
         })
         .then(() => {
-          window.location.href = window.location.origin + '/login';
+          router.replace('/login')
+          // window.location.href = window.location.origin + '/login';
         });
     }
     return res;

+ 1 - 1
src/main.js

@@ -202,7 +202,7 @@ router.beforeEach(async(to, from, next) => {
 
   let auth = localStorage.getItem("auth") || false;
   if (to.path != "/login" && to.path!='/temppage' &&to.path!='/fogetpassword' && !auth) {
-    window.location.href =  window.location.origin + '/login';
+    next('/login')
     return false;
   }