Browse Source

导出文件添加head头

hella_online_20250313
王宇飞 4 weeks ago
parent
commit
754a9b09c8
  1. 25
      src/config/axios/index.ts

25
src/config/axios/index.ts

@ -24,6 +24,23 @@ const request = (option: any) => {
}
})
}
const requestHeaders = (option: any) => {
const { url, method, params, data, headersType, responseType,headers, ...config } = option
return service({
url: url,
method,
params,
data,
...config,
responseType: responseType,
headers: {
'Content-Type': headersType || default_headers,
'language': language,
'Referer1': router.currentRoute.value.fullPath.split('?')[0],
...headers
}
})
}
export default {
get: async <T = any>(option: any) => {
const res = await request({ method: 'GET', ...option })
@ -61,6 +78,14 @@ export default {
const res = await request({ method: 'POST', responseType: 'blob', ...option })
return res as unknown as Promise<T>
},
downloadHeaders: async <T = any>(option: any) => {
const res = await requestHeaders({ method: 'GET', responseType: 'blob', ...option })
return res as unknown as Promise<T>
},
downloadPostHeaders: async <T = any>(option: any) => {
const res = await requestHeaders({ method: 'POST', responseType: 'blob', ...option })
return res as unknown as Promise<T>
},
upload: async <T = any>(option: any) => {
option.headersType = 'multipart/form-data'
const res = await request({ method: 'POST', ...option })

Loading…
Cancel
Save