mirror of
https://gitee.com/nicefold/seewis-soybean-plus.git
synced 2026-10-14 10:02:13 +08:00
fix(utils): 忽略请求取消错误提示
This commit is contained in:
@@ -4,7 +4,7 @@ import axiosRetry from 'axios-retry';
|
|||||||
import { nanoid } from '@sa/utils';
|
import { nanoid } from '@sa/utils';
|
||||||
import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options';
|
import { createAxiosConfig, createDefaultOptions, createRetryOptions } from './options';
|
||||||
import { transformResponse } from './shared';
|
import { transformResponse } from './shared';
|
||||||
import { BACKEND_ERROR_CODE, REQUEST_ID_KEY } from './constant';
|
import { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, REQUEST_ID_KEY } from './constant';
|
||||||
import type {
|
import type {
|
||||||
CustomAxiosRequestConfig,
|
CustomAxiosRequestConfig,
|
||||||
FlatRequestInstance,
|
FlatRequestInstance,
|
||||||
@@ -174,6 +174,6 @@ export function createFlatRequest<ResponseData, ApiData, State extends Record<st
|
|||||||
return flatRequest;
|
return flatRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { BACKEND_ERROR_CODE, REQUEST_ID_KEY };
|
export { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, REQUEST_ID_KEY };
|
||||||
export type * from './type';
|
export type * from './type';
|
||||||
export type { CreateAxiosDefaults, AxiosError };
|
export type { CreateAxiosDefaults, AxiosError };
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
import type { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||||
import { BACKEND_ERROR_CODE, createFlatRequest } from '@sa/axios';
|
import { BACKEND_ERROR_CODE, REQUEST_CANCELED_CODE, createFlatRequest } from '@sa/axios';
|
||||||
import { useAuthStore } from '@/store/modules/auth';
|
import { useAuthStore } from '@/store/modules/auth';
|
||||||
import { localStg, sessionStg } from '@/utils/storage';
|
import { localStg, sessionStg } from '@/utils/storage';
|
||||||
import { getServiceBaseURL } from '@/utils/service';
|
import { getServiceBaseURL } from '@/utils/service';
|
||||||
@@ -150,6 +150,9 @@ export const request = createFlatRequest(
|
|||||||
},
|
},
|
||||||
onError(error) {
|
onError(error) {
|
||||||
// when the request is fail, you can show error message
|
// when the request is fail, you can show error message
|
||||||
|
if (error.code === REQUEST_CANCELED_CODE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let message = error.message;
|
let message = error.message;
|
||||||
let backendErrorCode = '';
|
let backendErrorCode = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user