From 86e11baeb2602cc765e58f5914fdb3b10d3aa812 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud <79562285+wangdan-fit2cloud@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:34:51 +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 205f3b5c4..036f4104a 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)