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), }) }, })