吉安感知网项目-前端
罗广辉
2026-02-27 3cf3cd88a7b7a49e3300e8e8c1e9034eb69a3429
uniapps/work-app/src/utils/websocket.js
@@ -114,8 +114,8 @@
    this.socketTask.send({
      data: JSON.stringify(message),
      success: () => {
        // console.log('WebSocket消息发送成功:', message)
        useGlobalWS();
        console.log('WebSocket消息发送成功:', message)
        // useGlobalWS();
      },
      fail: (error) => {
        // console.error('WebSocket消息发送失败:', error)
@@ -124,15 +124,15 @@
  }
  // 开始心跳检测
  startPing() {
    this.stopPing()
    // 每25秒发送一次心跳
    this.pingTimer = setInterval(() => {
      if (this.connected) {
        this.send('ping', 'system')
      }
    }, 25000)
  }
  // startPing() {
  //   this.stopPing()
  //   // 每25秒发送一次心跳
  //   this.pingTimer = setInterval(() => {
  //     if (this.connected) {
  //       this.send('ping', 'system')
  //     }
  //   }, 25000)
  // }
  // 停止心跳检测
  stopPing() {