This commit is contained in:
beabigegg
2025-09-04 18:59:27 +08:00
parent 6eabdb2f07
commit 457bb442af

View File

@@ -466,7 +466,7 @@ const downloadCombinedFile = async () => {
const response = await filesAPI.downloadCombineFile(jobUuid.value) const response = await filesAPI.downloadCombineFile(jobUuid.value)
// 從響應頭獲取檔案名 // 從響應頭獲取檔案名
let filename = 'combined_file.xlsx' let filename = 'combined_file.docx'
if (response.headers && response.headers['content-disposition']) { if (response.headers && response.headers['content-disposition']) {
const contentDisposition = response.headers['content-disposition'] const contentDisposition = response.headers['content-disposition']
const match = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/) const match = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/)
@@ -476,8 +476,14 @@ const downloadCombinedFile = async () => {
} else { } else {
// 使用預設檔名或從任務資料獲取 // 使用預設檔名或從任務資料獲取
const originalName = job.value.original_filename const originalName = job.value.original_filename
const baseName = originalName ? originalName.split('.')[0] : 'combined' if (originalName) {
filename = `combined_${baseName}.xlsx` const nameParts = originalName.split('.')
const baseName = nameParts.slice(0, -1).join('.')
const extension = nameParts[nameParts.length - 1]
filename = `combined_${baseName}.${extension}`
} else {
filename = 'combined_file.docx'
}
} }
// 創建下載連結 // 創建下載連結