tangning 4 meses atrás
pai
commit
379463cd25
1 arquivos alterados com 15 adições e 11 exclusões
  1. 15 11
      src/request/index.ts

+ 15 - 11
src/request/index.ts

@@ -101,21 +101,25 @@ axios.interceptors.request.use(async (config) => {
 });
 
 const responseInterceptor = (res: AxiosResponse<any, any>) => {
+  const route = router.currentRoute.value;
   closeLoading();
   if (res.data.code === 4010 || res.data.code === 7012 || res.data.code === 4008){
     const { setLoginShow, loginShow } = getLogin();
     console.log("4010",loginShow,'loginShow', res);
-    setLoginShow(true)
-    throw res.data.msg;
+    if(route.name == 'drawShareFile'){
+      setLoginShow(true)
+      throw res.data.msg;
+    }else{
+      ElMessageBox.alert("您没有访问权限", "提示", {
+        confirmButtonText: "我知道了",
+        type: "warning",
+        showClose: false
+      }).then(async () => {
+        window.open(window.location.origin + "/admin/#/statistics/scene");
+      });
+    }
     // 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;
@@ -126,8 +130,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;