feat: vue3 axios add download function

This commit is contained in:
xingyu
2022-07-25 21:03:14 +08:00
parent 611e11ae23
commit b085f35dfe
26 changed files with 48 additions and 37 deletions

View File

@ -37,12 +37,17 @@ async function putFn<T = any>(option: AxiosConfig): Promise<T> {
const res = await request({ method: 'PUT', ...option })
return res.data
}
async function downloadFn<T = any>(option: AxiosConfig): Promise<T> {
const res = await request({ method: 'GET', responseType: 'blob', ...option })
return res as unknown as Promise<T>
}
export const useAxios = () => {
return {
get: getFn,
post: postFn,
delete: deleteFn,
put: putFn
put: putFn,
download: downloadFn
}
}