This commit is contained in:
dap
2025-01-21 12:03:08 +08:00
4 changed files with 50 additions and 46 deletions

View File

@@ -1,10 +1,6 @@
import type { AxiosInstance, AxiosResponse } from 'axios';
import type {
HttpResponse,
RequestClientConfig,
RequestClientOptions,
} from './types';
import type { RequestClientConfig, RequestClientOptions } from './types';
import { bindMethods, merge } from '@vben/utils';
@@ -54,24 +50,6 @@ class RequestClient {
this.addResponseInterceptor =
interceptorManager.addResponseInterceptor.bind(interceptorManager);
// 添加基础的响应处理,根据设置决定返回响应的哪一部分
this.addResponseInterceptor<HttpResponse>({
fulfilled: (response) => {
const { config, data: responseData, status } = response;
if (config.responseReturn === 'raw') {
return response;
}
const { code, data } = responseData;
if (status >= 200 && status < 400 && code === 0) {
return config.responseReturn === 'body' ? responseData : data;
}
throw Object.assign({}, response, { response });
},
});
// 实例化文件上传器
const fileUploader = new FileUploader(this);
this.upload = fileUploader.upload.bind(fileUploader);