diff --git a/src/config/axios/index.ts b/src/config/axios/index.ts index 1c49f58e7..9db983035 100644 --- a/src/config/axios/index.ts +++ b/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 (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 }, + downloadHeaders: async (option: any) => { + const res = await requestHeaders({ method: 'GET', responseType: 'blob', ...option }) + return res as unknown as Promise + }, + downloadPostHeaders: async (option: any) => { + const res = await requestHeaders({ method: 'POST', responseType: 'blob', ...option }) + return res as unknown as Promise + }, upload: async (option: any) => { option.headersType = 'multipart/form-data' const res = await request({ method: 'POST', ...option })