From 8b707272ca0932155f4e9ba720977efde0c22e60 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Thu, 14 Nov 2024 18:26:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=89=93=E5=BC=80cha?= =?UTF-8?q?tId=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/ai-chat/index.vue | 51 +++++++++++++---------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index 5ce521ff0..69f7b1454 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -139,57 +139,50 @@ const handleDebounceClick = debounce((val, other_params_data?: any, chat?: chatT }, 200) /** - * 对话 + * 打开对话id */ -function getChartOpenId(chat?: any) { - loading.value = true +const openChatId: () => Promise = () => { const obj = props.applicationDetails if (props.appId) { return applicationApi .getChatOpen(props.appId) .then((res) => { chartOpenId.value = res.data - chatMessage(chat) + return res.data }) .catch((res) => { if (res.response.status === 403) { - application.asyncAppAuthentication(accessToken).then(() => { - getChartOpenId(chat) + return application.asyncAppAuthentication(accessToken).then(() => { + return openChatId() }) - } else { - loading.value = false - return Promise.reject(res) } + return Promise.reject(res) }) } else { if (isWorkFlow(obj.type)) { const submitObj = { work_flow: obj.work_flow } - return applicationApi - .postWorkflowChatOpen(submitObj) - .then((res) => { - chartOpenId.value = res.data - chatMessage(chat) - }) - .catch((res) => { - loading.value = false - return Promise.reject(res) - }) + return applicationApi.postWorkflowChatOpen(submitObj).then((res) => { + chartOpenId.value = res.data + return res.data + }) } else { - return applicationApi - .postChatOpen(obj) - .then((res) => { - chartOpenId.value = res.data - chatMessage(chat) - }) - .catch((res) => { - loading.value = false - return Promise.reject(res) - }) + return applicationApi.postChatOpen(obj).then((res) => { + chartOpenId.value = res.data + return res.data + }) } } } +/** + * 对话 + */ +function getChartOpenId(chat?: any) { + return openChatId().then(() => { + chatMessage(chat) + }) +} /** * 获取一个递归函数,处理流式数据