Skip to content

feat: 指令别名功能#373

Merged
lzx8589561 merged 1 commit intoZToolsCenter:mainfrom
Particaly:feat/feature-code-alias-support
Apr 1, 2026
Merged

feat: 指令别名功能#373
lzx8589561 merged 1 commit intoZToolsCenter:mainfrom
Particaly:feat/feature-code-alias-support

Conversation

@Particaly
Copy link
Copy Markdown
Collaborator

resolve: #306

  • 新增 CommandAliasStore 类型与归一化逻辑 (src/shared/commandShared.ts)

    • 支持别名 + 自定义图标的配置结构
    • 兼容旧版 string[] 格式,自动去重去空
  • 主进程 API 扩展

    • internal:get-commands: 返回规范指令列表供设置页构建别名目标选择器
    • internal:update-command-aliases: 保存别名配置并触发指令缓存失效与主窗口刷新
    • CommandsAPI.invalidateCommandsCache(): 统一缓存失效处理
  • 渲染进程搜索集成

    • commandUtils.getCommandId() 迁移至 @shared/commandShared,保持 commandId 主键一致
    • commandDataStore 搜索阶段注入 alias 匹配字段
  • 设置页 UI

    • ShortcutsSetting 新增别名映射对话框组件
    • AllCommandsSetting 新增 alias 图标标识与别名列表展示
    • 新增 alias.svg 图标资源
  • 类型与构建配置

    • electron.vite.config.ts 添加 @shared 路径别名
    • tsconfig.*.json 同步配置

- 新增 CommandAliasStore 类型与归一化逻辑 (src/shared/commandShared.ts)
  - 支持别名 + 自定义图标的配置结构
  - 兼容旧版 string[] 格式,自动去重去空

- 主进程 API 扩展
  - internal:get-commands: 返回规范指令列表供设置页构建别名目标选择器
  - internal:update-command-aliases: 保存别名配置并触发指令缓存失效与主窗口刷新
  - CommandsAPI.invalidateCommandsCache(): 统一缓存失效处理

- 渲染进程搜索集成
  - commandUtils.getCommandId() 迁移至 @shared/commandShared,保持 commandId 主键一致
  - commandDataStore 搜索阶段注入 alias 匹配字段

- 设置页 UI
  - ShortcutsSetting 新增别名映射对话框组件
  - AllCommandsSetting 新增 alias 图标标识与别名列表展示
  - 新增 alias.svg 图标资源

- 类型与构建配置
  - electron.vite.config.ts 添加 @shared 路径别名
  - tsconfig.*.json 同步配置
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a command alias feature, allowing users to define custom names and icons for plugin commands. The implementation includes a management UI in the settings, IPC handlers for persistence, and search engine updates to support alias-based discovery. Feedback focused on enhancing the robustness of IPC input handling and optimizing the performance of icon resolution during search operations.

})

// alias 保存链路:归一化 -> 持久化 -> 失效 commands cache -> 通知主窗口刷新搜索索引。
const normalizedAliases = normalizeCommandAliases(aliases)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The normalizeCommandAliases function is called on the input aliases object. Since aliases is received directly from the IPC call, it is safer to perform deep cloning or validation before passing it to a normalization function that might expect a specific structure, especially since normalizeCommandAliases performs property access on aliases entries.

_score: r.score || 0
result: {
...r.item,
icon: aliasMatch ? getAliasEntryIcon(r.item, aliasMatch.value) : r.item.icon,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The getAliasEntryIcon function is called inside a map operation. If r.item is large or complex, this could impact performance during search. Consider if the icon resolution can be pre-calculated or cached more efficiently.

@lzx8589561 lzx8589561 merged commit 3bcee82 into ZToolsCenter:main Apr 1, 2026
@Particaly Particaly deleted the feat/feature-code-alias-support branch April 2, 2026 00:41
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.

[Feature] 能否增加插件 功能指令 的自定义?

2 participants