/ 下崽🐱 /
export const download = async function (param = {}) {try {if (typeof param === 'string') {window.open(param);return;}// 处理blob下载const {url, ...otherParam} = param;let res = await axios({url,method: 'post',data: otherParam,withCredentials: true,responseType: 'blob'});const {data: blob, headers: {'content-disposition': contentDisposition}} = res;const fileName = decodeURIComponent(contentDisposition.split('=')[1], 'UTF-8');if (window.navigator.msSaveOrOpenBlob) {navigator.msSaveBlob(blob, fileName);return;}const selfURL = window.URL || window.webkitURL;url && selfURL.revokeObjectURL(url);const toBlobUrl = selfURL.createObjectURL(blob);const aEl = document.createElement('a');aEl.href = toBlobUrl;aEl.download = fileName;aEl.click();}catch (err) {message.error(`下载失败 ${err}`);}};/*************/import {download} from 'utils/request';download(downloadUrl);
