云端文件下载
This commit is contained in:
@@ -34,6 +34,7 @@ class WebSocketManager {
|
||||
this.isManualClose = false
|
||||
// 关闭现有连接
|
||||
if (this.ws) {
|
||||
console.log('关闭现有连接');
|
||||
this.close()
|
||||
}
|
||||
try {
|
||||
@@ -92,7 +93,7 @@ class WebSocketManager {
|
||||
}
|
||||
})
|
||||
this.ws.onError((err) => {
|
||||
console.error('WebSocket 错误:', err)
|
||||
console.error('WebSocket 错误:', JSON.stringify(err))
|
||||
this.handleError(err)
|
||||
})
|
||||
this.ws.onClose((event) => {
|
||||
@@ -299,11 +300,12 @@ class WebSocketManager {
|
||||
|
||||
if (this.ws) {
|
||||
// 移除所有事件监听,避免内存泄漏
|
||||
// 注意:不能用 null 调用回调,否则会触发 onError(null) 产生假错误日志
|
||||
// #ifdef APP-PLUS || MP-WEIXIN
|
||||
if (this.ws.onOpen) this.ws.onOpen(null)
|
||||
if (this.ws.onMessage) this.ws.onMessage(null)
|
||||
if (this.ws.onError) this.ws.onError(null)
|
||||
if (this.ws.onClose) this.ws.onClose(null)
|
||||
this.ws.onOpen(() => {})
|
||||
this.ws.onMessage(() => {})
|
||||
this.ws.onError(() => {})
|
||||
this.ws.onClose(() => {})
|
||||
// #endif
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user