From c556e4206381b3dc58b022b92bf1f1b0479dcf05 Mon Sep 17 00:00:00 2001 From: Hacker <721806280@qq.com> Date: Fri, 19 Nov 2021 09:22:22 +0000 Subject: [PATCH] =?UTF-8?q?update=20ruoyi-ui/src/plugins/download.js.=20?= =?UTF-8?q?=E4=BB=8E=E5=93=8D=E5=BA=94=E7=9A=84headers=E4=B8=AD=E7=9A=84Co?= =?UTF-8?q?ntent-disposition=E8=8E=B7=E5=8F=96filename,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/plugins/download.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ruoyi-ui/src/plugins/download.js b/ruoyi-ui/src/plugins/download.js index e1c664057..6c5c2074b 100644 --- a/ruoyi-ui/src/plugins/download.js +++ b/ruoyi-ui/src/plugins/download.js @@ -17,8 +17,11 @@ export default { }).then(async (res) => { const isLogin = await this.blobValidate(res.data); if (isLogin) { + const contentDisposition = decodeURI(res.headers['content-disposition']) + const result = new RegExp('filename=([^;]+\\.[^\\.;]+);*').exec(contentDisposition) + const fileName = result[1].replace(/\"/g, '') const blob = new Blob([res.data]) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + this.saveAs(blob, fileName) } else { Message.error('无效的会话,或者会话已过期,请重新登录。'); } @@ -34,8 +37,11 @@ export default { }).then(async (res) => { const isLogin = await this.blobValidate(res.data); if (isLogin) { + const contentDisposition = decodeURI(res.headers['content-disposition']) + const result = new RegExp('filename=([^;]+\\.[^\\.;]+);*').exec(contentDisposition) + const fileName = result[1].replace(/\"/g, '') const blob = new Blob([res.data]) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + this.saveAs(blob, fileName) } else { Message.error('无效的会话,或者会话已过期,请重新登录。'); } @@ -61,5 +67,4 @@ export default { saveAs(text, name, opts) { saveAs(text, name, opts); } -} - +} \ No newline at end of file