Commit 3ebad309 authored by 李苏's avatar 李苏 💬

单独调整,目前没用,已调整为common/request

parent 137e7e6d
...@@ -46,6 +46,11 @@ service.interceptors.response.use(res => { ...@@ -46,6 +46,11 @@ service.interceptors.response.use(res => {
// } // }
// 二进制数据则直接返回 // 二进制数据则直接返回
if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){ if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){
/* 保留文件名称*/
let filename = res.headers['content-disposition'].split('=')[1] // 截取字符串
filename = decodeURIComponent(escape(filename)); // 解码文件名
res.data.filename=filename||''
return res.data return res.data
} }
if (code === 401) { if (code === 401) {
...@@ -145,7 +150,7 @@ export function download(url, params, filename) { ...@@ -145,7 +150,7 @@ export function download(url, params, filename) {
const isLogin = await blobValidate(data); const isLogin = await blobValidate(data);
if (isLogin) { if (isLogin) {
const blob = new Blob([data]) const blob = new Blob([data])
saveAs(blob, filename) saveAs(blob, data.filename||filename)
} else { } else {
const resText = await data.text(); const resText = await data.text();
const rspObj = JSON.parse(resText); const rspObj = JSON.parse(resText);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment