From ac1d4fd8ef875312d11acd4e4e5935ced542c227 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Mon, 06 Jul 2026 15:50:16 +0800
Subject: [PATCH] docs: record R222 merge closure
---
C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte b/C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte
index acb3aaa..4efaa6a 100755
--- a/C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte
+++ b/C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte
@@ -1,4 +1,5 @@
<script lang="ts">
+ import { onDestroy } from 'svelte'
import { Call } from '@wailsio/runtime'
import { t } from '../../lib/i18n'
import { hotkeyVK } from '../../lib/stores/config'
@@ -7,10 +8,17 @@
let currentKeyName = $state('Ctrl')
let isRecording = $state(false)
let hintText = $state('')
+ let activeKeyHandler: ((e: KeyboardEvent) => void) | null = null
const unsub = hotkeyName.subscribe(k => { currentKeyName = k })
+ onDestroy(() => {
+ unsub()
+ clearHotkeyCapture()
+ })
+
async function startRecordingHotkey() {
+ clearHotkeyCapture()
isRecording = true
hintText = t('hotkeys.pressAnyKey')
@@ -44,13 +52,25 @@
} catch {}
})()
- document.removeEventListener('keydown', onKey)
+ clearHotkeyCapture()
}
}
+ activeKeyHandler = onKey
document.addEventListener('keydown', onKey)
}
+ function clearHotkeyCapture() {
+ if (activeKeyHandler) {
+ document.removeEventListener('keydown', activeKeyHandler)
+ activeKeyHandler = null
+ }
+ if (isRecording) {
+ isRecording = false
+ void Call.ByName('voicesnap/services.HotkeyService.StopRecordingHotkey').catch(() => {})
+ }
+ }
+
function mapKeyToVK(e: KeyboardEvent): number {
// Map browser key codes to Windows VK codes
switch (e.key) {
--
Gitblit v1.9.3