fix: 问答页面bug处理
This commit is contained in:
+3
-2
@@ -140,7 +140,7 @@ export default class WebSocketUtil {
|
||||
* @param {string|Object} message - 要发送的消息,可以是字符串或对象
|
||||
* @returns {WebSocketUtil} - 返回当前实例,支持链式调用
|
||||
*/
|
||||
send(message) {
|
||||
send(message, num = 1) {
|
||||
if (this.socketTask && this.getStatus() === 1) {
|
||||
// 发送消息,对象会自动转换为JSON字符串
|
||||
this.socketTask.send({
|
||||
@@ -156,8 +156,9 @@ export default class WebSocketUtil {
|
||||
} else {
|
||||
console.error('WebSocket连接未打开,无法发送消息');
|
||||
this.triggerEvent('error', new Error('WebSocket连接未打开'));
|
||||
if(num === 10) return
|
||||
setTimeout(()=>{
|
||||
this.send(message)
|
||||
this.send(message, num + 1)
|
||||
},500)
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user