fix: File-Format-Ftransit双侧切换功能,并且在转换成功后移除被转换的文件
This commit is contained in:
parent
b337f5c8f0
commit
49379f82fb
|
@ -104,7 +104,15 @@ export function getFileNameByHeaderContentDisposition(contentDisposition) {
|
||||||
return fileName
|
return fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchAndDownload = async (url, data, method = 'post') => {
|
/**
|
||||||
|
* 获取并下载文件
|
||||||
|
* @param {*} url
|
||||||
|
* @param {*} data
|
||||||
|
* @param {*} method
|
||||||
|
* @param {'fileName'|'file'} returnType
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const fetchAndDownload = async (url, data, method = 'post', returnType = 'fileName') => {
|
||||||
const apiBaseUrl = window._CONFIG['domianURL'] || '/jeecg-boot'
|
const apiBaseUrl = window._CONFIG['domianURL'] || '/jeecg-boot'
|
||||||
const sign = signMd5Utils.getSign(url, data)
|
const sign = signMd5Utils.getSign(url, data)
|
||||||
|
|
||||||
|
@ -138,7 +146,7 @@ export const fetchAndDownload = async (url, data, method = 'post') => {
|
||||||
const disposition = headers['content-disposition']
|
const disposition = headers['content-disposition']
|
||||||
const fileName = getFileNameByHeaderContentDisposition(disposition)
|
const fileName = getFileNameByHeaderContentDisposition(disposition)
|
||||||
saveAs(responseData, fileName)
|
saveAs(responseData, fileName)
|
||||||
return fileName
|
return returnType == 'fileName' ? fileName : new File([responseData], fileName)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error('This operation fails. Contact your system administrator')
|
message.error('This operation fails. Contact your system administrator')
|
||||||
|
|
|
@ -182,15 +182,15 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fileName = await fetchAndDownload(url, formData)
|
const file = await fetchAndDownload(url, formData, 'post', 'file')
|
||||||
if (target == 'left') {
|
if (target == 'left') {
|
||||||
this.leftFileList.push({
|
this.leftFileList.push(file)
|
||||||
name: fileName,
|
this.rightFileList.splice(this.rightSelFileIndex, 1)
|
||||||
})
|
this.rightSelFileIndex = null
|
||||||
} else {
|
} else {
|
||||||
this.rightFileList.push({
|
this.rightFileList.push(file)
|
||||||
name: fileName,
|
this.leftFileList.splice(this.leftSelFileIndex, 1)
|
||||||
})
|
this.leftSelFileIndex = null
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user