update ruoyi-ui/src/plugins/download.js.
从响应的headers中的Content-disposition获取filename,
This commit is contained in:
parent
91ad85aec1
commit
c556e42063
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user