tangning 8 miesięcy temu
rodzic
commit
bd307df2ec
1 zmienionych plików z 16 dodań i 13 usunięć
  1. 16 13
      src/request/index.ts

+ 16 - 13
src/request/index.ts

@@ -99,19 +99,20 @@ axios.interceptors.request.use(async (config) => {
 
 const responseInterceptor = (res: AxiosResponse<any, any>) => {
   closeLoading();
-  if(res.data.code == '8030'){
+  if(res.data.code == '8030' && router.currentRoute.value.name == 'drawCaseFile'){
     openErrorMsg(ui18n.t('sceneHome.yctipsErr'));
     throw res.data.msg;
+    return
   }
-  // if (res.data.code === 4010){
-  //   ElMessageBox.alert("您没有访问权限", "提示", {
-  //     confirmButtonText: "我知道了",
-  //     type: "warning",
-  //     showClose: false
-  //   }).then(async () => {
-  //     window.open(window.location.origin + "/admin/#/statistics/scene");
-  //   });
-  // };
+  if (res.data.code === 4010){
+    ElMessageBox.alert("您没有访问权限", "提示", {
+      confirmButtonText: "我知道了",
+      type: "warning",
+      showClose: false
+    }).then(async () => {
+      window.open(window.location.origin + "/admin/#/statistics/scene");
+    });
+  };
   // console.log("responseInterceptor", res);
   if (!successCode.includes(res.data.code) && res.config.responseType != "blob") {
     let errMsg = res.data.msg || res.data.message;
@@ -122,9 +123,11 @@ 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 });
-      // getAuth().clear();
+      if(router.currentRoute.value.name != 'drawCaseFile'){
+        window.location.href = window.location.origin + "/admin/#/login?redirect=" + redirect;
+        router.replace({ name: RouteName.login });
+        getAuth().clear();
+      }
     }
     throw res.data.msg;
   }