fix stop button status of Chat page

This commit is contained in:
josc146 2023-10-30 21:09:23 +08:00
parent 14b90bb36b
commit fed1594ddc

View File

@ -347,6 +347,8 @@ const ChatPanel: FC = observer(() => {
onmessage(e) { onmessage(e) {
scrollToBottom(); scrollToBottom();
if (e.data.trim() === '[DONE]') { if (e.data.trim() === '[DONE]') {
if (answerId! in chatSseControllers)
delete chatSseControllers[answerId!];
commonStore.conversation[answerId!].done = true; commonStore.conversation[answerId!].done = true;
commonStore.conversation[answerId!].content = commonStore.conversation[answerId!].content.trim(); commonStore.conversation[answerId!].content = commonStore.conversation[answerId!].content.trim();
commonStore.setConversation(commonStore.conversation); commonStore.setConversation(commonStore.conversation);
@ -381,6 +383,8 @@ const ChatPanel: FC = observer(() => {
console.log('Connection closed'); console.log('Connection closed');
}, },
onerror(err) { onerror(err) {
if (answerId! in chatSseControllers)
delete chatSseControllers[answerId!];
commonStore.conversation[answerId!].type = MessageType.Error; commonStore.conversation[answerId!].type = MessageType.Error;
commonStore.conversation[answerId!].done = true; commonStore.conversation[answerId!].done = true;
err = err.message || err; err = err.message || err;