From 7dea16d02269409ae22ef8009fd348fa7ea0bc0b Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 3 Apr 2025 10:31:29 +0800 Subject: [PATCH] perf: Optimization user input auto close when send message --- ui/src/components/ai-chat/index.vue | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index 205f3b5c464..036f4104a02 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -221,20 +221,21 @@ const checkInputParam = () => { } function sendMessage(val: string, other_params_data?: any, chat?: chatType) { - if (!userFormRef.value?.checkInputParam()) { - if (isUserInput.value) { + if (isUserInput.value) { + if (!userFormRef.value?.checkInputParam()) { showUserInput.value = true + return + } else { + let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}') + const newData = Object.keys(form_data.value).reduce((result: any, key: string) => { + result[key] = Object.prototype.hasOwnProperty.call(userFormData, key) + ? userFormData[key] + : form_data.value[key] + return result + }, {}) + localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData)) + showUserInput.value = false } - return - } else { - let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}') - const newData = Object.keys(form_data.value).reduce((result: any, key: string) => { - result[key] = Object.prototype.hasOwnProperty.call(userFormData, key) - ? userFormData[key] - : form_data.value[key] - return result - }, {}) - localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData)) } if (!loading.value && props.applicationDetails?.name) { handleDebounceClick(val, other_params_data, chat)