From 0914b458d3c6c369380d642da76a41c419b664de Mon Sep 17 00:00:00 2001 From: v-zhangjc9 Date: Wed, 18 Jun 2025 10:34:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai-web):=20=E4=BF=AE=E5=A4=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=A4=B1=E5=8E=BB=E7=84=A6=E7=82=B9=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E6=B2=A1=E6=9C=89=E6=96=AD=E5=BC=80=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E7=9A=84=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service-web/client/src/pages/ai/Conversation.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/service-web/client/src/pages/ai/Conversation.tsx b/service-web/client/src/pages/ai/Conversation.tsx index adb4710..7c10409 100644 --- a/service-web/client/src/pages/ai/Conversation.tsx +++ b/service-web/client/src/pages/ai/Conversation.tsx @@ -1,6 +1,7 @@ import {ClearOutlined, UserOutlined} from '@ant-design/icons' import {Bubble, Sender, useXAgent, useXChat, Welcome} from '@ant-design/x' import {fetchEventSource} from '@echofly/fetch-event-source' +import {useUnmount} from 'ahooks' import {Button, Collapse, Flex, Typography} from 'antd' import {isStrBlank, trim} from 'licia' import {useRef, useState} from 'react' @@ -40,6 +41,11 @@ function Conversation() { const abortController = useRef(null) const [input, setInput] = useState('') + useUnmount(() => { + console.log('Page Unmount') + abortController.current?.abort() + }) + const [agent] = useXAgent({ request: async (info, callbacks) => { await fetchEventSource(`${commonInfo.baseAiUrl}/chat/async`, { @@ -55,6 +61,7 @@ function Conversation() { }) }, onclose: () => callbacks.onSuccess([]), + onerror: error => callbacks.onError(error), }) }, })