shikeying
2023-02-24 6f0c15f71998bb08e5476ca04da8f6def7327250
src/plugins/download.js
@@ -5,12 +5,9 @@
import errorCode from '@/utils/errorCode'
import { blobValidate } from "@/utils/ruoyi";
// const baseURL = process.env.VUE_APP_BASE_API
const baseURL = "http://localhost:8082/admin";
export default {
  name(name, isDelete = true) {
    var url = baseURL + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete
    var url = globalConf.ftpUrl + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete
    axios({
      method: 'get',
      url: url,
@@ -27,7 +24,7 @@
    })
  },
  resource(resource) {
    var url = baseURL + "/common/download/resource?resource=" + encodeURI(resource);
    var url = globalConf.ftpUrl + "/common/download/resource?resource=" + encodeURI(resource);
    axios({
      method: 'get',
      url: url,
@@ -43,11 +40,22 @@
      }
    })
  },
  zip(url, name) {
    var url = baseURL + url;
  /**
   * 下载zip文件,如果local存在值,则从本地下载文件
   * @param url 业务链接
   * @param name 下载保存的文件名
   * @param local 只要不为空,就表示从本地下载
   * @date 2023-02-24 时克英添加 local 参数
   */
  zip(url, name, local) {
    let fullUrl = globalConf.ftpUrl + url;
    if(local !== null && local !== ""){
      fullUrl = globalConf.baseUrl + url;
    }
    axios({
      method: 'get',
      url: url,
      url: fullUrl,
      responseType: 'blob',
      headers: { 'Authorization': 'Bearer ' + getToken() }
    }).then(async (res) => {
@@ -56,7 +64,7 @@
        const blob = new Blob([res.data], { type: 'application/zip' })
        this.saveAs(blob, name)
      } else {
        this.printErrMsg(res.data);
        await this.printErrMsg(res.data);
      }
    })
  },