Skip to content

feat: 支持关闭插件搜索栏推送#520

Merged
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
guopenghui:main-push-toggle-option
Jun 3, 2026
Merged

feat: 支持关闭插件搜索栏推送#520
lzx8589561 merged 1 commit into
ZToolsCenter:mainfrom
guopenghui:main-push-toggle-option

Conversation

@guopenghui

Copy link
Copy Markdown
Contributor

变更内容

  • 为单个插件增加关闭 main push 的选项
  • 增加数据库 disabledMainPushPlugin 字段

动机

很多插件自带 main push 功能,目前无法自主关闭。当插件很多时,搜索栏信息会过多。
应该支持关闭单个插件 main push 的选项,

截图

image

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

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.

Code Review

This pull request introduces a new feature allowing users to toggle search bar push notifications ('main push') for individual plugins. It implements the UI toggle in the plugin detail toolbar, adds IPC handlers and backend APIs to persist this setting, and updates the command store to filter out commands from disabled main push plugins. Additionally, it ensures that plugin settings (including the new main push configuration) are cleaned up upon uninstallation. The review feedback highlights two performance optimization opportunities: avoiding redundant array normalization in commandDataStore.ts inside a loop, and preventing duplicate normalization calls within PluginsAPI.removePluginNameConfigs by directly filtering the already normalized list.

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.

Comment on lines +789 to +791
const isMainPush =
!!feature.mainPush &&
isMainPushPluginEnabled(plugin.name, disabledMainPushPluginNames.value)

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

性能优化建议

disabledMainPushPluginNames.value 已经是经过 normalizeConfigList 规范化后的 string[] 数组。在 buildPluginCommandItems 的循环中,对每个插件的每个 feature 都调用 isMainPushPluginEnabled 会导致重复调用 normalizeConfigList,从而产生不必要的数组分配和过滤操作(垃圾回收压力)。

建议直接使用 !disabledMainPushPluginNames.value.includes(plugin.name) 进行判断,避免重复规范化。

Suggested change
const isMainPush =
!!feature.mainPush &&
isMainPushPluginEnabled(plugin.name, disabledMainPushPluginNames.value)
const isMainPush =
!!feature.mainPush &&
!disabledMainPushPluginNames.value.includes(plugin.name)

Comment on lines +518 to +527
private removePluginNameConfigs(keys: string[], pluginName: string): void {
for (const key of keys) {
const current = databaseAPI.dbGet(key)
const normalized = normalizeConfigList(current)
const next = removePluginNameFromSettingList(current, pluginName)
if (next.length !== normalized.length) {
databaseAPI.dbPut(key, next)
}
}
}

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

代码简化与性能优化建议

removePluginNameConfigs 中,normalizeConfigList(current) 已经被调用了一次。接着调用 removePluginNameFromSettingList(current, pluginName) 会在内部再次调用 normalizeConfigList(current),造成了重复解析。

可以直接使用 normalized.filter 来生成 next 数组,这样既简化了代码,又避免了重复的规范化计算。此外,如果应用此优化,文件顶部的 removePluginNameFromSettingList 导入也可以一并移除。

Suggested change
private removePluginNameConfigs(keys: string[], pluginName: string): void {
for (const key of keys) {
const current = databaseAPI.dbGet(key)
const normalized = normalizeConfigList(current)
const next = removePluginNameFromSettingList(current, pluginName)
if (next.length !== normalized.length) {
databaseAPI.dbPut(key, next)
}
}
}
private removePluginNameConfigs(keys: string[], pluginName: string): void {
for (const key of keys) {
const current = databaseAPI.dbGet(key)
const normalized = normalizeConfigList(current)
const next = normalized.filter((name) => name !== pluginName)
if (next.length !== normalized.length) {
databaseAPI.dbPut(key, next)
}
}
}

@guopenghui guopenghui force-pushed the main-push-toggle-option branch from b1835e8 to 3497c6e Compare June 2, 2026 07:54
@guopenghui guopenghui marked this pull request as ready for review June 2, 2026 07:56
@guopenghui guopenghui force-pushed the main-push-toggle-option branch from 3497c6e to 14b767f Compare June 2, 2026 12:14
@lzx8589561 lzx8589561 merged commit 3086ba5 into ZToolsCenter:main Jun 3, 2026
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