refactor: 上传文件支持多选

This commit is contained in:
CaptainB 2024-12-04 14:36:11 +08:00
parent 6b4cee1412
commit b35b57fcd0

View File

@ -75,9 +75,9 @@
<div class="operate flex align-center">
<span v-if="props.applicationDetails.file_upload_enable" class="flex align-center">
<!-- accept="image/jpeg, image/png, image/gif"-->
<el-upload
action="#"
multiple
:auto-upload="false"
:show-file-list="false"
:accept="getAcceptList()"
@ -246,23 +246,23 @@ const uploadFile = async (file: any, fileList: any) => {
fileList.splice(0, fileList.length)
return
}
const formData = new FormData()
for (const file of fileList) {
formData.append('file', file.raw, file.name)
//
const extension = file.name.split('.').pop().toLowerCase() //
if (imageExtensions.includes(extension)) {
uploadImageList.value.push(file)
} else if (documentExtensions.includes(extension)) {
uploadDocumentList.value.push(file)
} else if (videoExtensions.includes(extension)) {
// videos.push(file)
} else if (audioExtensions.includes(extension)) {
// audios.push(file)
}
const formData = new FormData()
formData.append('file', file.raw, file.name)
//
const extension = file.name.split('.').pop().toLowerCase() //
if (imageExtensions.includes(extension)) {
uploadImageList.value.push(file)
} else if (documentExtensions.includes(extension)) {
uploadDocumentList.value.push(file)
} else if (videoExtensions.includes(extension)) {
// videos.push(file)
} else if (audioExtensions.includes(extension)) {
// audios.push(file)
}
if (!chatId_context.value) {
const res = await props.openChatId()
chatId_context.value = res