fix: 去除 esportXls 中 IE浏览器的支持
parent
c203357a73
commit
6466267722
|
@ -29,25 +29,21 @@ export function useMethods() {
|
||||||
if (!name || typeof name != 'string') {
|
if (!name || typeof name != 'string') {
|
||||||
name = '导出文件';
|
name = '导出文件';
|
||||||
}
|
}
|
||||||
let blobOptions = { type: 'application/vnd.ms-excel' };
|
const blobOptions = { type: 'application/vnd.ms-excel' };
|
||||||
let fileSuffix = '.xls';
|
let fileSuffix = '.xls';
|
||||||
if (isXlsx === true) {
|
if (isXlsx) {
|
||||||
blobOptions['type'] = XLSX_MIME_TYPE;
|
blobOptions['type'] = XLSX_MIME_TYPE;
|
||||||
fileSuffix = XLSX_FILE_SUFFIX;
|
fileSuffix = XLSX_FILE_SUFFIX;
|
||||||
}
|
}
|
||||||
if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
const objectURL = window.URL.createObjectURL(new Blob([data], blobOptions));
|
||||||
window.navigator.msSaveBlob(new Blob([data], blobOptions), name + fileSuffix);
|
const link = document.createElement('a');
|
||||||
} else {
|
|
||||||
let url = window.URL.createObjectURL(new Blob([data], blobOptions));
|
|
||||||
let link = document.createElement('a');
|
|
||||||
link.style.display = 'none';
|
link.style.display = 'none';
|
||||||
link.href = url;
|
link.href = objectURL;
|
||||||
link.setAttribute('download', name + fileSuffix);
|
link.setAttribute('download', name + fileSuffix);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link); //下载完成移除元素
|
document.body.removeChild(link); //下载完成移除元素
|
||||||
window.URL.revokeObjectURL(url); //释放掉blob对象
|
window.URL.revokeObjectURL(objectURL); //释放掉blob对象
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,11 +56,11 @@ export function useMethods() {
|
||||||
const isReturn = (fileInfo) => {
|
const isReturn = (fileInfo) => {
|
||||||
try {
|
try {
|
||||||
if (fileInfo.code === 201) {
|
if (fileInfo.code === 201) {
|
||||||
let {
|
const {
|
||||||
message,
|
message,
|
||||||
result: { msg, fileUrl, fileName },
|
result: { msg, fileUrl, fileName },
|
||||||
} = fileInfo;
|
} = fileInfo;
|
||||||
let href = glob.uploadUrl + fileUrl;
|
const href = glob.uploadUrl + fileUrl;
|
||||||
createWarningModal({
|
createWarningModal({
|
||||||
title: message,
|
title: message,
|
||||||
centered: false,
|
centered: false,
|
||||||
|
|
Loading…
Reference in New Issue