Commit 9c67bf12 by Apple\Apple

🔧 fix(chat): optimize SSE connection status handling

- Remove unnecessary undefined status check in readystatechange event
- Only show disconnection message for actual non-200 status codes
- Remove redundant else branch for normal status handling
- Prevent false "Connection lost" messages on successful completion
parent 4ff1084d
...@@ -239,12 +239,10 @@ const Playground = () => { ...@@ -239,12 +239,10 @@ const Playground = () => {
source.addEventListener('readystatechange', (e) => { source.addEventListener('readystatechange', (e) => {
if (e.readyState >= 2) { if (e.readyState >= 2) {
if (source.status === undefined || source.status !== 200) { if (source.status !== undefined && source.status !== 200) {
source.close(); source.close();
streamMessageUpdate(t('连接已断开'), 'content'); streamMessageUpdate(t('连接已断开'), 'content');
completeMessage('error'); completeMessage('error');
} else if (source.status === 200) {
// 正常状态,不需要特殊处理
} }
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment