/**
* 下载blob数据
* @param {object} res blob数据下载的响应头
* @param {String} fileName 文件名,可选
*/
export function downloadBlobData (res, fileName) {
const fileName = decodeURIComponent(res.headers['content-disposition'].split(';')[1].split('=')[1]) // 文件名
const data = res.data // Blob数据对象
const uA = window.navigator.userAgent
const isIE =
/msie\s|trident\/|edge\//i.test(uA) &&
!!('uniqueID' in document || 'documentMode' in document || 'ActiveXObject' in window || 'MSInputMethodContext' in window)
// 兼容IE
if (isIE) {
navigator.msSaveBlob(new Blob([data]), fileName)
} else {
const url = window.URL.createObjectURL(new Blob([data]))
exportFileByUrl(url, fileName)
}
}