/** * 同步下载 * @param data 带转换的arraybuffer数据 * @param name 文件名 */ export const omadownload = (data: any, name: string, fileType?: string) => { const uint8Msg: any = new Uint8Array(data); try { const uint8String = String.fromCharCode.apply(null, uint8Msg); if (uint8String.indexOf('success') > -1) { // message.error('导出失败'); return JSON.parse(uint8String); } } catch (error) { console.warn(error); } const url = window.URL.createObjectURL(new Blob([data], { type: fileType || 'application/vnd.ms-excel' })); const link = document.createElement('a'); link.style.display = 'none'; link.href = url; link.setAttribute('download', decodeURIComponent(name)); document.body.appendChild(link); link.click(); link.remove(); };