refactor: extract audio controls and scope whisper input

This commit is contained in:
illusia committed 2026-10-01 18:58:19 +08:00
1 parent d2caaa8f3c
commit 8b6c998c43
8 files changed
+244 -90

No files matched your search

+2
View File
@@ -185,6 +185,8 @@ The public join form uses explicit named field models and emits page actions. Th
The member panel and actions menu also share one page-owned member controller. The panel exposes an audio-dock slot; menu placement uses measured viewport bounds, converts through the page CSS zoom, and releases its resize observer/listener on unmount. Only desktop may open the move submenu on hover: mobile bottom-anchored menus change position when expanded and must open on click to avoid moving a member accidentally. Constrain short-window menus and allow scrolling.
The audio dock and whisper strip share the page-owned audio controller. Push-to-talk belongs to one primary pointer or one Space/Enter press; unrelated releases and key repeats must not change it. Failed pointer capture must not enable whispering. Clear ownership before releasing capture, and stop on blur, hidden controls/pages and disposal. The whisper component owns and releases its window/document listeners; keep media state in the voice layer.
Audio settings and password dialogs retain one page-owned media/connection state. Dialog focus supports initial focus, Tab cycling, Escape and return to the opener, with a connect-button fallback after pending connections disable that opener. Settings error feedback belongs to the current opening and latest request; closing synchronously stops recording tests, and scope disposal retires pending feedback and stops tests too. A non-password channel error must release the password dialog's pending state and preserve its draft for retry; reject duplicate submissions while pending.
Admin presentation components receive stable feature controllers; do not instantiate duplicate controllers in children. The welcome-language model remains page-owned and the skin file input belongs to its presentation component. Feature CSS crosses these boundaries with `:deep`, while shell and language-control selectors retain their existing scope. On narrow screens the brand and logout occupy the first row and all four navigation links share a separate row with at least 44 px high targets.
+24 -13
View File
@@ -1,18 +1,18 @@
# WebSpeak 代码待修改清单与修改方向
本文聚焦 `webspeak-webclient`,记录当前代码结构、待修改项、大致修改方向与验收条件。本批提取音频设置、频道密码和服务器密码弹窗,修复设置异步错误串入新操作、频道密码提交遇普通错误后持续等待的问题;最终统一验证通过 398 项测试及前后端构建。待办分为结构整理、已有改动验收和真实环境验证;缺少验证证据的事项不直接认定为代码故障。
本文聚焦 `webspeak-webclient`,记录当前代码结构、待修改项、大致修改方向与验收条件。本批提取桌面音频工具栏与私语控制条,修复私语键盘不可用、指针归属不明及控件隐藏后未停止的问题;统一验证通过 403 项测试及前后端构建。待办分为结构整理、已有改动验收和真实环境验证;缺少验证证据的事项不直接认定为代码故障。
按用户要求,每批仅处理当前节点相关问题,合并相关修复后统一验证,不扩展到无关模块。管理页主要交互与布局已检查,原生确认框阻塞的操作验收单独保留。加入、聊天、频道成员、成员菜单、音频设置及密码弹窗已拆分;后续处理音频工具栏与剩余语音活动、屏幕共享展示,样式格式整理单独进行。真实消息兼容、TeamSpeak 媒体、Android 真机及发布复现独立跟踪,可提前安排。媒体、连接、命令、诊断、消息、身份及公共皮肤状态已有独立模块,继续复用。当前待办和实施方向放在前部,历史修复及验证记录保留在后部。
按用户要求,每批仅处理当前节点相关问题,合并相关修复后统一验证,不扩展到无关模块。管理页主要交互与布局已检查,原生确认框阻塞的操作验收单独保留。加入、聊天、频道成员、成员菜单、音频设置及密码弹窗已拆分;音频工具栏与私语控制条本批已提取,后续处理剩余语音活动、诊断与屏幕共享展示,样式格式整理单独进行。真实消息兼容、TeamSpeak 媒体、Android 真机及发布复现独立跟踪,可提前安排。媒体、连接、命令、诊断、消息、身份及公共皮肤状态已有独立模块,继续复用。当前待办和实施方向放在前部,历史修复及验证记录保留在后部。
## 范围与依据
- 记录日期:2026 年 10 月 1 日。
- 当前记录基线:`dev` 分支,`b1e5be2f540ca4c19478092baa027f666b7cbedf`;应用版本 `0.2.5-preview`。以下现状包含当前工作区,不能全部归为该提交的内容。
- 本批仅处理 06-C 的音频设置、两个密码弹窗、焦点及相关错误反馈。业务状态和媒体资源仍由父页及现有控制模块拥有;协议、媒体实现、数据库和依赖未变。
- 新增 5 项设置异步错误与清理测试、3 项频道密码等待与重试测试;前 5 项已在旧实现上复现失败。相关修复合并后,最终 `npm run verify` 通过 398 项测试、后端编译及前端类型检查和生产构建。
- 当前记录基线:`dev` 分支,`9bdd860dc73d5256ac31b7528ec50a5a08657eed`;应用版本 `0.2.5-preview`。以下现状包含当前工作区,不能全部归为该提交的内容。
- 本批仅处理 06-C 的桌面音频工具栏、私语控制条及按住讲话的输入生命周期。业务状态和媒体资源仍由父页及现有控制模块拥有;协议、媒体实现、数据库和依赖未变。
- 新增 5 项私语操作测试,覆盖非主按钮、指针归属、捕获失败、键盘重复与松开及作用域释放。相关修复合并后,`npm run verify` 通过 403 项测试、后端编译及前端类型检查和生产构建;随后简化展示属性接口,并补跑前端类型检查与构建。
- 既有皮肤修复记录记载新增 23 项测试,以及 `npm run verify` 通过 385 项测试和前后端构建;其中 5 项先复现旧结果覆盖及失效归属问题。这些是此前批次的验证结果,不是本轮重新执行的结果。
- 本批浏览器使用实际前端及 HTTP/WebSocket 桥接、模拟 TeamSpeak 客户端,覆盖设置持久化、权限拒绝反馈、焦点循环、Esc、密码错误、等待、取消和普通错误后重试。三个弹窗共 45 组抽样布局检查通过,具体语言与皮肤配对见本批记录;模拟结果不能证明真实设备或 TeamSpeak 媒体可用。
- 上批 `b1e5be2` 的 CI 与 Docker 健康检查已确认成功(运行 36848422682);本批弹窗改动需使用自己的提交核对远端结果。
- 本批浏览器使用实际前端及 HTTP/WebSocket 桥接、模拟 TeamSpeak 客户端,覆盖音频快捷按钮、私语指针/键盘接线、隐藏与失焦停止。15 组语言/皮肤/尺寸抽样及 10 个桌面音量面板边界检查通过;模拟结果不能证明真实语音或伴奏传输可用。
- 上批 `9bdd860` 的 CI 与 Docker 健康检查已确认成功(运行 36851189830);本批工具栏改动需使用自己的提交核对远端结果。
- 下文“代码可确认”指控制流或配置可直接支持的判断;具体故障发生条件仍需回归用例验证。“待验收”表示证据尚缺,不等于已发生故障。P1/P2/P3 表示建议实施顺序,不代表安全漏洞等级。
- 后文身份、消息、媒体、皮肤等“实施记录”属于此前批次;其中“本批”指各记录对应的历史批次。当前待办以本页前部状态表为准。
@@ -31,7 +31,7 @@
| 浏览器连接与命令 | `web/src/voice/connection.ts`、`commands.ts` | 连接模块 132 行,拥有请求取消、期限、socket 与代次;命令模块 59 行,拥有确认等待及统一收尾 |
| 浏览器诊断 | `web/src/voice/audio-diagnostics.ts`、`web/src/composables/useWebClientPerformance.ts` | 采样模块 168 行,拥有等待、来源范围与兼容计数;面板 composable 管理轮询和可比样本的展示 |
| 会话消息状态 | `web/src/voice/session-state.ts` | 172 行;拥有成员与频道、聊天历史、事件、通知、会话范围和私聊身份映射 |
| 页面与业务状态 | `web/src/views/`、`web/src/composables/` | 主页面 895 行,管理页 251 行;聊天 composable 管理按会话和对象隔离的草稿、发送等待及反馈 |
| 页面与业务状态 | `web/src/views/`、`web/src/composables/` | 主页面 873 行,管理页 251 行;聊天 composable 管理按会话和对象隔离的草稿、发送等待及反馈 |
| 管理展示组件 | `web/src/components/admin/` | 服务器设置 125 行、运维 39 行、皮肤 48 行;状态仍由父页创建,主要表单与路由交互已验收 |
| 身份导入与导出 | `useWebClientIdentity.ts`、`components/web-client/IdentityImportDialog.vue` | 159 行状态模块与 53 行展示组件;异步操作、启动恢复与导出资源独立归属 |
| 前端基础服务 | `web/src/services/`、`web/src/i18n/`、`web/src/skins/` | 请求、浏览器存储、身份导入、主题、皮肤及多语言;皮肤运行时的提交受取消和期限保护 |
@@ -49,7 +49,7 @@
| 编号 | 优先级 | 待办及依据 | 大致修改方向 | 完成条件 |
| --- | --- | --- | --- | --- |
| 06-C 客户端 | P2 | 加入、聊天、频道成员、成员菜单、设置及密码弹窗已提取;音频工具栏与剩余语音活动、屏幕共享展示待整理,触屏拖动及原生输入框流程待验收 | 按区域提取,相关区域合并验收;页面保留连接和状态编排 | 表单、五语、主题、皮肤接口、键盘与窄屏布局保持一致 |
| 06-C 客户端 | P2 | 加入、聊天、频道成员、成员菜单、设置及密码弹窗已提取;工具栏与私语控制条已提取,剩余语音活动、诊断与屏幕共享展示待整理,触屏拖动及原生输入框流程待验收 | 按区域提取,相关区域合并验收;页面保留连接和状态编排 | 表单、五语、主题、皮肤接口、键盘与窄屏布局保持一致 |
| 06-C 管理页 | P2 | 展示拆分与主要交互已完成;移除皮肤时原生确认框使浏览器工具卡住,移除、断开会话及下载的完整浏览器流程仍缺记录 | 保留确认与业务逻辑,工具恢复或人工检查时补验,不为绕过工具问题重写功能 | 移除、断开与下载的实际结果有记录;状态及接口测试不能替代完整浏览器链路 |
| 03 | P2 | 共享契约已落地,真实收发与旧客户端兼容仍缺验收证据 | 用脱敏的实际消息样本核对字段、默认值、非法输入及兼容范围 | 两端解析一致;非法消息受控处理,不误丢有效事件 |
| 02-C | P2 | 本机与边界替身测试不能证明真实媒体链路 | 建立真实 TeamSpeak 双向语音、WebRTC 回退、伴奏和多用户验收步骤 | 记录版本、浏览器、网络、设备、步骤及实际结果 |
@@ -80,7 +80,7 @@
### 06-C 页面组件
当前依据:[WebClient.vue](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/WebClient.vue:1) 有 895 行,加入表单、聊天面板、频道成员、成员菜单、身份导入、音频设置及密码弹窗已独立;父页仍承载语音活动、音频工具栏和屏幕共享展示。[AdminView.vue](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/AdminView.vue:41) 已由 400 行减至 251 行,三个管理模板迁移到独立组件。管理页剩余浏览器验收缺口见前表,客户端继续明确展示边界;不以文件长度推定运行故障。
当前依据:[WebClient.vue](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/WebClient.vue:1) 有 873 行,加入表单、聊天面板、频道成员、成员菜单、身份导入、音频设置及密码弹窗已独立;父页仍承载语音活动、诊断和屏幕共享展示。[AdminView.vue](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/AdminView.vue:41) 已由 400 行减至 251 行,三个管理模板迁移到独立组件。管理页剩余浏览器验收缺口见前表,客户端继续明确展示边界;不以文件长度推定运行故障。
以下名称为建议,实施时按实际接口确定。按稳定区域迁移,相关展示区域合并后统一验收,避免同时重写模板和业务状态。
@@ -90,12 +90,13 @@
| 频道与成员,已提取 | `ChannelMemberPanel` 与 `MemberActionsMenu` 展示层级、成员状态和操作入口 | 复用父页单一 `useWebClientMembers`;面板保留音频工具栏插槽,菜单拥有定位观察器;动作仍交回现有控制层 | 搜索、频道切换、桌面指针拖动、调度及菜单边界已检查;真实触屏拖动及原生输入框仍待验收 |
| 聊天,已提取 | `ChatPanel` 展示标签、历史、草稿和发送反馈 | 草稿与待确认状态继续由单一 `useWebClientChat` 实例管理;保留外部打开私聊的入口 | 切标签保留草稿、发送失败与重试、目标离线、滚动和移动端切页 |
| 设置与密码弹窗,已提取 | `AudioSettingsDialog`、`ChannelPasswordDialog`、`ServerPasswordDialog` 展示设置及连接反馈;身份导入此前已提取 | 复用父页单一媒体与连接状态;设置错误受打开代次和请求顺序保护;共享焦点工具管理循环、Esc 和返回 | 焦点、Esc、设置持久化、密码等待与重试已检查;真实设备切换与录音待媒体验收 |
| 音频及共享展示 | 继续拆音频工具栏、剩余语音活动与屏幕共享展示 | 媒体仍由语音控制模块拥有,页面保留连接编排 | 静音、音量、私语按键、活动展示及共享操作接线 |
| 音频工具栏与私语,已提取 | `AudioDock` 展示桌面快捷操作;`WhisperControls` 展示目标与按住讲话入口 | 使用父页单一音频控制器;私语按钮只拥有当前输入,隐藏、失焦和卸载时停止;监听随组件释放 | 静音、音量、设置入口、伴奏不可用提示、指针/键盘命令及布局已检查,真实媒体另行验收 |
| 剩余语音及共享展示 | 继续拆语音活动、诊断与屏幕共享展示 | 媒体仍由语音控制模块拥有,页面保留连接编排 | 活动、诊断与共享操作接线,播放器元素及全屏引用保持一致 |
| 管理功能页,已提交 | `AdminServerSettings`、`AdminOperations`、`AdminSkins` 已提取,先验收这三个边界 | 父页创建三个管理 composable,通过稳定 `model` 对象传入;登录、CSRF、路由与总览仍在页面;欢迎词语言用具名模型传递,WebRTC 提示用事件返回 | 保存期间继续编辑、请求失败保留草稿、欢迎词语言、退出失败、路由切换、皮肤文件选择及操作互斥 |
接口只传该区域需要的状态和动作,避免把整页上下文塞进一个对象,也避免父子各自实例化同一个业务 composable。管理组件当前使用 `ReturnType<typeof useAdmin...>` 描述功能控制器,并在 setup 中解构,因此依赖父页维持同一控制器实例;若后续支持替换实例,需要同步调整读取方式。可以用 `Pick` 或专用接口缩小暴露范围,但不为形式重写已明确的状态归属。展示辅助函数如头像、时间格式在确有多处复用时集中,不额外引入全局状态层。
样式需要随组件边界一并核对。[客户端样式入口](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/WebClient.vue:895)和[管理页样式入口](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/AdminView.vue:251)均使用 `scoped`,当前 CSS 分别为 1,303 与 451 行。身份弹窗已有针对组件的 `:deep` 规则;管理页当前改动将大量功能区选择器改为 `:deep`,并保留部分外壳和语言控件选择器的原作用范围。不要把这项源码变化直接等同于视觉一致:需对比子组件内部、共享按钮与语言菜单的字体、间距、尺寸、折行,以及样式声明顺序和优先级。必要时改为组件自有样式或更窄的区域选择器,保留明暗主题、`data-ws-part` 和路由隔离,管理页保持独立于公开皮肤。
样式需要随组件边界一并核对。[客户端样式入口](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/WebClient.vue:873)和[管理页样式入口](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/views/AdminView.vue:251)均使用 `scoped`,当前 CSS 分别为 1,303 与 451 行。身份弹窗已有针对组件的 `:deep` 规则;管理页当前改动将大量功能区选择器改为 `:deep`,并保留部分外壳和语言控件选择器的原作用范围。不要把这项源码变化直接等同于视觉一致:需对比子组件内部、共享按钮与语言菜单的字体、间距、尺寸、折行,以及样式声明顺序和优先级。必要时改为组件自有样式或更窄的区域选择器,保留明暗主题、`data-ws-part` 和路由隔离,管理页保持独立于公开皮肤。
测试也需跟随边界调整:[皮肤节点检查](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/src/services/skin-pack.test.ts:80)在当前工作区已递归读取 `components/web-client` 和 `components/admin` 下的 Vue 文件,保留公开节点契约及管理页隔离检查。[管理页状态测试](<USER_HOME>/Desktop/othercode/teamspeakclient4web/webspeak-webclient/web/test/admin-view.test.mjs:79)已改为读取父页功能模型,仍用 `render: () => null` 替换模板,不能单独证明子组件的字段与事件接线正确。后续验收必须覆盖真实渲染的表单、按钮和路由交互;这属于测试覆盖边界,不能推定测试已发现业务故障。
@@ -103,7 +104,16 @@
每个区域验收包括桌面与窄屏、五语长文案、明暗主题和自定义皮肤;对比布局、滚动、弹层遮挡及键盘操作。编译通过和源码正则匹配不能替代实际渲染检查。
### 音频设置与密码弹窗的本批结果
### 音频工具栏与私语控制的本批结果
- `AudioDock.vue` 通过稳定对象接收所需语音引用与动作,设置及输出静音用事件返回;`WhisperControls.vue` 复用同一控制器,清空目标仍交回成员模块。原有皮肤节点和样式声明顺序保留。
- 私语只接受主指针左键,记录捕获指针并忽略其他指针的松开;捕获失败不进入讲话状态。新增空格/回车按住支持,忽略重复按键与无关松开。停止先清除归属,再释放捕获,避免丢失捕获事件重复停止。
- 控件失焦、窗口失焦、页面隐藏、移动页切走和组件卸载均停止当前按住操作;组件释放监听,音频控制器作用域释放也停止私语。5 项新增测试验证输入归属与清理。
- 浏览器确认右键不启动、左键启动、移出后松开停止;空格/回车各产生一组真实 WebSocket 开始/停止命令,模拟网关收到 `[true, false, true, false]`。窄屏隐藏与按钮失焦时状态停止,清空目标移除控制条。浏览器错误与警告记录为空。
- 工具栏拆分前后 22 个可见元素的尺寸、字体、颜色和间距一致。麦克风及输出静音、输入与输出音量、设置入口/关闭、伴奏缺少 WebRTC 的反馈已检查;当前没有真实麦克风授权,不作为音频效果证据。
- 布局使用 zh/浅色、en/深色、de/ILLUSIA、ru/浅色、ja/深色五组配对,每组检查 1280×720、390×844、320×568,共 15 组;另核对每组桌面输入/输出音量面板,共 10 个面板。等待语言及皮肤实际生效后记录边界,控件均未横向越界,音量面板均位于窗口内。
- 本批统一验证 403 项测试与前后端构建通过;属性接口简化后前端类型检查及构建再次通过。真实语音、伴奏和触屏设备结果仍归原媒体验收节点。
### 此前音频设置与密码弹窗的结果
- 三个展示组件复用父页现有状态,设置仅接收所需语音引用与控制动作,两个密码弹窗使用字段模型及提交/取消事件。共享焦点工具处理初始焦点、Tab 循环、Esc 和关闭后返回;服务器连接等待会使原按钮失焦,因此增加返回连接按钮的回退。
- 设置准备、设备选择和录音测试的错误只允许当前打开代次及最新请求发布;关闭同步停止录音测试,作用域释放也停止并使迟到反馈失效。5 项测试先在旧实现全部失败,再验证修复;没有改写底层媒体事务。
@@ -182,6 +192,7 @@ Android 记录具体设备和系统,验收连接、双向语音、输入输出
| 原事项或范围 | 当前状态 |
| --- | --- |
| 06-C 工具栏与私语 | 两个展示组件已提取,修复指针归属并支持键盘按住;隐藏、失焦及释放停止,403 项测试及浏览器接线/布局检查通过 |
| 06-C 设置与密码弹窗 | 三个展示组件已提取;修复迟到设置错误及频道密码普通错误后卡等待,新增 8 项回归;398 项测试与 45 组抽样布局检查通过,真实媒体验收另行保留 |
| 06-K 管理页导航 | 窄屏改为品牌与退出、四项导航两行布局;五语四路由四宽度共 80 组边界检查通过 |
| 06-C 频道成员与菜单 | 两个展示组件已提取;修复移动端误调度及短窗口菜单越界,390 项测试与 45 组边界检查通过;触屏及原生输入框验收仍保留 |
@@ -0,0 +1,41 @@
<template>
<div class="desktop-audio-dock" data-ws-part="voice.audio-dock" role="toolbar" :aria-label="t('desktopAudioControls')">
<div class="desktop-audio-dock-copy"><strong>{{ t('desktopAudioControls') }}</strong><span>{{ accompanimentActive ? t('accompanimentActive') : t('desktopAudioHint') }}</span></div>
<div class="desktop-audio-dock-actions">
<div class="dock-hover-control" data-ws-part="voice.audio-dock.microphone">
<button type="button" class="dock-audio-button microphone-header-toggle" :class="{ muted: microphoneMuted }" :title="microphoneMuted ? t('unmuteMic') : t('muteMic')" :aria-label="microphoneMuted ? t('microphoneMuted') : t('microphoneActive')" :aria-pressed="!microphoneMuted" aria-haspopup="dialog" @click="toggleMicrophone"><Icon :name="microphoneMuted ? 'mic-off' : 'mic'" :size="18" /></button>
<div class="dock-hover-panel dock-microphone-panel" data-ws-part="voice.audio-dock.microphone-panel" role="dialog" :aria-label="t('microphone')">
<div class="dock-slider-heading"><span>{{ t('inputVolume') }}</span><strong>{{ Math.round(inputVolume * 100) }}%</strong></div>
<input class="dock-slider" type="range" min="0" max="100" :value="inputVolume * 100" :style="rangeStyle(inputVolume, 1)" :aria-label="t('inputVolume')" @input="onInputVolume" />
<div class="dock-panel-divider"></div>
<label class="dock-switch-row"><span><strong>{{ t('noiseSuppression') }}</strong></span><input type="checkbox" :checked="noiseSuppressionEnabled" :aria-label="t('noiseSuppression')" @change="onNoiseSuppressionToggle" /></label>
</div>
</div>
<div class="dock-hover-control" data-ws-part="voice.audio-dock.output">
<button type="button" class="dock-audio-button" :class="{ muted: outputMuted }" :title="outputMuted ? t('unmuteOutput') : t('muteOutput')" :aria-label="outputMuted ? t('unmuteOutput') : t('muteOutput')" :aria-pressed="!outputMuted" aria-haspopup="dialog" @click="emit('outputMute')"><Icon :name="outputMuted ? 'volume-off' : 'volume'" :size="18" /></button>
<div class="dock-hover-panel dock-output-panel" data-ws-part="voice.audio-dock.output-panel" role="dialog" :aria-label="t('overallVolume')">
<div class="dock-slider-heading"><span>{{ t('overallVolume') }}</span><strong>{{ Math.round(outputVolume * 100) }}%</strong></div>
<input class="dock-slider" type="range" min="0" max="100" :value="outputVolume * 100" :style="rangeStyle(outputVolume, 1)" :aria-label="t('overallVolume')" @input="onOutputVolume" />
</div>
</div>
<button type="button" class="dock-audio-button" :title="t('audioSettings')" :aria-label="t('audioSettings')" @click="emit('settings')"><Icon name="settings" :size="18" /></button>
<button type="button" class="dock-audio-button accompaniment-toggle" :class="{ active: accompanimentActive }" :title="accompanimentActive ? t('stopAccompaniment') : t('startAccompaniment')" :aria-label="accompanimentActive ? t('stopAccompaniment') : t('startAccompaniment')" :aria-pressed="accompanimentActive" @click="toggleAccompaniment"><Icon name="music" :size="18" /></button>
</div>
</div>
</template>
<script setup lang="ts">
import Icon from "../Icon.vue";
import type { useVoiceWebSocket } from "../../composables/useVoiceWebSocket.js";
import type { useWebClientAudioControls } from "../../composables/useWebClientAudioControls.js";
const props = defineProps<{
model: Pick<ReturnType<typeof useVoiceWebSocket>, "microphoneMuted" | "inputVolume" | "outputVolume" | "outputMuted" | "noiseSuppressionEnabled" | "accompanimentActive">;
controls: Pick<ReturnType<typeof useWebClientAudioControls>, "toggleMicrophone" | "onInputVolume" | "onOutputVolume" | "onNoiseSuppressionToggle" | "toggleAccompaniment">;
t: (key: string) => string;
rangeStyle: (value: number, max: number) => Record<string, string>;
}>();
const { microphoneMuted, inputVolume, outputVolume, outputMuted, noiseSuppressionEnabled, accompanimentActive } = props.model;
const { toggleMicrophone, onInputVolume, onOutputVolume, onNoiseSuppressionToggle, toggleAccompaniment } = props.controls;
const emit = defineEmits<{ settings: []; outputMute: [] }>();
</script>
@@ -0,0 +1,34 @@
<template>
<div class="whisper-strip" data-ws-part="voice.whisper-strip">
<div class="whisper-strip-copy"><strong><Icon name="users" :size="15" /> {{ t('whisperTargets') }}</strong><span>{{ targets.map((member) => member.nickname).join('、') }}</span></div>
<button type="button" class="text-button" @click="emit('clear')">{{ t('clearWhisperTargets') }}</button>
<button type="button" class="whisper-ptt-button" :class="{ active: whisperPttActive || active }" :aria-pressed="whisperPttActive || active" @pointerdown.prevent="onWhisperPttDown" @pointerup.prevent="onWhisperPttUp" @pointercancel.prevent="onWhisperPttUp" @lostpointercapture="onWhisperPttUp" @keydown="onWhisperPttKeyDown" @keyup="onWhisperPttKeyUp" @blur="stopWhisperTalk"><Icon name="mic" :size="18" /> {{ whisperPttActive || active ? t('releaseWhisper') : t('whisperHoldToTalk') }}</button>
</div>
</template>
<script setup lang="ts">
import { onMounted, onBeforeUnmount, watch } from "vue";
import Icon from "../Icon.vue";
import type { useWebClientAudioControls } from "../../composables/useWebClientAudioControls.js";
const props = defineProps<{
targets: ReadonlyArray<{ nickname: string }>;
active: boolean;
enabled: boolean;
controls: Pick<ReturnType<typeof useWebClientAudioControls>, "whisperPttActive" | "onWhisperPttDown" | "onWhisperPttUp" | "onWhisperPttKeyDown" | "onWhisperPttKeyUp" | "stopWhisperTalk">;
t: (key: string) => string;
}>();
const { whisperPttActive, onWhisperPttDown, onWhisperPttUp, onWhisperPttKeyDown, onWhisperPttKeyUp, stopWhisperTalk } = props.controls;
const emit = defineEmits<{ clear: [] }>();
function onVisibilityChange() { if (document.hidden) stopWhisperTalk(); }
watch(() => props.enabled, enabled => { if (!enabled) stopWhisperTalk(); }, { flush: "sync" });
onMounted(() => {
window.addEventListener("blur", stopWhisperTalk);
document.addEventListener("visibilitychange", onVisibilityChange);
});
onBeforeUnmount(() => {
stopWhisperTalk();
window.removeEventListener("blur", stopWhisperTalk);
document.removeEventListener("visibilitychange", onVisibilityChange);
});
</script>
@@ -64,6 +64,8 @@ export function useWebClientAudioControls({
const micMeterBars = computed(() => Math.round(micLevel.value * 24));
let settingsGeneration = 0;
let settingsRequest = 0;
let whisperPointer: { id: number; target: HTMLElement } | null = null;
let whisperKey: string | null = null;
function beginSettingsRequest(): () => boolean {
settingsError.value = "";
@@ -167,23 +169,49 @@ export function useWebClientAudioControls({
}
function onWhisperPttDown(event: PointerEvent): void {
if (!whisperTargetIds.size) return;
if (!whisperTargetIds.size || whisperPttActive.value || event.button !== 0 || !event.isPrimary) return;
const target = event.currentTarget as HTMLElement | null;
if (target?.setPointerCapture && !target.hasPointerCapture(event.pointerId)) target.setPointerCapture(event.pointerId);
if (!target) return;
target.focus();
try {
target.setPointerCapture(event.pointerId);
} catch {
return;
}
whisperPointer = { id: event.pointerId, target };
whisperPttActive.value = true;
setWhisperActive(true);
}
function onWhisperPttUp(event: PointerEvent): void {
const target = event.currentTarget as HTMLElement | null;
if (target?.releasePointerCapture && target.hasPointerCapture(event.pointerId)) target.releasePointerCapture(event.pointerId);
if (event.pointerId !== whisperPointer?.id) return;
stopWhisperTalk();
}
function onWhisperPttKeyDown(event: KeyboardEvent): void {
if (event.key !== " " && event.key !== "Enter") return;
event.preventDefault();
if (event.repeat || event.altKey || event.ctrlKey || event.metaKey || !whisperTargetIds.size || whisperPttActive.value) return;
whisperKey = event.key;
whisperPttActive.value = true;
setWhisperActive(true);
}
function onWhisperPttKeyUp(event: KeyboardEvent): void {
if (event.key !== whisperKey) return;
event.preventDefault();
stopWhisperTalk();
}
function stopWhisperTalk(): void {
const pointer = whisperPointer;
whisperPointer = null;
whisperKey = null;
if (!whisperPttActive.value) return;
whisperPttActive.value = false;
setWhisperActive(false);
// Clear ownership first: releasing capture can synchronously emit lostpointercapture.
if (pointer?.target.hasPointerCapture(pointer.id)) pointer.target.releasePointerCapture(pointer.id);
}
watch(settingsOpen, (open) => {
@@ -200,6 +228,7 @@ export function useWebClientAudioControls({
onScopeDispose(() => {
settingsGeneration++;
stopMicrophoneTest();
stopWhisperTalk();
});
return {
@@ -220,6 +249,8 @@ export function useWebClientAudioControls({
toggleAccompaniment,
onWhisperPttDown,
onWhisperPttUp,
onWhisperPttKeyDown,
onWhisperPttKeyUp,
stopWhisperTalk,
};
}
+43 -43
View File
@@ -376,16 +376,16 @@
.workspace-actions { align-items: center; flex-wrap: nowrap; }
.workspace-actions .header-action { flex: 0 0 34px; padding: 0; line-height: 0; }
.workspace-actions .header-action .ui-icon { margin: 0; }
.desktop-audio-dock { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; min-width: 0; margin-top: 12px; padding: 9px; color: var(--text-muted); background: color-mix(in srgb, var(--accent) 8%, var(--surface-1)); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 20px color-mix(in srgb, var(--text-primary) 10%, transparent); }
.desktop-audio-dock-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 3px; }
.desktop-audio-dock-copy strong { overflow: hidden; color: var(--text-primary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.desktop-audio-dock-copy span { overflow: hidden; font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.desktop-audio-dock-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.dock-audio-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--text-muted); background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: color .16s, background .16s, border-color .16s, transform .16s; }
.dock-audio-button:hover, .dock-audio-button:focus-visible { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-1)); border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); transform: translateY(-1px); }
.dock-audio-button.microphone-header-toggle.muted { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface-1)); }
.dock-audio-button.muted { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface-1)); }
.dock-audio-button.accompaniment-toggle.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface-1)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
:deep(.desktop-audio-dock) { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; min-width: 0; margin-top: 12px; padding: 9px; color: var(--text-muted); background: color-mix(in srgb, var(--accent) 8%, var(--surface-1)); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 20px color-mix(in srgb, var(--text-primary) 10%, transparent); }
:deep(.desktop-audio-dock-copy) { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 3px; }
:deep(.desktop-audio-dock-copy strong) { overflow: hidden; color: var(--text-primary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
:deep(.desktop-audio-dock-copy span) { overflow: hidden; font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
:deep(.desktop-audio-dock-actions) { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
:deep(.dock-audio-button) { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; color: var(--text-muted); background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: color .16s, background .16s, border-color .16s, transform .16s; }
:deep(.dock-audio-button:hover), :deep(.dock-audio-button:focus-visible) { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-1)); border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); transform: translateY(-1px); }
:deep(.dock-audio-button.microphone-header-toggle.muted) { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface-1)); }
:deep(.dock-audio-button.muted) { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface-1)); }
:deep(.dock-audio-button.accompaniment-toggle.active) { color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface-1)); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.settings-mode-switch { width: fit-content; margin: 0 0 7px; }
:deep(.settings-hint) { margin: -1px 0 19px; color: #8b9994; font-size: 11px; }
@@ -471,12 +471,12 @@
@media (max-width: 740px) { :deep(.member-submenu-panel) { position: static; min-width: 0; max-height: 190px; margin: 4px 0 0 24px; padding: 4px; border-radius: 10px; box-shadow: none; } :deep(.member-submenu-panel button) { min-height: 42px; font-size: 13px; } }
/* M007 whisper target controls and M008 mobile navigation. */
.whisper-strip { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 12px 14px; color: #52645e; border: 1px solid #d6ebe5; border-radius: 10px; background: #eef8f5; }
.whisper-strip-copy { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.whisper-strip-copy strong { display: inline-flex; align-items: center; gap: 6px; color: #006a64; font-size: 12px; white-space: nowrap; }
.whisper-strip-copy span { overflow: hidden; color: #71837d; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.whisper-ptt-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 12px; color: #fff; background: #006a64; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; touch-action: none; user-select: none; }
.whisper-ptt-button.active { background: #2f9d5c; box-shadow: 0 0 0 4px rgba(47,157,92,.16); }
:deep(.whisper-strip) { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 12px 14px; color: #52645e; border: 1px solid #d6ebe5; border-radius: 10px; background: #eef8f5; }
:deep(.whisper-strip-copy) { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
:deep(.whisper-strip-copy strong) { display: inline-flex; align-items: center; gap: 6px; color: #006a64; font-size: 12px; white-space: nowrap; }
:deep(.whisper-strip-copy span) { overflow: hidden; color: #71837d; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
:deep(.whisper-ptt-button) { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 12px; color: #fff; background: #006a64; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; touch-action: none; user-select: none; }
:deep(.whisper-ptt-button.active) { background: #2f9d5c; box-shadow: 0 0 0 4px rgba(47,157,92,.16); }
.mobile-nav, .mobile-more-panel { display: none; }
:deep(.mobile-section-hidden) { display: block; }
@@ -502,9 +502,9 @@
.mobile-nav button { display: grid; place-items: center; gap: 3px; min-width: 0; color: var(--text-muted); background: transparent; border-radius: 8px; font-size: 11px; cursor: pointer; }
.mobile-nav button.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 700; }
.mobile-nav button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whisper-strip { align-items: stretch; flex-wrap: wrap; gap: 8px; }
.whisper-strip-copy { width: 100%; flex: 1 0 100%; }
.whisper-ptt-button { flex: 1; min-height: 46px; }
:deep(.whisper-strip) { align-items: stretch; flex-wrap: wrap; gap: 8px; }
:deep(.whisper-strip-copy) { width: 100%; flex: 1 0 100%; }
:deep(.whisper-ptt-button) { flex: 1; min-height: 46px; }
:deep(.whisper-strip > .text-button) { min-height: 38px; }
}
@@ -628,7 +628,7 @@
:deep(.member-presence) { width: 10px; height: 10px; }
:deep(.member-copy strong) { font-size: 14px; }
:deep(.member-copy span) { margin-top: 3px; font-size: 12px; }
.desktop-audio-dock, :deep(.member-flags), :deep(.member-volume), .member-panel-tip { display: none; }
:deep(.desktop-audio-dock), :deep(.member-flags), :deep(.member-volume), .member-panel-tip { display: none; }
:deep(.member-action-button) { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; color: var(--text-muted); background: transparent; border-radius: 10px; cursor: pointer; }
:deep(.member-action-button:hover), :deep(.member-action-button:active) { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-1)); }
@@ -898,13 +898,13 @@
left/right:0 即与内容宽度完全一致);chat-panel 作为包含块
并加 padding-bottom 补偿原占位,避免消息列表被遮挡。 */
:deep(.app-shell .member-panel) { position: relative; overflow: visible; padding-bottom: calc(18px + 12px + 52px); }
.desktop-audio-dock { position: absolute; z-index: 6; left: 18px; right: 18px; bottom: 18px; margin-top: 0; }
:deep(.desktop-audio-dock) { position: absolute; z-index: 6; left: 18px; right: 18px; bottom: 18px; margin-top: 0; }
.app-shell .chat-panel { position: relative; padding-bottom: calc(16px + 48px); }
:deep(.app-shell .message-composer) { position: absolute; z-index: 3; left: 0; right: 0; bottom: 16px; margin-bottom: 0; }
}
.dock-hover-control { position: relative; flex: 0 0 34px; }
.dock-hover-panel {
:deep(.dock-hover-control) { position: relative; flex: 0 0 34px; }
:deep(.dock-hover-panel) {
position: absolute;
z-index: 20;
right: 50%;
@@ -922,27 +922,27 @@
transform: translate(50%, 6px);
transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}
.dock-hover-panel::after { content: ""; position: absolute; right: auto; bottom: -6px; left: 50%; width: 10px; height: 10px; background: var(--surface-1); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: translateX(-50%) rotate(45deg); }
.dock-hover-control:hover .dock-hover-panel,
.dock-hover-control:focus-within .dock-hover-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(50%, 0); }
.dock-microphone-panel { width: min(246px, calc(100vw - 32px)); }
.dock-slider-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dock-slider-heading span { min-width: 0; overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.dock-slider-heading strong { flex: 0 0 auto; color: var(--accent); font-size: 11px; }
.dock-slider { width: 100%; height: 5px; margin: 11px 0 1px; appearance: none; border-radius: 999px; outline: none; cursor: pointer; }
.dock-slider::-webkit-slider-thumb { width: 14px; height: 14px; appearance: none; border: 2px solid #81d8d0; border-radius: 50%; background: var(--surface-1); box-shadow: 0 2px 4px color-mix(in srgb, var(--text-primary) 14%, transparent); cursor: pointer; }
.dock-slider::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid #81d8d0; border-radius: 50%; background: var(--surface-1); box-shadow: 0 2px 4px color-mix(in srgb, var(--text-primary) 14%, transparent); cursor: pointer; }
.dock-panel-divider { height: 1px; margin: 12px 0; background: var(--border); }
.dock-switch-row, :deep(.mobile-noise-toggle) { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.dock-switch-row > span, :deep(.mobile-noise-toggle > span) { min-width: 0; }
.dock-switch-row strong, :deep(.mobile-noise-toggle strong) { display: block; color: var(--text-primary); font-size: 11px; }
:deep(.dock-hover-panel::after) { content: ""; position: absolute; right: auto; bottom: -6px; left: 50%; width: 10px; height: 10px; background: var(--surface-1); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: translateX(-50%) rotate(45deg); }
:deep(.dock-hover-control:hover .dock-hover-panel),
:deep(.dock-hover-control:focus-within .dock-hover-panel) { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(50%, 0); }
:deep(.dock-microphone-panel) { width: min(246px, calc(100vw - 32px)); }
:deep(.dock-slider-heading) { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
:deep(.dock-slider-heading span) { min-width: 0; overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
:deep(.dock-slider-heading strong) { flex: 0 0 auto; color: var(--accent); font-size: 11px; }
:deep(.dock-slider) { width: 100%; height: 5px; margin: 11px 0 1px; appearance: none; border-radius: 999px; outline: none; cursor: pointer; }
:deep(.dock-slider::-webkit-slider-thumb) { width: 14px; height: 14px; appearance: none; border: 2px solid #81d8d0; border-radius: 50%; background: var(--surface-1); box-shadow: 0 2px 4px color-mix(in srgb, var(--text-primary) 14%, transparent); cursor: pointer; }
:deep(.dock-slider::-moz-range-thumb) { width: 14px; height: 14px; border: 2px solid #81d8d0; border-radius: 50%; background: var(--surface-1); box-shadow: 0 2px 4px color-mix(in srgb, var(--text-primary) 14%, transparent); cursor: pointer; }
:deep(.dock-panel-divider) { height: 1px; margin: 12px 0; background: var(--border); }
:deep(.dock-switch-row), :deep(.mobile-noise-toggle) { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
:deep(.dock-switch-row > span), :deep(.mobile-noise-toggle > span) { min-width: 0; }
:deep(.dock-switch-row strong), :deep(.mobile-noise-toggle strong) { display: block; color: var(--text-primary); font-size: 11px; }
:deep(.mobile-noise-toggle) { margin-bottom: 18px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
:deep(.mobile-noise-toggle small) { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; line-height: 1.4; }
.dock-switch-row input, :deep(.mobile-noise-toggle input) { position: relative; width: 34px; height: 20px; flex: 0 0 34px; margin: 0; padding: 0; appearance: none; border: 2px solid var(--border); border-radius: 999px; outline: none; background: var(--surface-2); cursor: pointer; transition: background .16s ease, border-color .16s ease; }
.dock-switch-row input::before, :deep(.mobile-noise-toggle input::before) { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); transition: transform .16s ease, background .16s ease; }
.dock-switch-row input:checked, :deep(.mobile-noise-toggle input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 72%, var(--surface-2)); }
.dock-switch-row input:checked::before, :deep(.mobile-noise-toggle input:checked::before) { background: var(--surface-1); transform: translateX(14px); }
.dock-switch-row input:focus-visible, :deep(.mobile-noise-toggle input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
:deep(.dock-switch-row input), :deep(.mobile-noise-toggle input) { position: relative; width: 34px; height: 20px; flex: 0 0 34px; margin: 0; padding: 0; appearance: none; border: 2px solid var(--border); border-radius: 999px; outline: none; background: var(--surface-2); cursor: pointer; transition: background .16s ease, border-color .16s ease; }
:deep(.dock-switch-row input::before), :deep(.mobile-noise-toggle input::before) { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); transition: transform .16s ease, background .16s ease; }
:deep(.dock-switch-row input:checked), :deep(.mobile-noise-toggle input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 72%, var(--surface-2)); }
:deep(.dock-switch-row input:checked::before), :deep(.mobile-noise-toggle input:checked::before) { background: var(--surface-1); transform: translateX(14px); }
:deep(.dock-switch-row input:focus-visible), :deep(.mobile-noise-toggle input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
:deep(.member-row[draggable="true"]) { cursor: grab; touch-action: none; }
:deep(.member-row[draggable="true"]:active) { cursor: grabbing; }
@@ -951,7 +951,7 @@
:deep(.member-channel-group.drag-over .member-channel-heading) { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, var(--surface-1)); }
@media (prefers-reduced-motion: reduce) {
.dock-hover-panel, .dock-switch-row input, :deep(.mobile-noise-toggle input) { transition-duration: .01ms; }
:deep(.dock-hover-panel), :deep(.dock-switch-row input), :deep(.mobile-noise-toggle input) { transition-duration: .01ms; }
}
.screen-share-inline-error { display: flex; align-items: center; gap: 7px; margin: 10px 0 0; padding: 8px 10px; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: 9px; background: color-mix(in srgb, var(--danger) 12%, var(--surface-1)); font-size: 10px; line-height: 1.4; }
+8 -30
View File
@@ -186,11 +186,8 @@
</article>
</div>
<div v-else class="voice-empty" data-ws-part="voice.members.empty"><span class="empty-icon"><Icon name="users" :size="20" /></span><strong>{{ t('waitingForMembers') }}</strong><span>{{ t('prepareMicrophone') }}</span></div>
<div v-if="whisperTargetIds.size" class="whisper-strip" data-ws-part="voice.whisper-strip">
<div class="whisper-strip-copy"><strong><Icon name="users" :size="15" /> {{ t('whisperTargets') }}</strong><span>{{ whisperTargets.map((member) => member.nickname).join('、') }}</span></div>
<button type="button" class="text-button" @click="clearWhisperTargets">{{ t('clearWhisperTargets') }}</button>
<button type="button" class="whisper-ptt-button" :class="{ active: whisperPttActive || whisperActive }" :aria-pressed="whisperPttActive || whisperActive" @pointerdown.prevent="onWhisperPttDown" @pointerup.prevent="onWhisperPttUp" @pointercancel.prevent="onWhisperPttUp" @lostpointercapture="onWhisperPttUp"><Icon name="mic" :size="18" /> {{ whisperPttActive || whisperActive ? t('releaseWhisper') : t('whisperHoldToTalk') }}</button>
</div>
<WhisperControls v-if="whisperTargetIds.size" :targets="whisperTargets" :active="whisperActive"
:enabled="!isMobileViewport || mobileSection === 'voice'" :controls="audioControls" :t="t" @clear="clearWhisperTargets" />
<div class="mobile-voice-controls">
<button type="button" class="mobile-voice-toggle" :class="{ muted: microphoneMuted }" :aria-pressed="!microphoneMuted" @click="toggleMicrophone"><Icon :name="microphoneMuted ? 'mic-off' : 'mic'" :size="18" /><span>{{ microphoneMuted ? t('unmuteMic') : t('muteMic') }}</span></button>
<button type="button" class="mobile-voice-settings" @click="settingsOpen = true"><Icon name="settings" :size="17" /><span>{{ t('audioSettings') }}</span></button>
@@ -211,29 +208,8 @@
:mobile-visible="mobileSection === 'channels'" :is-mobile-viewport="isMobileViewport"
:volumes="volumes" :avatar-style="avatarStyle" :avatar-initial="avatarInitial"
:range-style="rangeStyle" :t="t" @select-channel="selectChannel" @volume-input="onVolInput">
<div v-if="!isMobileViewport" class="desktop-audio-dock" data-ws-part="voice.audio-dock" role="toolbar" :aria-label="t('desktopAudioControls')">
<div class="desktop-audio-dock-copy"><strong>{{ t('desktopAudioControls') }}</strong><span>{{ accompanimentActive ? t('accompanimentActive') : t('desktopAudioHint') }}</span></div>
<div class="desktop-audio-dock-actions">
<div class="dock-hover-control" data-ws-part="voice.audio-dock.microphone">
<button type="button" class="dock-audio-button microphone-header-toggle" :class="{ muted: microphoneMuted }" :title="microphoneMuted ? t('unmuteMic') : t('muteMic')" :aria-label="microphoneMuted ? t('microphoneMuted') : t('microphoneActive')" :aria-pressed="!microphoneMuted" aria-haspopup="dialog" @click="toggleMicrophone"><Icon :name="microphoneMuted ? 'mic-off' : 'mic'" :size="18" /></button>
<div class="dock-hover-panel dock-microphone-panel" data-ws-part="voice.audio-dock.microphone-panel" role="dialog" :aria-label="t('microphone')">
<div class="dock-slider-heading"><span>{{ t('inputVolume') }}</span><strong>{{ Math.round(inputVolume * 100) }}%</strong></div>
<input class="dock-slider" type="range" min="0" max="100" :value="inputVolume * 100" :style="rangeStyle(inputVolume, 1)" :aria-label="t('inputVolume')" @input="onInputVolume" />
<div class="dock-panel-divider"></div>
<label class="dock-switch-row"><span><strong>{{ t('noiseSuppression') }}</strong></span><input type="checkbox" :checked="noiseSuppressionEnabled" :aria-label="t('noiseSuppression')" @change="onNoiseSuppressionToggle" /></label>
</div>
</div>
<div class="dock-hover-control" data-ws-part="voice.audio-dock.output">
<button type="button" class="dock-audio-button" :class="{ muted: outputMuted }" :title="outputMuted ? t('unmuteOutput') : t('muteOutput')" :aria-label="outputMuted ? t('unmuteOutput') : t('muteOutput')" :aria-pressed="!outputMuted" aria-haspopup="dialog" @click="toggleOutputMute"><Icon :name="outputMuted ? 'volume-off' : 'volume'" :size="18" /></button>
<div class="dock-hover-panel dock-output-panel" data-ws-part="voice.audio-dock.output-panel" role="dialog" :aria-label="t('overallVolume')">
<div class="dock-slider-heading"><span>{{ t('overallVolume') }}</span><strong>{{ Math.round(outputVolume * 100) }}%</strong></div>
<input class="dock-slider" type="range" min="0" max="100" :value="outputVolume * 100" :style="rangeStyle(outputVolume, 1)" :aria-label="t('overallVolume')" @input="onOutputVolume" />
</div>
</div>
<button type="button" class="dock-audio-button" :title="t('audioSettings')" :aria-label="t('audioSettings')" @click="settingsOpen = true"><Icon name="settings" :size="18" /></button>
<button type="button" class="dock-audio-button accompaniment-toggle" :class="{ active: accompanimentActive }" :title="accompanimentActive ? t('stopAccompaniment') : t('startAccompaniment')" :aria-label="accompanimentActive ? t('stopAccompaniment') : t('startAccompaniment')" :aria-pressed="accompanimentActive" @click="toggleAccompaniment"><Icon name="music" :size="18" /></button>
</div>
</div>
<AudioDock v-if="!isMobileViewport" :model="audioDockState" :controls="audioControls"
:t="t" :range-style="rangeStyle" @settings="settingsOpen = true" @output-mute="toggleOutputMute" />
</ChannelMemberPanel>
<section v-if="mobileSection === 'more'" class="mobile-more-panel" data-ws-part="voice.mobile-more">
@@ -280,6 +256,8 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
import Icon from "../components/Icon.vue";
import AudioDock from "../components/web-client/AudioDock.vue";
import WhisperControls from "../components/web-client/WhisperControls.vue";
import AudioSettingsDialog from "../components/web-client/AudioSettingsDialog.vue";
import ChannelPasswordDialog from "../components/web-client/ChannelPasswordDialog.vue";
import ServerPasswordDialog from "../components/web-client/ServerPasswordDialog.vue";
@@ -549,8 +527,8 @@ const audioControls = useWebClientAudioControls({
showToast,
t,
});
const { whisperPttActive, onInputVolume, onNoiseSuppressionToggle, onOutputVolume,
toggleMicrophone, toggleAccompaniment, onWhisperPttDown, onWhisperPttUp, stopWhisperTalk } = audioControls;
const { toggleMicrophone, stopWhisperTalk } = audioControls;
const audioDockState = { microphoneMuted, inputVolume, outputVolume, outputMuted, noiseSuppressionEnabled, accompanimentActive };
const audioSettingsState = {
inputDevices,
outputDevices,
+57
View File
@@ -80,3 +80,60 @@ test("unmount stops recording and retires device preparation", async t => {
preparation.reject(new DOMException("old", "NotAllowedError")); await Promise.resolve();
assert.equal(controls.settingsError.value, "");
});
function whisperFixture(t) {
const sent = [], captures = new Set();
const target = { focus() {}, setPointerCapture: id => captures.add(id), hasPointerCapture: id => captures.has(id), releasePointerCapture: id => captures.delete(id) };
const fixture = mount(t, { whisperTargetIds: new Set([7]), setWhisperActive: active => sent.push(active) });
return { ...fixture, sent, captures, pointer: (id = 1, button = 0, isPrimary = true) => ({ pointerId: id, button, isPrimary, currentTarget: target }) };
}
const keyEvent = (key, extra = {}) => ({ key, preventDefault() {}, ...extra });
test("secondary buttons and non-primary pointers cannot start whispering", t => {
const { controls, pointer, sent } = whisperFixture(t);
controls.onWhisperPttDown(pointer(1, 2));
controls.onWhisperPttDown(pointer(2, 0, false));
assert.deepEqual(sent, []);
});
test("only the pointer that started whispering may release it", t => {
const { controls, pointer, sent, captures } = whisperFixture(t);
controls.onWhisperPttDown(pointer());
controls.onWhisperPttUp(pointer(2));
assert.equal(controls.whisperPttActive.value, true);
controls.onWhisperPttDown(pointer(2));
controls.onWhisperPttUp(pointer());
controls.onWhisperPttUp(pointer());
assert.deepEqual(sent, [true, false]);
assert.equal(captures.size, 0);
});
test("capture failure does not leave whisper enabled", t => {
const { controls, pointer, sent } = whisperFixture(t);
const event = pointer();
event.currentTarget.setPointerCapture = () => { throw new Error("pointer no longer active"); };
assert.doesNotThrow(() => controls.onWhisperPttDown(event));
assert.deepEqual(sent, []);
});
test("keyboard whisper ignores repeat and unrelated releases", t => {
const { controls, sent, pointer } = whisperFixture(t);
controls.onWhisperPttKeyDown(keyEvent(" "));
controls.onWhisperPttKeyDown(keyEvent(" ", { repeat: true }));
controls.onWhisperPttKeyUp(keyEvent("Enter"));
controls.onWhisperPttUp(pointer());
assert.equal(controls.whisperPttActive.value, true);
controls.onWhisperPttKeyUp(keyEvent(" "));
controls.onWhisperPttKeyDown(keyEvent("Enter"));
controls.stopWhisperTalk();
controls.onWhisperPttKeyUp(keyEvent("Enter"));
assert.deepEqual(sent, [true, false, true, false]);
});
test("scope disposal releases an active whisper and its capture", t => {
const { controls, sent, captures, pointer, scope } = whisperFixture(t);
controls.onWhisperPttDown(pointer());
scope.stop();
assert.deepEqual(sent, [true, false]);
assert.equal(captures.size, 0);
});