From 6cd49f0ce4b02c4d93c191565ded3a7ef2057226 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 May 2026 21:02:54 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(im):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=BB=E5=8F=AB=E5=8F=96=E6=B6=88=E9=80=9A=E8=AF=9D=E6=97=B6?= =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E5=81=B6=E5=8F=91=E6=9C=AA=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E7=9A=84=E7=AB=9E=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/im/home/composables/useLiveKitRoom.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/views/im/home/composables/useLiveKitRoom.ts b/src/views/im/home/composables/useLiveKitRoom.ts index a9aa24987..a4c1eb560 100644 --- a/src/views/im/home/composables/useLiveKitRoom.ts +++ b/src/views/im/home/composables/useLiveKitRoom.ts @@ -120,11 +120,18 @@ export function useLiveKitRoom() { const warmup = prewarmMedia(opts) // 建立 WebSocket 信令 + WebRTC 媒体通道;完成后 localParticipant 可用,已在房参与者会通过 ParticipantConnected 事件批量推送 await r.connect(url, token) + // 期间被外部 disconnect 替换;中止后续 publish,避免摄像头被重新启用 + if (_room.value !== r) { + return + } localParticipant.value = r.localParticipant isConnected.value = true // 预热结果不直接发布(避免 SDK 与外部 track 生命周期纠缠),仅等待权限就绪后再走标准 setXxxEnabled await warmup + if (_room.value !== r) { + return + } // 麦克风与摄像头权限相互独立,并行启用发布 const inits: Promise[] = [] if (opts.audio) {