This commit is contained in:
2025-09-22 16:27:06 +08:00
parent 95ecde2788
commit ca2b70dfbe

View File

@@ -324,14 +324,29 @@ const SSEManager = {
}, },
handleError() { handleError() {
console.log('=== SSE错误处理 ===')
console.log('准备断开并重连SSE')
this.disconnect() this.disconnect()
setTimeout(() => this.connect(), 3000) setTimeout(() => {
console.log('🔄 开始重连SSE')
this.connect()
}, 3000)
}, },
disconnect() { disconnect() {
if (this.connection) { if (this.connection) {
try { this.connection.close() } catch {} console.log('=== SSE断开连接 ===')
console.log('断开连接URL:', this.connection.url)
console.log('断开前状态:', this.connection.readyState)
try {
this.connection.close()
console.log('✅ SSE连接已主动关闭')
} catch (e) {
console.log('❌ SSE关闭时出错:', e.message)
}
this.connection = null this.connection = null
} else {
console.log('⚠️ 尝试断开SSE但连接不存在')
} }
}, },