287287 </div >
288288</template >
289289<script setup lang="ts">
290- import { ref , computed , onMounted , nextTick , watch } from ' vue'
290+ import { ref , computed , onMounted , nextTick , watch , reactive } from ' vue'
291291import Recorder from ' recorder-core'
292292import TouchChat from ' ./TouchChat.vue'
293293import applicationApi from ' @/api/application'
@@ -392,17 +392,7 @@ const checkMaxFilesLimit = () => {
392392 uploadOtherList .value .length
393393 )
394394}
395- const file_name_eq = (str : string , str1 : string ) => {
396- return (
397- str .replaceAll (' ' , ' ' ) === str1 .replaceAll (' ' , ' ' ) ||
398- decodeHtmlEntities (str ) === decodeHtmlEntities (str1 )
399- )
400- }
401- function decodeHtmlEntities(str : string ) {
402- const tempDiv = document .createElement (' div' )
403- tempDiv .innerHTML = str
404- return tempDiv .textContent || tempDiv .innerText || ' '
405- }
395+
406396const uploadFile = async (file : any , fileList : any ) => {
407397 const { maxFiles, fileLimit } = props .applicationDetails .file_upload_setting
408398 // 单次上传文件数量限制
@@ -427,6 +417,7 @@ const uploadFile = async (file: any, fileList: any) => {
427417 const formData = new FormData ()
428418 formData .append (' file' , file .raw , file .name )
429419 //
420+ file = reactive (file )
430421 const extension = file .name .split (' .' ).pop ().toUpperCase () // 获取文件后缀名并转为小写
431422 if (imageExtensions .includes (extension )) {
432423 uploadImageList .value .push (file )
@@ -460,41 +451,9 @@ const uploadFile = async (file: any, fileList: any) => {
460451 )
461452 .then ((response ) => {
462453 fileList .splice (0 , fileList .length )
463- uploadImageList .value .forEach ((file : any ) => {
464- const f = response .data .filter ((f : any ) => file_name_eq (f .name , file .name ))
465- if (f .length > 0 ) {
466- file .url = f [0 ].url
467- file .file_id = f [0 ].file_id
468- }
469- })
470- uploadDocumentList .value .forEach ((file : any ) => {
471- const f = response .data .filter ((f : any ) => file_name_eq (f .name , file .name ))
472- if (f .length > 0 ) {
473- file .url = f [0 ].url
474- file .file_id = f [0 ].file_id
475- }
476- })
477- uploadAudioList .value .forEach ((file : any ) => {
478- const f = response .data .filter ((f : any ) => file_name_eq (f .name , file .name ))
479- if (f .length > 0 ) {
480- file .url = f [0 ].url
481- file .file_id = f [0 ].file_id
482- }
483- })
484- uploadVideoList .value .forEach ((file : any ) => {
485- const f = response .data .filter ((f : any ) => file_name_eq (f .name , file .name ))
486- if (f .length > 0 ) {
487- file .url = f [0 ].url
488- file .file_id = f [0 ].file_id
489- }
490- })
491- uploadOtherList .value .forEach ((file : any ) => {
492- const f = response .data .filter ((f : any ) => file_name_eq (f .name , file .name ))
493- if (f .length > 0 ) {
494- file .url = f [0 ].url
495- file .file_id = f [0 ].file_id
496- }
497- })
454+ file .url = response .data [0 ].url
455+ file .file_id = response .data [0 ].file_id
456+
498457 if (! inputValue .value && uploadImageList .value .length > 0 ) {
499458 inputValue .value = t (' chat.uploadFile.imageMessage' )
500459 }
0 commit comments