@@ -356,7 +356,9 @@ const localLoading = computed({
356356 },
357357})
358358
359- const uploadLoading = ref (false )
359+ const uploadLoading = computed (() => {
360+ return Object .values (filePromisionDict .value ).length > 0
361+ })
360362
361363const inputPlaceholder = computed (() => {
362364 return recorderStatus .value === ' START'
@@ -411,7 +413,7 @@ const checkMaxFilesLimit = () => {
411413 uploadOtherList .value .length
412414 )
413415}
414-
416+ const filePromisionDict : any = ref < any >({})
415417const uploadFile = async (file : any , fileList : any ) => {
416418 const { maxFiles, fileLimit } = props .applicationDetails .file_upload_setting
417419 // 单次上传文件数量限制
@@ -445,6 +447,7 @@ const uploadFile = async (file: any, fileList: any) => {
445447 )
446448 return
447449 }
450+ filePromisionDict .value [file .uid ] = false
448451 const inner = reactive (file )
449452 fileAllList .value .push (inner )
450453 if (! chatId_context .value ) {
@@ -453,23 +456,15 @@ const uploadFile = async (file: any, fileList: any) => {
453456 }
454457 const api =
455458 props .type === ' debug-ai-chat'
456- ? applicationApi .postUploadFile (
457- file .raw ,
458- ' TEMPORARY_120_MINUTE' ,
459- ' TEMPORARY_120_MINUTE' ,
460- uploadLoading ,
461- )
462- : chatAPI .postUploadFile (file .raw , chatId_context .value , ' CHAT' , uploadLoading )
459+ ? applicationApi .postUploadFile (file .raw , ' TEMPORARY_120_MINUTE' , ' TEMPORARY_120_MINUTE' )
460+ : chatAPI .postUploadFile (file .raw , chatId_context .value , ' CHAT' )
461+
463462 api .then ((ok ) => {
464463 inner .url = ok .data
465464 const split_path = ok .data .split (' /' )
466465 inner .file_id = split_path [split_path .length - 1 ]
466+ delete filePromisionDict .value [file .uid ]
467467 })
468- if (! inputValue .value && uploadImageList .value .length > 0 ) {
469- inputValue .value = t (' chat.uploadFile.imageMessage' )
470- } else {
471- inputValue .value = t (' chat.uploadFile.fileMessage' )
472- }
473468}
474469// 粘贴处理
475470const handlePaste = (event : ClipboardEvent ) => {
@@ -549,8 +544,18 @@ const uploadOtherList = computed(() =>
549544const showDelete = ref (' ' )
550545
551546const isDisabledChat = computed (
552- () => ! (inputValue .value .trim () && (props .appId || props .applicationDetails ?.name )),
547+ () =>
548+ ! (
549+ (inputValue .value .trim () ||
550+ uploadImageList .value .length > 0 ||
551+ uploadDocumentList .value .length > 0 ||
552+ uploadVideoList .value .length > 0 ||
553+ uploadAudioList .value .length > 0 ||
554+ uploadOtherList .value .length > 0 ) &&
555+ (props .appId || props .applicationDetails ?.name )
556+ ),
553557)
558+
554559// 是否显示移动端语音按钮
555560const isMicrophone = ref (false )
556561const switchMicrophone = (status : boolean ) => {
@@ -758,11 +763,34 @@ const stopTimer = () => {
758763 }
759764}
760765
766+ const getQuestion = () => {
767+ if (! inputValue .value .trim ()) {
768+ const fileLenth = [
769+ uploadImageList .value .length > 0 ,
770+ uploadDocumentList .value .length > 0 ,
771+ uploadAudioList .value .length > 0 ,
772+ uploadOtherList .value .length > 0 ,
773+ ]
774+ if (fileLenth .filter ((f ) => f ).length > 1 ) {
775+ return t (' chat.uploadFile.otherMessage' )
776+ } else if (fileLenth [0 ]) {
777+ return t (' chat.uploadFile.imageMessage' )
778+ } else if (fileLenth [1 ]) {
779+ return t (' chat.uploadFile.documentMessage' )
780+ } else if (fileLenth [2 ]) {
781+ return t (' chat.uploadFile.audioMessage' )
782+ } else if (fileLenth [3 ]) {
783+ return t (' chat.uploadFile.otherMessage' )
784+ }
785+ }
786+
787+ return inputValue .value .trim ()
788+ }
761789function autoSendMessage() {
762790 props
763791 .validate ()
764792 .then (() => {
765- props .sendMessage (inputValue . value , {
793+ props .sendMessage (getQuestion () , {
766794 image_list: uploadImageList .value ,
767795 document_list: uploadDocumentList .value ,
768796 audio_list: uploadAudioList .value ,
@@ -797,7 +825,7 @@ function sendChatHandle(event?: any) {
797825 // 如果没有按下组合键,则会阻止默认事件
798826 event ?.preventDefault ()
799827 if (! isDisabledChat .value && ! props .loading && ! event ?.isComposing && ! uploadLoading .value ) {
800- if (inputValue .value .trim ()) {
828+ if (inputValue .value .trim () || fileAllList . value . length > 0 ) {
801829 autoSendMessage ()
802830 }
803831 }
0 commit comments