gaoluyang
2026-05-12 16c398f1dd39a87ae1681eef200fe80e80c2c7b1
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);