吉安感知网项目-前端
shuishen
2026-02-03 89380e6260a75d1d3b94de687ebcc2f50d50659d
applications/drone-command/src/views/audioCall.vue
@@ -36,7 +36,7 @@
import { ref, computed, onBeforeUnmount } from 'vue'
/** ✅ 你的 WS 地址前缀(后面拼 userId) */
const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId='
const WS_BASE = 'wss://域名/ws/chat?userId='
const uid = ref('2')
const peerUid = ref('3')
@@ -64,13 +64,11 @@
   const s = String(seconds.value % 60).padStart(2, '0')
   return `${m}:${s}`
})
function startTimer() {
   stopTimer()
   seconds.value = 0
   timer = setInterval(() => seconds.value++, 1000)
}
function stopTimer() {
   if (timer) clearInterval(timer)
   timer = null
@@ -78,7 +76,6 @@
// 心跳
let pingTimer = null
function startPing() {
   stopPing()
   // 每 25 秒发一次 ping(你后端有 PING/PONG)
@@ -86,7 +83,6 @@
      if (connected.value) send('ping', 'system', null)
   }, 25000)
}
function stopPing() {
   if (pingTimer) clearInterval(pingTimer)
   pingTimer = null
@@ -135,8 +131,7 @@
      const stream = e.streams[0]
      if (remoteAudio.value) {
         remoteAudio.value.srcObject = stream
         remoteAudio.value.play().catch(() => {
         })
         remoteAudio.value.play().catch(() => {})
      }
   }
@@ -411,8 +406,7 @@
function cleanup(sendToPeer) {
   try {
      if (sendToPeer) send('hangup', peerUid.value, null)
   } catch {
   }
   } catch {}
   stopTimer()