fix(voice): enable screen share in built-in member cards

This commit is contained in:
illusia committed 2026-10-11 23:30:09 +08:00
1 parent df2ff79e15
commit 13499541e0
4 files changed
+81 -24

No files matched your search

+9
View File
@@ -544,3 +544,12 @@
- 版本与分发:浅色/深色升至 1.0.1,ILLUSIA 升至 2.0.1,KAAK 升至 3.1.73。新增可复用的 ILLUSIA `.wskin` 构建脚本;重建 ILLUSIA 与 KAAK 示例包及内置分发包。
- 验证:皮肤目录和包定向测试 24/24 通过;`npm run verify` 全部通过(685/685 测试、服务端构建、前端类型检查及 Vite 生产构建);`git diff --check` 通过。3040 上 ILLUSIA 包返回 3,545,262 字节、KAAK 包返回 21,761 字节,均与刚构建的分发包长度一致。没有正在共享的真实语音会话可供目视确认动态标记和观看行为。
- 当前状态:代码、皮肤包、记录和自动验证已完成;按持续指示推送到 `dev`。
## 本轮纠正(2026-10-11,修复 KAAK 以外成员卡不显示共享)
- 用户验收指出:更新后仍只有 KAAK 可见共享状态。此前只补主题样式,没有让成员卡实际开启该功能。
- 根因:`VoiceMemberCards.showScreenShare` 是可选 Boolean prop,Vue 会把未传入的 Boolean prop 解析为 `false`。KAAK 的 widget 配置显式传 `screenShare: true`,而默认宿主成员卡未传,因此浅色、深色和 ILLUSIA 页面将共享检测与观看 UI 全部关闭。样式包版本更新不会改变这个运行时默认值。
- 修复:将成员卡的 `showScreenShare` 默认值设为 `true`,默认宿主模板也显式开启;皮肤仍可通过 `screenShare: false` 关闭。远端流检测/观看现在仅依赖共享控制,不再错误依赖本机共享状态对象;本机启停控件仍要求状态对象。
- 回归测试:真实 SSR 渲染 `VoiceMemberCards`,不给本机共享状态,只提供活动远端共享和控制,确认生成共享标记与观看按钮;另确认显式 `screenShare: false` 完全隐藏这组 UI。定向屏幕共享测试 8/8 通过。
- 验证:`npm run verify` 通过(687/687 测试、服务端 TypeScript 构建、前端类型检查与生产构建)。实际活动语音房间暂不可用,尚未目视确认动态流;本地构建产物已更新。
- 当前状态:修复及自动验证完成;按持续指示提交并推送至 `dev`,并更新本地 3040。
@@ -55,7 +55,7 @@
><Icon name="mic-off" :size="14" /></span
>
<span
v-if="shareEnabled && screenShareStreamForMember(member)"
v-if="screenShareStreamForMember(member)"
class="screen-share-live-indicator"
data-ws-part="voice.member.live-indicator"
><span
@@ -69,7 +69,7 @@
><span>{{ t("sharingScreen") }}</span></span
>
<button
v-if="shareEnabled && member.isSelf && (screenShareActive || screenShareStarting)"
v-if="screenShareStatusEnabled && member.isSelf && (screenShareActive || screenShareStarting)"
type="button"
class="screen-share-stop-button"
data-ws-part="voice.member.stop-share"
@@ -87,10 +87,10 @@
><span data-ws-part="voice.member.status">{{
isSpeaking(member) ? t("speaking") : member.isSelf ? t("connectedYou") : t("connected")
}}</span>
<div
v-if="shareEnabled && (member.isSelf || screenShareStreamForMember(member))"
class="screen-share-card-actions"
data-ws-part="voice.member.share-actions"
<div
v-if="screenShareStreamForMember(member) || (member.isSelf && screenShareStatusEnabled)"
class="screen-share-card-actions"
data-ws-part="voice.member.share-actions"
>
<template v-if="member.isSelf && !screenShareActive && !screenShareStarting">
<div class="screen-share-start-actions">
@@ -163,7 +163,7 @@ import Icon from "../Icon.vue";
import { computed } from "vue";
import type { ChannelMember, useVoiceWebSocket } from "../../composables/useVoiceWebSocket.js";
import type { useWebClientScreenShare } from "../../composables/useWebClientScreenShare.js";
const props = defineProps<{
const props = withDefaults(defineProps<{
currentMembers: ChannelMember[]; isMobileViewport: boolean; showMemberActions?: boolean;
showScreenShare?: boolean;
sharing?: Pick<ReturnType<typeof useVoiceWebSocket>, "screenShareActive" | "screenShareStarting" | "screenShareViewingStreamId"> & Pick<ReturnType<typeof useWebClientScreenShare>, "settingsOpen">;
@@ -171,17 +171,18 @@ const props = defineProps<{
isSpeaking: (member: ChannelMember) => boolean;
avatarStyle: (name: string, isSelf?: boolean, avatar?: string) => Record<string, string>;
avatarInitial: (name: string) => string; t: (key: string) => string;
}>();
const shareEnabled = computed(() => props.showScreenShare !== false && Boolean(props.sharing && props.controls));
const screenShareActive = computed(() => shareEnabled.value && Boolean(props.sharing?.screenShareActive.value));
const screenShareStarting = computed(() => shareEnabled.value && Boolean(props.sharing?.screenShareStarting.value));
const screenShareViewingStreamId = computed(() => shareEnabled.value ? props.sharing?.screenShareViewingStreamId.value ?? null : null);
const screenShareSettingsOpen = computed(() => shareEnabled.value && Boolean(props.sharing?.settingsOpen.value));
const screenShareStreamForMember = (member: ChannelMember) => shareEnabled.value ? props.controls?.streamForMember(member) ?? null : null;
const toggleScreenShareForMember = (member: ChannelMember) => { if (shareEnabled.value) props.controls?.toggleForMember(member); };
const startScreenShareWithSettings = () => { if (shareEnabled.value) void props.controls?.startWithSettings(); };
}>(), { showScreenShare: true });
const screenShareControlsEnabled = computed(() => props.showScreenShare !== false && Boolean(props.controls));
const screenShareStatusEnabled = computed(() => screenShareControlsEnabled.value && Boolean(props.sharing));
const screenShareActive = computed(() => screenShareStatusEnabled.value && Boolean(props.sharing?.screenShareActive.value));
const screenShareStarting = computed(() => screenShareStatusEnabled.value && Boolean(props.sharing?.screenShareStarting.value));
const screenShareViewingStreamId = computed(() => screenShareStatusEnabled.value ? props.sharing?.screenShareViewingStreamId.value ?? null : null);
const screenShareSettingsOpen = computed(() => screenShareStatusEnabled.value && Boolean(props.sharing?.settingsOpen.value));
const screenShareStreamForMember = (member: ChannelMember) => screenShareControlsEnabled.value ? props.controls?.streamForMember(member) ?? null : null;
const toggleScreenShareForMember = (member: ChannelMember) => { if (screenShareControlsEnabled.value) props.controls?.toggleForMember(member); };
const startScreenShareWithSettings = () => { if (screenShareStatusEnabled.value) void props.controls?.startWithSettings(); };
function toggleScreenShareSettings() {
if (!shareEnabled.value || !props.sharing) return;
if (!screenShareStatusEnabled.value || !props.sharing) return;
props.sharing.settingsOpen.value = !props.sharing.settingsOpen.value;
}
const emit = defineEmits<{ memberActions: [member: ChannelMember, event: MouseEvent]; stopShare: [] }>();
+5 -4
View File
@@ -674,10 +674,11 @@
:avatar-initial="avatarInitial"
:t="t"
/>
<VoiceMemberCards
:current-members="currentMembers"
:is-mobile-viewport="isMobileViewport"
:sharing="memberSharingState"
<VoiceMemberCards
:current-members="currentMembers"
:is-mobile-viewport="isMobileViewport"
:show-screen-share="true"
:sharing="memberSharingState"
:controls="screenShareControls"
:is-speaking="isSpeaking"
:avatar-style="avatarStyle"
+49 -3
View File
@@ -1,13 +1,16 @@
import assert from "node:assert/strict";
import { before, after, test } from "node:test";
import { fileURLToPath } from "node:url";
import vue from "@vitejs/plugin-vue";
import { createServer } from "vite";
import { createRenderer, nextTick, shallowRef, markRaw } from "vue";
let vite, useWebClientScreenShare;
import { createRenderer, createSSRApp, nextTick, shallowRef, markRaw } from "vue";
import { renderToString } from "@vue/server-renderer";
let vite, useWebClientScreenShare, VoiceMemberCards;
const renderer = createRenderer({ createComment: text => ({ text }), createText: text => ({ text }), createElement: () => ({}), insert() {}, remove() {}, setText() {}, setElementText() {}, patchProp() {}, parentNode: () => null, nextSibling: () => null });
before(async () => {
vite = await createServer({ configFile: false, root: fileURLToPath(new URL("../", import.meta.url)), server: { middlewareMode: true, hmr: false, ws: false, watch: null }, optimizeDeps: { noDiscovery: true, include: [] }, appType: "custom" });
vite = await createServer({ configFile: false, plugins: [vue()], root: fileURLToPath(new URL("../", import.meta.url)), server: { middlewareMode: true, hmr: false, ws: false, watch: null }, optimizeDeps: { noDiscovery: true, include: [] }, appType: "custom" });
({ useWebClientScreenShare } = await vite.ssrLoadModule("/src/composables/useWebClientScreenShare.ts"));
({ default: VoiceMemberCards } = await vite.ssrLoadModule("/src/components/web-client/VoiceMemberCards.vue"));
});
after(async () => { await vite?.close(); });
function mount(t, initialStream = null) {
@@ -73,6 +76,49 @@ test("known screen owner IDs cannot fall back to another member with the same ni
} finally { f.app.unmount(); }
});
test("member cards detect and expose a remote share without depending on local share status", async () => {
let lookupCount = 0;
const html = await renderToString(createSSRApp(VoiceMemberCards, {
currentMembers: [
{ id: 7, nickname: "Remote sharer", isSelf: false, inputMuted: false },
{ id: 8, nickname: "Local viewer", isSelf: true, inputMuted: false },
],
isMobileViewport: false,
controls: {
streamForMember: member => { lookupCount++; return member.id === 7 ? { streamId: "active-share" } : null; },
toggleForMember() {},
startWithSettings() {},
},
isSpeaking: () => false,
avatarStyle: () => ({}),
avatarInitial: nickname => nickname[0],
t: key => key,
}));
assert.ok(lookupCount > 0, "member cards query the available share controls");
assert.match(html, /screen-share-live-indicator/);
assert.match(html, /sharingScreen/);
assert.match(html, /screen-share-card-button/);
assert.match(html, /watchScreenShare/);
assert.equal((html.match(/screen-share-card-actions/g) ?? []).length, 1);
assert.doesNotMatch(html, /startScreenShare/);
});
test("a skin can explicitly opt the member-card widget out of screen-share UI", async () => {
const html = await renderToString(createSSRApp(VoiceMemberCards, {
currentMembers: [{ id: 7, nickname: "Remote sharer", isSelf: false, inputMuted: false }],
isMobileViewport: false,
showScreenShare: false,
controls: { streamForMember: () => ({ streamId: "active-share" }), toggleForMember() {}, startWithSettings() {} },
isSpeaking: () => false,
avatarStyle: () => ({}),
avatarInitial: nickname => nickname[0],
t: key => key,
}));
assert.doesNotMatch(html, /screen-share-live-indicator|screen-share-card-button/);
});
test("share settings submit the selected resolution and frame rate", async t => {
const f = mount(t);
try { f.ui.settingsOpen.value = true; f.ui.resolutionPreset.value = "720p"; f.ui.frameRate.value = 30; await f.ui.startWithSettings();