feat(ctxmenu): 右键菜单精简——摘掉提示词模板/样式节点与三个低频插件命令
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m29s

用户要求:右键菜单里这些入口平时用不到,去掉。
- 插件节点:提示词模板(ptpl)、样式节点(style)不再出现在右键菜单
- 插件命令:标注 / 修图、位图转矢量、收藏选中的提示词不再出现在右键菜单

只影响右键菜单入口;插件本身(工具栏插件菜单、节点气泡、插件页)照常可用,
想恢复删掉 CTX_SKIP_VARIANTS / CTX_SKIP_COMMANDS 里的对应项即可。
插件分组标题与分隔线按过滤后的数量决定,全被过滤时不会留空标题。

实测(web 预览,插件已加载):空画布右键 = 提示词/图片/文本/组合/连接/中继/配置/输出 + 相册/网页/便利贴;
选中节点右键 = …选中操作▸ / 粘贴节点组 / 清空剪贴板 / 该节点▸ / 白底图 / 抠图,目标三项已消失。
This commit is contained in:
qiqi committed 2026-11-27 22:51:29 +08:00
1 parent 6fbd9ea33c
commit b901d3deb1
2 files changed
+10 -4

No files matched your search

+9 -3
View File
@@ -221,6 +221,12 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
const GenerationState = (typeof window !== 'undefined' && window.IWBGenerationState) || null
const PluginHost = (typeof window !== 'undefined' && window.IWBPluginHost) || null
const wPluginCommands = []
// 右键菜单精简(2026-11-27 用户要求):下面这些插件入口平时用不到,从右键菜单里摘掉。
// 只影响右键菜单;插件本身(工具栏 / 节点气泡 / 插件页)照常,想恢复从列表里删掉对应项即可。
const CTX_SKIP_VARIANTS = ['ptpl', 'style']
const CTX_SKIP_COMMANDS = ['image-annotate', 'image-vectorize', 'collect-selected', 'collect-prompt']
const ctxSkippedVariant = (v) => { const tail = String((v && v.id) || '').split(':').pop(); const t = String((v && v.title) || ''); return CTX_SKIP_VARIANTS.indexOf(tail) >= 0 || t === '提示词模板' || t === '样式节点' }
const ctxSkippedCommand = (c) => { const tail = String((c && c.id) || '').split(':').pop(); const t = String((c && c.title) || ''); return CTX_SKIP_COMMANDS.indexOf(tail) >= 0 || tail.indexOf('collect-') === 0 || t.indexOf('标注 / 修图') === 0 || t.indexOf('位图转矢量') === 0 }
const wPluginNodeVariants = []
// F2(P2-11b):变体元数据渲染回退表(按变体 id)。插件停用/未加载时,旧插件节点仍能渲染标题。
// 与 wPluginNodeVariants(菜单/运行用,仅"已激活"变体)分开,故不影响启停语义。
@@ -7869,7 +7875,7 @@ const tbCenterSeed = (type, refs) => {
[['prompt', '提示词', I('file-text')], ['ref', '图片', I('ref')], ['textout', '文本', I('textout')], ['combine', '组合', I('server-plus')], ['batch', '连接', I('batch')], ['relay', '中继', I('circle-dot')], ['gen', '配置', I('gen')], ...(wPrivateToolsOn ? [['llm', '润色', I('llm')], ['layer', '分层', I('layer')]] : []), ['out', '输出', I('presentation')]].map(([t, label, ic]) => el('button', { key: t, className: 'iwb-ctx-item', onClick: () => { addNode(t, Math.round(ctxMenu.wx - NODE_W / 2), Math.round(ctxMenu.wy - 20)); setCtxMenu(null) } }, ic, el('span', { className: 'iwb-btn-text' }, label))),
// 插件节点单独成组(2026-11-19 用户要求):与内置节点之间加分割线 + 组标题,
// 不再挤在「输出」后面让用户以为也是内置类型。插件停用/未装时整组(含分隔线)不渲染。
...(pluginNodeVariants.length ? [el('div', { key: 'plug-sep', className: 'iwb-ctx-sep' }, null), el('div', { key: 'plug-title', className: 'iwb-ctx-title' }, '插件节点'), ...pluginNodeVariants.map((v) => el('button', { key: 'plugin-node-' + v.id, className: 'iwb-ctx-item', onClick: () => { addPluginNode(v.id, Math.round(ctxMenu.wx - NODE_W / 2), Math.round(ctxMenu.wy - 20)); setCtxMenu(null) } }, I(v.icon || 'puzzle'), el('span', { className: 'iwb-btn-text' }, String(v.title || v.id))))] : []),
...(pluginNodeVariants.some((v) => !ctxSkippedVariant(v)) ? [el('div', { key: 'plug-sep', className: 'iwb-ctx-sep' }, null), el('div', { key: 'plug-title', className: 'iwb-ctx-title' }, '插件节点'), ...pluginNodeVariants.filter((v) => !ctxSkippedVariant(v)).map((v) => el('button', { key: 'plugin-node-' + v.id, className: 'iwb-ctx-item', onClick: () => { addPluginNode(v.id, Math.round(ctxMenu.wx - NODE_W / 2), Math.round(ctxMenu.wy - 20)); setCtxMenu(null) } }, I(v.icon || 'puzzle'), el('span', { className: 'iwb-btn-text' }, String(v.title || v.id))))] : []),
el('div', { className: 'iwb-ctx-sep' }, null),
// 两组收进二级菜单(2026-11-19 用户要求:一级 18 项太长)。入口是普通 button:
// hover / 键盘 Tab / 点击获得焦点都会用 :focus-within 展开,条目与原来完全一致。
@@ -7893,8 +7899,8 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
return el('div', { className: 'iwb-ctx-subwrap' }, el('button', { className: 'iwb-ctx-item' }, I('edit'), el('span', { className: 'iwb-btn-text' }, '该节点'), el('i', { className: 'iwb-ctx-arrow' }, '▸')), el('div', { className: 'iwb-ctxmenu iwb-ctx-sub' }, items))
})(),
// 插件命令(v3.26.109 恢复渲染):由 ctx.commands.register 注册,插件停用即消失
wPluginCommands.length ? el('div', { className: 'iwb-ctx-sep' }, null) : null,
...wPluginCommands.map((c) => el('button', { key: 'pcmd_' + c.id, className: 'iwb-ctx-item iwb-ctx-plugin', onClick: () => { setCtxMenu(null); try { const r = c.run(); if (r && typeof r.catch === 'function') r.catch(() => {}) } catch (e) { setNotice({ type: 'err', text: '插件命令失败:' + String((e && e.message) || e) }) } } }, I(c.icon || 'puzzle'), el('span', { className: 'iwb-btn-text' }, c.title))),
wPluginCommands.filter((c) => !ctxSkippedCommand(c)).length ? el('div', { className: 'iwb-ctx-sep' }, null) : null,
...wPluginCommands.filter((c) => !ctxSkippedCommand(c)).map((c) => el('button', { key: 'pcmd_' + c.id, className: 'iwb-ctx-item iwb-ctx-plugin', onClick: () => { setCtxMenu(null); try { const r = c.run(); if (r && typeof r.catch === 'function') r.catch(() => {}) } catch (e) { setNotice({ type: 'err', text: '插件命令失败:' + String((e && e.message) || e) }) } } }, I(c.icon || 'puzzle'), el('span', { className: 'iwb-btn-text' }, c.title))),
el('div', { className: 'iwb-ctx-sep' }, null),
),
) : null,
+1 -1
View File
@@ -22,7 +22,7 @@
- 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob_<hash>_<len>`** (A) `app.js:2143`;`{__cache}`(Cache Storage)为兜底;\`ref_\`(`app.js` 内定义的 `IDB_REF_PREFIX = 'ref_'`)为 legacy 形态 (A)。
- 大图判定:`isBigDataUrl` = `data:` 且 `length > 3000` (A) `app.js:2018`;**画布保存保留阈值** `< 16384` 才原样保留 (A) `app.js:2182`。**两处阈值并存,含义不同**。
- 单测是**源码契约测试**:`tests/` 目录共 **493** 处源码文本钉点(`source.includes` / `source.indexOf` / `/re/.test(source)`),分布在 **20** 个文件(其中 `iwb-v32-web-test.js` 一个就占 **407**)→ **结构性重构会先打红测试**。**该数字已由 `tests/source-text-ratchet-test.js` 的「只减不增」棘轮守门**(2026-10-20 起守卫范围从 1 个文件扩到全目录:新增任何一处源码文本钉点都会打红)。**2026-11-12 复算**(`npm run audit:pins`,v3.24.76):二分 STRUCT **417** / NAME **76**;形态 **POS 403 / NEG 87 / COUNT 3**;难度 **易 62 / 中 316 / 难 115**。钉点减法第一批(v3.24.72)把 **537 → 505**:8 条探针钉点改为「门禁内 spec 是否真的读该计数器」、5 条改为运行时断言(生产态 `window` 上无探针)、10 条改为 DOM 断言(质量档位禁用 / 传输页无三模式按钮 / 模型项 title)、4 条改为运行时对象断言(健康检查两域、策略对象冻结)、其余 9 条有同文件 DOM 等价断言或仅剩 NEG。第二批(v3.24.76)把 **505 → 493**:94-5~7 三条「多标签释放语义」(10 处正则)换成 `tests/iwb-tabs-release.spec.js` 的 3 条真 e2e,剩 1 条「消费方契约」(断言该 spec 在门禁内且 spec 源码真的读两个探针);另 2 条 `wPurgeIntent.add` 钉点改为读 `src/workspace-purge.js`。**这一批一换就查出 3 个真缺陷**(objectURL 从未释放 / 彻底删除留孤儿标签 · session / 刷新后误回收打开标签的图)—— 见 CHANGELOG v3.24.76。
- `app.js` = 单 IIFE **8,323 行**(**双层预算**:绝对上限 8,329 / 占总源码 ≤ 40%,现 **26.1%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,174 行**(上限 **2,179**,余量 5;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **117** 个模块 / 23,517 行,`sourceModules` 117 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
- `app.js` = 单 IIFE **8,329 行**(**双层预算**:绝对上限 8,329 / 占总源码 ≤ 40%,现 **26.2%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,174 行**(上限 **2,179**,余量 5;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **117** 个模块 / 23,517 行,`sourceModules` 117 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
- 门禁:`npm run verify` = `verify:ci`(`build` → `node --check app.js` → `node --check dist/app.js` → `check-dist.js` → `lint`(ESLint 正确性规则,`src/` + `app.js`,P4-16a)→ `test:unit` → `test` → `test:facts`)+ `test:e2e` (A) `package.json`。
## 2. 门禁与环境现状