文件树、打包、过滤
function showFileTimeFilterPopover() {
快捷键、热键
const hotkeys = await createWindowHotkeyController({ application: app,
getMainWindow: () => preferredMainWindow || mainWindow,
toggleSnippetWindow: () => snippetController?.toggle(),
toggleQuickCmdForm: () => void quickCmdFormController?.show().catch((error) => console.warn('Quick Cmd Form 打开失败', error)),
adjustMouse, globalShortcut });
if (!globalShortcut.register(key, () => commands.execute(command))) {
// Preserve the editing focus before the click opens the lazily loaded palette.
// Keyboard activation still uses the button's normal focus behavior.
//.,, 保持焦点,便于恢复
document.querySelector('#command-palette-button').addEventListener('mousedown', (event) => {
if (event.button === 0) event.preventDefault();
});
export class CommandRegistry {
constructor() { this.commands = new Map(); }
register(command) {
if (!command.id || this.commands.has(command.id)) throw new Error(`重复的命令 ID:${command.id}`);
this.commands.set(command.id, { source: 'system', ...command });
}
execute(id) { return this.commands.get(id)?.execute(); }
}