From 413c55fdcb30be8e32ab213c49c6214d14d897e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Tue, 4 Jul 2023 16:38:56 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20=E4=B8=8B?= =?UTF-8?q?=E8=BD=BDzip=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0=E9=81=AE?= =?UTF-8?q?=E7=BD=A9=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui-vue3/src/plugins/download.js | 8 +++++++- ruoyi-ui/src/plugins/download.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui-vue3/src/plugins/download.js b/ruoyi-ui-vue3/src/plugins/download.js index e0aa71fb9..c7603869c 100644 --- a/ruoyi-ui-vue3/src/plugins/download.js +++ b/ruoyi-ui-vue3/src/plugins/download.js @@ -21,7 +21,7 @@ export default { const isBlob = blobValidate(res.data); if (isBlob) { const blob = new Blob([res.data], { type: 'application/octet-stream' }) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + this.saveAs(blob, decodeURIComponent(res.headers['download-filename'])) } else { this.printErrMsg(res.data); } @@ -34,6 +34,7 @@ export default { }, zip(url, name) { var url = baseURL + url + downloadLoadingInstance = ElLoading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) axios({ method: 'get', url: url, @@ -50,6 +51,11 @@ export default { } else { this.printErrMsg(res.data); } + downloadLoadingInstance.close(); + }).catch((r) => { + console.error(r) + ElMessage.error('下载文件出现错误,请联系管理员!') + downloadLoadingInstance.close(); }) }, saveAs(text, name, opts) { diff --git a/ruoyi-ui/src/plugins/download.js b/ruoyi-ui/src/plugins/download.js index 7e19cf0a8..bd0d8db7a 100644 --- a/ruoyi-ui/src/plugins/download.js +++ b/ruoyi-ui/src/plugins/download.js @@ -21,7 +21,7 @@ export default { const isBlob = blobValidate(res.data); if (isBlob) { const blob = new Blob([res.data], { type: 'application/octet-stream' }) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + this.saveAs(blob, decodeURIComponent(res.headers['download-filename'])) } else { this.printErrMsg(res.data); } @@ -34,6 +34,7 @@ export default { }, zip(url, name) { var url = baseURL + url + downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) axios({ method: 'get', url: url, @@ -50,6 +51,11 @@ export default { } else { this.printErrMsg(res.data); } + downloadLoadingInstance.close(); + }).catch((r) => { + console.error(r) + Message.error('下载文件出现错误,请联系管理员!') + downloadLoadingInstance.close(); }) }, saveAs(text, name, opts) {