feat:支持禁用 ESC。插件内弹窗很多都是 ESC 来关闭的,退出插件可以用 Cmd + W/Q #332#556
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a configurable 'esc' built-in shortcut key, updating the settings UI, main process API, renderer keydown handler, and window store to support enabling or disabling it. A critical issue was identified in the renderer's keydown handler where an asynchronous await database call is executed before event.preventDefault(), which prevents the default behavior from being successfully blocked. It is recommended to use the synchronous windowStore.builtInEscShortcutEnabled state instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const settings = (await window.ztools.dbGet('settings-general')) || {} | ||
| const isEnabled = settings?.builtinAppShortcutsEnabled?.esc !== false | ||
| if (!isEnabled) { | ||
| return | ||
| } |
There was a problem hiding this comment.
在 JavaScript/TypeScript 的事件处理函数中,event.preventDefault() 必须在事件的同步执行流中调用。如果在调用 event.preventDefault() 之前使用了 await(即进行了异步等待),那么在 Promise 解析并执行后续代码时,浏览器/Electron 的默认事件行为已经发生,此时再调用 event.preventDefault() 将完全失效。
为了解决这个问题,建议直接使用已经加载到 windowStore 中的 builtInEscShortcutEnabled 进行同步判断,这样可以确保 event.preventDefault() 能够正常工作并阻止默认行为。
if (!windowStore.builtInEscShortcutEnabled) {
return
}
38c833e to
2593e66
Compare
No description provided.