liyong
2026-05-14 bfc02d9cd38ccdeb09b3a1f2545e1c75cdf39b29
src/plugins/download.js
@@ -1,4 +1,4 @@
import axios from "axios";
import axios from "axios";
import { ElLoading, ElMessage } from "element-plus";
import { saveAs } from "file-saver";
import { getToken } from "@/utils/auth";
@@ -82,6 +82,16 @@
  saveAs(text, name, opts) {
    saveAs(text, name, opts);
  },
  byUrl(url, filename) {
    // 将URL中的preview替换成download
    const downloadUrl = url.replace(/preview/g, 'download')
    const link = document.createElement('a')
    link.href = downloadUrl
    link.download = filename || ''
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
  },
  async printErrMsg(data) {
    const resText = await data.text();
    const rspObj = JSON.parse(resText);