@@ -454,10 +454,6 @@ const uploadFile = async (file: any, fileList: any) => {
454454 fileList .splice (0 , fileList .length )
455455 file .url = response .data [0 ].url
456456 file .file_id = response .data [0 ].file_id
457-
458- if (! inputValue .value && uploadImageList .value .length > 0 ) {
459- inputValue .value = t (' chat.uploadFile.imageMessage' )
460- }
461457 })
462458}
463459// 粘贴处理
@@ -532,7 +528,16 @@ const uploadOtherList = ref<Array<any>>([])
532528const showDelete = ref (' ' )
533529
534530const isDisabledChat = computed (
535- () => ! (inputValue .value .trim () && (props .appId || props .applicationDetails ?.name ))
531+ () =>
532+ ! (
533+ (inputValue .value .trim () ||
534+ uploadImageList .value .length > 0 ||
535+ uploadDocumentList .value .length > 0 ||
536+ uploadVideoList .value .length > 0 ||
537+ uploadAudioList .value .length > 0 ||
538+ uploadOtherList .value .length > 0 ) &&
539+ (props .appId || props .applicationDetails ?.name )
540+ )
536541)
537542// 是否显示移动端语音按钮
538543const isMicrophone = ref (false )
@@ -732,11 +737,34 @@ const stopTimer = () => {
732737 }
733738}
734739
740+ const getQuestion = () => {
741+ if (! inputValue .value .trim ()) {
742+ const fileLenth = [
743+ uploadImageList .value .length > 0 ,
744+ uploadDocumentList .value .length > 0 ,
745+ uploadAudioList .value .length > 0 ,
746+ uploadOtherList .value .length > 0
747+ ]
748+ if (fileLenth .filter ((f ) => f ).length > 1 ) {
749+ return t (' chat.uploadFile.otherMessage' )
750+ } else if (fileLenth [0 ]) {
751+ return t (' chat.uploadFile.imageMessage' )
752+ } else if (fileLenth [1 ]) {
753+ return t (' chat.uploadFile.documentMessage' )
754+ } else if (fileLenth [2 ]) {
755+ return t (' chat.uploadFile.audioMessage' )
756+ } else if (fileLenth [3 ]) {
757+ return t (' chat.uploadFile.otherMessage' )
758+ }
759+ }
760+
761+ return inputValue .value .trim ()
762+ }
735763function autoSendMessage() {
736764 props
737765 .validate ()
738766 .then (() => {
739- props .sendMessage (inputValue . value , {
767+ props .sendMessage (getQuestion () , {
740768 image_list: uploadImageList .value ,
741769 document_list: uploadDocumentList .value ,
742770 audio_list: uploadAudioList .value ,
@@ -771,7 +799,14 @@ function sendChatHandle(event?: any) {
771799 // 如果没有按下组合键,则会阻止默认事件
772800 event ?.preventDefault ()
773801 if (! isDisabledChat .value && ! props .loading && ! event ?.isComposing ) {
774- if (inputValue .value .trim ()) {
802+ if (
803+ inputValue .value .trim () ||
804+ uploadImageList .value .length > 0 ||
805+ uploadDocumentList .value .length > 0 ||
806+ uploadAudioList .value .length > 0 ||
807+ uploadVideoList .value .length > 0 ||
808+ uploadOtherList .value .length > 0
809+ ) {
775810 autoSendMessage ()
776811 }
777812 }
0 commit comments