From 375a3b2c0dc12ebf01887959eed2c067e5eae3e8 Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 27 Nov 2026 23:05:28 +0800 Subject: [PATCH] =?UTF-8?q?docs(ctx-menu):=20=E4=BF=AE=E6=AD=A3=E3=80=8C?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=E5=85=A5=E5=8F=A3=E3=80=8D=E8=A1=A8=E8=BF=B0?= =?UTF-8?q?=E2=80=94=E2=80=94=E5=B7=A5=E5=85=B7=E6=A0=8F=E4=B9=9F=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E4=BA=86=20promptlib/style-source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 我上一版文档写「提示词模板/样式节点需要时走工具栏插件菜单」,这是错的: 工具栏⊕菜单由 app.js 的 PLUGIN_TOOLBAR_HIDE = { promptlib: true, 'style-source': true } 按插件整体隐藏, 实际只剩 相册 / 网页 / 便利贴(与用户实测截图一致)。 - docs/standards/ctx-menu.md:新增 §3「两条独立的隐藏机制(别混)」表格(工具栏按插件、右键按入口), 并修正排除名单里的替代入口说明 - scripts/ctx-menu-audit.js:补三条断言——PLUGIN_TOOLBAR_HIDE 存在且含 promptlib / style-source, 防止工具栏那一侧被悄悄删掉 --- docs/standards/ctx-menu.md | 12 +++++++++++- scripts/ctx-menu-audit.js | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/standards/ctx-menu.md b/docs/standards/ctx-menu.md index 5443887..a56fd1e 100644 --- a/docs/standards/ctx-menu.md +++ b/docs/standards/ctx-menu.md @@ -18,7 +18,7 @@ | 常量 | 值 | 对应入口 | 理由 | | --- | --- | --- | --- | -| `CTX_SKIP_VARIANTS` | `ptpl`、`style` | 提示词模板、样式节点 | 平时用不到;需要时走工具栏插件菜单 / 插件页 | +| `CTX_SKIP_VARIANTS` | `ptpl`、`style` | 提示词模板、样式节点 | 平时用不到;这两个插件整体在工具栏也是隐藏的(见 §3),要用从插件页 / 插件设置进入 | | `CTX_SKIP_COMMANDS` | `image-annotate`、`image-vectorize`、`collect-selected`、`collect-prompt` | 标注 / 修图、位图转矢量、收藏选中的提示词 | 同上;且标注/修图有节点气泡入口,收藏有提示词库入口 | 过滤函数同在该处:`ctxSkippedVariant(v)` / `ctxSkippedCommand(c)`。 @@ -30,6 +30,16 @@ - 插件节点:`pluginNodeVariants.filter((v) => !ctxSkippedVariant(v)).map(...)` - 插件命令:`wPluginCommands.filter((c) => !ctxSkippedCommand(c))`(分隔线也按过滤后的数量决定,全被过滤时不留空标题) +## 3. 两条独立的隐藏机制(别混) + +| 机制 | 位置 | 作用范围 | 现状 | +| --- | --- | --- | --- | +| 工具栏插件菜单 | `app.js` 的 `PLUGIN_TOOLBAR_HIDE = { promptlib: true, 'style-source': true }` | **整个插件**的所有变体都不进工具栏 ⊕ 菜单 | 所以工具栏只剩下 相册 / 网页 / 便利贴 | +| 右键菜单 | `CTX_SKIP_VARIANTS` / `CTX_SKIP_COMMANDS` | 只影响右键菜单入口 | 见 §2 | + +注意:变体自己也能声明 `toolbar: 'hide'`(插件侧),宿主 `PLUGIN_TOOLBAR_HIDE` 是兜底。 +改任一侧都要同步检查另一侧,别出现「右键没了但工具栏还在」或反过来。 + ## 3. 增删流程 1. 想**再隐藏**一个入口:把它的 id(或标题)加到对应常量数组里;不需要改插件 diff --git a/scripts/ctx-menu-audit.js b/scripts/ctx-menu-audit.js index 2ba412e..1693c55 100644 --- a/scripts/ctx-menu-audit.js +++ b/scripts/ctx-menu-audit.js @@ -24,5 +24,11 @@ const commands = (/const CTX_SKIP_COMMANDS = \[([^\]]*)\]/.exec(app) || [])[1] | for (const id of ['ptpl', 'style']) check('变体名单含 ' + id, variants.indexOf("'" + id + "'") >= 0) for (const id of ['image-annotate', 'image-vectorize', 'collect-selected']) check('命令名单含 ' + id, commands.indexOf("'" + id + "'") >= 0) +// 工具栏侧:整个插件不进 ⊕ 菜单(PROMPTLIB / style-source)。两侧机制独立,都要守住。 +const toolbarHide = (/const PLUGIN_TOOLBAR_HIDE = \{([^}]*)\}/.exec(app) || [])[1] || '' +check('PLUGIN_TOOLBAR_HIDE 存在', toolbarHide.length > 0, '工具栏插件菜单的隐藏名单') +check('工具栏隐藏 promptlib', toolbarHide.indexOf('promptlib') >= 0) +check('工具栏隐藏 style-source', toolbarHide.indexOf('style-source') >= 0) + if (fail) { console.error('ctx-menu-audit: ' + fail + ' 项失败'); process.exit(1) } console.log('ctx-menu-audit: 通过')