🔧 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:
@@ -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) {
|
|
||||||
// 正常状态,不需要特殊处理
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user