🔧 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
This commit is contained in:
Apple\Apple
2025-05-26 20:24:04 +08:00
parent 3454d6c29e
commit fa06ea19a6

View File

@@ -239,12 +239,10 @@ const Playground = () => {
source.addEventListener('readystatechange', (e) => {
if (e.readyState >= 2) {
if (source.status === undefined || source.status !== 200) {
if (source.status !== undefined && source.status !== 200) {
source.close();
streamMessageUpdate(t('连接已断开'), 'content');
completeMessage('error');
} else if (source.status === 200) {
// 正常状态,不需要特殊处理
}
}
});