feat(meeting): 实现投屏用户UID计算和显示优化
- 添加calculateScreenActualUid函数用于计算投屏实际声网UID - 新增screenShareActualUid计算属性获取投屏实际UID - 优化teacherPreferredPrimaryUid逻辑优先使用投屏实际UID - 更新secondaryUid计算逻辑适配投屏实际UID判断 - 修改小窗标题显示逻辑使用实际投屏UID判断 - 调整isPrimaryScreenSharing计算方式匹配实际投屏UID - 添加投屏开始和结束的消息日志记录功能
This commit is contained in:
@ -176,8 +176,25 @@
|
|||||||
|
|
||||||
const isTeacherDualStream = computed(() => Boolean(teacherUid.value && screenShareOwnerUid.value));
|
const isTeacherDualStream = computed(() => Boolean(teacherUid.value && screenShareOwnerUid.value));
|
||||||
|
|
||||||
|
/** 根据投屏用户短 UID 计算实际的声网 UID */
|
||||||
|
function calculateScreenActualUid(uid: number): number {
|
||||||
|
return uid + 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取当前投屏的实际声网 UID(如果有) */
|
||||||
|
const screenShareActualUid = computed<number | null>(() => {
|
||||||
|
if (typeof screenShareOwnerUid.value === 'number' && screenShareOwnerUid.value > 0) {
|
||||||
|
return calculateScreenActualUid(screenShareOwnerUid.value);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
const teacherPreferredPrimaryUid = computed<number | string | null>(() => {
|
const teacherPreferredPrimaryUid = computed<number | string | null>(() => {
|
||||||
return screenShareOwnerUid.value ?? speakerUid.value ?? (teacherUid.value || null);
|
// 如果有投屏,优先使用投屏的实际 UID
|
||||||
|
if (screenShareActualUid.value) {
|
||||||
|
return screenShareActualUid.value;
|
||||||
|
}
|
||||||
|
return speakerUid.value ?? (teacherUid.value || null);
|
||||||
});
|
});
|
||||||
|
|
||||||
const primaryUid = computed<number | string | null>(() => {
|
const primaryUid = computed<number | string | null>(() => {
|
||||||
@ -197,7 +214,9 @@
|
|||||||
if (!teacherUid.value || !screenShareOwnerUid.value) {
|
if (!teacherUid.value || !screenShareOwnerUid.value) {
|
||||||
return null;
|
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<number | string | null>(() => secondaryUid.value);
|
const selfWindowUid = computed<number | string | null>(() => secondaryUid.value);
|
||||||
@ -215,7 +234,7 @@
|
|||||||
if (!selfWindowUid.value) {
|
if (!selfWindowUid.value) {
|
||||||
return userName.value;
|
return userName.value;
|
||||||
}
|
}
|
||||||
if (selfWindowUid.value === screenShareOwnerUid.value) {
|
if (selfWindowUid.value === screenShareActualUid.value) {
|
||||||
return `${screenOwnerName.value || '主讲'}(投屏)`;
|
return `${screenOwnerName.value || '主讲'}(投屏)`;
|
||||||
}
|
}
|
||||||
return '主讲(摄像头)';
|
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 */
|
/** 舞台容器 DOM */
|
||||||
const stageRef = ref<HTMLDivElement | null>(null);
|
const stageRef = ref<HTMLDivElement | null>(null);
|
||||||
@ -537,6 +556,7 @@
|
|||||||
const targetUid = packet.data?.targetUid;
|
const targetUid = packet.data?.targetUid;
|
||||||
if (typeof targetUid === 'number') {
|
if (typeof targetUid === 'number') {
|
||||||
screenShareOwnerUid.value = targetUid;
|
screenShareOwnerUid.value = targetUid;
|
||||||
|
console.log('[屏幕共享] 收到开始投屏消息:', { targetUid, calculatedActualUid: calculateScreenActualUid(targetUid) });
|
||||||
Toast.info?.(`用户 ${targetUid} 开始投屏`);
|
Toast.info?.(`用户 ${targetUid} 开始投屏`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -545,6 +565,7 @@
|
|||||||
const targetUid = packet.data?.targetUid;
|
const targetUid = packet.data?.targetUid;
|
||||||
if (typeof targetUid === 'number') {
|
if (typeof targetUid === 'number') {
|
||||||
screenShareOwnerUid.value = null;
|
screenShareOwnerUid.value = null;
|
||||||
|
console.log('[屏幕共享] 收到停止投屏消息:', { targetUid });
|
||||||
Toast.info?.(`用户 ${targetUid} 停止投屏`);
|
Toast.info?.(`用户 ${targetUid} 停止投屏`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user