From fecea2c7a4ecc48b2354868894e78be361a2ccf1 Mon Sep 17 00:00:00 2001
From: Cw <cw@git.boborobots.com>
Date: Sat, 04 Jul 2026 16:53:53 +0800
Subject: [PATCH] Fix Windows ASR model paths for non-ASCII users

---
 C1.source/privatevoice.src/frontend/src/components/settings/GeneralPage.svelte |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/C1.source/privatevoice.src/frontend/src/components/settings/GeneralPage.svelte b/C1.source/privatevoice.src/frontend/src/components/settings/GeneralPage.svelte
index d54ca49..7b48d66 100755
--- a/C1.source/privatevoice.src/frontend/src/components/settings/GeneralPage.svelte
+++ b/C1.source/privatevoice.src/frontend/src/components/settings/GeneralPage.svelte
@@ -1,4 +1,5 @@
 <script lang="ts">
+  import { onDestroy } from 'svelte'
   import { Call } from '@wailsio/runtime'
   import ToggleSwitch from '../shared/ToggleSwitch.svelte'
   import { t } from '../../lib/i18n'
@@ -26,6 +27,7 @@
   let hintText = $state('')
   let devices = $state<InputDevice[]>([])
   let showDeviceDropdown = $state(false)
+  let activeKeyHandler: ((e: KeyboardEvent) => void) | null = null
 
   const unsub1 = autoHide.subscribe(v => { autoHideVal = v })
   const unsub2 = startAtLogin.subscribe(v => { startAtLoginVal = v })
@@ -36,6 +38,11 @@
   const unsub7 = soundFeedback.subscribe(v => { soundFeedbackVal = v })
   const unsub8 = copyToClipboard.subscribe(v => { copyToClipboardVal = v })
   const unsub9 = hotkeyMode.subscribe(v => { hotkeyModeVal = v })
+
+  onDestroy(() => {
+    unsub1(); unsub2(); unsub3(); unsub4(); unsub5(); unsub6(); unsub7(); unsub8(); unsub9()
+    clearHotkeyCapture()
+  })
 
   // Load actual device name from backend on mount
   async function loadDeviceName() {
@@ -160,6 +167,7 @@
   }
 
   async function startRecordingHotkey() {
+    clearHotkeyCapture()
     isRecording = true
     hintText = t('hotkeys.pressAnyKey')
 
@@ -191,13 +199,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 {
     switch (e.key) {
       case 'Control': return e.location === 1 ? 0xA2 : e.location === 2 ? 0xA3 : 0x11

--
Gitblit v1.9.3