From a49e027613e23342db6c5ddceaf041119755cc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=E6=98=B5=E7=A7=B0=E9=87=8D=E8=A6=81=E5=90=97O?= Date: Sun, 15 Mar 2026 20:42:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(meeting):=20=E5=AE=9E=E7=8E=B0=E6=8A=95?= =?UTF-8?q?=E5=B1=8F=E7=94=A8=E6=88=B7UID=E8=AE=A1=E7=AE=97=E5=92=8C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加calculateScreenActualUid函数用于计算投屏实际声网UID - 新增screenShareActualUid计算属性获取投屏实际UID - 优化teacherPreferredPrimaryUid逻辑优先使用投屏实际UID - 更新secondaryUid计算逻辑适配投屏实际UID判断 - 修改小窗标题显示逻辑使用实际投屏UID判断 - 调整isPrimaryScreenSharing计算方式匹配实际投屏UID - 添加投屏开始和结束的消息日志记录功能 --- .../meeting-room/meeting-room-student.vue | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/views/meeting/meeting-room/meeting-room-student.vue b/src/views/meeting/meeting-room/meeting-room-student.vue index 1d4890c..0a9fcda 100644 --- a/src/views/meeting/meeting-room/meeting-room-student.vue +++ b/src/views/meeting/meeting-room/meeting-room-student.vue @@ -176,8 +176,25 @@ const isTeacherDualStream = computed(() => Boolean(teacherUid.value && screenShareOwnerUid.value)); + /** 根据投屏用户短 UID 计算实际的声网 UID */ + function calculateScreenActualUid(uid: number): number { + return uid + 1000000; + } + + /** 获取当前投屏的实际声网 UID(如果有) */ + const screenShareActualUid = computed(() => { + if (typeof screenShareOwnerUid.value === 'number' && screenShareOwnerUid.value > 0) { + return calculateScreenActualUid(screenShareOwnerUid.value); + } + return null; + }); + const teacherPreferredPrimaryUid = computed(() => { - return screenShareOwnerUid.value ?? speakerUid.value ?? (teacherUid.value || null); + // 如果有投屏,优先使用投屏的实际 UID + if (screenShareActualUid.value) { + return screenShareActualUid.value; + } + return speakerUid.value ?? (teacherUid.value || null); }); const primaryUid = computed(() => { @@ -197,7 +214,9 @@ if (!teacherUid.value || !screenShareOwnerUid.value) { return null; } - return primaryUid.value === screenShareOwnerUid.value ? teacherUid.value : screenShareOwnerUid.value; + // 如果主讲是投屏,小窗显示老师摄像头;否则显示投屏 + const primaryIsScreen = primaryUid.value === screenShareActualUid.value; + return primaryIsScreen ? teacherUid.value : screenShareActualUid.value; }); const selfWindowUid = computed(() => secondaryUid.value); @@ -215,7 +234,7 @@ if (!selfWindowUid.value) { return userName.value; } - if (selfWindowUid.value === screenShareOwnerUid.value) { + if (selfWindowUid.value === screenShareActualUid.value) { return `${screenOwnerName.value || '主讲'}(投屏)`; } return '主讲(摄像头)'; @@ -235,7 +254,7 @@ }); /** 是否为投屏主画面 */ - const isPrimaryScreenSharing = computed(() => Boolean(primaryUid.value && screenShareOwnerUid.value === primaryUid.value)); + const isPrimaryScreenSharing = computed(() => Boolean(primaryUid.value && primaryUid.value === screenShareActualUid.value)); /** 舞台容器 DOM */ const stageRef = ref(null); @@ -537,6 +556,7 @@ const targetUid = packet.data?.targetUid; if (typeof targetUid === 'number') { screenShareOwnerUid.value = targetUid; + console.log('[屏幕共享] 收到开始投屏消息:', { targetUid, calculatedActualUid: calculateScreenActualUid(targetUid) }); Toast.info?.(`用户 ${targetUid} 开始投屏`); } break; @@ -545,6 +565,7 @@ const targetUid = packet.data?.targetUid; if (typeof targetUid === 'number') { screenShareOwnerUid.value = null; + console.log('[屏幕共享] 收到停止投屏消息:', { targetUid }); Toast.info?.(`用户 ${targetUid} 停止投屏`); } break;