From aaea414d5a1bed6fdf1d2c7c23ae316e2ffbdc25 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Mon, 2 Mar 2026 05:43:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Chrome=20=E4=B8=8A?= =?UTF-8?q?=E5=BD=95=E9=9F=B3=E6=8C=89=E9=92=AE=E8=A2=AB=20pointerleave=20?= =?UTF-8?q?=E8=BF=87=E6=97=A9=E4=B8=AD=E6=96=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 pointerdown 时调用 setPointerCapture 锁定指针事件 - 在 pointerup 时释放 pointer capture - 防止 async startRecording 期间 pointerleave 意外触发 stopRecording - mic-wrapper 添加 touch-action: none 防止浏览器拦截触摸 --- web/app.ts | 3 +++ web/style.css | 1 + 2 files changed, 4 insertions(+) diff --git a/web/app.ts b/web/app.ts index a05ccc2..12c2372 100644 --- a/web/app.ts +++ b/web/app.ts @@ -359,10 +359,13 @@ function bindMicButton(): void { micBtn.addEventListener("pointerdown", (e: PointerEvent) => { if (e.button !== 0) return; e.preventDefault(); + // Capture pointer so pointerleave won't fire while held + micBtn.setPointerCapture(e.pointerId); startRecording(); }); micBtn.addEventListener("pointerup", (e: PointerEvent) => { e.preventDefault(); + micBtn.releasePointerCapture(e.pointerId); stopRecording(); }); micBtn.addEventListener("pointerleave", () => { diff --git a/web/style.css b/web/style.css index 2cd0aa9..b786332 100644 --- a/web/style.css +++ b/web/style.css @@ -198,6 +198,7 @@ header h1 { display: flex; align-items: center; justify-content: center; + touch-action: none; } #mic-btn {