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