From 6ca2ffc1ea4b6a967315c37e9bc9bd19ce0a42eb Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Wed, 19 Aug 2026 22:32:04 +0800 Subject: [PATCH] feat(ui): add viewer volume and room codes --- docs/project-memory.md | 2 +- docs/status.md | 2 +- docs/方案设计.md | 8 +- docs/需求理解.md | 4 +- index.html | 1 + public/favicon.svg | 5 ++ src/client/components/RoomCode.tsx | 84 ++++++++++++++++++++ src/client/components/room-code.ts | 7 ++ src/client/media/viewer-volume.ts | 63 +++++++++++++++ src/client/pages/HostPage.tsx | 6 +- src/client/pages/ViewerPage.tsx | 82 +++++++++++++++----- src/client/styles.css | 120 ++++++++++++++++++++++++++++- tests/room-code.test.ts | 21 +++++ tests/viewer-volume.test.ts | 65 ++++++++++++++++ 14 files changed, 442 insertions(+), 28 deletions(-) create mode 100644 public/favicon.svg create mode 100644 src/client/components/RoomCode.tsx create mode 100644 src/client/components/room-code.ts create mode 100644 src/client/media/viewer-volume.ts create mode 100644 tests/room-code.test.ts create mode 100644 tests/viewer-volume.test.ts diff --git a/docs/project-memory.md b/docs/project-memory.md index f9ce80d..bafe7ef 100644 --- a/docs/project-memory.md +++ b/docs/project-memory.md @@ -27,7 +27,7 @@ Last updated: 2026-08-19 - Flagship media is UDP; HTTPS/WSS stays TLS/TCP. Old production retains coturn TURN for rollback. The candidate uses self-hosted STUN-only ordinary ICE and separate LiveKit SFU/UDP, with no TURN/media-TCP wire. - Treat settings as ceilings and deployed degradation as unclassified. Use correlated Host A+B/Viewer C to compare exact `769de201f7cc` against current `main` for Host-only recovery, game FPS/load, preview cost, actual codec/encoder and one-variable rebuilds; then gate SVC before custom `LOW`. Never use UA or a composite score. - Production reports poor film audio and self-echo when system capture includes voice software. Diagnose audio A/B/C and sync; Web cannot isolate arbitrary processes and `maxBitrate` is not quality-up. A Windows 11 native candidate defaults to game-process-tree audio and never widens silently; Windows 10 remains unresolved/unsupported. See `docs/research/browser-screen-audio-quality.md`. -- Post-gate UI: local volume/mute, display name, transient roster, local-only candidate endpoints, and RTP loss rate; no accounts, database, telemetry, media, or routing effects. +- Candidate UI has local Viewer volume/mute, copyable room codes, and a favicon. Names/roster, endpoint details, and RTP loss remain pending; no wire, media, or routing effects. - Do not add scene detection, dynamic-FPS control, or forced AV1 until stats and target hardware prove the need. Codec acceptance requires actual negotiation, power-efficient candidate evidence, interval encode cost, game FPS, CPU/GPU and sender count; Discord's native capture/hardware tuning is comparison evidence, not proof of server re-encoding or a reusable preset. - Keep room policy deployment-driven: public/password-only rooms are random and temporary; password plus SQLite enables sequential persistent rooms and reusable stopped links. - Deferred architecture audit: `docs/maintenance.md`. diff --git a/docs/status.md b/docs/status.md index 986bcc9..0aa5f0b 100644 --- a/docs/status.md +++ b/docs/status.md @@ -54,7 +54,7 @@ sync, and voice-source leakage in parallel when it does not displace that P0; owns two-state policy. An isolated exact room later gates peer/SFU UDP and bounded failure before replacing the old release. Selected-edge TURN, if later justified, is a separate complete change rather than part of this canary. -Post-gate UI adds local volume/mute, names/roster, endpoint details, and RTP loss. +Candidate UI has volume, room-code copy and favicon; names/roster/diagnostics remain. ADR-0004 still requires a full-resolution 30-minute `1/3/5/8` network, resource, quality, latency, recovery, and browser/mobile-leaf matrix. A separate diff --git a/docs/方案设计.md b/docs/方案设计.md index 00ff46e..8ab53c4 100644 --- a/docs/方案设计.md +++ b/docs/方案设计.md @@ -248,12 +248,12 @@ hop 按[低服务器成本媒体路由](./research/low-server-media-routes.md) ## 界面结构 -首屏就是工具,不做营销页。视觉采用中性深灰工作台,绿色表示 direct、琥珀色表示 relay/警告、红色表示失败,避免单一蓝紫色主题。 +首屏就是工具,不做营销页。视觉采用中性深灰工作台,绿色表示 direct、琥珀色表示 relay/警告、红色表示失败,避免单一蓝紫色主题;浏览器 favicon 复用页头 `MonitorUp` 的深绿底、绿色显示器和上行箭头语言。 - 全站 gate:仅在配置 `ACCESS_PASSWORD` 且 cookie 无效时显示一个密码输入窗口;验证后返回原目标路径。 -- 分享者根页面:顶部显示“{分享者显示名} 的房间”和房间状态;主区域保持稳定的 16:9 舞台。未发布、已停止或可恢复错误状态时,舞台内以同等尺寸和权重显示“开始分享”和“加入房间”,中间只用“或”与分隔线表达发送/接收;前者直接开始现有分享流程,后者直接进入 `/join`,不增加首页、向导或拓扑选择。直播时舞台显示本地预览,底部保留停止、暂停、质量档位和复制邀请。 +- 分享者根页面:顶部显示“{分享者显示名} 的房间”和房间状态,并在标题旁显示可单独复制的紧凑房间号;主区域保持稳定的 16:9 舞台。未发布、已停止或可恢复错误状态时,舞台内以同等尺寸和权重显示“开始分享”和“加入房间”,中间只用“或”与分隔线表达发送/接收;前者直接开始现有分享流程,后者直接进入 `/join`,不增加首页、向导或拓扑选择。直播时舞台显示本地预览,底部保留停止、暂停、质量档位和复制完整邀请链接。 - `/join`:只输入正整数形式的数字房间码,成功后进入 `/r/{code}`。 -- `/r/{code}` 观看者:主区域最大化远端视频;顶部显示房间与连接状态;提供本地音量、静音、全屏和重试控制,不要求额外邀请码或 viewer token。 +- `/r/{code}` 观看者:主区域最大化远端视频;标题旁显示可复制的紧凑房间号,顶部保留连接状态;提供本地音量、静音、全屏和重试控制,不要求额外邀请码或 viewer token。 - 移动端:视频保持稳定宽高比,控制与状态移到视频下方,任何文字和按钮不得溢出或遮挡。 两端默认显示紧凑的在线 roster;Host 与 Viewer 均可修改本机显示名,更新只影响之后由服务端广播的纯文本 roster。一个不持久化的“显示连接详情”复选框按页展开信令、ICE/TURN、浏览器实际暴露的本地/远端候选地址、codec、RTT、RTP 丢包率、编解码耗时及逐边统计;真实连接失败、音频缺失、持续画质受限和需要用户动作的告警始终可见,不能被该开关隐藏。分享者默认观看人数必须来自房间 roster,而不是只统计当前由 host 直连的媒体 child。 @@ -262,7 +262,7 @@ hop 按[低服务器成本媒体路由](./research/low-server-media-routes.md) 按钮使用 `lucide-react` 图标并提供可访问名称和 tooltip。动态状态区域固定最小尺寸,避免连接状态变化导致布局跳动。320、375 与 390 CSS px 下两个首屏动作仍须同排等宽、文字不溢出且触控高度至少 44 px;展开详情不遮挡视频或引入横向滚动。 -观看端音量条直接写入当前 `