| | |
| | | <strong v-if="state==='in-call'" class="status-text">通话时长:{{ durationText }}</strong> |
| | | </div> |
| | | <div class="button-group"> |
| | | <button @click="requestCall" :disabled="!connected || state!=='idle'" class="btn btn-call">呼叫</button> |
| | | <button v-if="state === 'idle' && !receiveParameters" @click="requestCall" :disabled="!connected" class="btn btn-call">呼叫</button> |
| | | |
| | | <button v-if="state==='ringing'" @click="acceptCall" class="btn btn-accept incoming-accept">接听</button> |
| | | <button v-if="state==='ringing'" @click="rejectCall" class="btn btn-reject incoming-reject">拒绝</button> |
| | |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | console.log('收拾收拾',route.query.voiceparams); |
| | | // 定义receiveParameters变量,用于模板中判断是否显示呼叫按钮 |
| | | const receiveParameters = ref(route.query.contact || null); |
| | | |
| | | const receiveParameters = route.query.contact |
| | | console.log('接收参数', receiveParameters) |
| | | onMounted(() => { |
| | | console.log('收拾收拾',route.query.voiceparams); |
| | | console.log('接收参数', receiveParameters.value) |
| | | |
| | | // 解析并使用contact参数 |
| | | if (receiveParameters) { |
| | | if (receiveParameters.value) { |
| | | try { |
| | | const contact = JSON.parse(decodeURIComponent(receiveParameters)) |
| | | const contact = JSON.parse(decodeURIComponent(receiveParameters.value)) |
| | | if (contact.friendId) { |
| | | peerUid.value = contact.friendId |
| | | log('🔗 从contact参数获取peerUid:', contact.friendId) |
| | |
| | | parseUrlParams() |
| | | // 自动连接WebSocket |
| | | connectWS() |
| | | }) |
| | | }); |
| | | |
| | | // 监听连接状态,当connected变为true且有receiveParameters时自动呼叫 |
| | | watch(() => connected.value, (newVal) => { |
| | | if (newVal && state.value === 'idle' && receiveParameters.value) { |
| | | log('📞 连接成功且有contact参数,自动发起呼叫'); |
| | | requestCall(); |
| | | } |
| | | }); |
| | | |
| | | // 监听连接状态,连接成功后自动呼叫 |
| | | // watch(() => connected.value, (newVal) => { |