From 2593e66e194c4e3eb268fa2ba613be09ebe0a7c7 Mon Sep 17 00:00:00 2001 From: cjhgit <1418503647@qq.com> Date: Sat, 20 Jun 2026 18:17:58 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E7=A6=81?= =?UTF-8?q?=E7=94=A8=20ESC=E3=80=82=E6=8F=92=E4=BB=B6=E5=86=85=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E5=BE=88=E5=A4=9A=E9=83=BD=E6=98=AF=20ESC=20=E6=9D=A5?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=9A=84=EF=BC=8C=E9=80=80=E5=87=BA=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=8F=AF=E4=BB=A5=E7=94=A8=20Cmd=20+=20W/Q=20#332?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/ShortcutsSetting/ShortcutsSetting.vue | 13 +++++++++++-- src/main/api/plugin/ui.ts | 6 ++++++ src/renderer/src/App.vue | 4 ++++ src/renderer/src/stores/windowStore.ts | 11 +++++++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/internal-plugins/setting/src/views/ShortcutsSetting/ShortcutsSetting.vue b/internal-plugins/setting/src/views/ShortcutsSetting/ShortcutsSetting.vue index 7470325e..f5726d8a 100644 --- a/internal-plugins/setting/src/views/ShortcutsSetting/ShortcutsSetting.vue +++ b/internal-plugins/setting/src/views/ShortcutsSetting/ShortcutsSetting.vue @@ -32,7 +32,7 @@ interface GlobalShortcut { autoCopy?: boolean } -type BuiltInShortcutKey = 'search' | 'closePlugin' | 'killPlugin' +type BuiltInShortcutKey = 'search' | 'closePlugin' | 'killPlugin' | 'esc' type BuiltInShortcutConfig = Record @@ -49,7 +49,8 @@ interface AliasRow { const DEFAULT_BUILTIN_SHORTCUTS_ENABLED: BuiltInShortcutConfig = { search: true, closePlugin: true, - killPlugin: true + killPlugin: true, + esc: true } // 获取平台信息 @@ -100,6 +101,14 @@ const baseBuiltInShortcuts: GlobalShortcut[] = [ configurable: true, configKey: 'closePlugin' }, + { + id: 'builtin-esc', + shortcut: 'ESC', + target: '清空输入/退出插件/隐藏窗口', + enabled: true, + configurable: true, + configKey: 'esc' + }, { id: 'builtin-devtools', shortcut: 'DEVTOOLS', diff --git a/src/main/api/plugin/ui.ts b/src/main/api/plugin/ui.ts index c0f3133f..aa316543 100644 --- a/src/main/api/plugin/ui.ts +++ b/src/main/api/plugin/ui.ts @@ -63,6 +63,12 @@ export class PluginUIAPI { // 插件 ESC 按键事件(由插件 preload 通过 JS 拦截后上报) ipcMain.on('plugin-esc-pressed', () => { + const settings = databaseAPI.dbGet('settings-general') || {} + const escShortcutEnabled = settings?.builtinAppShortcutsEnabled?.esc !== false + if (!escShortcutEnabled) { + return + } + if (this.pluginManager && typeof this.pluginManager.handlePluginEsc === 'function') { this.pluginManager.handlePluginEsc() } diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 28872b89..e7f281b6 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -473,6 +473,10 @@ async function handleKeydown(event: KeyboardEvent): Promise { // Escape 键特殊处理 if (event.key === 'Escape') { + if (!windowStore.builtInEscShortcutEnabled) { + return + } + event.preventDefault() if (currentView.value === ViewMode.Plugin) { diff --git a/src/renderer/src/stores/windowStore.ts b/src/renderer/src/stores/windowStore.ts index 3fddfea3..abc74912 100644 --- a/src/renderer/src/stores/windowStore.ts +++ b/src/renderer/src/stores/windowStore.ts @@ -39,7 +39,7 @@ export type AutoClearOption = 'immediately' | '1m' | '2m' | '3m' | '5m' | '10m' // 搜索框模式选项 export type SearchMode = 'aggregate' | 'list' export type TabKeyFunction = 'navigate' | 'target-command' -export type BuiltInShortcutKey = 'search' | 'closePlugin' | 'killPlugin' +export type BuiltInShortcutKey = 'search' | 'closePlugin' | 'killPlugin' | 'esc' // 更新下载状态 interface UpdateDownloadInfo { @@ -70,6 +70,7 @@ export const useWindowStore = defineStore('window', () => { const builtInSearchShortcutEnabled = ref(true) const builtInClosePluginShortcutEnabled = ref(true) const builtInKillPluginShortcutEnabled = ref(true) + const builtInEscShortcutEnabled = ref(true) // 悬浮球双击目标指令 const floatingBallDoubleClickCommand = ref('') @@ -232,7 +233,11 @@ export const useWindowStore = defineStore('window', () => { builtInClosePluginShortcutEnabled.value = value return } - builtInKillPluginShortcutEnabled.value = value + if (key === 'killPlugin') { + builtInKillPluginShortcutEnabled.value = value + return + } + builtInEscShortcutEnabled.value = value } function updateFloatingBallDoubleClickCommand(value: string): void { @@ -569,6 +574,7 @@ export const useWindowStore = defineStore('window', () => { builtInSearchShortcutEnabled.value = config.search !== false builtInClosePluginShortcutEnabled.value = config.closePlugin !== false builtInKillPluginShortcutEnabled.value = config.killPlugin !== false + builtInEscShortcutEnabled.value = config.esc !== false } } else { // 默认蓝色 @@ -632,6 +638,7 @@ export const useWindowStore = defineStore('window', () => { builtInSearchShortcutEnabled, builtInClosePluginShortcutEnabled, builtInKillPluginShortcutEnabled, + builtInEscShortcutEnabled, updateBuiltInShortcutEnabled, floatingBallDoubleClickCommand, updateFloatingBallDoubleClickCommand,