tangning 4 months ago
parent
commit
3ce0a8031a
1 changed files with 14 additions and 14 deletions
  1. 14 14
      src/request/index.ts

+ 14 - 14
src/request/index.ts

@@ -54,8 +54,8 @@ axios.interceptors.request.use(async (config) => {
   if (!token && !~notLoginUrls.indexOf(config.url)) {
     // router.replace({ name: RouteName.login });
     let redirect = encodeURIComponent(`${window.location.href}`);
-    window.location.href = window.location.origin + "/admin/#/login?redirect=" + redirect;
-    throw "用户未登录";
+    // window.location.href = window.location.origin + "/admin/#/login?redirect=" + redirect;
+    // throw "用户未登录";
   }
   config.headers.token = token;
   config.headers['caseid'] = caseId;
@@ -102,16 +102,16 @@ const responseInterceptor = (res: AxiosResponse<any, any>) => {
     const { setLoginShow, loginShow } = getLogin();
     console.log("4010",loginShow,'loginShow', res);
     setLoginShow(true)
-    // throw res.data.msg;
-    console.log("4010",loginShow,'loginShow', res);
-    setLoginShow(true);
-    ElMessageBox.alert("您没有访问权限", "提示", {
-      confirmButtonText: "我知道了",
-      type: "warning",
-      showClose: false
-    }).then(async () => {
-      window.open(window.location.origin + "/admin/#/statistics/scene");
-    });
+    throw res.data.msg;
+    // console.log("4010",loginShow,'loginShow', res);
+    // setLoginShow(true);
+    // ElMessageBox.alert("您没有访问权限", "提示", {
+    //   confirmButtonText: "我知道了",
+    //   type: "warning",
+    //   showClose: false
+    // }).then(async () => {
+    //   window.open(window.location.origin + "/admin/#/statistics/scene");
+    // });
   };
   if (!successCode.includes(res.data.code) && res.config?.responseType != "blob") {
     let errMsg = res.data.msg || res.data.message;
@@ -122,8 +122,8 @@ const responseInterceptor = (res: AxiosResponse<any, any>) => {
       errMsg === "token已经失效,请重新登录"
     ) {
       let redirect = encodeURIComponent(`${window.location.href}`);
-      window.location.href = window.location.origin + "/admin/#/login?redirect=" + redirect;
-      router.replace({ name: RouteName.login });
+      // window.location.href = window.location.origin + "/admin/#/login?redirect=" + redirect;
+      // router.replace({ name: RouteName.login });
       getAuth().clear();
     }
     throw res.data.msg;