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