fix(ai-service): WebSocket长连接重构 + 环境隔离 + this上下文修复
- 改为长连接模式:首次建立WebSocket后保持不断开,后续复用 - 添加 #ifdef MP-WEIXIN / #ifdef H5 环境隔离 - 修复 ensureWebSocketConnected 中 .bind(this) 导致 this 为 undefined 的问题 - 组件 onUnload 中调用 disconnectWebSocket() 断开连接
This commit is contained in:
@@ -596,6 +596,10 @@ export default {
|
||||
this.scrollToBottom()
|
||||
})
|
||||
},
|
||||
onUnload() {
|
||||
// 页面销毁时断开 WebSocket 长连接
|
||||
aiService.disconnectWebSocket();
|
||||
},
|
||||
watch: {
|
||||
messages: {
|
||||
handler(newVal, oldVal) {
|
||||
|
||||
Reference in New Issue
Block a user