Ariver
2026-07-11 015f1089ea875a153dd2a18ef42c25145d4868f5
C1.source/privatevoice.src/frontend/src/components/settings/HotkeysPage.svelte
@@ -5,7 +5,7 @@
  import { hotkeyVK } from '../../lib/stores/config'
  import { hotkeyName } from '../../lib/stores/indicator'
  let currentKeyName = $state('Ctrl')
  let currentKeyName = $state('')
  let isRecording = $state(false)
  let hintText = $state('')
  let activeKeyHandler: ((e: KeyboardEvent) => void) | null = null
@@ -31,6 +31,12 @@
      e.preventDefault()
      e.stopPropagation()
      if (isHotkeyCaptureCancel(e)) {
        hintText = t('status.cancelled')
        clearHotkeyCapture()
        return
      }
      const vk = mapKeyToVK(e)
      if (vk > 0) {
        isRecording = false
@@ -42,7 +48,7 @@
          try {
            await Call.ByName('voicesnap/services.HotkeyService.SetHotkey', vk)
            const name: any = await Call.ByName('voicesnap/services.HotkeyService.GetKeyName', vk)
            if (name) {
            if (typeof name === 'string') {
              hotkeyName.set(name)
              currentKeyName = name
            }
@@ -58,6 +64,10 @@
    activeKeyHandler = onKey
    document.addEventListener('keydown', onKey)
  }
  function isHotkeyCaptureCancel(e: KeyboardEvent): boolean {
    return e.key === 'Escape' || e.key === 'Esc'
  }
  function clearHotkeyCapture() {
@@ -105,14 +115,18 @@
    <div class="hotkey-display">
      <div class="hotkey-info">
        <span class="hotkey-label">{t('hotkeys.current')}</span>
        <div class="hotkey-key" class:recording={isRecording}>
          {isRecording ? '...' : currentKeyName}
        <div class="hotkey-key" class:recording={isRecording} class:unset={!isRecording && !currentKeyName}>
          {isRecording ? '...' : (currentKeyName || t('hotkeys.unset'))}
        </div>
      </div>
      <button class="change-btn" onclick={startRecordingHotkey} disabled={isRecording}>
        {t('hotkeys.change')}
        {currentKeyName ? t('hotkeys.change') : t('hotkeys.set')}
      </button>
    </div>
    {#if !currentKeyName && !isRecording}
      <p class="hint">{t('hotkeys.unsetDesc')}</p>
    {/if}
    {#if hintText}
      <p class="hint" class:recording={isRecording}>{hintText}</p>
@@ -193,6 +207,12 @@
    animation: pulse 1s infinite;
  }
  .hotkey-key.unset {
    color: var(--color-secondary-label);
    font-size: var(--font-size-base);
    font-weight: 500;
  }
  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }