From 98550c5e9e0dfda84a088798c517496555cca4e2 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Mon, 22 Sep 2025 17:22:42 +0800 Subject: [PATCH] fix: Incomplete file upload resulted in Exception: 'file_id' error when answering --- .../component/chat-input-operate/index.vue | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index 69fdfb9e523..a2f95812365 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -163,7 +163,7 @@ @TouchEnd="TouchEnd" :time="recorderTime" :start="recorderStatus === 'START'" - :disabled="loading" + :disabled="localLoading" /> - + @@ -268,11 +268,11 @@ - - + + @@ -339,9 +339,13 @@ const chatId_context = computed({ emit('update:chatId', v) } }) +const uploadLoading = computed(() => { + return Object.values(filePromisionDict.value).length > 0 +}) + const localLoading = computed({ get: () => { - return props.loading + return props.loading || uploadLoading.value }, set: (v) => { emit('update:loading', v) @@ -393,7 +397,7 @@ const checkMaxFilesLimit = () => { uploadOtherList.value.length ) } - +const filePromisionDict: any = ref({}) const uploadFile = async (file: any, fileList: any) => { const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting // 单次上传文件数量限制 @@ -414,7 +418,7 @@ const uploadFile = async (file: any, fileList: any) => { fileList.splice(0, fileList.length) return } - + filePromisionDict.value[file.uid] = false const formData = new FormData() formData.append('file', file.raw, file.name) // @@ -454,6 +458,7 @@ const uploadFile = async (file: any, fileList: any) => { fileList.splice(0, fileList.length) file.url = response.data[0].url file.file_id = response.data[0].file_id + delete filePromisionDict.value[file.uid] }) } // 粘贴处理 @@ -798,7 +803,7 @@ function sendChatHandle(event?: any) { if (!event?.ctrlKey && !event?.shiftKey && !event?.altKey && !event?.metaKey) { // 如果没有按下组合键,则会阻止默认事件 event?.preventDefault() - if (!isDisabledChat.value && !props.loading && !event?.isComposing) { + if (!isDisabledChat.value && !localLoading.value && !event?.isComposing) { if ( inputValue.value.trim() || uploadImageList.value.length > 0 ||