吉安感知网项目-前端
张含笑
2026-02-11 ffa816c14e386b0cc2ceed728af0d2487a2b76dc
feat:更换id
3 files modified
103 ■■■■ changed files
applications/drone-command/src/views/audioCall.vue 8 ●●●● patch | view | raw | blame | history
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue 90 ●●●● patch | view | raw | blame | history
uniapps/work-app/src/hooks/useGlobalWS.js 5 ●●●●● patch | view | raw | blame | history
applications/drone-command/src/views/audioCall.vue
@@ -36,10 +36,10 @@
import { ref, computed, onBeforeUnmount } from 'vue'
/** ✅ 你的 WS 地址前缀(后面拼 userId) */
const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId='
const WS_BASE = 'ws://218.202.104.82:38201/ws/chat'
const uid = ref('2')
const peerUid = ref('3')
const uid = ref('1')
const peerUid = ref('2011686857615683585')
const connected = ref(false)
const state = ref('idle') // idle | calling | ringing | in-call
@@ -310,7 +310,7 @@
function connectWS() {
    if (ws) ws.close()
    ws = new WebSocket(WS_BASE + encodeURIComponent(uid.value))
    ws = new WebSocket(WS_BASE, "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjBkM2NlYmZhLTU4NTUtNDQ1OS04YWQwLTk2NzBlODM2N2Q2OCIsInVzZXJuYW1lIjoiYWRtaW4ifQ.ALOJPzPad4OGNIwx3U61eXEZaGeVd46KlJhVXVWBXMg9q-ks8LqJTx8eXoS-SjjrYDegdAZCkn_TW-xqbe6C6A")
    ws.onopen = () => {
        connected.value = true
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
@@ -43,6 +43,50 @@
/** ✅ 你的 WS 地址前缀(后面拼 userId) */
// const WS_BASE = 'ws://218.202.104.82:38201/ws/chat?userId='
const WS_BASE = 'ws://218.202.104.82:38201/ws/chat'
const uid = ref('2011686857615683585')
const peerUid = ref('1')
// 联系人名称
const contactName = ref('张三')
const connected = ref(false)
const state = ref('idle') // idle | calling | ringing | in-call
const logText = ref('')
const remoteAudio = ref(null)
// 通话结束相关
const callEnded = ref(false)
const endMessage = ref('对方已挂断')
const endTimer = ref(null)
// token 存储
const accessToken = ref('')
let ws = null
let pc = null
let localStream = null
const pendingCandidates = []
// 来电暂存
let incomingFrom = null
let acceptedByMe = false // 我是否已经点了接听
let offeredByPeer = false // 是否已收到对方 offer(用于流程判断)
// 计时
let timer = null
const seconds = ref(0)
const durationText = computed(() => {
    const m = String(Math.floor(seconds.value / 60)).padStart(2, '0')
    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
}
// 解析URL参数
const parseUrlParams = () => {
    // 1. 优先从route.query.voiceparams获取参数
@@ -105,51 +149,7 @@
    if (userId) {
        return userId
    }
    return '3' // 默认值
}
const uid = ref('3')
const peerUid = ref('2')
// 联系人名称
const contactName = ref('张三')
const connected = ref(false)
const state = ref('idle') // idle | calling | ringing | in-call
const logText = ref('')
const remoteAudio = ref(null)
// 通话结束相关
const callEnded = ref(false)
const endMessage = ref('对方已挂断')
const endTimer = ref(null)
// token 存储
const accessToken = ref('')
let ws = null
let pc = null
let localStream = null
const pendingCandidates = []
// 来电暂存
let incomingFrom = null
let acceptedByMe = false // 我是否已经点了接听
let offeredByPeer = false // 是否已收到对方 offer(用于流程判断)
// 计时
let timer = null
const seconds = ref(0)
const durationText = computed(() => {
    const m = String(Math.floor(seconds.value / 60)).padStart(2, '0')
    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
    return '2011686857615683585' // 默认值
}
// 心跳
uniapps/work-app/src/hooks/useGlobalWS.js
@@ -8,9 +8,10 @@
  const callStatus = ref(null)
  // 设置默认用户ID为3
  const defaultUserId = '8';
  const defaultUserId = '2011686857615683585';
  // WebSocket基础URL
  const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId=';
  // const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId=';
  const WS_BASE = 'ws://218.202.104.82:38201/ws/chat';
    // 消息处理
  function messageHandler(payload) {