Skip to content

feat(workflow): add keyboard shortcuts, shortcut editor, and cross-platform support#6400

Open
DurantChan1 wants to merge 1 commit into
1Panel-dev:v2from
DurantChan1:durantchan1/keys_shortcut
Open

feat(workflow): add keyboard shortcuts, shortcut editor, and cross-platform support#6400
DurantChan1 wants to merge 1 commit into
1Panel-dev:v2from
DurantChan1:durantchan1/keys_shortcut

Conversation

@DurantChan1

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

该分支为 MaxKB 工作流编辑器增加了完整的键盘快捷键系统,覆盖应用工作流、知识库工作流和工具工作流三种类型。引入了可配置的快捷键映射系统、可视化快捷键编辑对话框、跨平台支持(macOS 修饰键 vs Windows/Linux),以及工具栏按钮上的快捷键提示 tooltip。同时支持框中选取 / 点选模式通过 S/H 键快速切换,并完成了中英文繁简体 i18n 国际化。

Summary of your change

新增文件:

  • shortcut-config.ts — 集中式快捷键配置模块,定义了 17 个动作(保存、调试、发布、搜索节点、撤销、重做、复制、粘贴、删除、框选模式、点选模式、放大、缩小、适应画布、收起全部、展开全部、一键美化)及其默认键位(Mousetrap 格式)。支持用户通过 localStorage 自定义覆盖,提供 CRUD 函数(getShortcutKeys、setShortcutKeys、resetShortcutKeys、resetAllShortcutKeys、getAllShortcuts)和跨平台显示格式化工具 formatKeysForDisplay(Mac 显示 ⌘⇧⌃⌥ 符号,Windows 显示 Ctrl/Shift/Alt 文本)。
  • ShortcutEditor.vue — 快捷键编辑对话框(el-dialog),以表格列出所有快捷键。用户可点击"编辑"进入按键录制模式(监听 keydown 事件捕获修饰键+组合键),确认/取消修改,单独或全部重置快捷键。修改保存到 localStorage,刷新页面后生效。

修改文件:

  • shortcut.ts — 扩展 initDefaultShortcut 函数,新增 ShortcutOptions 参数(onSave、onDebug、onPublish 回调及 isDragMode ref)。新增 10 个快捷键处理器:保存(Cmd/Ctrl+S)、调试(Cmd/Ctrl+Shift+D)、发布(Cmd/Ctrl+Shift+P)、放大/缩小(Cmd/Ctrl+=/-)、适应画布(Cmd/Ctrl+0)、框选/点选模式(S/H)、收起/展开全部节点(Cmd/Ctrl+[ / ])、一键美化(Cmd/Ctrl+Shift+L)。恢复了 backspace/del/delete 节点删除处理器,清理了已注释的死代码。
  • index.vue(workflow) — 通过 provide('isDragMode', ref(false)) 在 NodeControl 和快捷键处理器之间共享光标模式状态。向上层视图注册 @save@debug@publish 事件。
  • NodeControl.vue — 在所有工具栏按钮上增加 el-tooltip 提示框,显示对应的快捷键(如"框选模式 (S)"、"缩小 (⌘+-)")。将 isDrag 重构为 isDragMode 以使用共享 ref。
  • NodeSearch.vue — 搜索按钮增加 tooltip 提示 Ctrl+F / Cmd+F 快捷键。
    应用/知识库/工具工作流视图 — 在调试/保存/发布按钮上增加 el-tooltip 提示快捷键。将 组件的 save、debug、publish 事件连接到父组件方法。在下拉菜单中新增"快捷键设置"入口,通过 shortcutEditorVisible v-model 打开 ShortcutEditor。
    国际化(en-US、zh-CN、zh-Hant workflow.ts) — 新增 control.dragMode、control.clickMode 和完整的 shortcut.* 键位定义(11 个字段),包括标题、动作、快捷键、操作、按下提示、重置、恢复默认、刷新提示。

Please indicate you've done the following:

  • [x ] Made sure tests are passing and test coverage is added if needed.
  • [x ] Made sure commit message follow the rule of Conventional Commits specification.
  • [ x] Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

…atform support

- Fix undo/redo: remove duplicate handlers (LogicFlow core already handles them)
- Add Ctrl+S/Cmd+S save, Ctrl+Shift+D debug, Ctrl+Shift+P publish shortcuts
- Add S key for box-select mode, H key for hand/point mode
- Add Ctrl+=/- zoom in/out, Ctrl+0 fit view, Ctrl+[/] collapse/expand all
- Add Ctrl+Shift+L auto-layout beautify, Ctrl+F node search
- Create shortcut-config.ts for customizable keybindings (localStorage)
- Create ShortcutEditor.vue dialog for viewing/editing all shortcuts
- Add tooltip hints for all toolbar buttons and header buttons
- Cross-platform Mac support: auto-detect and show Cmd/Ctrl appropriately
- Share cursor mode state via provide/inject for toolbar button sync
- Update i18n for zh-CN, zh-Hant, en-US with shortcut-related keys

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants