|
|
|
@ -35,7 +35,11 @@ const transform: AxiosTransform = { |
|
|
|
*/ |
|
|
|
transformRequestHook: (res: AxiosResponse<Result>, options: RequestOptions) => { |
|
|
|
const { t } = useI18n(); |
|
|
|
const { isTransformRequestResult } = options; |
|
|
|
const { isTransformRequestResult, isReturnNativeResponse } = options; |
|
|
|
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
|
|
|
if (isReturnNativeResponse) { |
|
|
|
return res; |
|
|
|
} |
|
|
|
// 不进行任何处理,直接返回
|
|
|
|
// 用于页面代码可能需要直接获取code,data,message这些信息时开启
|
|
|
|
if (!isTransformRequestResult) { |
|
|
|
@ -192,6 +196,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) { |
|
|
|
requestOptions: { |
|
|
|
// 默认将prefix 添加到url
|
|
|
|
joinPrefix: true, |
|
|
|
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
|
|
|
isReturnNativeResponse: false, |
|
|
|
// 需要对返回数据进行处理
|
|
|
|
isTransformRequestResult: true, |
|
|
|
// post请求的时候添加参数到url
|
|
|
|
|