Browse Source

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

lucw 7 months ago
parent
commit
cb8a26e5e2
1 changed files with 30 additions and 25 deletions
  1. 30 25
      src/utils/request.js

+ 30 - 25
src/utils/request.js

@@ -50,9 +50,14 @@ service.interceptors.response.use(
     // token 自动续期
 
     if (window.__POWERED_BY_QIANKUN__) {
-      console.log('主应用的 window 对象:', window.parent);
-      if (window.parentWindow) {
-        window.parentWindow.businessstatus = res;
+      console.log('子应用的 window 对象:', window.fetchNew);
+      console.log('子应用的 window 对象:', window.parentWindow?.fetchNew);
+      if (window.parentWindow && window.parentWindow?.fetchNew) {
+        window.parentWindow.fetchNew({
+          code: res.data.code,
+          message: res.data.message,
+          apiUrl: res.config.url
+        });
       }
     }
 
@@ -87,28 +92,28 @@ service.interceptors.response.use(
     //   }
     // }
     // 登录过期处理
-    if (error?.response?.status === 401) {
-      const currentPath = router.currentRoute.path;
-      if (currentPath === LAYOUT_PATH) {
-        logout(true);
-      } else {
-        MessageBox.alert('登录状态已过期, 请退出重新登录!', '系统提示', {
-          confirmButtonText: '重新登录',
-          callback: (action) => {
-            if (action === 'confirm') {
-              logout(false, currentPath);
-            }
-          },
-          beforeClose: () => {
-            MessageBox.close();
-          }
-        });
-      }
-      return Promise.reject(new Error(error.response.data?.message));
-    } else if (!error?.response?.status) {
-      Message.error('服务调用失败,请联系管理员!');
-    }
-    return Promise.reject(error);
+    // if (error?.response?.status === 401) {
+    //   const currentPath = router.currentRoute.path;
+    //   if (currentPath === LAYOUT_PATH) {
+    //     logout(true);
+    //   } else {
+    //     MessageBox.alert('登录状态已过期, 请退出重新登录!', '系统提示', {
+    //       confirmButtonText: '重新登录',
+    //       callback: (action) => {
+    //         if (action === 'confirm') {
+    //           logout(false, currentPath);
+    //         }
+    //       },
+    //       beforeClose: () => {
+    //         MessageBox.close();
+    //       }
+    //     });
+    //   }
+    //   return Promise.reject(new Error(error.response.data?.message));
+    // } else if (!error?.response?.status) {
+    //   Message.error('服务调用失败,请联系管理员!');
+    // }
+    // return Promise.reject(error);
   }
 );