gaoluyang
2025-03-07 58192a194d0667ebb880a16cbde36363fdc1d535
src/plugins/download.js
@@ -81,14 +81,15 @@
        downloadLoadingInstance.close();
      });
  },
  async downloadFileFromUrl(url, filename) {
  async saveAs(text, name, opts) {
    if (typeof text === "string") {
    try {
      let state = /\.(jpg|jpeg|png|gif)$/i.test(url) // 判断是否为图片
        let state = /\.(jpg|jpeg|png|gif)$/i.test(text) // 判断是否为图片
      let url1 = ''
      if (state) {
        url1 = Vue.prototype.javaApi + '/img/' + url;
          url1 = Vue.prototype.javaApi + '/img/' + text;
      } else {
        url1 = Vue.prototype.javaApi + '/word/' + url
          url1 = Vue.prototype.javaApi + '/word/' + text
      }
      // 使用 fetch 获取文件
      const response = await fetch(url1);
@@ -103,15 +104,17 @@
    } catch (error) {
      Message.error(error);
    }
  },
  saveAs(text, name, opts) {
    } else {
    // 流下载
    blobToText(text).then((result) => {
      blobToText(text)
        .then((result) => {
      Message.error(result.msg);
    }).catch(() => {
        })
        .catch(() => {
      saveAs(text, name, opts);
      Message.success("数据导出成功");
    });
    }
  },
  async printErrMsg(data) {
    const resText = await data.text();