import JSZipUtils from 'jszip-utils'; import JSZip from 'jszip'; export default class ExeJSZip { // 用于获取url地址对应的文件内容 getBinaryContent(url, progressFn = () => {}) { return new Promise((resolve, reject) => { if (typeof url !== "string") reject(new Error("url 参数不合法")); JSZipUtils.getBinaryContent(url, { progress: progressFn, callback: (err, data) => { if (err) { reject(err); } else { resolve(data); } }, }); }); } // 遍历Zip文件 async iterateZipFile(data) { JSZip.support.nodebuffer = false; let zip = await JSZip.loadAsync(data); return zip; } }