Explorar o código

当不允许报错提示时,404的接口就不要提示出来

louhangfei hai 1 ano
pai
achega
64218b454a
Modificáronse 2 ficheiros con 11 adicións e 5 borrados
  1. 9 4
      src/api/datamanagement/alert.ts
  2. 2 1
      src/utils/http/axios/index.ts

+ 9 - 4
src/api/datamanagement/alert.ts

@@ -26,8 +26,13 @@ export const getWorkLocationList = () => {
 
 // AI问题类型(issueMainType-issueType)
 export const getAIMainList = () => {
-  return http.request({
-    url: '/issue/getIssueSubTypeList',
-    method: 'get',
-  });
+  return http.request(
+    {
+      url: '/issue/getIssueSubTypeList',
+      method: 'get',
+    },
+    {
+      isShowErrorMessage: false,
+    },
+  );
 };

+ 2 - 1
src/utils/http/axios/index.ts

@@ -256,7 +256,8 @@ const transform: AxiosTransform = {
     }
     // 请求是否被取消
     const isCancel = axios.isCancel(error);
-    if (!isCancel) {
+    const isShowErrorMessage = error.response.config.requestOptions.isShowErrorMessage;
+    if (!isCancel && isShowErrorMessage) {
       checkStatus(error.response && error.response.status, msg);
     } else {
       console.warn(error, '请求被取消!');