mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-25 14:20:21 +08:00
refactor(projects): axios处理的请求结果去除网路状态
This commit is contained in:
@@ -34,7 +34,7 @@ export function handleAxiosError(axiosError: AxiosError) {
|
||||
// 请求不成功的错误
|
||||
const errorCode: ErrorStatus = axiosError.response.status as ErrorStatus;
|
||||
const msg = ERROR_STATUS[errorCode] || DEFAULT_REQUEST_ERROR_MSG;
|
||||
Object.assign(error, { code: errorCode, msg });
|
||||
Object.assign(error, { code: errorCode || DEFAULT_REQUEST_ERROR_CODE, msg });
|
||||
}
|
||||
|
||||
showErrorMsg(error);
|
||||
|
||||
@@ -14,13 +14,11 @@ export function resultMiddleware<MiddlewareData>(
|
||||
const hasError = errorIndex > -1;
|
||||
const successResult: CustomSuccessRequestResult<MiddlewareData> = {
|
||||
data: resultHandler(...requests.map(item => item.data)),
|
||||
error: null,
|
||||
networkStatus: window.navigator.onLine
|
||||
error: null
|
||||
};
|
||||
const failResult: CustomFailRequestResult = {
|
||||
data: null,
|
||||
error: requests[errorIndex].error!,
|
||||
networkStatus: window.navigator.onLine
|
||||
error: requests[errorIndex].error!
|
||||
};
|
||||
return hasError ? failResult : successResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user