fix: 问答页面bug处理

This commit is contained in:
yanghang
2025-07-21 15:39:13 +08:00
parent 2fe3ae7ee4
commit 3b41571b0c
3 changed files with 51 additions and 46 deletions
+3 -2
View File
@@ -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;