Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17434535e8 | ||
|
|
e0e8fa0327 | ||
|
|
c81a107b5f | ||
|
|
940c92982d | ||
|
|
10a63e5edb | ||
|
|
f4a5709e8b | ||
|
|
513c300e43 | ||
|
|
cb9cb9ceec | ||
|
|
203098163c | ||
|
|
f5c81740d2 | ||
|
|
68c10b625c | ||
|
|
9f29996823 | ||
|
|
df229eecff | ||
|
|
968ff46a4c | ||
|
|
5002fbbefb | ||
|
|
015e427627 | ||
|
|
846a59b4c2 | ||
|
|
8cbe1d5923 | ||
|
|
69e98b9ecc | ||
|
|
d2b1a15878 | ||
|
|
eeb67656f2 | ||
|
|
4ae0b4b156 | ||
|
|
c158d7c37e | ||
|
|
81abda87ae | ||
|
|
c9aa6f78b3 | ||
|
|
5fc09c2382 | ||
|
|
2b8e337db8 | ||
|
|
9225a76895 | ||
|
|
01c922d7e4 | ||
|
|
aa05efe536 | ||
|
|
7c0896ed97 | ||
|
|
fcb429772e | ||
|
|
03f74629a4 | ||
|
|
de1a38e211 | ||
|
|
983eb511b4 | ||
|
|
3abe96d389 | ||
|
|
8c87ae2743 | ||
|
|
5ca6cda7a5 | ||
|
|
edc0b1f916 | ||
|
|
9a011dc825 | ||
|
|
f1462a5862 | ||
|
|
cd7d478782 | ||
|
|
071f7f44d6 | ||
|
|
980481a897 | ||
|
|
e017f8733f | ||
|
|
b28cc2d183 | ||
|
|
d7fdae8877 | ||
|
|
bc77f007a0 | ||
|
|
d2bef9f348 | ||
|
|
06d2a8bc5b | ||
|
|
d9e3d84c0c | ||
|
|
af3a9cdf8f | ||
|
|
92a8b6af0d | ||
|
|
f6c66fcd89 | ||
|
|
262bcc037b | ||
|
|
2cc5126f70 | ||
|
|
5d68e0249a | ||
|
|
bb0b3f3e8f | ||
|
|
204f9103aa | ||
|
|
8e40ba2870 | ||
|
|
d45065101b | ||
|
|
702fbf5132 | ||
|
|
8944f2a78f | ||
|
|
7335f59288 | ||
|
|
16109a39f4 | ||
|
|
b25ba45872 | ||
|
|
b8f5d4d8eb | ||
|
|
fb69d17615 | ||
|
|
98f7f8e6d4 | ||
|
|
0e80c55adf | ||
|
|
dd58e4a7b5 | ||
|
|
e9435a5cfe | ||
|
|
054aec958e | ||
|
|
96c786e8ca | ||
|
|
3792081ddd | ||
|
|
b1e3fea494 | ||
|
|
81c520fe52 | ||
|
|
1277a4398a | ||
|
|
a0a696a2e6 | ||
|
|
5e2f9dd876 | ||
|
|
9739764d2f | ||
|
|
3483cc4174 | ||
|
|
61dbd0abe8 | ||
|
|
95ccb8ec29 | ||
|
|
843291cd66 | ||
|
|
e2b7c9919a | ||
|
|
de85aff6df | ||
|
|
10d97e74d8 | ||
|
|
cce51e6ccd | ||
|
|
3565b5aec2 | ||
|
|
a4550d5654 | ||
|
|
76115bcce8 | ||
|
|
ea219d92c4 | ||
|
|
84df19fb59 | ||
|
|
af1070ec78 | ||
|
|
f2be2a7a9f | ||
|
|
b597ee4d69 | ||
|
|
e60c2798db |
No files matched your search
@@ -14,6 +14,264 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.26.49(2026-11-23)M4-B6 收尾:插件契约从「赦免文件」改成「声明皮肤」
|
||||
|
||||
> **状态:✅ 已发布**(2026-11-23)macOS 双架构 dmg + 签名更新产物 + `latest.json` 更新源已上线;
|
||||
> 同时发布 4 个插件(KV 远程加载 + 插件市场 zip)。**Windows 本版不发**,`latest.json` 暂不含
|
||||
> `windows-x86_64` 条目(按脚本规则:win 未同批则不合入,避免版本错配死循环)。
|
||||
|
||||
M4 的最后一批。用户能感知的几乎没有 —— 只有浏览器插件里那颗「连接已关闭」的小灰点
|
||||
从写死的 `#888780` 改成跟随主题(亮色略深、暗色略亮)。真正的改动在**守门规则**上。
|
||||
|
||||
**① 16 处半像素字号清零,`style.css` 里一个不剩**
|
||||
|
||||
| 位置 | 改前 | 改后 |
|
||||
|---|---|---|
|
||||
| 备份列表项 / 确认框正文 | 13.5px ×2 | `--iwb-font-md`(13) |
|
||||
| 备份文件名 / 右键菜单项 / 操作日志 / 资源浮标 | 12.5px ×4 | `--iwb-font-sm`(12) |
|
||||
| 继承条 / 插件市场卡标签 ×3 / 已安装徽标 | 10.5px ×5 | `--iwb-font-xs`(11) |
|
||||
| 插件市场卡副标题 ×4 | 11.5px ×4 | `--iwb-font-sm`(12) |
|
||||
|
||||
顺带删掉 2 条**归并后变成重复**的声明:`.iwb-mk-card .iwb-mk-name` 与 `.iwb-mk-sub` 原本用
|
||||
13.5/11.5 覆盖全局的 13/12,归并后与全局同值、特异性更高却没有新信息 —— 留着就是下一个「改它没反应」的陷阱。
|
||||
守卫从「设置范围内禁半像素」收紧成「**全文件**禁半像素」。
|
||||
|
||||
**② `--iwb-control-h` 不扩到全局控件(B4 留的悬念,这里裁定)**
|
||||
|
||||
B4 时把设置页的输入框与按钮统一到 30px,当时留下「B6 再决定全局跟不跟」。结论是**不跟**:
|
||||
全局 `.iwb-input` 是「内容撑高」(12px 字 + 6px 竖内边距 + 1px 描边 ≈ 28px),服务的是画布、节点卡、停靠栏里的**紧凑控件**;
|
||||
`control-h` 要解决的是「输入框与按钮并排时高低不齐」,而那种并排只出现在设置页表单里。
|
||||
强行统一到 30 会让画布与节点里的每个输入框长 2px,节点总高、面板行距、浮条位置全跟着动 ——
|
||||
零观感的批次不该带这个。判据写进守卫:**有没有并排的另一半**,而不是「哪个更大」。
|
||||
|
||||
**③ 插件主题契约:文件级豁免 6 → 0**
|
||||
|
||||
旧规则里有一张 `ALLOW_FILES`,把整个插件文件放进去就等于对它放弃颜色检查。B6 时它攒了 6 条,逐条查过去发现根本不是一类问题:
|
||||
|
||||
| 文件 | 真实情况 | 处理 |
|
||||
|---|---|---|
|
||||
| `style-source` / `blank-canvas` | **过期豁免**:hex 全在 `var(--x,#hex)` fallback 里,规则本来就会放行 | 直接删豁免,测试照样过 |
|
||||
| `image-annotate` | 整套 Catppuccin 调色板(470 处),深色专业工具 UI | manifest 声明 `skin: 'private'` |
|
||||
| `image-vectorize` | 自绘深色 UI(`#1b1b22` 系列,58 处) | 同上 |
|
||||
| `browser` / `batch-export` | **混合**:面板跟主题走,按钮用自家强调色(绿/橙/蓝/红) | 见下 |
|
||||
|
||||
新规则按「颜色在这段 UI 里是什么角色」分三类,判据都写在测试里:
|
||||
|
||||
- **表面/文字/边框色** → 必须 `var(--iwb-*)`。这台机器上的判据是 **chroma**(`max-min` of RGB)< 24:
|
||||
近中性的颜色看起来就是「灰」,拿它当面板底或正文色,暗色下必然白板或黑洞。
|
||||
- **强调/状态色** → 允许写死,但**不用查表**(表会过期、会被人往里加)。chroma ≥ 24 就是有明确色相,
|
||||
亮暗两端都读得出来。测试会把用到的强调色逐条打印出来供 review。
|
||||
- **私有皮肤** → 在 manifest 里 `skin: 'private'`,颜色全放行,**代价是不得引用宿主颜色 token**。
|
||||
混用才是「一半跟主题走、一半写死」在暗色下花屏的真正根源 —— 这才是旧 `ALLOW_FILES` 一直盖住的问题。
|
||||
|
||||
内容色(看片台白底、画布填充)用行内 `/*iwb:content*/` 标记放行:同一个 `#fff` 在面板上是 bug、
|
||||
在画布上是内容,**值分不出来,上下文才分得出来**。所以豁免从「整个文件」降到「这一条声明」。
|
||||
|
||||
**插件版本**:`browser` 1.7.1(状态点跟随主题)、`batch-export` 1.2.1(看片台标内容色)、
|
||||
`image-annotate` 1.20.7 与 `image-vectorize` 0.6.1(声明私有皮肤)。产物同步走
|
||||
`scripts/sync-plugins-from-repo.js`,内容寻址文件名与 SRI 一并重建。
|
||||
|
||||
**验收偏差:视觉基线变了 8 张,不是计划里写的「零观感」。**
|
||||
变的正好是 ②④⑤⑥ × 亮/暗四个**含画布**的场景,①首页与③设置弹窗 0 diff。
|
||||
原因是画布节点里的 `.iwb-oplog`(11.5→12)、`.iwb-inherit-bar`(10.5→11)、
|
||||
`.iwb-resource-float-title`(12.5→12) 与右键菜单 `.iwb-ctx-item`(12.5→12) 都在这些场景里,
|
||||
半像素归成整数会改变文字栅格化,逐像素比对(threshold 0)必然有差异。
|
||||
做过 A/B 回退验证:把 `style.css` 换回 B5 版本后 12/12 通过,确认差异来自本批而不是环境噪声;
|
||||
逐张看过 diff,只有文字与小图标边缘的抗锯齿变化,没有裁切、重叠、面板位移或边框错位。
|
||||
**结论:0.5px 的字号归整在肉眼上是零变化,在逐像素基线上不是** —— 以后凡是动字号就别再写「预期 0 diff」。
|
||||
|
||||
**这一批的方法论收获:豁免不是「欠的债」,是「没讲清的分歧」。**
|
||||
6 个豁免里 2 个早已可删(没人回来删)、2 个是设计选择(自带皮肤)、2 个是真混合(要修)。
|
||||
用一张文件名单把三种情况盖在一起,结果是谁也不敢动其中任何一个。
|
||||
拆开之后:2 个删掉、2 个变成有代价的公开声明、1 个真修(browser 灰点)、1 个标内容色。
|
||||
**只要豁免里混着不同性质的东西,它就会一直长。**
|
||||
|
||||
## v3.26.48(2026-11-23)画布节点:端口不再是黑洞
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿、12 张视觉基线变了 8 张且逐张核对;未打 tag)
|
||||
|
||||
M4-B5 批次。用户能感知的是**深色画布上节点的连接端口看得见了**——它以前是嵌在卡片上的黑洞。
|
||||
|
||||
**端口在两个主题下往相反方向错**
|
||||
|
||||
| 主题 | 改前 | 改后 |
|
||||
|---|---|---|
|
||||
| 暗色 | `--iwb-layer` = `#161616` 打在节点卡 `#3d3d3d` 上,差 39 级 | `--iwb-field` = `#494949`,差 12 级,读作凸起小圆点 |
|
||||
| 亮色 | `#f5f5f5` 打在 `#efefef` 卡上,只靠 1.5px 描边才勉强看见 | `#ffffff` + 描边,白点清晰 |
|
||||
|
||||
同一个病灶在节点内还有 6 处,一并改成 `field`:引用图占位(`.iwb-ref-img` / `.iwb-ref-single`)、
|
||||
引用链接按钮、迷你引用空位、任务结果图、节点标题带 hover。
|
||||
|
||||
**端口描边单独处理**:换完底色后放大 8 倍才发现深色下端口「糊成一团」—— 描边用的是 `--iwb-border2`(`#4d4d4d`),
|
||||
和新的填充 `#494949` 几乎同色,等于没有描边。改成由文字色派生的 `color-mix(text 55%, transparent)`:
|
||||
亮 `#828282` / 暗 `#9e9e9e`,对填充各 4.6:1 / 3.4:1(非文字元素红线 3:1),两个主题同一档锐度。
|
||||
|
||||
**浮条按钮 hover 在深色下完全没有反馈**
|
||||
浮条底是 `--iwb-panel`(`#1c1c1c`),子项 hover 用 `--iwb-layer2`(也是 `#1c1c1c`)——改数字没用,
|
||||
因为它俩就是同一个颜色。改为 `color-mix(text 10%, transparent)`。任务卡里的「等待」按钮同理。
|
||||
|
||||
**归并**
|
||||
- 字号:12→`sm`、15→`lg`、11→`xs`、13→`md`,**全部等值**;8/10px 微缩徽标保留(闭集最低档 11 会把 12px 角标撑破)。
|
||||
- 圆角:8px→`control`、6/5px→`chip`、14px→`popover`,只剩 `50%`(圆)与 `2px`(占位条)。
|
||||
节点本体本来就走 `--iwb-node-radius`(外观里可调),不受影响。
|
||||
- 间距:52 处等值、13 处 1px 级微调;最大一处是提示词节点体 `14px 18px → 12/16`(节点高度 −4px)。
|
||||
- 阴影:浮条与节点选中/连接态的内联 `rgba(...)` 走 `elevation-2`。
|
||||
- 删 6 个死类名 / 6 条规则:`gen-sizerow` `gen-qualityrow` `gen-tag` `size-x` `size-align` `size-badge`
|
||||
(尺寸/质量 UI 早已并入图像设置浮层,这些规则还在样式表里躺着)。
|
||||
|
||||
**新增守卫** `tests/node-scope-test.js`(进 `test:unit`):节点卡内部禁 `--iwb-layer/layer2/panel` 作背景
|
||||
(浮条除外,它本身就是浮层)、端口三态底色断言、节点区字号/间距/圆角必须走档位、死类名不复现。
|
||||
|
||||
验收:计算样式逐属性 diff(节点/标题带/端口/浮条/生图参数/任务卡),变化全部为预期项;
|
||||
`verify:ci` 全绿;审计:字号写死 212→188、圆角 128→104、间距 483→416、`style.css` 2314→2307 行。
|
||||
|
||||
**顺带修掉视觉基线的一处「假绿灯」**:`toHaveScreenshot` 的 `threshold` 默认 0.2,
|
||||
而 `maxDiffPixels: 0` 只约束「超阈值像素数」,两者叠加并不等于逐像素精确 —— 端口描边改的 19 级差异
|
||||
正好被吃掉,基线没更新、比对还报 12/12 通过。已把 `threshold` 压到 0 并重生成基线(仍 12/12)。
|
||||
|
||||
## v3.26.47(2026-11-23)设置页:输入框与按钮终于一样高,半像素字号清零
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿、12 张视觉基线只有设置弹窗 2 张变化且已核对;未打 tag)
|
||||
|
||||
M4-B4 批次。用户能感知的是**设置页更整齐**:同一行里输入框 33px、按钮 24px 的 9px 落差没有了,现在都是 30px。
|
||||
|
||||
**控件等高(本批的主任务)**
|
||||
- 新增 `--iwb-control-h: 30px`。设置页输入框竖内边距 7→6(13px 字 + 6×2 + 2 描边 = 30),
|
||||
默认按钮 24→30(`align-items:center` 自带居中,不用改内边距)。
|
||||
- 渠道卡片是「卡片里的卡片」,显式 `height: auto` 按自身内边距算高,不吃固定高度。
|
||||
- 没动全局 `.iwb-input`(现在 28px):改它会让画布、停靠栏、节点里每个输入框都长 2px,
|
||||
这不是本批该带的观感变化。B6 收尾再定。
|
||||
|
||||
**字号**
|
||||
- 设置页正文 14→13、标题 16→15,与同屏 `section-title(15)` 落到同一档(原来 16/15 差 1px,
|
||||
读起来是两个「差不多大」的层级)。范围内半像素字号清零:13.5×8 → `md(13)`、12.5×2 → `sm(12)`。
|
||||
|
||||
**删 21 条死规则**
|
||||
- 十四组类名在 `dist/app.js` 与 `plugins/**` 里都是 0 次:`setcell`(+hover/on/label)、`setgrid`、`setopen`、
|
||||
`ratio-mini(-auto)`/`ratio-box`、`set-page-head(-headtext)`、`set-row`(两处定义,一 grid 一 flex)、
|
||||
`set-row-*`、`pop-anchor .setcell`、`appear-val`、`appear-note-only`。
|
||||
- `.iwb-set-row` 是插件设置页改版时被 `.iwb-mk-setrow` 取代的旧类。
|
||||
|
||||
**修掉一条「写了但从未生效」的声明**
|
||||
- `.iwb-set-nav-item { padding: 7px 9px }` 被 `.iwb-settings-modal .iwb-tab`(两个类)按 specificity 压掉,
|
||||
实测一直是 8/16 —— 改它毫无反应。
|
||||
- 同类:`.iwb-appear-range` 写了两遍(`flex:1 1 0` 又被 `flex:0 1 260px` 覆盖),合并成一条。
|
||||
|
||||
**新增守卫** `tests/settings-scope-test.js`(已进 `test:unit`):
|
||||
控件必须共用 `--iwb-control-h`、范围内禁半像素字号、9 个死类名不许复现、**引用的 token 必须存在**。
|
||||
最后一条是本批真踩到的坑:`--iwb-radius-pill` 拼错(真名 `--iwb-radius-full`)会让声明整条失效、圆角静默变 0,
|
||||
亮色基线看不出来 —— 这类错误只能靠断言。
|
||||
|
||||
## v3.26.46(2026-11-23)首页/库:字号与间距收进档位,删掉 30 条死规则
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿、12 张视觉基线只有首页 2 张变化且已核对;未打 tag)
|
||||
|
||||
M4-B3 批次。用户能感知的是**首页更紧凑了一点**:侧栏条目矮 4px、主标题小 2px、卡片脚注更贴底。
|
||||
|
||||
**删死代码(本批一半的工作量在这)**
|
||||
|
||||
- 25 个类名在产物里出现 0 次,对应 **30 条规则直接删**:`home-title/subtitle/new/head/kicker/card-main/card-check/card-rename/cats/side-foot/menu-btn/menu-sep`、`lib-tabs/lib-tab/lib-handle`。都是历史布局的残留。
|
||||
- 批量管理的复选框:v3.22 起改成「点卡片=选中」,DOM 里早就不渲染复选框了,两条 `.iwb-home-card-check` 样式还留着。
|
||||
- **`.iwb-home-panel` 上叠了 5 层 padding**(`90px` / `116px … 60px` / `24px` / `72px` / 最终 `padding:0`)—— 前四层全被最后一条 specificity 更高的规则覆盖,改数字毫无反应,一并清掉。
|
||||
|
||||
**首页/库 106 条规则换 token**
|
||||
|
||||
- 间距写死从 **91 处降到 5 处**,剩下 5 处全是布局值(`max(24px, calc((100vw - 1580px)/2))` 版心留白、`1580px` 版心宽、`52px` 对齐导航栏),并在规范里写明「为什么这几个必须写死」。
|
||||
- 字号写死清零。归并:14→`md(13)`、16→`lg(15)`、18→`xl(17)`、26→`display(24)`。
|
||||
- 新增 `--iwb-font-display: 24px`(第 7 档):首页主标题原本 26px,压到 `2xl(20)` 会和面板标题同级,页面层级会塌。这一档只给「页面叫什么名字」用,不许进卡片/面板/列表。
|
||||
|
||||
**验收方式换了**
|
||||
|
||||
- 不再只靠肉眼看截图:改动前后各采一次首页 20 个关键元素的**计算样式**(`font-size` / `padding` / `margin` / `gap` / `radius` / `height`)逐项比对。20 个里 9 个有变化,全部是预期项,没有「没打算改却被改」的属性。
|
||||
- 12 张视觉基线:**只有首页亮/暗 2 张变化**,其余 10 张 0 diff —— 正是「只动首页/库」的期望结果。
|
||||
- 单测里钉像素值的断言(`css.includes('font-size: 15px')`)改为钉 token 档位(`var(--iwb-font-lg)`),断言语义从「这个值」升级为「这个层级」。
|
||||
|
||||
## v3.26.45(2026-11-23)浮层层级表 + 阴影四档:修好「弹窗里点保存看不到成功提示」
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿、12 张视觉基线 0 diff;未打 tag)
|
||||
|
||||
M4-B2 批次。用户能感知的只有一件事:**在弹窗/确认框里操作,成功提示现在看得见了**。其余是层级与阴影的归一。
|
||||
|
||||
**修掉一个「改 CSS 治不好」的层级 bug**
|
||||
|
||||
- `.iwb-toast` 原本挂在 `.iwb-overlay` 内部,而 `.iwb-overlay` 自带 `z-index:100` + `position:fixed`,本身就是一个**堆叠上下文** —— 里面的 toast 写多少都压不过 portal 到 `body` 的弹窗(300)。所以此前「弹窗里点保存,什么都没发生」其实是提示被盖住了。
|
||||
- 修法不是调数字,而是把 toast 也 portal 到 `body`;随后层级数字才生效(实测:`elementFromPoint` 命中 toast 本身,而不是遮罩)。
|
||||
|
||||
**层级表(14 档,`--iwb-z-*`)**
|
||||
|
||||
- 新增一张层级表,数值只在 `scripts/gen-tokens.js` 写一次:`ctx 90 / ctx-menu 91 / curtain 100 / command 120 / sheet 260 / sheet-menu 270 / modal 300 / modal-menu 310 / splash 400 / toast 500 / preview 800 / anchor 3200 / palette 3300 / alert 4000`。
|
||||
- 浮层族(弹窗、全窗口面板、命令面板、右键菜单、toast、锚定浮层、确认框、崩溃屏)全部改用 token,裸 `z-index` 取值种类从 42 降到 31。
|
||||
- 三条关系被测试钉死:`ctx-menu < sheet < modal`、`toast > modal`、`sheet-menu` 卡在 sheet 与 modal 之间。
|
||||
|
||||
**阴影四档 + 圆角归一**
|
||||
|
||||
- 新增 `--iwb-elevation-1..4`(贴面 / 浮窗菜单 / 命令面板 / 弹窗),浮层从 8 种阴影写法收成 4 档;`.iwb-pop` 圆角 18px 归到 `radius-popover(14)`,浮层圆角只剩 1 种。
|
||||
- `--sh-sm/md/lg` 的引用归零,三个 legacy 名标 `@deprecated`(保留给外部样式,不删)。
|
||||
|
||||
**新增守卫**:`tests/overlay-layer-test.js` —— 层级表存在性、9 条顺序约束、浮层族禁裸 `z-index`、引用的 token 必须存在、toast 必须 portal。
|
||||
|
||||
## v3.26.44(2026-11-23)设计 token 体系重建:暗色真正变深、卡片内控件不再「挖黑洞」
|
||||
|
||||
本轮是 UI 设计语言的地基工程,观感变化集中在暗色主题。四个阶段(D1–D10 缺陷修复 → M0 视觉基线 → M1 清账 → M2 色彩模型 → M3 单一源)一次交付。
|
||||
|
||||
**色彩模型重建(D1–D9)**
|
||||
|
||||
- 暗色从「中灰底 + 浅灰字」改为真正的深色:#121212 应用底 / #313131 画布 / #3d3d3d 节点卡,正文 #e3e3e3。旧值在暗色下正文与底色只差 4.5:1,长时间看眼睛累。
|
||||
- 13 个表面逐层重算,并加了「相对派生」约束:节点卡相对画布、卡片内控件相对节点卡 —— 每一层都保证比它贴着的那层浮起来(之前存在节点卡比画布更暗的层次反转)。
|
||||
- 对比度改成硬指标并在生成期强制夹紧(正文 7:1 / 次要 4.5:1 / 弱化 3:1 / 画布文字 6:1 / 品牌字 4.5:1),实测最差 text 7.02、text2 4.64、textDim 3.12、canvasText 6.1。
|
||||
- 新增 `--iwb-brand-text`(品牌色用于文字时的安全版本,34 处 `color: var(--iwb-brand)` 改为引用它)、`--iwb-bg-menu`(浮层统一底色)、`--iwb-focus-ring`(键盘焦点环,并给 `:focus-visible` 统一兜底)。
|
||||
- hover 5 处、浮层 3 处从写死色值改走 token;修正首页卡片在暗色下与背景同色「隐身」的问题。
|
||||
|
||||
**卡片内控件面(D10,验收反馈)**
|
||||
|
||||
- 根因:卡片内控件吃 `--iwb-panel`/`--iwb-layer`(这两个贴着应用底色派生),而节点卡是画布派生的,两者不在同一亮度带 —— 暗色下卡片 #3d3d3d 里嵌 #1a1a1a 下拉框、#151515 任务卡,差 33–39 级,看着像在灰卡上挖洞。
|
||||
- 新增 `--iwb-field`(卡片内控件面,跟随节点卡派生:亮 #ffffff / 暗 #494949),8 处切过去(任务卡、生图参数框、节点内输入、输出组、进度条、组合/批量来源行),差降到 12 级,靠 1px 描边定边界。
|
||||
- 插件内嵌面暗色 #101010 → #191919(提示词库搜索框同样曾是黑窟窿)。
|
||||
- 修节点内「生成」按钮:底色取文字色、字却用白色 → 1.2:1 几乎看不见;改用页面底色,亮 9.4:1 / 暗 13.9:1。
|
||||
|
||||
**单一源(M3,零观感)**
|
||||
|
||||
- `src/theme-tokens.js` 的 `derive()` = 唯一源,生成 `src/design-tokens.css`(静态快照,顶住 JS 执行前那一帧)与 `dist/tokens.json`(DTCG,可导入 Penpot / Figma Variables,暗色值在 `$extensions`)。
|
||||
- 尺度层(间距/圆角/字号/阴影/过渡)也进生成器,`style.css` 只剩组件规则。
|
||||
- 三道闸门:`tokens:check`(进 `verify:ci`,报第一处差异行)、`build` 漂移即失败、`theme-static-snapshot-test` 逐 token 比对。
|
||||
- 视觉基线 12 张(6 场景 × 亮暗)纳入门禁,亮色逐像素 0 diff。
|
||||
|
||||
## v3.26.41(2026-11-23)继承态提示词把文案与参考图交给组合/连接节点
|
||||
|
||||
- 修「提示词接风格库变量节点后,组合节点读不到文案、也不往下带参考图」(出图一直正常,所以表现为「能出图、组合是空的」)。
|
||||
- 根因:来源判定只看节点自身 `data.text`,提示词处于「继承 · 来自 上一级」时自己没存字,被当成无文本来源整路丢弃 —— 组合取行、组合写入 `combined`、组合→文本/分层节点的图片汇总同时失效。
|
||||
- 修复只动来源判定层(`batchSrcText` / `isBatchSrc` 支持 `(edges, nodes)`),自身无文案时按节点体显示的同一套顺序取上游第一条(提示词不拼合多路);组合节点的拼接、分隔符、附加文案、排序逻辑零改动。
|
||||
- 连接(batch)节点同步修好:继承态提示词现在能进来源列表、生成输出端口、推送正确文案。
|
||||
- 穿透范围限定为提示词/文本/中继/连接,组合、LLM、插件节点不越过;上游停用不参与;环不死循环。
|
||||
|
||||
## v3.26.40(2026-11-23)Windows:修复 PowerShell 弹窗
|
||||
|
||||
- Windows 状态栏内存探测改用 CREATE_NO_WINDOW 启动 PowerShell,不再每 4 秒弹出控制台窗口。
|
||||
- macOS 行为不变(Unix 分支仍用 ps)。
|
||||
|
||||
## v3.26.39(2026-11-22)修正插件插入落点与封面插入
|
||||
|
||||
- promptlib 1.6.18:拖拽落点按节点宽高居中到鼠标;详情「插入模板节点/插入画布/插入图片」落到画布可视中心;拖拽期间禁用文本选择。
|
||||
- 宿主:新增 CanvasGeometry.promptCenterSpot,提示词/封面插入不再被左侧面板遮挡。
|
||||
- 修复详情「插入图片」:封面文件先解析为 dataURL 再插入。
|
||||
|
||||
## v3.26.38(2026-11-22)插件节点交互修复 + 标注覆盖保留原图
|
||||
|
||||
### 提示词库(promptlib 1.6.16)
|
||||
- 拖拽改为指针拖拽(对齐风格库):不再用原生 HTML5 DnD,修掉“拖入后第一次点不动/选中文本、需先点空白”的顽疾。
|
||||
- 拖拽跟手幽灵卡片(封面 + 名称 + 模板/文本节点提示)。
|
||||
- 节点创建走 canvasWrite.createNode + canvas.screenToWorld,落地即选中、可直接拖动。
|
||||
- 双击卡片查看详情;详情 → 编辑 → 保存回到详情。
|
||||
- 封面卡高度恢复;悬停缩放改内层背景层(不再闪烁);封面不拦截指针。
|
||||
- 未选中时模板变量输入框不拦截指针;只读正文不拦截指针(单击=选中节点,双击=编辑)。
|
||||
|
||||
### 宿主
|
||||
- canvasWrite.setNodeImage 覆盖前备份原图到 data.orig;节点右键新增「还原替换前原图」。
|
||||
- 新增 docs/standards/plugin-node-drag.md:插件节点拖入/能力/指针交互踩坑记录。
|
||||
|
||||
### 已知问题
|
||||
- 标注插件「覆盖」后原图需通过右键「还原替换前原图」找回;若旧节点在本次更新前已被覆盖,无备份。
|
||||
|
||||
## v3.26.37(2026-11-22)提示词库 1.6.6:变量 / 模板节点 / 备份 / 设置内嵌
|
||||
|
||||
### 提示词库(promptlib 1.6.6)
|
||||
|
||||
@@ -41,7 +41,7 @@ build esbuild 打包到 dist/(单 dist/app.js = src/ 模块按序
|
||||
node --check app.js 与 dist/app.js 语法
|
||||
check-dist.js 产物体检
|
||||
lint ESLint(src/ + app.js,正确性规则)
|
||||
test:unit 116 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test:unit 121 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test relay-task-graph-fixture + iwb-v32-web-test
|
||||
test:facts 事实基线守门(见 §5)
|
||||
typecheck 渐进类型检查(tsc --noEmit;范围 = src/*.js,不含 app.js)
|
||||
|
||||
@@ -3492,10 +3492,12 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
|
||||
let t = 'light'
|
||||
try { const s = lsRawGet('iwb_theme', null); if (s === 'dark' || s === 'system') t = s } catch (e) { /* ignore */ }
|
||||
applyTheme(t)
|
||||
// 跟随系统时,系统外观切换要实时反映(不用重开窗口)
|
||||
// 跟随系统时,系统外观切换要实时反映(不用重开窗口)。除了切 class 与落盘,还必须广播一次事件:
|
||||
// 内联 token 由 applyAppearance 写在 <html> 上,它挂的 effect 依赖 [config, theme],而 theme 在这里
|
||||
// 恒为 'system' 不会变 ⇒ 不广播就会出现「class 已暗、inline 还是亮」的混色半成品(D1,2026-11-23 修)。
|
||||
try {
|
||||
const mq = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
if (mq && mq.addEventListener) mq.addEventListener('change', () => { try { if (lsRawGet('iwb_theme', null) === 'system') applyTheme('system') } catch (e) { /* ignore */ } })
|
||||
if (mq && mq.addEventListener) mq.addEventListener('change', () => { try { if (lsRawGet('iwb_theme', null) === 'system') { applyTheme('system'); window.dispatchEvent(new CustomEvent('iwb:theme-change')) } } catch (e) { /* ignore */ } })
|
||||
} catch (e) { /* ignore */ }
|
||||
return t
|
||||
}
|
||||
@@ -5631,6 +5633,12 @@ const tbCenterSeed = (type, refs) => {
|
||||
return String(pr.name || pr.id || '') + ' · ' + (k ? String(k.name || k.id) : '无分组')
|
||||
} catch (e) { return '' }
|
||||
}
|
||||
// 覆盖式替换图片前备份原图:优先保留已有 orig,其次 data,最后 url。返回 updateNode patch。
|
||||
function origImagePatch(prev, dataUrl) {
|
||||
const orig = (prev && prev.orig) || (prev && typeof prev.data === 'string' && /^data:/i.test(prev.data) ? prev.data : '') || (prev && typeof prev.url === 'string' ? prev.url : '')
|
||||
return orig ? { data: String(dataUrl), url: '', orig } : { data: String(dataUrl), url: '' }
|
||||
}
|
||||
|
||||
function Workbench() {
|
||||
// runtime-workbench-logic 模块的 app.js 模块级依赖:渲染前注入一次(常量/纯函数,无陈旧值风险)
|
||||
if (IWWorkbenchLogic && !IWWorkbenchLogic.__iwbInjected) {
|
||||
@@ -5789,9 +5797,8 @@ const tbCenterSeed = (type, refs) => {
|
||||
},
|
||||
setNodeImage: (id, dataUrl) => {
|
||||
if (!/^data:/i.test(String(dataUrl || ''))) return false
|
||||
if (!refs.nodes.some((x) => x.id === id)) return false
|
||||
updateNode(id, { data: String(dataUrl), url: '' })
|
||||
return true
|
||||
const t = refs.nodes.find((x) => x.id === id); if (!t) return false
|
||||
updateNode(id, origImagePatch(t.data || {}, String(dataUrl))); return true
|
||||
},
|
||||
}
|
||||
return () => { wPluginCanvasBridge = null }
|
||||
@@ -6135,7 +6142,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
refs.config = config
|
||||
// 外观:配置到位/切换主题时把画布底色与主题色写到 :root(放在 config 同步之后,
|
||||
// 否则首屏拿不到配置,改完颜色要重启才生效)
|
||||
useEffect(() => { try { applyAppearance(config) } catch (e) { /* ignore */ } }, [config, theme])
|
||||
useEffect(() => { const f = () => { try { applyAppearance(config) } catch (e) { /* ignore */ } }; f(); window.addEventListener('iwb:theme-change', f); return () => window.removeEventListener('iwb:theme-change', f) }, [config, theme])
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
// 启动时一次性迁移历史 localStorage 里的 base64 大图到 IndexedDB(释放空间,治撑爆)
|
||||
@@ -6886,9 +6893,9 @@ const tbCenterSeed = (type, refs) => {
|
||||
}
|
||||
continue
|
||||
}
|
||||
const bsrcs = edges.filter((e) => e.to === bn.id).map((e) => nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n) && !(n.data && n.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const bsrcs = edges.filter((e) => e.to === bn.id).map((e) => nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, edges, nodes) && !(n.data && n.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
if (!bsrcs.length) continue
|
||||
const textOf = (src) => batchJoinedText(bn.data, batchSrcText(src))
|
||||
const textOf = (src) => batchJoinedText(bn.data, batchSrcText(src, edges, nodes))
|
||||
for (const e of edges) {
|
||||
if (e.from !== bn.id) continue
|
||||
const dst = nodes.find((n) => n.id === e.to)
|
||||
@@ -7804,7 +7811,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
if (!e || !e.to) continue
|
||||
const dst = refs.nodeMap.get(e.to)
|
||||
const src = refs.nodeMap.get(e.from)
|
||||
if (!dst || !src || dst.type !== 'batch' || !isBatchSrc(src)) continue
|
||||
if (!dst || !src || dst.type !== 'batch' || !isBatchSrc(src, edges, nodes)) continue
|
||||
if (!m.has(dst.id)) m.set(dst.id, [])
|
||||
if (!m.get(dst.id).some((n) => n.id === src.id)) m.get(dst.id).push(src)
|
||||
}
|
||||
@@ -8070,7 +8077,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
const node = refs.nodes.find((n) => n.id === id)
|
||||
if (node) {
|
||||
if (batchSrcId) {
|
||||
const bsrcs = refs.edges.filter((e) => e.to === id).map((e) => refs.nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const bsrcs = refs.edges.filter((e) => e.to === id).map((e) => refs.nodes.find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, refs.edges, refs.nodes)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const idx = bsrcs.findIndex((s) => s.id === batchSrcId)
|
||||
if (idx >= 0) portPos = { x: node.x + nodeWidth(node), y: node.y + batchPortTop(idx, Math.max(1, bsrcs.length), hOf(node)) }
|
||||
} else {
|
||||
@@ -8211,7 +8218,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
},
|
||||
insert: (text, name) => {
|
||||
const id = uid('n')
|
||||
const spot = findSpot('prompt')
|
||||
const spot = CanvasGeometry.promptCenterSpot(wPluginCanvasBridge, 280, 120) || findSpot('prompt')
|
||||
commitCanvas(refs.nodes.concat([{ id, type: 'prompt', x: spot.x, y: spot.y, data: { text: text || '', title: name || '' } }]), undefined, undefined)
|
||||
setSel([id])
|
||||
setNotice({ type: 'ok', text: '已插入提示词:' + (name || '') })
|
||||
@@ -8221,7 +8228,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
insertImage: (cover, name) => wPromptInsertImage({
|
||||
insertRefNode: (data, nm, w) => {
|
||||
const id = uid('n')
|
||||
const spot = findSpot('ref')
|
||||
const spot = CanvasGeometry.promptCenterSpot(wPluginCanvasBridge, w || 280, 180) || findSpot('ref')
|
||||
commitCanvas(refs.nodes.concat([{ id, type: 'ref', x: spot.x, y: spot.y, w: w || 280, data: { data: data, name: nm } }]), undefined, undefined)
|
||||
setSel([id])
|
||||
setNotice({ type: 'ok', text: '已插入封面图片' })
|
||||
@@ -8662,6 +8669,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
const items = []
|
||||
if (isImageProducer(tgt)) items.push(el('button', { key: 'run', className: 'iwb-ctx-item', onClick: () => { runProducer(tgt.id); setCtxMenu(null) } }, I('run'), el('span', { className: 'iwb-btn-text' }, tgt.type === 'layer' ? '运行该分层' : '运行该生图')))
|
||||
if (tgt.type === 'llm') items.push(el('button', { key: 'pol', className: 'iwb-ctx-item', onClick: () => { runLLM(tgt.id); setCtxMenu(null) } }, I('llm'), el('span', { className: 'iwb-btn-text' }, '▶ 润色')))
|
||||
if (tgt.type === 'ref' && tgt.data && typeof tgt.data.orig === 'string' && tgt.data.orig) items.push(el('button', { key: 'restore-orig', className: 'iwb-ctx-item', onClick: () => { pushHistory(); updateNode(tgt.id, { data: tgt.data.orig, url: '', orig: '' }); setCtxMenu(null) } }, I('undo'), el('span', { className: 'iwb-btn-text' }, '还原替换前原图')))
|
||||
if (tgt.type === 'prompt' && (tgt.data.text || '').trim()) items.push(el('button', { key: 'fav', className: 'iwb-ctx-item', onClick: () => { addPromptToLibrary(tgt.id); setCtxMenu(null) } }, I('star'), el('span', { className: 'iwb-btn-text' }, '添加该提示词')))
|
||||
items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => { const rc = e && e.currentTarget ? e.currentTarget.getBoundingClientRect() : null; setCtxMenu(null); if (UiGenCfgModule && UiGenCfgModule.openNodeBgPalette) UiGenCfgModule.openNodeBgPalette({ current: (tgt.data && tgt.data.bg) || '', anchorRect: rc, onPreview: (bg) => previewNodeBg([tgt.id], bg), onPreviewEnd: endNodeBgPreview, onPick: (bg) => updateNode(tgt.id, { bg }) }) } }, I('palette'), el('span', { className: 'iwb-btn-text' }, '背景色')), el('button', { key: 'ren', className: 'iwb-ctx-item', onClick: () => { setCtxMenu(null); wRenameNodeDialog(tgt, td, updateNode) } }, I('edit'), el('span', { className: 'iwb-btn-text' }, '重命名节点')), el('button', { key: 'del', className: 'iwb-ctx-item iwb-ctx-danger', onClick: () => { deleteNodes([tgt.id]); setCtxMenu(null) } }, I('x'), el('span', { className: 'iwb-btn-text' }, '删除该节点')))
|
||||
// 子菜单默认向上展开(底对齐入口):两组入口都在一级菜单下半区,向下会顶出视口
|
||||
@@ -8670,7 +8678,7 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
|
||||
el('div', { className: 'iwb-ctx-sep' }, null),
|
||||
),
|
||||
) : null,
|
||||
toast ? el('div', { className: 'iwb-toast iwb-toast-' + toast.type }, toast.text) : null,
|
||||
toast ? ReactDOM.createPortal(el('div', { className: 'iwb-toast iwb-toast-' + toast.type }, toast.text), document.body) : null, // portal 到 body:.iwb-overlay 是堆叠上下文,内联再高也压不过弹窗(见 tests/overlay-layer-test.js)
|
||||
preview ? ReactDOM.createPortal(el(ImagePreview, { list: (typeof preview === 'string' ? [preview] : preview.list), idx: (typeof preview === 'string' ? 0 : preview.idx), onNav: (i) => setPreview({ list: (typeof preview === 'string' ? [preview] : preview.list), idx: i }), onClose: () => setPreview(null), onFlash: (t, ty) => setNotice({ type: ty === 'err' ? 'err' : 'ok', text: t }) }), document.body) : null,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -14,8 +14,13 @@
|
||||
|
||||
- [项目工程与设计规范](standards/project-engineering-standards.md) —— 核心规则:排序 / 任务图 / API / 持久化 / 测试 / 发布 / 分层边界 / 交互契约 / 性能铁律
|
||||
- [工程规则库](standards/engineering-rulebook.md) —— 从实战沉淀的逐条工程规则(按主题聚类),实现与评审引用
|
||||
- [**设计 Token 规范**](standards/design-tokens.md) —— UI 设计语言的**唯一数值来源**:颜色/间距/字号/圆角/阴影/层级/动效 + 新增流程 + 现状审计(`node scripts/token-audit.js` 可复核)
|
||||
- [**现状架构与性能事实基线**](standards/architecture-current-state.md) —— 改性能/内存/存储前的**首读**:逐条带 `file:line` 的现状事实 + 「别乱动 / 别重试」清单
|
||||
|
||||
## 计划(进行中的执行计划)
|
||||
|
||||
- [**设计 Token 落地计划**](plans/design-tokens-rollout.md) —— M0–M6 六个里程碑、六批迁移、闸门与验收指标;配套规范见 [设计 Token 规范](standards/design-tokens.md)
|
||||
|
||||
## 变更历史
|
||||
|
||||
- [规范变更记录](history/spec-changelog.md) —— 规范的历史版本流水(数值/行为按当时口径)
|
||||
|
||||
@@ -0,0 +1,429 @@
|
||||
# 设计 Token 落地计划(Design Tokens Rollout)
|
||||
|
||||
- 版本:1.1
|
||||
- 状态:**进行中**(2026-11-23 四个决定按建议项裁定,见规范 §9;M0 执行中)
|
||||
- 上游规范:[`docs/standards/design-tokens.md`](../standards/design-tokens.md)(v1.0)
|
||||
- 审计工具:`node scripts/token-audit.js`(默认)/ `--contrast` / `--json`
|
||||
- 本计划管「怎么做、按什么顺序、怎么验收、什么时候算完」;**数值定义不在本文**,一律以上游规范为准。
|
||||
|
||||
## 0. 一句话
|
||||
|
||||
把散落在 2505 行 CSS 里的 **19 档字号 / 18 档圆角 / 30 档间距 / 52 种阴影 / 42 档层级**,收敛成一套**新模块和新插件可以直接照着写**的 token 体系,并用闸门保证它不会再散掉。
|
||||
|
||||
## 1. 三条验收目标
|
||||
|
||||
| # | 目标 | 怎么算达成 |
|
||||
|---|---|---|
|
||||
| G1 | **新代码不再写裸值** | 新增 PR 里裸 `#hex`、裸 `px`(字号/圆角/间距)为 0,由闸门强制 |
|
||||
| G2 | **改一处,全站跟随** | 改品牌色/圆角后,亮色、暗色、插件面板、官网四处同时变化,无需逐个改 |
|
||||
| G3 | **新模块/插件有明确接入路径** | 照 §5.2 的 9 步能独立完成一个面板,不需要逐像素 review |
|
||||
|
||||
## 2. 范围
|
||||
|
||||
**做**:客户端壳层与面板(`style.css`)、`src/ui-*.js` 内联样式、插件面板、官网 `site/`、外观管线(`theme-tokens.js` / `ui-appearance.js`)。
|
||||
|
||||
**不做**:画布内容色(节点自定义底色、画笔色、标注色——属用户数据);图片渲染与压缩;图标造型设计(只统一尺寸与描边);布局结构(本计划不移动任何面板位置)。
|
||||
|
||||
## 3. 里程碑总览
|
||||
|
||||
| 里程碑 | 内容 | 产出 | 预估 | 依赖 |
|
||||
|---|---|---|---|---|
|
||||
| **M0** | 决策 + 视觉基线 | 基线截图 + 4 个决定定稿 | 0.5d | ✅ 已完成 2026-11-23 |
|
||||
| **M1** | 清账 | 未定义变量清零、审计脚本入库 | 0.5d | ✅ 已完成 2026-11-23 |
|
||||
| **M2** | 色彩模型重建(D1–D9) | 对比度全绿、单一写入点 | 1.5d | ✅ 已完成 2026-11-23 |
|
||||
| **M3** | 单一源 + 导出 | `design-tokens.css`、`tokens.json` | 1d | M2 |
|
||||
| **M4** | 六批迁移 | 尺度收敛、5 套 tab 合一 | 3.5d | M3 |
|
||||
| **M5** | 闸门与治理 | `token-lint`、棘轮测试、RFC | 1d | M4 |
|
||||
| **M6** | 延展验证 | 一个新面板 + 一个插件改版 | 0.5d | M5 |
|
||||
|
||||
合计约 **8.5 人日**,分 6 个版本交付(见 §5)。M6 不是「收尾」,它是**证明这套东西真的能用**的验收环节——没做 M6 就不算完成。
|
||||
|
||||
## 4. 详细任务
|
||||
|
||||
### M0 决策与基线(0.5d)
|
||||
|
||||
| ID | 任务 | 文件 | 验收 |
|
||||
|---|---|---|---|
|
||||
| T0.1 | 定 §9 的 4 个决定(圆角 14/12、半像素字号、间距迁移方式、色彩模型修复范围) | — | 规范 §9 表格填入选择,状态改「生效」 |
|
||||
| T0.2 | 建立视觉基线:6 个场景 × 亮/暗 = 12 张 | `tests/visual-tokens.spec.js` | `npx playwright test visual-tokens` 生成 `__screenshots__/` |
|
||||
| T0.3 | 基线纳入 git(首次全部新增,不比对) | 同上 | 提交后 `--update-snapshots` 可复现 |
|
||||
|
||||
**6 个场景**:首页 / 画布(含节点与连线)/ 设置弹窗 / 图库抽屉 / 插件面板(提示词库)/ 右键菜单。
|
||||
|
||||
截图稳定化要求(否则后面「0 diff」是假的):固定 `viewport 1280×800`、`deviceScaleFactor 1`、`animations: 'disabled'`、`caret: 'hide'`、等待 `document.fonts.ready`。
|
||||
|
||||
### M1 清账(0.5d,视觉零变化 —— 已执行,2026-11-23)
|
||||
|
||||
| ID | 任务 | 位置 | 结果 |
|
||||
|---|---|---|---|
|
||||
| T1.1 | `--iwb-accent` 未定义 | `style.css:690,691` | **改为删除两条规则**:复核发现 `.iwb-btn-active` / `.iwb-layout-lock-state` 从 fork 起无 JS 生产者 → 原「按钮高亮失效」的判断作废。12 张基线 **0 diff**(说明从未影响观感) |
|
||||
| T1.2 | 自引用 fallback `var(--iwb-err, var(--iwb-err))` | `.iwb-resume-warning` | → `var(--iwb-err)` |
|
||||
| T1.3 | 6 个虚构 token(`--sp-panel/line/text`、`--rd-12`、`--fs-12/13`)换真值 | `.iwb-resume-*` | 全部等值替换 → `--iwb-panel/border/text`、`--rd-lg`、`--fs-md/lg` |
|
||||
| T1.4 | 死 token 标 `@deprecated` | `:root` | **15 个**(不是 28:`--iwb-plugin-*` 12 个是插件契约,`--iwb-surface` 单独标注),带替代名,保留到 M4 结束 |
|
||||
| T1.5 | 审计脚本 + 视觉基线入库 | `scripts/token-audit.js`、`tests/_visual-tokens.spec.js` | `audit:tokens` / `test:visual` 两个 npm script;指标从 7/28 变 **0/25** |
|
||||
|
||||
**验收**:`node scripts/token-audit.js` 的「引用了但从未定义」= **0** ✅;12 张基线 0 diff ✅。
|
||||
|
||||
**回滚**:单 commit 可 revert。
|
||||
|
||||
### M2 色彩模型重建(1.5d,**有可见变化**,独立版本发)—— ✅ 已完成 2026-11-23
|
||||
|
||||
这是整个计划里唯一「用户会发现界面变了」的阶段,所以单独发版、单独附对比图。
|
||||
逐条做法与实测数字见 `design-tokens.md` §1.8,这里只记**与计划的偏差**(计划是纸上的,执行会碰到真东西)。
|
||||
|
||||
| ID | 缺陷 | 执行结果 | 与计划的偏差及理由 |
|
||||
|---|---|---|---|
|
||||
| T2.1a | D1③ 系统跟随不重算 | ✅ 3.26.43 已修 | — |
|
||||
| T2.1 | D1 三写入者 | ✅ `.theme-dark` 颜色改为 derive 快照;结构层统一成一套 `color-mix`,`derive`/`apply` 都按同系数重算 | **没有删掉 `.theme-dark` 的颜色值**。计划说「颜色全部删,由 derive 统一写」,但那样 JS 执行前那一帧会退回 `:root` 的亮色 → 暗色用户每次启动闪白。改为「静态快照 = derive 输出」,并加守卫测试钉死 |
|
||||
| T2.2 | D3 夹错表面 | ✅ `clampAgainst(fg, surfaces, min)`,13 个表面取最差 | 表面清单比计划多(把 hover/dockBg/chrome/plugin×4 也算进去),因为它们在 `style.css` 里都承载文字 |
|
||||
| T2.3 | D4 text2 只保 3.2 | ✅ 提到 4.5 | **没有新增 `--iwb-color-text-tertiary`**:`textDim` 已经承担三级语义,多一个名字只会多一处要维护的映射 |
|
||||
| T2.4 | D5 textDim 不可读 | ✅ 退一步后夹到 3.0 | 同上,复用 `textDim` |
|
||||
| T2.5 | 节点标题在画布上 1.9:1 | ✅ 新增 `--iwb-color-text-on-canvas`(对 canvas 按 6:1 派生) | **保留 `opacity:.8`**。计划说去掉,但 opacity 同时承担「未选中 vs 选中」的视觉差异,去掉就得另找状态表达 —— 改成把对比度目标提到 6:1 抵消混色衰减,一举两得 |
|
||||
| T2.6 | D6 layer 方向翻转 + 一词多义 | ✅ `layer` 固定为 inset(两套主题都比 panel 暗);hover→`--iwb-hover`、浮层→`--iwb-bg-menu` | **`var(--iwb-layer)` 没有降到 0**(现 49 处)。计划要拆成 4 个语义并清零,但其中 chip/端口/小标签与「凹槽」是同一层,硬拆只会造出两个值几乎一样的 token。实际拆了**两条方向性错误**的(hover 会变暗、浮层会变暗),剩下的确实是 inset |
|
||||
| T2.7 | D7 品牌色退化 | ✅ `--iwb-brand` 取 seedAccent;拆 `--iwb-brand-text` | **多拆了一个 brand-text**:计划只改 `--iwb-brand` 的值,但它在暗色下当文字只有 3.9:1 —— 填充和文字是两个角色,一个值满足不了 |
|
||||
| T2.8 | D8 无状态层 | ✅ 新增 `--iwb-focus-ring`,统一 3 处 + `:where()` 兜底 | **只做了焦点环,没做 state-hover/pressed/disabled 四件套**。那四个要连带替换 36 处散落的 `color-mix(6%~16%)`,属 M4 的批量迁移;先做焦点环是因为它是「完全没有」而不是「不统一」 |
|
||||
| T2.9 | D9 暗色 24 条硬编码 | ✅ 删 8 组、改 token 3 组,剩 16 条 | 剩下 16 条全是节点预设底色(`data-bg="white|cyan|…"`)的暗色对位,是**独立于 token 的色板**,不该被 token 化 |
|
||||
|
||||
**计划外新增(执行中发现的三处层次反转)**:nodeBg 比画布暗、border 与 nodeBg 撞色、首页卡片隐身。详见 `design-tokens.md` §1.8。
|
||||
|
||||
**新增守卫**:`tests/theme-static-snapshot-test.js` —— CSS 静态快照必须等于 `derive()` 输出(58 色值 × 2 套)。
|
||||
|
||||
**验收反馈修正(同日,D10)**:老马看暗色截图后指出「暗色的这些深色框是不是可以再浅一点,现在对比度高了一些」。
|
||||
采样确认卡片 `#3d3d3d` / 下拉 `#1a1a1a` / 任务卡 `#151515`(差 33–39 级)。新增 `--iwb-field`(卡片内控件面,暗 `#494949`)
|
||||
+ 8 处节点内控件切换 + `field` 进 `textSurfaces` + `pluginInset` 提亮 + 反相主按钮文字色,卡片↔控件差降到 12 级。
|
||||
**这条说明 D6 只做对了一半**:把 `layer` 钉成「比 panel 暗」是对的,但没意识到「面板」和「节点卡片」不在同一亮度带 ——
|
||||
`layer` 只对面板成立,卡片内需要另一层语义(判据见 `design-tokens.md` §1.9)。亮色 12 张基线逐像素 0 diff。
|
||||
|
||||
**回滚**:M2 是一个 commit;`.theme-dark` 与 `:root` 的旧值都在 git 里,`git revert` 即回到「中灰暗色」。
|
||||
|
||||
|
||||
### M3 单一源与导出(1d,零观感)—— ✅ 已完成 2026-11-23
|
||||
|
||||
| ID | 任务 | 文件 | 验收 |
|
||||
|---|---|---|---|
|
||||
| T3.1 | 新建 `src/design-tokens.css`:L1(14 间距 / 6 圆角 / 8 字号)+ L2 语义 + legacy 别名;**只放静态值,无 JS** | 新增 | 变量在 DevTools 有值 |
|
||||
| T3.2 | 构建拼接:`design-tokens.css` 在 `style.css` 之前内联(Tauri 不能靠 `@import`) | `scripts/build.js` | `dist/style.css` 首段是本文件内容 |
|
||||
| T3.3 | `scripts/tokens-export.js`:解析 `design-tokens.css` → `dist/tokens.json`(DTCG `{$value,$type}`) | 新增 | JSON 可被 Penpot / Figma Variables 导入 |
|
||||
| T3.4 | 别名方向:阶段 1 legacy 为源,新名 `var(--legacy)`;文档写明阶段 2(M5 后)翻转 | `design-tokens.css` | 插件读 legacy 仍有值 |
|
||||
| T3.5 | 视觉基线零 diff | — | 12 张截图 `maxDiffPixels: 0` |
|
||||
|
||||
**执行结果(2026-11-23)**:
|
||||
|
||||
| ID | 计划 | 实际 | 偏差与理由 |
|
||||
|---|---|---|---|
|
||||
| T3.1 | `src/design-tokens.css`:L1 + L2 + legacy 别名,只放静态值 | ✅ 158 行(含 `:root` 77 条 / `.theme-dark` 39 条 / 亮色动效 6 条) | 文件头写明「生成文件勿手改」。**L1 尺度也搬进来了**(`SCALE` 表在生成器里),否则「单一源」只覆盖颜色 |
|
||||
| T3.2 | 构建时内联到 style.css 之前 | ✅ `scripts/build.js` 拼接 `design-tokens.css + style.css` 再 minify | 拼接而非复制:dist 里仍只有一个 `style.css`,`<link>` 不用改,Tauri 也不依赖 `@import` |
|
||||
| T3.3 | `scripts/tokens-export.js` 解析 CSS → `dist/tokens.json` | ✅ 合并进 `scripts/gen-tokens.js`(`--write` 同时产出 CSS 与 JSON;JSON 由**解析生成的 CSS** 得到) | 分成两个脚本会让「导出的 JSON」与「实际生效的 CSS」有两次解析口径,多一个漂移点。本仓库的规矩是「一个产物一个生成者」 |
|
||||
| T3.4 | 别名方向:阶段 1 legacy 为源 | ✅ 未翻转(插件仍读 `--iwb-plugin-*` 别名) | 与计划一致,翻转留到 M5 之后再评估 |
|
||||
| T3.5 | 12 张基线 `maxDiffPixels: 0` | ✅ 12/12 通过,零 diff | 换文件不动值,所以像素级零变化(这也反过来证明搬家没丢声明:77/39/6 条逐条比对过) |
|
||||
|
||||
**M3 的真正收益不是「文件搬家」**,而是把静态快照从**手写**变成**产物**:D1「同一批 token 有三个写入者」到此只剩
|
||||
`derive()` 一个写入者 + 两个生成产物,人不用再记「改公式要同步 CSS」(M2 期间我自己就漏过 `nodeBg` 与 `brand-text` 两次)。
|
||||
|
||||
三道闸门:`tokens:check`(进 verify:ci,报第一处差异行)、`build` 漂移即失败、`theme-static-snapshot-test`(逐 token 报错)。
|
||||
|
||||
**已知限制**:`--iwb-anim-*` 与 `--sh-*` 的暗色值是生成器里的常量表(不来自 `derive()`),因为它们是「主题皮肤」而非派生色;
|
||||
将来若要支持自定义暗色皮肤,需要把它们并入 `derive()`。
|
||||
|
||||
### M4 六批迁移(3.5d)
|
||||
|
||||
每批一个 PR,**等值替换为主**,仅 B1 有行为收敛(5 套 tab 合一)。
|
||||
|
||||
| 批次 | 范围 | 关键动作 | 预估 | 验收 |
|
||||
|---|---|---|---|---|
|
||||
| **B1 壳层** ✅ | `.iwb-tabstrip/.iwb-tab`(5 套)、`.iwb-dock-*`、`.iwb-toolbar*`、`.iwb-statusbar` | 页签收敛为 1 套(单框扁平 + 品牌高亮 + `--iwb-tab-height`);字号/圆角/间距换 token | 0.5d | 首页/画布截图;5 套类名只留 1 套 |
|
||||
| **B2 浮层** ✅ | `.iwb-modal/.iwb-fullmask/.iwb-command/.iwb-ctxmenu/.iwb-toast/.iwb-pop*` | 圆角 → `radius-panel/popover`;阴影 → `elevation-2/3/4`;z-index → `--iwb-z-*`(toast 提到 modal 之上) | 0.5d | 遮罩/弹窗层级实测:toast 在确认框之上 |
|
||||
| **B3 首页/库** ✅ | `.iwb-home-*/.iwb-lib-*/.iwb-res-*` | 间距归并(就近下取)、字号 7 档(新增 `display`) | 0.5d | 首页截图;文案换行逐条看 |
|
||||
| **B4 设置/外观** ✅ | `.iwb-settings-modal/.iwb-appear-*/.iwb-set*` | 控件统一 `control-h`(输入框与按钮等高);半像素字号清零 | 0.5d | 设置页截图 + 计算样式 diff |
|
||||
| **B5 节点** ✅ | `.iwb-node*/.iwb-gen-*/.iwb-port` | 节点卡内部表面统一 `field`(修端口黑洞)、字号 12/15 归口、圆角归并 | 1d | 画布截图 + 计算样式 diff |
|
||||
| **B6 插件** ✅ | `plugins/**` + 插件源码仓库 | 硬编码 → `--iwb-*`;`ALLOW_FILES` 逐项清零(6 → 0) | 0.5d | 契约测试白名单 4 → **0** |
|
||||
|
||||
**B1 执行结果(v3.26.44,2026-11-23)**:
|
||||
|
||||
| 项 | 计划 | 实际 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 5 套 tab → 1 套 | 合并 5 份实现 | **3 套是死代码,直接删**;活着的只有 1 套 | `iwb-drawer-tab` / `iwb-rail-tab` / `iwb-res-tab` 在 `dist/app.js` 里出现 **0 次**(抽屉已被停靠栏取代、右竖栏只剩手势排除列表里的名字、资源中心的 e2e 用例点的是不存在的元素)。收敛动作因此变成「删死规则 + 统一活着的一套」,零行为风险 |
|
||||
| 激活态 | 1 条 | 1 条:品牌 14% 底 + **主文字色** + 600(暗色加深到 22%) | 原为 tint 9% 中性底 + text。品牌淡底:亮 `#d2d3d5` 落在 `#e3e3e3` 上(差 17 级)、暗 `#2f3034` 落在 `#1e1e1e` 上(差 16 级)。文字一开始写成 `brand-text`,实测亮色只有 **4.42:1**(低于 4.5)且比未激活标签的 text2(4.46)还弱 —— 选中项不该最不清楚,改回 `--iwb-text`(亮 6.92 / 暗 10.27) |
|
||||
| 尺度 token | 新增 | 间距 13 档(px 命名)+ 圆角 6 档 + 字号 6 档 + 组件尺寸 3 个 | 砍掉计划里的 L2 别名层(`gap-*` / `pad-*`)与 8 档字号语义名,理由记在 `design-tokens.md` §3.2/§3.3 |
|
||||
| 36px 收口 | 3 处 | **6 处** | `tabstrip` 高度 + `dockarea`/`home-panel`/`landing-panel`/`canvas-topbar`/`wsrail` 的 `top`,全部改 `--iwb-chrome-h`。这条是本批最实在的收益:改标签条高度不会再漏改让位层 |
|
||||
| 壳层换 token | dock/toolbar/statusbar | 14 处(圆角/字号,等值) | 阴影与 z-index 留给 B2(B1 只做等值替换,避免和浮层那批混在一起) |
|
||||
|
||||
**验收**:12 张视觉基线 10 张变化、2 张(右键菜单)零 diff;diff 逐张看过,**只有顶部激活标签与设置侧栏选中项**,
|
||||
节点/控件/工具栏/状态栏全部零 diff(说明 D10 的卡片内控件面没被这次改动带坏)。`verify:ci` 全绿。
|
||||
|
||||
**踩到的三个坑**:
|
||||
1. `gen-tokens.js` 的块注释里写了 `--sp-*/--rd-*`,`*/` 提前闭合注释导致语法错误 —— 注释里别让 `*` 紧挨 `/`。
|
||||
2. 三处单测(`page-chrome` / `single-canvas-shell` / `left-resource-layout` / `three-page-layout`)都**钉着已删除的
|
||||
`.iwb-res-tabs` 存在**,其中两处注释还写着「已下线,钉点移除」—— 注释和断言互相矛盾,导致死 CSS 谁也不敢删。
|
||||
已全部改成「不得复活」的反向断言。
|
||||
3. 新增 token 后审计里的「定义但未引用」从 25 涨到 35:多出的 10 个是给 B2–B5 备的接口,不是死变量。
|
||||
|
||||
**B2 执行结果(v3.26.45,2026-11-23)**:
|
||||
|
||||
| 项 | 计划 | 实际 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 层级表 | 9 档、裸值归零 | **14 档**,裸值种类 42 → 31 | 只覆盖浮层族。画布内端口/手柄/浮条属局部堆叠(B5);停靠栏 20–36 是**连续值**(lib 20 / drawer 22 / rightrail 24 / wsrail 25 / nav 35 / tabstrip 36),压成 3 档等于重排队一次堆叠,收益为零。1000 段的 `home-menu(1000/1001)` 未迁移,所以 `anchor/palette/alert` 保留 3200/3300/4000 |
|
||||
| toast 层级 | 改 `z-index` 数字 | **改数字无效,改 portal** | `.iwb-overlay` 自带 `z-index:100` + `position:fixed`,是一个**堆叠上下文**:里面的 toast 写 500 也压不过 portal 到 body 的弹窗(300)。见下方「最大的坑」 |
|
||||
| 阴影 | `elevation-2/3/4` | **4 档**(补 `elevation-1` 给贴面浮条),浮层 8 种写法 → 4 | 顺带把 `--sh-*` 的 3 处引用清零,三个 legacy 名全部 `@deprecated` |
|
||||
| 圆角 | 全部换 token | 12 处,其中 11 处等值;`.iwb-pop` 18px → `radius-popover(14)` | 18px 在闭集之外且只此一处;归并后浮层圆角只剩 1 种 |
|
||||
| 视觉基线 | 12 张 0 diff | ✅ 12/12 | 阴影 alpha `.28→.18`、`pop` 圆角 18→14 都在 playwright 阈值(0.2)内 |
|
||||
| `verify:ci` | 全绿 | ✅ | 中途被 `source-text-ratchet`(`Workbench()` 行数 +1)和 `architecture-facts-guard`(单测数 118→119)拦了两次,见坑 2、3 |
|
||||
|
||||
**最大的坑:堆叠上下文让「改数字」变成假修复。**
|
||||
第一版只把 `.iwb-toast` 的 `z-index` 从 200 改成 `var(--iwb-z-toast)`(500),`verify:ci` 全绿、基线 0 diff,
|
||||
看起来完工了。写探针实测才发现:toast 的父节点是 `.iwb-overlay`,它自己带 `z-index:100` ——
|
||||
**子元素的层级被父级封住**,500 只在 overlay 内部有效,对外仍是 100,弹窗(300) 照样压着它。
|
||||
改成 `ReactDOM.createPortal(..., document.body)` 后,`elementFromPoint` 才命中 toast 本身。
|
||||
教训:`z-index` 的验收不能看「值对不对」,要看「同屏两个元素谁在上面」——不能只看 CSS,要跑命中测试。
|
||||
|
||||
**另两个坑**:
|
||||
1. 比值更隐蔽的一类:`z-index: var(--iwb-z-modal)` 若变量名拼错,声明**整条失效并静默退化成 `auto`**,
|
||||
没有报错、没有控制台警告。所以守卫测试里有一条「引用的 z token 必须存在」(M5 的 token-lint 会扩到全仓)。
|
||||
2. `source-text-ratchet-test` 按**行数**钉 `Workbench()`:加 3 行注释也算「逻辑变长」。最终把说明压成一行行尾注释,
|
||||
长解释放在守卫测试与本文里 —— 这类解释写在棘轮文件里注定被删,写在测试里才活得住。
|
||||
3. 新增单测文件会让 `CONTRIBUTING.md` 的单测计数过期,`node scripts/sync-facts.js --write` 一条命令同步。
|
||||
|
||||
**B3 执行结果(v3.26.46,2026-11-23)**:
|
||||
|
||||
| 项 | 计划 | 实际 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 死代码 | — | **删 30 条死规则 + 4 条死声明** | 25 个类名在 `dist/app.js` 里 0 次:`home-title/subtitle/new/head/kicker/card-main/card-check*/card-rename/cats/side-foot/menu-btn/menu-sep`、`lib-tabs/lib-tab/lib-handle`。另有一条 `manage` 复选框规则:批量管理 v3.22 起改成「点卡片=选中」,元素根本不渲染,样式还留着 |
|
||||
| `.iwb-lib-*` 不是死代码 | 按 B1 经验先查引用 | **是插件契约,保留并 token 化** | `plugins/promptlib` 与 `plugins/grouplib` 在外壳里直接复用宿主的 `.iwb-lib-head/body/chips/cards/searchscope` 并局部覆盖。只按 `dist/app.js` 计数会误判成死代码 —— 必须连 `plugins/**` 一起查 |
|
||||
| 间距 | 就近下取 | 91 处 → **5 处**(全是布局值) | 只留 `max(24px, calc(...))` 页面留白、`1580px` 版心、`52px` 导航让位;规范里写明「为什么这几个必须写死」 |
|
||||
| 字号 | 8 档 | **7 档**(6 + 新增 `display` 24px) | 首页主标题 26px 压到 `2xl(20)` 会与面板标题同级,层级塌掉。归并:14→`md(13)`、16→`lg(15)`、18→`xl(17)`、26→`display(24)` |
|
||||
| 视觉基线 | 12 张 0 diff | **首页 2 张变化,其余 10 张 0 diff** | 正是「只动首页/库」的期望结果;首页亮/暗各看过一遍,无裁切、无重叠、无换行错位 |
|
||||
|
||||
**做法:用「计算样式 diff」代替「肉眼看截图」。**
|
||||
改动前先用 Playwright 采一份首页 20 个关键元素的 `fontSize / padding / margin / gap / radius / height`,
|
||||
改完再采一份,逐元素比对。20 个元素里 9 个有变化,全部是预期内的(侧栏 item 38→34、主标题 26→24 等),
|
||||
没有「我没打算改却被改了」的项。截图只能告诉你「看起来不一样」,这个能告诉你**具体哪个属性从多少变成了多少**。
|
||||
B4/B5 建议照这个办法做(比逐张看截图快,也不会漏)。
|
||||
|
||||
**踩到的两个坑**:
|
||||
1. **同一属性叠了 5 层**:`.iwb-home-panel` 上有 4 条规则写 padding(`90px` / `116px … 60px` / `24px` / `72px`),
|
||||
全被后面 specificity 更高的 `.iwb-overlay .iwb-home-panel { padding: 0 }` 覆盖 —— 改数字一点反应都没有。
|
||||
这类「看起来在管布局、实际全是死声明」的叠层最费时间,靠计算样式一采就现形(padding 采出来是 `0px`)。
|
||||
2. **单测钉着像素值**:`page-chrome-regression-test` 里 `css.includes('font-size: 15px')` 这类断言,
|
||||
token 化后必红,但它真正要保护的是「卡片标题用 `lg` 档」这个层级关系。已改成钉 token 档位
|
||||
(`font-size: var(--iwb-font-lg)`),断言反而更强了。
|
||||
|
||||
**B4 执行结果(v3.26.47,2026-11-23)**:设置 / 外观。
|
||||
|
||||
| 项 | 计划 | 实际 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 死代码 | — | **删 21 条死规则** | 十四组类名在 `dist/app.js` 与 `plugins/**` 里都是 0 次:`setcell`(+hover/on/label)、`setgrid`、`setopen`、`ratio-mini(-auto)/ratio-box`、`set-page-head(-headtext)`、`set-row`(两处定义,一 grid 一 flex)、`set-row-text/desc/main/title`、`pop-anchor .setcell`、`appear-val`、`appear-note-only`。`set-row` 是插件设置页改版时被 `.iwb-mk-setrow` 取代的旧类 |
|
||||
| 控件等高 | `control-height` | **`--iwb-control-h: 30px`**,输入框 + 默认按钮共用 | 实测输入框 33px、按钮 24px,同一行差 9px。取 30:输入框竖内边距 7→6(13px 字 + 6×2 + 2 描边 = 30),按钮 24→30(`align-items:center` 自带居中) |
|
||||
| 半像素字号 | 并入整数档 | **范围内清零**(13.5×8、12.5×2) | 13.5→`md(13)`、12.5→`sm(12)`。全局还剩 16 处(备份页、右键菜单、插件市场卡),留给 B5/B6 |
|
||||
| 标题层级 | 16 归 lg 还是 xl | **归 `lg(15)`** | 与同屏 `section-title(15)` 落到同一档。原来是「标题 16 / 分节 15」两个差不多大的层级,读起来分不出主次 |
|
||||
| 假声明 | — | **删 1 条** | `.iwb-set-nav-item` 的 `padding: 7px 9px` 被 `.iwb-settings-modal .iwb-tab`(2 个类)压掉,实测一直是 8/16,改它毫无反应 |
|
||||
| 重复规则 | — | **合并 1 组** | `.iwb-appear-range` 写了两遍(`flex:1 1 0` 后又被 `flex:0 1 260px` 覆盖),只剩 `min/max-width` 生效 |
|
||||
| 视觉基线 | 12 张 | **设置弹窗亮/暗 2 张变化,其余 10 张 0 diff** | ②③ 两张都看过:无裁切、无溢出、按钮与输入框齐平 |
|
||||
| 守卫 | — | **新增 `tests/settings-scope-test.js`** | 三条不变量:控件必须共用 `control-h`、范围内禁半像素字号、9 个死类名不许复现 |
|
||||
|
||||
**这一批的坑与 B3 同源,但更隐蔽:特异性吃掉声明。**
|
||||
`.iwb-set-nav-item { padding: 7px 9px }` 读起来就是「导航项用 7/9」,但导航项同时带 `.iwb-tab` 类,
|
||||
而 `.iwb-settings-modal .iwb-tab { padding: 8px 16px }` 是两个类选择器 —— 按 specificity 赢,7/9 从未生效。
|
||||
**这类错误的特征是「改它没反应」,不是「改错值」**,只有采计算样式才看得见(B3 的 `.iwb-home-panel` 五层 padding 是同一病因)。
|
||||
规律:`{ 组件 } .{ 元素 }` 形式的覆盖规则会静默压掉 `.{ 元素 }` 上的同属性声明,写单类规则前必须先搜一遍这个元素还被谁管着。
|
||||
|
||||
**为什么 `--iwb-control-h` 只给设置页**:全局 `.iwb-input` 现在 28px(`padding: 6px 9px` + 12px 字),
|
||||
直接改成 30 会让画布、停靠栏、节点里的每个输入框都长 2px —— B4 是「几乎零观感」的批次,不该带这个。
|
||||
设置页是控件最密、且**输入框与按钮并排**的地方(别处多是纯输入或纯按钮),先在这里立规矩,
|
||||
B6 收尾时再决定全局跟不跟。
|
||||
|
||||
### B5 节点(3.26.48)执行结果
|
||||
|
||||
**计划里写的是「端口/小标签换 `bg-chip`」,实际发现没这个 token,而且诊断错了**。端口真正的问题不是缺个 chip 底,
|
||||
是它在**两个主题下往相反方向错**:亮色 `#f5f5f5` 打在 `#efefef` 卡上几乎看不见(靠 1.5px 描边撑),
|
||||
暗色 `#161616` 打在 `#3d3d3d` 卡上是一颗纯黑洞 —— 和 D10 修的「卡片内控件挖黑洞」同一个病,只是端口太小没人注意。
|
||||
|
||||
| 项 | 改前 | 改后 |
|
||||
|---|---|---|
|
||||
| 端口底色(暗色) | `#161616`(对卡片差 39 级) | `#494949`(差 12 级) |
|
||||
| 端口底色(亮色) | `#f5f5f5`(差 6 级,几乎不可见) | `#ffffff` + 1.5px `#ababab` 描边 |
|
||||
| 节点内用面板表面色的控件 | 7 处 | **0 处**(`ref-img`/`ref-single`/`upload-link`/`refmini-empty`/`task-result-img`/`node-head:hover`/端口) |
|
||||
| 范围内字号写死 | 20 处 | 0(8/10px 微缩徽标按例外保留) |
|
||||
| 范围内圆角写死 | 24 处 | 只剩 `50%` 与 `2px` 占位条 |
|
||||
| 范围内间距写死 | 70 处 | 只剩端口热区 `inset: -9px` |
|
||||
|
||||
**第二个「改数字没反应」**:浮条底是 `--iwb-panel`,子项 hover 用 `--iwb-layer2` —— 深色下两者都是 `#1c1c1c`,
|
||||
hover 完全没反馈。改成 `color-mix(text 10%, transparent)` 后两个主题都有。这类 bug 截图只能看出「好像没反应」,
|
||||
计算样式能直接给出「hover 前后 background 都是 rgb(28,28,28)」。
|
||||
|
||||
**新增守卫 `tests/node-scope-test.js`**(进 `test:unit`):节点卡内部禁 `--iwb-layer/layer2/panel` 作背景
|
||||
(浮条除外,它本身是浮层)、端口三态底色断言、节点区字号/间距/圆角必须走档位、6 个死类名不复现。
|
||||
|
||||
**验收偏差**:12 张基线里变了 **8 张**(②④⑤⑥ × 亮/暗),不是预期的 2 张 —— ④⑤⑥ 三个场景的画布背后
|
||||
也有节点,端口与标题带的改动同样会显现。逐张看过:无裁切、无重叠、无错位。
|
||||
|
||||
**本批抓到的最有价值的一条:视觉基线一直在「假绿灯」**。`toHaveScreenshot` 的 `threshold` 默认 **0.2**
|
||||
(每像素 YCbCr 距离),而 `maxDiffPixels: 0` 只约束「超阈值像素数」——两者叠加**不等于逐像素精确**。
|
||||
端口描边从 `#ababab` 改成 `color-mix(text 55%)` 后亮色只差约 19 级,正好落在 0.2 里:基线没更新、
|
||||
比对报 12/12 通过、`--update-snapshots` 也不写盘(它同样按阈值判断「有没有变」)。
|
||||
已把 `threshold` 显式压到 **0**,重生成 8 张基线后仍 12/12 通过(同机渲染是确定性的),
|
||||
「0 diff」从此名副其实。**此前各批写的「逐像素 0 diff」都应按这个口径重读**:真实含义是「没有超过 0.2 的像素」。
|
||||
|
||||
### B6 收尾(3.26.49)执行结果
|
||||
|
||||
**计划写的是「插件硬编码 → `--iwb-*`,ALLOW_FILES 逐项清零」,实际做下来发现「全部 token 化」是错的**:
|
||||
被豁免的 6 个文件根本不是一类问题,其中两个插件的颜色是**自带整套调色板的深色专业工具 UI**,
|
||||
塞进宿主 token 会毁掉设计(标注的 Catppuccin 388 处、矢量化的 77 处)。
|
||||
|
||||
| 项 | 计划 | 实际 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 白名单 | 4 → 0 | **6 项 → 0** | 计划里的「4」是早期数字,中途加过两项。逐条查过去:`style-source` / `blank-canvas` 是**过期豁免**(hex 全在 `var()` fallback 里,规则本来放行),删掉后测试照样过 |
|
||||
| 插件改造 | 硬编码 → token | **分三类,只修 1 处真问题** | 2 个删豁免;2 个在 manifest 声明 `skin:'private'`(代价:不得引用宿主颜色 token);`browser` / `batch-export` 属混合态,真正要修的只有 browser 那颗写死 `#888780` 的「连接关闭」状态点 |
|
||||
| 半像素字号 | 16 处 | **16 处清零 + 删 2 条冗余规则** | `.iwb-mk-card .iwb-mk-name` / `.iwb-mk-sub` 原本用 13.5/11.5 覆盖全局的 13/12,归并后与全局同值 —— 留着就是下一个「改它没反应」 |
|
||||
| `control-h` | B6 再决定 | **不扩全局** | 判据从「哪个更大」换成「有没有并排的另一半」:并排表单用 `control-h`,成组的紧凑控件(画布/节点/停靠栏)靠内容撑高。强行 30px 会把节点撑高 2px |
|
||||
| 守卫 | — | **契约测试重写 + 设置范围断言扩到全文件** | 新增「全局 `.iwb-input` 不得写死 height」一条;半像素从「设置范围内」收紧成「全文件」 |
|
||||
|
||||
**本批最大的认知修正:豁免不是欠的债,是没讲清的分歧。**
|
||||
|
||||
一张 `ALLOW_FILES` 把三种完全不同的情况盖在一起 —— 已经能删的、设计上就是这么干的、真混合的。
|
||||
盖在一起的结果是谁也不敢动其中任何一个,名单只会越加越长。拆开之后每种都有明确处置,
|
||||
而且「私有皮肤」从此变成**有代价的公开声明**(必须自洽,不得借宿主的颜色),比「测试别管这个文件」强得多。
|
||||
|
||||
**判据设计上的一个取舍**:强调色用 **chroma**(`max-min` of RGB ≥ 24)判断,不维护允许色表。
|
||||
表会过期(这次 6 条豁免里 2 条就是过期没删),也会被人顺手往里加;chroma 是颜色自身的属性,不需要维护。
|
||||
内容色相反,用的是**行内标记** `/*iwb:content*/` —— 同一个 `#fff` 在面板上是 bug、在画布上是内容,
|
||||
值分不出来,只能靠上下文声明。
|
||||
|
||||
**验收偏差:12 张基线变了 8 张(②④⑤⑥ × 亮/暗),不是计划里的「零」。** 含画布的四个场景里
|
||||
都有节点,`.iwb-oplog` / `.iwb-inherit-bar` / `.iwb-resource-float-title` 与右键菜单 `.iwb-ctx-item`
|
||||
的字号从半像素归到整数,文字栅格化必然改,在 `threshold: 0` 下就是差异。
|
||||
做过 A/B 回退(换回 B5 的 `style.css` → 12/12 通过)确认不是环境噪声,逐张 diff 只有文字/小图标边缘,
|
||||
没有裁切、重叠或面板位移。**结论:0.5px 归整肉眼零变化、逐像素不是零** —— 以后凡是动字号,
|
||||
不要再写「预期 0 diff」。8 张基线已重生成,复核 12/12。
|
||||
|
||||
**审计口径同步**:`token-audit.js` 的插件段从「数 hex」改成三类分开报(中性色写死 / 私有皮肤 / 强调色),
|
||||
与契约测试同口径。B6 后:中性色写死 **0**、私有皮肤 2 个、强调色 18 处。
|
||||
|
||||
**每批三条硬验收**:
|
||||
1. 亮/暗两张截图 `0 diff`(B1 例外:允许 tab 视觉变化,需人工确认)
|
||||
2. `token-audit.js` 对应计数下降
|
||||
3. `npm run verify:ci` 全绿
|
||||
|
||||
**回滚**:一批一个 commit,revert 即回。
|
||||
|
||||
### M5 闸门与治理(1d)
|
||||
|
||||
| ID | 任务 | 文件 | 规则 |
|
||||
|---|---|---|---|
|
||||
| T5.1 | `scripts/token-lint.js` | 新增 | 新增行出现裸 `#hex` / 裸 `px`(font-size、border-radius、padding、gap)→ 失败;四级白名单(内容色、布局尺寸、变量兜底、临时例外带到期版本) |
|
||||
| T5.2 | 棘轮基线 | `tests/fixtures/token-baseline.json` | 计数只降不升 |
|
||||
| T5.3 | 完整性 + 自引用 | `tests/design-token-ratchet-test.js` | `var()` 目标必须存在;禁 `var(--x, var(--x))` |
|
||||
| T5.4 | 对比度回归 | `tests/theme-contrast-test.js` | text 对 5 表面 ≥4.5;tertiary ≥3.0;on-brand ≥4.5 |
|
||||
| T5.5 | 层级规则 | token-lint | 禁裸 `z-index`;插件不得超 `--iwb-z-popover` |
|
||||
| T5.6 | 接入 `verify:ci` | `package.json` | 三条命令失败即 CI 失败 |
|
||||
| T5.7 | 流程文档落章 | `design-tokens.md` §5 | RFC 模板、9 步、弃用窗口、PR 三问 |
|
||||
|
||||
### M6 延展验证(0.5d)
|
||||
|
||||
| ID | 任务 | 验收 |
|
||||
|---|---|---|
|
||||
| T6.1 | 用 token 重做一个真实面板(建议「插件管理」分区:表格 + 卡片 + 开关,覆盖面够) | 新代码零裸值;token-lint 通过 |
|
||||
| T6.2 | 选 `plugin-batch-export`(15 处硬编码)改版并发一个 patch | 契约测试白名单移除该项;插件暗色正常 |
|
||||
| T6.3 | 把这次的两份实现写成「接入案例」附在规范 §5.2 下 | 后来者照抄即可 |
|
||||
|
||||
## 5. 发布节奏
|
||||
|
||||
| 版本 | 内容 | 观感 | 备注 |
|
||||
|---|---|---|---|
|
||||
| 3.26.43 | M0 + M1 | 仅按钮高亮恢复 | 清账,风险最低 |
|
||||
| 3.26.44 | M2 + M3 + M4-B1 | **有变化** | 附亮/暗前后对比图;单独可回滚。M3 与 B1 搭同一版:M3 零观感、B1 只有标签变化,合起来只解释一次 |
|
||||
| 3.26.45 | M4-B2 浮层 | 几乎零(阴影略软 + toast 可见性修复) | 层级表 + 阴影 4 档;toast 从「被弹窗盖住」修好,用户能感知的是「以前看不到的成功提示现在看得到」 |
|
||||
| 3.26.46 | M4-B3 首页/库 | **有变化** | 首页主标题 26→24、侧栏条目 38→34、卡片脚注更紧;同时删了 30 条死规则。用户能感知的是「首页更紧凑」,附亮/暗前后对比图 |
|
||||
| 3.26.47 | M4-B4 设置/外观 | **轻微** | 设置页正文 14→13、标题 16→15;同行输入框与按钮由「33 vs 24」变成都在 30。用户能感知的是「设置页更整齐」,不是「字变小」——13 与 15 仍在原层级里 |
|
||||
| 3.26.48 | M4-B5 节点 | **有变化(暗色改善明显)** | 端口从「黑洞」变成可见小圆点、提示词节点高度 −4px、浮条阴影统一。用户能感知的是「深色画布上端口看得见了」,附放大对比图 |
|
||||
| 3.26.49 | M4-B6 ✅ | 肉眼零,基线 8 张变化 | 收尾:16 处半像素清零、`control-h` 不扩全局(裁定)、插件契约文件级豁免 **6 → 0**。②④⑤⑥ 含画布场景因字号栅格化变化更新基线,逐张核对无错位 |
|
||||
| 3.27.7 | M5 | 零 | 闸门上线 |
|
||||
| 3.28.0 | M6 | 零 | 案例沉淀 |
|
||||
|
||||
> 前置:3.26.42(外观 v2)需先发,本计划从 3.26.43 起。
|
||||
> 插件侧:`batch-export` / `browser` / `image-vectorize` / `image-annotate` 各自在下次 patch 版本清硬编码,**不阻塞客户端**。
|
||||
|
||||
## 6. 度量看板
|
||||
|
||||
| 指标 | 基线(实测) | M4 后目标 | M6 后目标 |
|
||||
|---|---|---|---|
|
||||
| 引用但未定义的变量 | 7 | 0 | 0 |
|
||||
| 字号档数 | 19 | 7(B6 后散值 **13**:半像素已全部清零,剩 8/10 微缩徽标与画布区的 14/16/18/22/28/30,属 M5 棘轮范围;闭集 7 档已建) | 7 |
|
||||
| 圆角档数 | 18 | 5 | 5 |
|
||||
| 间距档数 | 30 | ≤16 | ≤16 |
|
||||
| 字号写死处 | 268 | ≤60(B6 后 **170**) | ≤20 |
|
||||
| 圆角写死处 | 164 | ≤40(B6 后 **103**) | ≤10 |
|
||||
| 间距写死处 | 629 | ≤200(B6 后 **415**) | ≤80 |
|
||||
| 阴影写法种类 | 52 | ≤8 | 5 |
|
||||
| z-index 取值种类 | 42 | ≤10(B2 后 **31**) | 9 |
|
||||
| `var(--iwb-layer)` 引用 | 59(一词多义) | 0(已拆) | 0 |
|
||||
| 暗色硬编码色行 | 24 | 0 | 0 |
|
||||
| text 对表面 <4.5 的格数 | 暗色 4 格 | 0 | 0 |
|
||||
| 插件契约白名单文件 | 6(文件级豁免) | 0(B6 起按角色分类:私有皮肤自声明 + 强调色 chroma 判据 + 内容色行内标记) | 0 |
|
||||
| 视觉基线 diff | 无基线 | 每批 0 | 每批 0 |
|
||||
|
||||
## 7. 风险登记
|
||||
|
||||
| 风险 | 触发信号 | 应对 |
|
||||
|---|---|---|
|
||||
| 截图基线不稳(字体/DPR/动画) | 同代码两次跑出 diff | 固定 viewport/DPR、`document.fonts.ready`、禁用动画;仍不稳则该批改为「人工双图对照」 |
|
||||
| M2 观感变化引发返工 | 老马看完说「暗色变冷了」 | M2 单独版本 + 3 个预置(默认/休息/高对比),不满意只回滚该版本 |
|
||||
| `--iwb-layer` 拆分把某个组件改坏 | B5 节点内布局错位 | 拆分先只建新 token 不改引用;按组件逐个切,一批 5 个以内 |
|
||||
| app.js 体量与源码文本棘轮(`tests/source-text-ratchet-test.js`,只减不增) | CI 报棘轮或事实守卫失败 | 本计划不往 app.js 加逻辑;D1 的 mq 改动用「派发事件 + 现有 setTheme」实现,行数不增 |
|
||||
| 事实基线守卫计数不符 | `test:facts` 失败 | 每批结束跑 `node scripts/sync-facts.js --write` |
|
||||
| 插件仓库不在本仓,改不动 | 白名单清不掉 | 先在 `plugins/` 内改运行时包并验证,再同步插件源码仓库发版 |
|
||||
| CSS 体积增长 | `dist/style.css` 超过 +8KB | L1+L2 约 60 行,实测应 <4KB;超了说明 L3 建多了 |
|
||||
|
||||
## 8. 决策依赖(卡点)
|
||||
|
||||
| 决定 | 卡住哪个里程碑 | 不定会怎样 |
|
||||
|---|---|---|
|
||||
| ① 面板圆角 14 / 12 | M4-B2 | 浮层圆角无法统一,只能维持现状三值 |
|
||||
| ② 半像素字号并入 | M4-B3/B4 | 字号档只能停在 19 |
|
||||
| ③ 间距等值 / 收敛 | M4 全部 | 迁移方式无法开工 |
|
||||
| ④ 色彩模型修全量 / 只修 D1+D3 | M2 | 只能先做 D1(唯一零观感项) |
|
||||
|
||||
## 9. 延展路径(这套体系的用途)
|
||||
|
||||
**新增一个面板**:读规范 §3 → 用 L2 token 搭 → 截图亮/暗 → 过 `token-lint` → 提 PR(三问)。预期不需要设计逐像素确认。
|
||||
|
||||
**新增一个插件**:按 §5.2 九步;只能引用 `--iwb-*` 的 L2 子集;z-index 不超 popover;自带亮/暗截图。
|
||||
|
||||
**新增一套主题(未来)**:只加 `seeds`(中性/强调/深度)+ `overrides`,不新增 token 名 —— 这是当前外观面板已经具备的能力,token 化之后它自动覆盖插件与官网。
|
||||
|
||||
**多品牌(若将来需要)**:`--iwb-brand` 由 `seedAccent` 驱动,换品牌 = 换一个 seed + 一份 `tokens.json` 覆盖,不改组件。
|
||||
|
||||
## 10. 不做
|
||||
|
||||
- 不引入 Tailwind / CSS-in-JS / Style Dictionary
|
||||
- 不重命名现有 66 个 `--iwb-*`(插件兼容优先)
|
||||
- 不做 Figma 双向同步(只单向导出 `tokens.json`)
|
||||
- 不为每个组件建 L3 token(白名单制,≥2 消费者)
|
||||
- 不在本计划里调整任何布局结构或交互流程
|
||||
|
||||
## 11. 节奏
|
||||
|
||||
每批结束只问三个问题:**截图 diff 是不是 0 / 计数有没有降 / verify:ci 绿不绿**。三个都过就进下一批,不过就停在原地修——不带着已知偏差往前推。
|
||||
|
||||
## 附 A:产出物清单
|
||||
|
||||
| 文件 | 作用 | 阶段 |
|
||||
|---|---|---|
|
||||
| `docs/standards/design-tokens.md` | 规范(数值唯一来源) | 已完成 v1.0 |
|
||||
| `docs/plans/design-tokens-rollout.md` | 本计划 | 本文 |
|
||||
| `scripts/token-audit.js` | 现状审计 / 对比度复核 | 已完成 |
|
||||
| `tests/visual-tokens.spec.js` | 12 张视觉基线 | M0 |
|
||||
| `src/design-tokens.css` | L1+L2 单一源 | M3 |
|
||||
| `scripts/tokens-export.js` + `dist/tokens.json` | 设计侧导入 | M3 |
|
||||
| `scripts/token-lint.js` | 新增裸值拦截 | M5 |
|
||||
| `tests/design-token-ratchet-test.js` | 计数只降不升 | M5 |
|
||||
| `tests/theme-contrast-test.js` | 对比度回归 | M2→M5 |
|
||||
|
||||
## 附 B:命令速查
|
||||
|
||||
```bash
|
||||
node scripts/token-audit.js # 现状审计
|
||||
node scripts/token-audit.js --contrast # 对比度矩阵 + 静态/派生差异
|
||||
node scripts/token-audit.js --json # 机器可读(闸门基线)
|
||||
npx playwright test visual-tokens # 视觉基线
|
||||
npm run verify:ci # 全量门禁
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(image-workbench-web)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = a40c038`(线上 `v3.26.37+a40c038` —— **未上线**(本地测试中):左右停靠栏配色对齐主色调(新增 `--iwb-dock-bg` 进灰阶 ramp + 头部深一档 + `.iwb-pcard` 补白底)+ 修 `Cargo.toml`/`Cargo.lock` 版本漂移,四处统一到 3.25.58)。上一条 3.25.30:线上实际运行提交是 docs 提交 `7df9dc4`,bump 提交为 `4be78c0`;2026-11-16 已发**测试站 + 正式站**,三地址一致 + `IWB_VERIFY_STRICT=1` 通过。v3.24.85 是「代码体检收口」(棘轮收回 Workbench 3090→2998 + 图库索引 4 条绕过锁的写路径收口到 `mutate` + 文档数字校准),`stable` / `stable-v3.24.85` / `stable-verified-2026-11-16` 均指向 `7df9dc4`。上一条 —— 2026-11-14 发**测试站 + 正式站** `https://test.image-workbench-web.pages.dev`:**v3.24.84 修「生图节点连了 3 条上游只出 1 个任务」**(任务 id 与去重基准改用新字段 `ownerNodeId`=本节点自己,不再用随继承冒泡的 `sourceNodeId` ⇒ 连几条线就几个任务;`relay` 仍归约到真实文本来源,同一来源多路径抵达只算一次)。上一条 v3.24.83:**修「插件节点冷启动退化成一段文本」**(插件节点体是异步注册的,`registerNodeType` 在 `render` 由无变有时自增 `NODE_TYPES_REV`,`NodeCard` 比它 ⇒ 注册那一刻重建一次;`canvas-normalize` 按命名规则把 `plugin:<id>:<variant>` 认作已知类型,不再降级成 `plugin` 并写回存档);配套插件 `style-source` 1.3.2 把节点体样式改为**脚本执行时注入**(此前只在面板 `mount()` 注入 ⇒ 从存档直接进画布时节点无样式、缩略图按原图铺满)。上一条 v3.24.82 同批:提示词/文本节点**显示上游继承文本**(自己 `data.text` 为空时把上游那段话显示在框里,改一个字即接管,另有「恢复跟随」清空回跟随;多路上游按 Y 轴取第一条)+ 修 `nodeRefsOf` 的 textout 分支只认 llm/batch/combine 上游导致「样式 → 文本 → 分层」丢参考图;再上一条 v3.24.81:① 插件节点可自定义节点体(`render(node, props, host)` 画真实 DOM,宿主不每帧重建 ⇒ 输入框不失焦);② 节点自带参考图(`data.refOn/refUrl` ⇒ 任务图里补伪参考图,坐标取节点自身 ⇒ 仍参与「图片按 X 轴排序」);③ 连线白名单按 `data.outKind === 'prompt'` 归一化,7 条规则一次放行,内置节点行为逐字不变。上一条 v3.24.80 = 离开页面的兜底保存不递增 rev(2026-11-14 07:20 补发 —— 首发 11-13 23:25 撞 Cloudflare Workers API 事故 `503 no healthy upstream`,期间正式站保持在 `v3.24.79+8598a57` 未动)。v3.24.83 的 bump 提交即 `0a27a42`(v3.24.82 为 `ef6cf42`、v3.24.81 为 `dba71e3`);主干 HEAD 会继续前进,见 [`RELEASES.md`](../RELEASES.md))| 历史分支 `refactor/architecture` / `feat/multi-canvas-tabs` / `refactor/state-store` 已于 2026-10-20 清理(内容均已并入 main,归档标签 `archive/*`),本文**计数类事实**已按 main HEAD 复算。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = c81a107`(线上 `v3.26.49+c81a107` —— 2026-11-23 **M4-B6 收尾**:`style.css` 剩余 16 处半像素字号全清零(守卫收紧为全文件断言)、`--iwb-control-h` 裁定不扩到全局控件(并排表单 vs 成组紧凑控件);插件主题契约重写,`ALLOW_FILES` 文件级豁免 **6 → 0** —— 改为「私有皮肤 manifest 自声明 `skin` + chroma 强调色判据 + 内容色行内标记」,声明私有皮肤的插件不得引用宿主颜色 token;同步 4 个插件版本,插件侧中性色写死归零;视觉基线 8 张因字号栅格化变化更新,A/B 回退确认非环境噪声;上一条 `v3.26.48+cb9cb9c` —— **M4-B5 节点**:节点卡内部表面统一 `--iwb-field` —— 端口底色从 `#161616`(暗色对卡片差 39 级,一颗黑洞)改 `#494949`(差 12 级),同病灶另 6 处(ref-img/ref-single/upload-link/refmini-empty/task-result-img/node-head:hover)一并改;浮条与任务卡 hover 改 `color-mix(text 10%)`(原来 panel 与 layer2 深色同色,hover 无反馈);字号 12/15/11/13 全归档位、圆角 8/6/5/14 归并、间距 52 处等值 + 13 处 1px 级微调;删 6 个死类名;新增 `tests/node-scope-test.js` 钉「节点内禁用面板表面色」;上一条 `v3.26.47+f5c8174` —— **M4-B4 设置/外观**:新增 `--iwb-control-h`(30px) 修「同行输入框 33px / 按钮 24px」的 9px 落差;设置页正文 14→13、标题 16→15,范围内半像素字号清零;删 21 条死规则(setcell/setgrid/set-row/appear-val 等);新增 `tests/settings-scope-test.js` 钉「控件等高 / 死类名不复现 / 引用的 token 必须存在」;上一条 `v3.26.46+9f29996` —— 2026-11-23 **M4-B3 首页/库**:删 30 条零生产者规则(25 个类名在产物里 0 次)+ 4 条被 specificity 覆盖的死声明,`style.css` 2391→2339 行;首页/库 106 条规则换 token,间距写死 91→5(只剩版心与导航让位的布局值)、字号写死清零,新增 `--iwb-font-display:24px` 第 7 档;验收改为「计算样式逐元素 diff + 12 张基线只首页 2 张变化」;上一条 `v3.26.45+968ff46` —— **M4-B2 浮层层级表 + 阴影四档**:14 档 `--iwb-z-*`(裸 z-index 取值种类 42→31)、`--iwb-elevation-1..4`(浮层 8 种阴影写法→4 档)、`.iwb-pop` 圆角 18→`radius-popover(14)`;修「弹窗里点保存看不到提示」—— 根因不是层级数字而是 `.iwb-overlay` 本身就是堆叠上下文,toast 改为 portal 到 `body`;新增 `tests/overlay-layer-test.js` 钉 9 条顺序约束;上一条 `v3.26.44+846a59b` —— **设计 token 体系重建**:D1–D9 色彩模型改为真正的深色(#121212 底 / 正文 #e3e3e3、13 个表面逐层相对派生 + 对比度生成期夹紧)、D10 新增 `--iwb-field` 卡片内控件面(暗色不再在灰卡上挖黑洞)、M3 单一源(`derive()` → `design-tokens.css` + `tokens.json`,`tokens:check` 进 CI);**安装包已本地构建,NAS 尚未上传**);上一条 `v3.26.41+2b8e337`:继承态提示词把上游文案与参考图交给组合/连接节点(来源判定加 `(edges, nodes)`,组合拼接逻辑零改动);再上一条 `v3.26.40+d9e3d84`:左右停靠栏配色对齐主色调(新增 `--iwb-dock-bg` 进灰阶 ramp + 头部深一档 + `.iwb-pcard` 补白底)+ 修 `Cargo.toml`/`Cargo.lock` 版本漂移,四处统一到 3.25.58)。上一条 3.25.30:线上实际运行提交是 docs 提交 `7df9dc4`,bump 提交为 `4be78c0`;2026-11-16 已发**测试站 + 正式站**,三地址一致 + `IWB_VERIFY_STRICT=1` 通过。v3.24.85 是「代码体检收口」(棘轮收回 Workbench 3090→2998 + 图库索引 4 条绕过锁的写路径收口到 `mutate` + 文档数字校准),`stable` / `stable-v3.24.85` / `stable-verified-2026-11-16` 均指向 `7df9dc4`。上一条 —— 2026-11-14 发**测试站 + 正式站** `https://test.image-workbench-web.pages.dev`:**v3.24.84 修「生图节点连了 3 条上游只出 1 个任务」**(任务 id 与去重基准改用新字段 `ownerNodeId`=本节点自己,不再用随继承冒泡的 `sourceNodeId` ⇒ 连几条线就几个任务;`relay` 仍归约到真实文本来源,同一来源多路径抵达只算一次)。上一条 v3.24.83:**修「插件节点冷启动退化成一段文本」**(插件节点体是异步注册的,`registerNodeType` 在 `render` 由无变有时自增 `NODE_TYPES_REV`,`NodeCard` 比它 ⇒ 注册那一刻重建一次;`canvas-normalize` 按命名规则把 `plugin:<id>:<variant>` 认作已知类型,不再降级成 `plugin` 并写回存档);配套插件 `style-source` 1.3.2 把节点体样式改为**脚本执行时注入**(此前只在面板 `mount()` 注入 ⇒ 从存档直接进画布时节点无样式、缩略图按原图铺Line truncated
|
||||
<!-- 2026-10-28 P1 拆分批 1:新增 src/generation-task-graph.js(5 个任务图纯函数自 app.js 迁出)
|
||||
⇒ 模块数 60→61、耦合面 51→52、sourceModules 60→61。耦合面只**新增** IWBWTaskGraph,无删除。
|
||||
2026-10-28 P1 拆分批 2:新增 src/storage-config-shape.js(9 个配置形状纯函数自 app.js 迁出)
|
||||
|
||||
@@ -0,0 +1,886 @@
|
||||
# 设计 Token 规范(Design Tokens)
|
||||
|
||||
- 规范版本:1.0.0(已定稿)
|
||||
- 状态:**生效**(2026-11-23 按 §9 建议项 A/A/A/A 裁定;新代码从即日起按本文写)
|
||||
- 适用范围:`style.css`、`src/ui-*.js` 内联样式、`plugins/**`、`site/**`(官网)
|
||||
- 定位:**UI 设计语言的唯一数值来源**。任何颜色、间距、字号、圆角、阴影、层级、动效的取值,以本文为准
|
||||
- 复核方式:`node scripts/token-audit.js`(只读,随时可跑,数字与本文 §1 对齐)
|
||||
- 落地计划:[`docs/plans/design-tokens-rollout.md`](../plans/design-tokens-rollout.md)(M0–M6,含批次、验收、闸门)
|
||||
|
||||
## 0. 与其它文档的关系
|
||||
|
||||
| 文档 | 管什么 | 与本文的边界 |
|
||||
|---|---|---|
|
||||
| 本文 `design-tokens.md` | **数值**:有哪些 token、值是多少、怎么加、怎么改 | 新增/修改任何视觉数值,先改这里 |
|
||||
| `project-engineering-standards.md` §12.4 | **行为**:tab 必须单框扁平、预览图必须同时约束宽高 | 引用本文的 token,不重复定义值 |
|
||||
| `plugin-theme.md` | **插件契约**:插件只能用哪几个变量 | 是本文 L2 层的「插件子集」 |
|
||||
| `architecture-current-state.md` | **事实基线**:行号、性能实测 | 本文的数字来自 `token-audit.js`,不手写 |
|
||||
|
||||
冲突判定:**事实基线 > 本文 > 行为规范 > 历史留档**。但「设计该长什么样」以本文为准。
|
||||
|
||||
---
|
||||
|
||||
## 1. 调研结论(实测,可复核)
|
||||
|
||||
### 1.1 五个硬事实
|
||||
|
||||
| 指标 | 实测值 | 说明 |
|
||||
|---|---|---|
|
||||
| `style.css` 规模 | 2505 行 | 单文件承载全部 UI 样式 |
|
||||
| 自定义属性定义 | 83 个 | 被 `var()` 引用 63 个 |
|
||||
| **引用了但从未定义** | **0 个**(M1 前 7 个) | 原为 `--iwb-accent` `--sp-panel` `--sp-line` `--sp-text` `--rd-12` `--fs-12` `--fs-13`,2026-11-23 全部清零 |
|
||||
| 定义了但从未引用 | 28 个 | 含 `--sp-1..5`、`--rd-sm/md/lg`、`--fs-xs/md/lg/xl` 等 |
|
||||
| 尺寸 token 采用率 | **约 0.5%** | `--sp-*` 被引用 **0 次**;`--rd*` 3 次、`--fs-*` 4 次、`--sh-*` 3 次,而写死的间距 644 处、圆角 164 处、字号 281 处 |
|
||||
|
||||
**结论:项目不缺 token,缺的是「token 被当成唯一写法」这件事。** 已经有一套 `--sp-*` / `--rd-*` / `--fs-*` / `--sh-*` 在 `:root` 里躺了十几个版本,几乎没有一行代码用它。
|
||||
|
||||
### 1.2 尺度离散度(这才是「设计语言不统一」的量化证据)
|
||||
|
||||
| 尺度 | 取值种类 | 实际分布 |
|
||||
|---|---|---|
|
||||
| 字号 | **19 档** | 8 / 10 / **10.5** / 11 / **11.5** / 12 / **12.5** / 13 / **13.5** / 14 / 15 / 16 / 17 / 18 / 22 / 26 / 28 / 30 / 34 |
|
||||
| 圆角 | **18 档** | 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 11 / 12 / 14 / 16 / 18 / 20 / 22 / 999 |
|
||||
| 间距 | **30 档** | 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 12 / 14 / 16 / 18 / 20 / 22 / 24 / 26 / 30 / 31 / 40 / 42 / 52 / 64 / 72 / 90 / 92 / 96 / 116 / 120 |
|
||||
| z-index | **42 档** | 0…9999(含 3200 / 3300 / 4000 / 9999) |
|
||||
| box-shadow | **52 种写法** | 79 处声明 |
|
||||
| 颜色 | hex 127 + rgba 77 | 颜色层是唯一「token 化程度较高」的层(≈70%) |
|
||||
|
||||
半像素字号(10.5 / 11.5 / 12.5 / 13.5)在 Windows 100% 缩放下必然发虚——这不是审美问题,是渲染问题。
|
||||
|
||||
### 1.3 七个具体缺陷(带行号,可直接改)
|
||||
|
||||
| # | 位置 | 问题 | 后果 |
|
||||
|---|---|---|---|
|
||||
| 1 | `style.css:690,691`(已删,见 §1.7) | 用 `var(--iwb-accent)`,全仓无此定义 | 深层问题比「颜色失效」更彻底:`.iwb-btn-active` / `.iwb-layout-lock-state` **从 fork 起就没有任何 JS 生产者**(`git log -S` 可查)。所以它不是用户可见 bug,而是两条**永不生效的死规则**。已随 M1 删除 |
|
||||
| 2 | `style.css:1034,1038,1046` | 引用 `--sp-panel` `--sp-line` `--sp-text` `--rd-12` `--fs-12` `--fs-13`(全未定义) | 靠 fallback 兜着,等于「绕过主题的硬编码」:暗色下这几处不跟随 |
|
||||
| 3 | `style.css:1046` | `color: var(--iwb-err, var(--iwb-err))` 自引用 fallback | 声明无意义;这类写法应被闸门拦掉 |
|
||||
| 4 | `1276` / `650` / `528` / `804` / `1317` | **五套 tab**:`.iwb-tab` r7、`.iwb-drawer-tab` r8 + 边框 + active 用 `--iwb-layer` 底、`.iwb-lib-tab` r8 带下边框、`.iwb-rail-tab` r8 + brand 14% 底、`.iwb-res-tab` r8 | 同一产品里「页签选中」有 4 种视觉表达;`.iwb-drawer-tab` 已**违反** §12.4「单框扁平 + 品牌色高亮」 |
|
||||
| 5 | `288` / `437` / `826` / `2108` | 同为浮层,圆角 12 / 12 / 12 / 10,阴影三种:`0 4px 16px rgba(0,0,0,.12)`、`0 8px 30px rgba(0,0,0,.25)`、`0 18px 60px rgba(0,0,0,.32)` | 浮层「高低」看不出层级逻辑;硬编码黑在暗色下完全失效 |
|
||||
| 6 | `2011` / `1734` / `1956` / `580` | z-index 9999(确认框)/ 4000(崩溃页)/ 3300(调色板)/ toast 仅 200 | **toast 会被确认框和调色板盖住**;插件可任意插入任意层 |
|
||||
| 7 | `plugins/**` + `tests/plugin-theme-contract-test.js` | 契约测试的 `ALLOW_FILES` 把 image-annotate、image-vectorize、batch-export、browser **整文件豁免** | 规则对最重要的四个插件失效;白名单成了永久免死金牌。**B6 已解决**:文件级豁免清零,改为「私有皮肤自声明 + 角色分类」,见 §3.10 |
|
||||
|
||||
### 1.4 插件与官网
|
||||
|
||||
- 插件侧共 14 个文件、引用 `var(--iwb-*)` **363 次**——说明插件**愿意**跟随主题,障碍在「没有可用的数值规范」,缺的正是 `--iwb-radius-*` / `--iwb-font-*` / `--iwb-gap-*` 这几组。
|
||||
- 官网 `site/assets/style.css` 只有 5 个变量(`--fg` `--line` `--muted` `--soft` `--radius`),与客户端**零共享**。改一次品牌色要改两处 → 这就是「对外一套、对内一套」的根源。
|
||||
|
||||
---
|
||||
|
||||
### 1.5 现有色彩模型的结构性缺陷(比「缺尺度 token」更严重)
|
||||
|
||||
`theme-tokens.js` 的模型本身是对的(seed → derive → clamp)。问题在**前提假设**:它假设「一套 token 只有一个表面、只有一个写入者」。这两个假设都不成立。
|
||||
|
||||
#### D1 同一批 token 有三个写入者,没有单一事实源
|
||||
|
||||
`:root`(`style.css:3`)、`.theme-dark`(`style.css:88`)、`applyTo()` 写 inline(`theme-tokens.js:144`)都在写同名变量。inline 优先级最高 ⇒ JS 跑过之后,前两处全是被压制的死值,但没人删,也没人知道它们已经无效。
|
||||
|
||||
两个可复现的后果:
|
||||
|
||||
1. **首屏闪变**。`--iwb-chrome` / `--iwb-dock-bg` / `--iwb-home-bg` 在 CSS 里用 `color-mix(bg, canvas)` 算一遍(`style.css:9,13,23`),在 JS 里用 `mix(surface3, canvas, .45)` 再算一遍(`theme-tokens.js:116-120`)——**两套公式**。首帧是 CSS 的值,apply 之后跳到 JS 的值。
|
||||
2. **系统外观切换不重算**。`app.js:3497` 的 `matchMedia` 监听只调 `applyTheme()`,而 `applyTheme`(`app.js:3485`)只 `toggle('theme-dark')`、不碰 React state;重算只挂在 `useEffect([config, theme])`(`app.js:6143`)。`applyTheme` 不改 state ⇒ effect 不重跑 ⇒ **日落自动转暗后,class 变了、inline token 还是旧值**,界面配色不变。
|
||||
|
||||
#### D2 同名 token 两套值(静态 vs 派生)
|
||||
|
||||
| token | `:root`/`.theme-dark` 静态 | `derive()` 默认种子 | 差异 |
|
||||
|---|---|---|---|
|
||||
| `--iwb-bg`(暗) | `#757575` | `#121212` | 中灰 vs 近黑 |
|
||||
| `--iwb-panel`(暗) | `#a5a5a5` | `#1c1c1c` | 同上 |
|
||||
| `--iwb-layer2`(暗) | `#b0b0b0` | `#1c1c1c` | 后者与 panel 同值 |
|
||||
| `--iwb-text`(暗) | `#111111` | `#888888` | **深字 vs 浅字** |
|
||||
| `--iwb-brand`(亮) | `#4d5668`(= text2) | `#6b7280` | 品牌色两值 |
|
||||
| `--iwb-err`(亮) | `#e5484d` | `#ef4444` | 两套红 |
|
||||
|
||||
静态那套是「中灰底 + 深字」(dim gray),派生那套是「近黑底 + 浅字」(true dark)。**同一个「暗色」名下有两位数的色差**,切主题等于换设计。
|
||||
|
||||
#### D3 文字对比度只对 `bg` 一个表面夹紧
|
||||
|
||||
`derive()` 里 `clampText(textBase, surface0, 4.5)` —— 只对 `bg` 校验,但 `--iwb-text` 实际出现在 8 个表面上。实测(默认种子):
|
||||
|
||||
| 表面 | 亮色 text | 暗色 text |
|
||||
|---|---|---|
|
||||
| bg | 5.05 | 5.28 |
|
||||
| panel | 5.36 | 4.81 |
|
||||
| layer | 4.96 | **3.94** |
|
||||
| layer2 | 5.41 | 4.81 |
|
||||
| nodeBg | 4.75 | **4.38** |
|
||||
| canvasBg | **3.17** | **3.67** |
|
||||
| pluginSurface | 4.96 | **4.43** |
|
||||
| pluginCard | 5.36 | **3.94** |
|
||||
|
||||
暗色下有 4 个表面低于 4.5:1。这是「夹紧对象选错」的必然结果,不是种子没调好。
|
||||
|
||||
#### D4 `--iwb-text2` 只保证 3.2:1,却是用得最多的文字色
|
||||
|
||||
`clampText(..., 3.2)`。实测亮色 3.28–3.74、暗色 2.74–3.67。它在 `style.css` 里被引用 **181 次**,是标签、节点标题、次要信息的默认色。12px 正文不适用 WCAG 的「大字号」豁免 ⇒ 这 181 处按 AA 全部不达标。
|
||||
|
||||
**最直观的一处**:`.iwb-node-title`(`style.css:180`)是 `color: var(--iwb-text2); opacity: .8`,而节点标题带画在**画布**上(`bottom:100%`、`background:transparent`)。于是:
|
||||
|
||||
- 亮色:`text2` 对 `canvasBg` = **2.19:1**,再乘 0.8 不透明度 ≈ **1.9:1**
|
||||
- 暗色:**2.55:1** → 约 **2.2:1**
|
||||
|
||||
节点标题是画布上被读得最多的字,它现在是「灰雾」。这不是审美偏好,是可测的失败。
|
||||
|
||||
#### D5 `--iwb-textDim` 实际不可读
|
||||
|
||||
`textDim = mix(text2, surface0, 0.35)`。亮色对 bg **2.12:1**、暗色 **2.25:1**。用在占位符与说明文字上,等于「设计上写了的字,用户看不见」。
|
||||
|
||||
#### D6 `layer` 的层次语义在暗色下翻转
|
||||
|
||||
| | panel | layer | 关系 |
|
||||
|---|---|---|---|
|
||||
| 亮色 | `#fefefe` | `#f5f5f5` | layer 更暗 = 内嵌 |
|
||||
| 暗色 | `#1c1c1c` | `#2c2c2c` | layer 更亮 = 凸起 |
|
||||
|
||||
同名 token 在亮/暗下表达相反的层次。组件只要用 `--iwb-layer` 做「内嵌块」,暗色下就变成「浮起块」;hover 用 layer 的组件同样反向。
|
||||
|
||||
#### D7 品牌色退化成次要文字色
|
||||
|
||||
静态 `--iwb-brand: var(--iwb-text2)`(`style.css:32`)。于是「主按钮底色」「选中描边」「焦点色」与「次要文字」同值 ⇒ 层级压缩,`color-mix(brand 14%)` 做出来的高亮和 `color-mix(text2 …)` 视觉等价。配合 D2,品牌色还有两个值。
|
||||
|
||||
#### D8 没有状态层,也没有焦点环
|
||||
|
||||
现有只有 `--iwb-hover` 一个状态值;`pressed` / `disabled` / `selected` / `focus` 四个状态没有 token ⇒ 各组件自己发明(`color-mix(--iwb-brand …)` 36 处、`color-mix(--iwb-text …)` 4 处,比例 6%/7%/12%/14%/16% 各不相同)。**全仓没有任何 focus ring token**,键盘导航无视觉反馈。
|
||||
|
||||
#### D9 暗色是靠 24 条硬编码补丁堆出来的,不是靠派生
|
||||
|
||||
`.theme-dark` 共 49 条规则,其中 **24 条直接写死色值**(`style.css:1519 #e0e0e0`、`1526 #1a1a1a`、`1531 #111`、`1533 #ff5f5f`、`1855` 用 `#0f0f0f` 混色、`2266` 用 `#fff 88%`…),只有 5 条走变量。
|
||||
|
||||
后果:**自动配色/自定义种子只对亮色完整生效**。用户改了种子切到暗色,这 24 处仍是写死的灰 —— 这就是「两套外观系统」体感的真正来源(不是外观面板的问题,是暗色有一半是手绘的)。
|
||||
|
||||
#### D10 卡片内的控件面没有独立语义,暗色下被算成「黑洞」
|
||||
|
||||
`--iwb-panel`(#1c1c1c) 与 `--iwb-layer`(#161616) 都是**贴着应用底色**派生的,用途是「面板」与「面板里的凹槽」。
|
||||
但节点卡片是画布派生的 `--iwb-node-bg`(#3d3d3d) —— 两者不在同一亮度带。
|
||||
|
||||
后果:`#3d3d3d` 的卡片里嵌入 `#1c1c1c` 的下拉框、`#161616` 的任务卡,灰阶差 33–39 级。
|
||||
亮色下看不出来,因为 panel(#fefefe) 与 nodeBg(#efefef) 本来就在同一带(差 15 级,且是「白底上浅灰」)。
|
||||
暗色这套算出来的不是「凹槽」,是「在同一张卡片上挖了六个洞」——用户第一眼给出的判词就是这个(2026-11-23)。
|
||||
|
||||
> **判据**:控件的光学重量应该由**它所在的那张卡片**决定,不是由应用底色决定。
|
||||
> 所以「嵌套在卡片里的控件面」必须相对 `nodeBg` 派生,和 `nodeBg` 相对 `canvas` 派生是同一条原则。
|
||||
|
||||
修法见 §1.9:新增 `--iwb-field`(亮=`#ffffff`,暗=`nodeBg` 往白 6% = `#494949`)。
|
||||
|
||||
### 1.6 结论:优化是必要的,但顺序要反过来
|
||||
|
||||
> **执行状态(2026-11-23)**:下表九条已全部修复,做法与实测数字见 §1.8。本节保留为「为什么必须先修色彩模型」的论证。
|
||||
|
||||
| 缺陷 | 性质 | 加尺度 token 能解决吗 |
|
||||
|---|---|---|
|
||||
| D1 三写入者 / 系统切换不重算 | 架构 + 可见 bug | 不能 |
|
||||
| D3 对比度夹错表面 | 算法 bug | 不能 |
|
||||
| D4 text2 3.2:1 用 181 次 | 规范红线定错 | 不能 |
|
||||
| D5 textDim 2.12:1 | 算法参数错 | 不能 |
|
||||
| D6 layer 语义反转 | 语义定义缺失 | 不能 |
|
||||
| D7 品牌色退化 | 值定义错 | 不能 |
|
||||
| D8 缺状态层/焦点环 | 层缺失 | 不能 |
|
||||
| D9 暗色 24 条硬编码补丁 | 派生未覆盖 | 不能 |
|
||||
| D10 卡片内控件面缺语义(暗色黑洞) | 语义分层缺失 | 不能(§1.9 已修) |
|
||||
| 字号/圆角/间距离散 | 层缺失 | **能**(§3) |
|
||||
|
||||
**所以优先级应为:先修色彩模型(D1–D9),再统一尺度(§3)。** 反过来的话,会把 30 档间距迁到一套「暗色下正文不达标、内嵌块方向相反」的配色上,等于把错误标准化。
|
||||
|
||||
### 1.7 M1 清账执行记录(2026-11-23)
|
||||
|
||||
| 动作 | 位置 | 处理 |
|
||||
|---|---|---|
|
||||
| `--iwb-accent` 两条规则 | `style.css` `.iwb-toolbar-bottom .iwb-btn-active` / `.iwb-layout-lock-state` | **删除**。复核发现两个类从 fork 快照起就没有 JS 生产者,属上游遗留死选择器 —— 「按钮高亮失效」的判断作废,改为「规则永不生效」 |
|
||||
| 6 个虚构 token | `.iwb-resume-bar` / `.iwb-resume-text` / `.iwb-resume-warning` | `--sp-panel→--iwb-panel`、`--sp-line→--iwb-border`、`--sp-text→--iwb-text`、`--rd-12→--rd-lg`(12px)、`--fs-13→--fs-lg`(13px)、`--fs-12→--fs-md`(12px),**全部等值** |
|
||||
| 自引用 fallback | `.iwb-resume-warning` | `var(--iwb-err, var(--iwb-err))` → `var(--iwb-err)` |
|
||||
| 死 token 标注 | `:root` 第一代尺度 token | 15 个(`--sp-1..5`/`--rd-sm|md|lg`/`--fs-xs|md|lg|xl`/`--sh-sm`/`--tr-base|slow`)加 `@deprecated` + 替代名,**保留定义**到 M4 结束 |
|
||||
| `--iwb-surface` | `:root` | 标 `@deprecated` 并注明「derive() 不写它,一用就是暗色纯白底」 |
|
||||
|
||||
清账后审计:**引用未定义 = 0**(原 7)、定义未引用 25(原 28,因 `--rd-lg`/`--fs-md`/`--fs-lg` 转为在用)。
|
||||
|
||||
**D1 的第一刀(系统跟随)同批修掉**:`app.js` 的 `matchMedia` 回调原本只 `toggle('theme-dark')`,不重算
|
||||
写在 `<html>` 上的内联 token,而重算挂在 `useEffect([config, theme])`、`theme` 恒为 `'system'` 不会变 ⇒
|
||||
日落自动转暗后出现「壳层暗、画布亮」的混色半成品。改法:回调里补一次 `iwb:theme-change` 事件广播,
|
||||
由该 effect 订阅后原地重跑 `applyAppearance`(行数零增长)。实测:切暗后 `--iwb-bg` 由 `#f7f7f7` → `#121212`,
|
||||
切回亮色同样即时。D1 的另外两刀(删 `.theme-dark` 颜色、把 chrome/dock 公式从 JS 挪回 CSS)依赖 D9,
|
||||
留在 3.26.44。
|
||||
说明:**`--iwb-plugin-*` 那 12 个「未被 style.css 引用」的变量不是死 token**,它们是插件契约(`theme-tokens.js` 写、`plugins/**` 读),审计脚本的单文件口径会误判,已在 §7 的验收里注明口径。
|
||||
|
||||
### 1.8 M2 色彩模型修复执行记录(2026-11-23,v3.26.44)
|
||||
|
||||
九条缺陷全部落地。**这是本计划唯一一批「用户能看出变化」的改动**,单独占一个版本号。
|
||||
|
||||
| 缺陷 | 修法 | 结果 |
|
||||
|---|---|---|
|
||||
| **D1** 三写入者 | ①`:root`/`.theme-dark` 改成 derive 的**静态快照**(同一套值,只用来顶住 JS 执行前那一帧);②结构层 `chrome/homeBg/dockBg/dockHeadBg` 统一成 CSS `color-mix` 一套公式,`derive()` 与 `ui-appearance.apply()` 都按同一系数重算;③暗色块不再重复定义结构层(让 `:root` 的公式在 `html` 上重新求值) | 三处公式变一处;首屏不再跳变 |
|
||||
| **D2** 同名两套值 | `.theme-dark` 从「中灰底 #757575 + 深字 #111」改为 derive 的暗色快照(近黑 + 浅字) | 切主题不再是「换了个产品」 |
|
||||
| **D3** 只对 bg 夹紧 | 新增 `clampAgainst(fg, surfaces, min)`:文字对 **13 个承载表面**取最差者夹紧(bg/panel/inset/layer2/panel/nodeBg/hover/dockBg/chrome/plugin×4) | 暗色正文最低从 3.94 → **7.11** |
|
||||
| **D4** text2 只保 3.2 | 提到 4.5(AA 正文),`RATIO.text2` | 亮 4.60 / 暗 4.68(原 3.49 / 3.34) |
|
||||
| **D5** textDim 2.12 | 从 text2 退一步再夹到 3.0(AA 大字下限) | 亮 3.25 / 暗 3.14(原 2.12 / 2.25) |
|
||||
| **D6** layer 语义反转 | `layer` 固定为「内嵌/凹槽」语义,两套主题都**比 panel 暗**(暗色 .66→.83);hover、浮层、胶囊从 `layer` 里拆出来,分别用 `--iwb-hover` / `--iwb-bg-menu` | 57 处引用重新归类:5 hover、3 浮层、其余仍是内嵌 |
|
||||
| **D7** 品牌色退化 | `--iwb-brand` 恢复为强调色种子 `#6b7280`;另拆 `--iwb-brand-text`(按对比度夹紧,暗色 #a6aab2),34 处「文字/图标」引用点切换 | 主按钮与次要文字不再同值 |
|
||||
| **D8** 无焦点环 | 新增 `--iwb-focus-ring`(2px,走 brand-text),统一 3 处各自发明的焦点样式,并用 `:where()` 低权重兜底补齐所有可聚焦元素 | Tab 走查不再出现 Chromium 默认蓝环 |
|
||||
| **D9** 24 条暗色硬编码 | 能删的删(顶栏 `#e0e0e0` 6 组、status-err、input `#111`)、方向错的改 token(hover 白底→`color-mix(text 12%)`、nav 选中反色、logotext→`text-dim`)、`.iwb-task-refinfo` 的亮色硬编码 `#8a93a6` 也一并改 `text-dim` | 49 条规则里剩 16 条,全部是**节点预设底色的暗色对位**(`data-bg="white|cyan|…"`),与 token 无关,合理保留 |
|
||||
|
||||
**同批修掉三个此前没人发现的层次反转**(都是「同一个 token 在两套主题里方向相反」的变体):
|
||||
|
||||
1. **节点比画布暗**:`nodeBg` 与 `canvas` 各自独立 mix,暗色算出 `#242424` < 画布 `#313131` —— 卡片看着是凹进去的。改成相对画布派生(亮 72% / 暗 6% 往白走),`depth` 拉到 0/60 两端都保证浮起。
|
||||
2. **`border` 与 `nodeBg` 撞色**:改完 nodeBg 后两者都是 `#3d3d3d`,暗色节点边框直接消失。暗色 `border` 系数 0.52 → 0.60(`#333333`)。
|
||||
3. **首页卡片隐身**:`homeBg` 暗色算出 `#1d1d1d`,比 panel `#1c1c1c` 还亮,于是卡片 52/48 混完等于背景。改 `homeBg` 暗色分支(0.35→0.12)+ 卡片改用浮起层 `--iwb-bg-menu`。
|
||||
|
||||
**新增 4 个 token**(都进了静态快照与守卫):
|
||||
|
||||
| token | 语义 | 亮 | 暗 |
|
||||
|---|---|---|---|
|
||||
| `--iwb-brand-text` | 品牌色的文字/图标版(按对比度夹紧) | `#575d69` | `#a6aab2` |
|
||||
| `--iwb-color-text-on-canvas` | 画布上的文字(对 canvas 按 6:1 派生,抵消 `opacity .8`) | `#404040` | `#b2b2b2` |
|
||||
| `--iwb-bg-menu` | 浮层底(右键菜单/更多菜单/确认框/首页卡片) | `#fefefe` | `#3c3c3c` |
|
||||
| `--iwb-focus-ring` | 键盘焦点环(`color-mix` 表达式,随主题) | 由 `brand-text` 派生 | 同左 |
|
||||
|
||||
**新增守卫 `tests/theme-static-snapshot-test.js`**:逐值比对 CSS 静态快照与 `derive()` 输出(58 个色值 × 亮暗两套)。
|
||||
它在本批里当场抓到两处我自己漏同步的地方(暗色 `nodeBg` 与 `brand-text`),这正是这道守卫存在的意义 ——
|
||||
「改派生公式忘同步 CSS」是这套双写模型最容易犯的错,靠人记是记不住的。
|
||||
|
||||
**已知限制**:`depth` 拉到 60 且暗色时,画布 `#676767` / 节点 `#707070` 都处在中等亮度,text(7:1) 与 text2(4.5:1) 的可选区间被压到接近纯白(`#f6f6f6` / `#f4f4f4`),层级感会变弱。默认 `depth=22` 不受影响。
|
||||
|
||||
### 1.9 验收反馈修正:暗色「黑洞方框」(2026-11-23,同版本内)
|
||||
|
||||
用户看暗色截图的原话:**「暗色的这些深色框是不是可以再浅一点,现在对比度高了一些」**。
|
||||
实测采样(524×177 的节点截图,像素级确认):卡片 `#3d3d3d`、下拉框 `#1a1a1a`、任务卡 `#151515` —— 差 33–39 级。
|
||||
|
||||
| 改动 | 内容 | 数值 |
|
||||
|---|---|---|
|
||||
| 新增 `--iwb-field` | 「卡片内的控件面」:跟随 `nodeBg` 派生,暗色比节点**亮**一档(D10) | 亮 `#ffffff` / 暗 `#494949`(`nodeBg #3d3d3d` + 往白 6%) |
|
||||
| 8 处节点内控件切换 | `.iwb-task`、`.iwb-gen-cell .iwb-input`、`.iwb-gen-settings` 的 input/pick/summary、`.iwb-node .iwb-input`(组合节点的分隔符 select 等)、`.iwb-out-group-card`、`.iwb-out-prog`、`.iwb-combine-src`、`.iwb-batch-src` | 卡片↔控件差从 33–39 级降到 **12 级**,靠 1px `#333` 描边定边界 |
|
||||
| `field` 进 `textSurfaces` | 控件变亮后,暗色正文必须重新夹紧(否则正文只剩 5.9:1) | text `#d1d1d1→#e3e3e3`、text2 `#aaaaaa→#bababa`、textDim `#8a8a8a→#989898`、brandText `#a6aab2→#b6bac0`;实测 7.02 / 4.64 / 3.12 |
|
||||
| `pluginInset` 暗色提亮 | `#101010`(对插件卡片 `#2c2c2c` 差 28 级,搜索框是黑窟窿)→ 从 `panel` 往下 10% | `#191919`(差 19 级,仍是凹槽) |
|
||||
| 修 `.iwb-node .iwb-btn-primary` 的文字色 | 反相按钮(底=文字色)却用 `--iwb-on-brand`(#fff) 做字 → 白字压浅灰 | 改 `--iwb-bg`:亮 9.4:1 / 暗 13.9:1(「生成」从几乎看不见到可读) |
|
||||
| 亮色不变的保证 | `field` 亮色取纯白(原输入框就是 `#fefefe`,差 1 级) | 亮色 12 张基线 **逐像素 0 diff**(Playwright 阈值 0.2 内) |
|
||||
|
||||
**新增使用规则(写进 M3 的 token 文档)**:
|
||||
|
||||
- 控件在**面板/弹窗/抽屉**里 → 用 `--iwb-layer` / `--iwb-layer2`(凹槽语义不变)。
|
||||
- 控件在**节点卡片**里 → 必须用 `--iwb-field`。判据不是「凹陷还是凸起」,而是「它贴在哪张卡片上」。
|
||||
|
||||
### 1.10 M4-B2 浮层收敛执行记录(2026-11-23,v3.26.45)
|
||||
|
||||
范围:`.iwb-modal / .iwb-fullmask / .iwb-command / .iwb-ctxmenu / .iwb-toast / .iwb-pop* / .iwb-ws-more`。
|
||||
产出:层级表 14 档(§3.6)+ 阴影 4 档(§3.5)+ 圆角全走 §3.4。
|
||||
|
||||
**最重要的一条不是 token,而是「改了数字也压不过」**:
|
||||
|
||||
> `.iwb-toast` 原本挂在 `.iwb-overlay`(`z-index:100`)内部。`z-index` 只在**同一堆叠上下文**里比大小,
|
||||
> 而 `.iwb-overlay` 自带 `z-index` + `position:fixed`,本身就是一个堆叠上下文 —— 里面的 toast 写 200、
|
||||
> 写 500、写 5000 都一样,整个子树被封在 100 这一层,压不过 portal 到 `body` 的弹窗(300)。
|
||||
> 所以「弹窗里点保存看不到提示」这条**只改 CSS 治不好**,必须 `ReactDOM.createPortal(..., document.body)`。
|
||||
> 实测(`document.elementFromPoint` 命中 toast 矩形中心):portal 前拿到遮罩,portal 后拿到 toast 自己。
|
||||
|
||||
| 项 | 计划 | 实际 | 说明 |
|
||||
|---|---|---|---|
|
||||
| 圆角 → `radius-*` | 全部替换 | 12 处等值替换;`.iwb-pop` 的 `18px` → `radius-popover(14)` | 18px 在 6 档闭集之外,且只此一处;4px 差值肉眼不可辨,归并后浮层圆角只剩 1 种 |
|
||||
| 阴影 → `elevation-2/3/4` | 3 档 | **4 档**(多了 `elevation-1` 给贴面浮条),浮层族 8 种写法 → 4 档 | 顺便让 `--sh-*` 引用归零(3 处全换掉),三个 legacy 名进 `@deprecated` |
|
||||
| z-index → `--iwb-z-*` | 9 档 | **14 档**,裸值种类 42 → 31 | 只覆盖浮层族;画布内端口/手柄是局部堆叠(B5),停靠栏 20–36 是连续值(压成 3 档等于重排队),见 §3.6 偏差 |
|
||||
| toast 提到 modal 之上 | 改 CSS 数字 | **改数字无效** → 改 portal | 见上;`tests/overlay-layer-test.js` 同时钉「数字顺序」和「必须 portal」两件事 |
|
||||
| 视觉基线 12 张 0 diff | 每批 0 | ✅ 12/12 通过 | 阴影 alpha 从 `.28` → `.18`、`.iwb-pop` 圆角 18→14 都在阈值内;`--iwb-z-*` 除 toast 外全部等值 |
|
||||
|
||||
**新增守卫**:`tests/overlay-layer-test.js`(进 `test:unit`)—— 层级表存在性、9 条顺序约束、
|
||||
浮层族禁裸 `z-index`、引用必须存在、toast 必须 portal。这条测试替换掉的是一类**没有报错的错**:
|
||||
`z-index` 拼错变量名时会静默退化为 `auto`,只在特定操作顺序下露馅。
|
||||
|
||||
### 1.11 M4-B5 节点执行记录(2026-11-23,v3.26.48)
|
||||
|
||||
范围:`.iwb-node* / .iwb-gen-* / .iwb-port / .iwb-relay / .iwb-lod-* / .iwb-ref-* / .iwb-task-*`(205 条规则)。
|
||||
|
||||
**这一批把 D10 的原则推到了最细的部件上**。端口是典型:
|
||||
|
||||
| 主题 | 改前 | 改后 | 结果 |
|
||||
|---|---|---|---|
|
||||
| 暗色 | `--iwb-layer` = `#161616` 打在节点卡 `#3d3d3d` 上 | `--iwb-field` = `#494949` | 差 39 级(黑洞)→ 12 级(凸起小圆点) |
|
||||
| 亮色 | `#f5f5f5` 打在 `#efefef` 卡上,靠 1.5px 描边才勉强看见 | `#ffffff` | 从「几乎不可见」到「白点带描边」 |
|
||||
|
||||
同一个病灶在节点内还有 6 处,一并改成 `field`:`.iwb-ref-img` / `.iwb-ref-single` /
|
||||
`.iwb-ref-url-row .iwb-ref-upload-link` / `.iwb-refmini-empty` / `.iwb-task-result-img` /
|
||||
`.iwb-node-head:hover`(标题带画在画布上)。
|
||||
|
||||
**另一类是「改数字没有反应」**:浮条底色是 `--iwb-panel`,子项 hover 用 `--iwb-layer2` ——
|
||||
深色下两者都是 `#1c1c1c`,hover 完全没有反馈。改为 `color-mix(text 10%, transparent)`:
|
||||
亮色压出浅灰、暗色提亮一档,两个主题都有反馈。`.iwb-task-btn-wait` 同理(它贴在 `field` 卡上)。
|
||||
|
||||
**第三条教训:换完填充还要看描边**。端口底色换成 `field` 后仍是「糊成一团」—— 描边用的是
|
||||
`--iwb-border2`,深色下是 `#4d4d4d`,与新的填充 `#494949` 几乎同色,1.5px 等于没有描边。
|
||||
12px 的小圆点只能靠 12 级填充差自我定义,边缘是软的。改为 `color-mix(text 55%, transparent)`:
|
||||
亮 `#828282` / 暗 `#9e9e9e`,对填充各 4.6:1 / 3.4:1(非文字元素红线 3:1)。
|
||||
**规则**:小尺寸元素(≤16px)的边界不能靠填充差,必须有独立可辨的描边;而 `border2` 这类
|
||||
「比描边再亮一档」的 token 在暗色下可能和填充撞车,换填充时必须连带验一次描边对比度。
|
||||
|
||||
| 项 | 计划 | 实际 |
|
||||
|---|---|---|
|
||||
| 节点内字号 | 12 / 15 归口 | 12→`sm`、15→`lg`、11→`xs`、13→`md`(**全部等值**,零观感);8/10px 微缩徽标保留(闭集最低档 11 会撑破 12px 角标) |
|
||||
| 圆角 | 走 `--iwb-node-radius` | 节点本体本来就走它(用户可调);其余 8px→`control`、6/5px→`chip`、14px→`popover`,只剩 `50%`(圆)与 `2px`(占位条) |
|
||||
| 端口/小标签换 `bg-chip` | 换 `bg-chip` | **没有这个 token**,且端口真正的问题是「比卡片暗 39 级」而不是「缺个 chip 底」→ 改用 `field`,hover/选中态用 `color-mix(brand 18%, field)`;描边另改 `color-mix(text 55%)`(见上) |
|
||||
| 间距归并 | 就近下取 | 52 处等值、13 处微调(1 的倍数级),最大一处是提示词节点体 `14px 18px → 12/16`(节点高度 −4px) |
|
||||
| 阴影 | 走 `elevation-*` | 浮条 `rgba(15,23,42,.12)` → `elevation-2`;节点选中/连接态的内联 `0 6px 20px rgba(0,0,0,.25)` → `elevation-2` |
|
||||
| 死规则 | — | 删 6 个类名 / 6 条规则:`gen-sizerow` `gen-qualityrow` `gen-tag` `size-x` `size-align` `size-badge`(尺寸/质量 UI 已并入图像设置浮层) |
|
||||
|
||||
**新增守卫**:`tests/node-scope-test.js`(进 `test:unit`)——① 节点卡内部禁 `--iwb-layer/layer2/panel`
|
||||
作背景(浮条除外,它是浮层);② 端口三个态的底色断言;③ 节点区字号/间距/圆角必须走档位;
|
||||
④ 6 个死类名不复现。第 ① 条是这一批的根因,写成断言比写进文档有效 —— 下一个加节点内控件的人
|
||||
会在 CI 上被拦,而不是在暗色截图里被用户发现。
|
||||
|
||||
## 2. 目标架构
|
||||
|
||||
### 2.1 三层模型(与 Primer / Ant Design v5 / Radix 同一套骨架)
|
||||
|
||||
```
|
||||
L1 Primitive ── 值,无名无语义。只有尺度和色阶,闭集,不许随意加
|
||||
│ --iwb-space-8: 8px --iwb-radius-8: 8px --iwb-font-12: 12px
|
||||
▼
|
||||
L2 Semantic ── 角色,唯一被业务代码消费的一层
|
||||
│ --iwb-gap-md: var(--iwb-space-8)
|
||||
│ --iwb-radius-card: var(--iwb-radius-8)
|
||||
│ --iwb-font-body: var(--iwb-font-12)
|
||||
▼
|
||||
L3 Contract ── 组件整体换肤时才加,能不建就不建
|
||||
--iwb-tab-height: 28px --iwb-control-height: 30px
|
||||
```
|
||||
|
||||
**纪律**:组件代码只允许引用 **L2**(插件只能引用 L2 的插件子集);L1 只在 L2 的定义里出现;L3 必须有 ≥2 个消费者才允许存在。
|
||||
|
||||
### 2.2 命名规则
|
||||
|
||||
```
|
||||
--iwb-{层}-{类别}-{角色}[-{状态}]
|
||||
```
|
||||
|
||||
| 类别 | L1(值名) | L2(角色名) | 示例 |
|
||||
|---|---|---|---|
|
||||
| 色 | `--iwb-c-{hue}-{step}` | `--iwb-color-{bg\|text\|border\|icon}-{role}` | `--iwb-color-bg-panel` |
|
||||
| 间距 | `--iwb-space-{值}` | `--iwb-gap-{xs\|sm\|md\|lg}` / `--iwb-pad-{control\|card\|panel}` | `--iwb-gap-md` |
|
||||
| 字号 | `--iwb-font-{值}` | `--iwb-font-{caption\|label\|body\|title…}` | `--iwb-font-body` |
|
||||
| 圆角 | `--iwb-radius-{值}` | `--iwb-radius-{control\|card\|panel\|popover\|pill}` | `--iwb-radius-card` |
|
||||
| 阴影 | `--iwb-elevation-{0..4}` | 同 L1(够用) | `--iwb-elevation-2` |
|
||||
| 层级 | `--iwb-z-{名}` | 同 L1 | `--iwb-z-modal` |
|
||||
| 动效 | `--iwb-dur-{fast\|base\|slow}` `--iwb-ease-{standard\|out}` | 同 L1 | `--iwb-dur-base` |
|
||||
|
||||
**为什么 L1 用值名不用语义名**:`--iwb-space-8` 不会撒谎,`--iwb-space-small` 会长歪(半年后「small」变成 12px)。
|
||||
|
||||
### 2.3 兼容策略:只增不改,别名过渡
|
||||
|
||||
现有 66 个平铺变量(`--iwb-text` `--iwb-panel` …)**不改名、不删值**——插件已经在用(363 次引用),改名等于让所有已装插件崩配色。
|
||||
|
||||
过渡方式(两阶段):
|
||||
|
||||
```css
|
||||
/* 阶段 1:legacy 是源,新名是别名。JS 仍然写 legacy,新代码读新名 */
|
||||
--iwb-panel: #ffffff; /* theme-tokens.js 写入 */
|
||||
--iwb-color-bg-panel: var(--iwb-panel); /* 新代码用这个 */
|
||||
|
||||
/* 阶段 2(S3 之后):翻转,新名是源,legacy 是别名。插件零改动 */
|
||||
--iwb-color-bg-panel: #ffffff;
|
||||
--iwb-panel: var(--iwb-color-bg-panel);
|
||||
```
|
||||
|
||||
关键点:**两阶段里两组变量同时存在且值相同**,所以任何时刻都不会出现「插件读到空值」。这是本文最重要的约束。
|
||||
|
||||
### 2.4 参考了谁、取了什么、丢了什么
|
||||
|
||||
| 来源 | 取的 | 不取的 | 理由 |
|
||||
|---|---|---|---|
|
||||
| **W3C DTCG**($value/$type/别名) | JSON 交换格式;构建期导出 `dist/tokens.json` 给设计侧 | 不引入完整 token 工具链 | 团队规模不需要 Style Dictionary |
|
||||
| **Radix Colors**(12 阶灰) | 「面板/卡片/内嵌/边框」四层不是拍脑袋,而是色阶的固定位置 | 不引入 12 阶全套 | 现有 4 层已够用,扩阶反而增加选择成本 |
|
||||
| **VS Code**(语义 ID + 用户覆盖) | **语义 ID 稳定 + 默认值可被用户覆盖** 的双层模型——与 `ui-appearance.js` 的 seeds/overrides 完全同构 | 不做主题 JSON 插件化 | 已有外观面板 |
|
||||
| **Ant Design v5**(seed → map → alias) | 「派生 = 算法,静态 = token」的职责分离 | 不做 CSS-in-JS | 项目是原生 CSS |
|
||||
| **Primer / Polaris** | 弃用窗口(≥2 个版本)+ 例外必须登记 | 不做组件级 token 全覆盖 | 组件 token 会爆炸 |
|
||||
|
||||
---
|
||||
|
||||
## 3. Token 清单
|
||||
|
||||
### 3.1 颜色(L2,代码唯一可用层)
|
||||
|
||||
现状 66 个平铺名保留为 legacy;下表是**新代码必须使用**的名字。`外观面板` 列标「可覆盖」的,用户在「外观」里能改,改完仍走同一条 `derive → overrides` 管线。
|
||||
|
||||
> ✅ **下表的名字自 v3.26.44 起全部存在**(`src/theme-tokens.js` 的 `derive()` 生成,实际值见
|
||||
> `src/design-tokens.css` 或 `dist/tokens.json`)。颜色仍以 `--iwb-*` 平铺名为主 —— legacy 长期保留,
|
||||
> **插件契约引用它们,不能删**;尺度层新代码用 §3.2–§3.5 的语义名,不要再新增平铺名。
|
||||
|
||||
| L2 token | 亮色默认 | 暗色默认 | 用在哪 | 外观面板 |
|
||||
|---|---|---|---|---|
|
||||
| `--iwb-color-bg-app` | `#f4f5f7` | `#757575` | 页面底 | 可覆盖 |
|
||||
| `--iwb-color-bg-canvas` | `#d9dbde` | `#6f6f6f` | 画布 | 可覆盖 |
|
||||
| `--iwb-color-bg-panel` | `#ffffff` | `#a5a5a5` | 面板/弹窗/菜单 | 可覆盖 |
|
||||
| `--iwb-color-bg-card` | 同 panel | 同 panel | 卡片、列表项 | 可覆盖 |
|
||||
| `--iwb-color-bg-inset` | `#f0f1f4` | `#9c9c9c` | 输入框、分组底 | 可覆盖 |
|
||||
| `--iwb-field` | `#ffffff` | `#494949` | **卡片内**一切面:输入框/下拉/任务卡/输出组,以及节点上的端口、引用图占位、标题带 hover;卡片外用 bg-inset | 否 |
|
||||
| `--iwb-color-bg-hover` | `#ececec` | 派生 | 行/卡 hover | 可覆盖 |
|
||||
| `--iwb-color-bg-selected` | `color-mix(brand 14%)` | 同 | 选中行 | 随品牌 |
|
||||
| `--iwb-color-text-primary` | `#1c2333` | `#111111` | 主文字 | 可覆盖 |
|
||||
| `--iwb-color-text-secondary` | `#4d5668` | `#2f2f2f` | 次要文字(≥3.2:1) | 可覆盖 |
|
||||
| `--iwb-color-text-tertiary` | `#7b8494` | 派生 | 说明/占位(≥3:1) | 可覆盖 |
|
||||
| `--iwb-color-text-on-brand` | `#ffffff` / `#1c2333` | 同 | 品牌底上的字(自动按对比度选) | 否 |
|
||||
| `--iwb-color-border` | `#d5d9e0` | `#4f4f4f` | 常规描边 | 可覆盖 |
|
||||
| `--iwb-color-border-strong` | `#b9bfca` | `#404040` | 强调描边/连线 | 可覆盖 |
|
||||
| `--iwb-color-brand` | `#6b7280` | `#1a1a1a` | 按钮/选中/端口 | 可覆盖 |
|
||||
| `--iwb-color-err` `-ok` `-warn` | `#e5484d` `#2f9e5f` `#d97706` | 提亮一档 | 语义状态 | 否 |
|
||||
| `--iwb-color-tint` | = text-primary | 同 | **半透明底/描边的基色**,刻意不跟随文字覆盖 | 否 |
|
||||
| `--iwb-color-node-text` `-node-text-2` | = text-primary/secondary | 同 | 节点内文字(与界面文字分家) | 可覆盖 |
|
||||
|
||||
**对比度红线**(`theme-tokens.js` 已实现夹紧,规范化为硬要求):
|
||||
|
||||
- 正文对所在表面 ≥ **4.5:1**;次要文字 ≥ **3.2:1**;非文字元素(边框/图标)≥ **3:1**
|
||||
- 品牌底上的字由 `contrast()` 自动选黑/白,**禁止手工指定**
|
||||
|
||||
#### 3.1.1 单一源与产物(M3)
|
||||
|
||||
颜色只有一个源:`src/theme-tokens.js` 的 `derive()`。它派生出两份产物,**都不许手改**:
|
||||
|
||||
| 产物 | 用途 | 生成 |
|
||||
|---|---|---|
|
||||
| `src/design-tokens.css` | 静态快照(`:root` / `.theme-dark` / 亮色动效 / 尺度 L1),顶住 JS 执行前那一帧 | `npm run tokens:write` |
|
||||
| `dist/tokens.json` | DTCG(`{$value,$type}`)导出,可导入 Penpot / Figma Variables;暗色值在 `$extensions.com.image-workbench.dark` | 构建时自动写 |
|
||||
|
||||
三道闸门:
|
||||
|
||||
1. `npm run tokens:check`(在 `verify:ci` 里)—— 快照与 `derive()` 不一致就失败,并指出第一处差异行;
|
||||
2. `npm run build` —— 漂移时直接构建失败(杜绝发出去的包用旧色板);
|
||||
3. `tests/theme-static-snapshot-test.js` —— 逐 token 比对(60 个色值 × 亮暗),报错能指到具体 token。
|
||||
|
||||
**尺度层(间距/圆角/字号/阴影/动效)也只写一次**:在 `scripts/gen-tokens.js` 的 `SCALE` 表里,产物同样进 `design-tokens.css`。
|
||||
|
||||
### 3.2 间距
|
||||
|
||||
**已落地(v3.26.44,M4-B1)**:13 档闭集,变量名直接用像素值 —— `--iwb-space-12` 一眼知道是 12px;
|
||||
序号命名(`--iwb-space-3`)得背表,所以不采用。
|
||||
|
||||
```
|
||||
--iwb-space-2:2px 4:4px 6:6px 8:8px 10:10px 12:12px 16:16px
|
||||
--iwb-space-20:20px 24:24px 32:32px 40:40px 48:48px 64:64px
|
||||
```
|
||||
|
||||
值来自 `scripts/gen-tokens.js` 的 `SCALE` 表(改值改那里,再 `npm run tokens:write`)。
|
||||
`0` 直接写 `0`,不设 token。
|
||||
|
||||
> **与初版计划的偏差(砍掉 L2 别名层)**:原计划还有 `--iwb-gap-2xs/xs/sm/md/lg/xl` +
|
||||
> `--iwb-pad-control/panel` 八个语义别名。落地时**没做** —— 每个尺寸多一个别名意味着查一次要跳两层,
|
||||
> 而本仓库已经在维护 66 个 legacy 平铺名,再加 8 个只会更难记。语义留给**组件级** token
|
||||
> (`--iwb-tab-h` / `--iwb-chrome-h`),那才是真正会复用的东西;`pad-control / pad-panel`
|
||||
> 等到 B4 做设置页控件时再评估(那时才知道真实的内边距分布)。
|
||||
|
||||
**归并映射**(迁移时照这张表替换,规则:**就近下取**,避免布局变大):
|
||||
|
||||
`1→2` `3→4` `5→6` `7→6` `9→8` `11→12` `14→12` `18→16` `22→24` `26→24` `31→32` `42→40` `52→48` `72→64`
|
||||
|
||||
> `90/92/96/116/120` 不是间距,是**布局尺寸**(侧栏宽、面板高)。它们不进 token,归 `--iwb-layout-*` 且必须写明「为什么是这个数」。
|
||||
|
||||
**B3 落地(v3.26.46)**:首页/库 106 条规则全量换 token,范围内写死的间距值从 91 处降到 **5 处**,
|
||||
剩下 5 处都是布局尺寸,不是节奏值:
|
||||
|
||||
| 保留值 | 位置 | 为什么必须写死 |
|
||||
|---|---|---|
|
||||
| `max(24px, calc((100vw - 1580px) / 2))` ×2 | `.iwb-home-panel, .iwb-landing-panel` 左右留白 | 内容最大宽 1580 的响应式算式,改成 token 反而看不出「1580 是什么」;`24px` 是窗口窄时的最小留白 |
|
||||
| `1580px` ×2 | 同上 | 内容版心宽度,属布局 |
|
||||
| `52px` ×1 | `.iwb-overlay.iwb-view-home .iwb-home-side { margin-left }` | 对齐一级导航栏宽度(`.iwb-navrail` 52px),不是一个间距 |
|
||||
|
||||
> 这一批**执行了收敛**(就近下取),没有按 §9-③ 的「先等值替换」走 —— 因为只换写法而不换值,
|
||||
> 30 档散值会原封不动留在代码里,「13px 的 gap 和 14px 的 padding 并存」这类问题看不见也治不了。
|
||||
> 已核对的观感变化:侧栏 item 38→34px、侧栏左右内边距 14→12、卡片脚注 18→16、首页主标题 26→24。
|
||||
> 值都往小走,没有出现「挤出一行 / 文字换行」。验收方式是**计算样式逐元素 diff**(见下)。
|
||||
|
||||
#### 3.2.1 组件级尺寸(B1 新增)
|
||||
|
||||
这类 token 不属于「间距/字号」通用尺度,而是**某个组件的固有尺寸**。它们存在的理由只有一个:
|
||||
**同一个数被多处写死过,漏改一处就错位**。
|
||||
|
||||
| token | 值 | 谁在用 | 为什么必须共享 |
|
||||
|---|---|---|---|
|
||||
| `--iwb-chrome-h` | 36px | `.iwb-tabstrip` 高度;`.iwb-dockarea`/`.iwb-home-panel`/`.iwb-landing-panel`/`.iwb-canvas-topbar`/`.iwb-wsrail` 的 `top` | 标签条高度一变,**6 处让位层**必须同时变,否则内容被标签条压住或露出空隙 |
|
||||
| `--iwb-tab-h` | 28px | `.iwb-tab` 高度 | 标签高度 |
|
||||
| `--iwb-tab-radius` | 7px | `.iwb-tab`、`.iwb-dock-btn`、`.iwb-dock-ghost` 圆角 | 小控件统一的圆角档 |
|
||||
|
||||
### 3.3 字号 / 行高 / 字重
|
||||
|
||||
**已落地(v3.26.44,M4-B1)**:6 档。**v3.26.46(M4-B3)补第 7 档 `display`**。
|
||||
|
||||
| token | 值 | 归并掉 | 用途 |
|
||||
|---|---|---|---|
|
||||
| `--iwb-font-xs` | 11px | 10, 11.5 | 状态栏、徽标、辅助信息 |
|
||||
| `--iwb-font-sm` | 12px | 12.5 | **默认正文 / 标签**(UI 里出现最多) |
|
||||
| `--iwb-font-md` | 13px | 13.5, **14** | 面板正文、列表项、工具栏标题 |
|
||||
| `--iwb-font-lg` | 15px | 14, 15.5, **16** | 小标题、节点标题、卡片标题 |
|
||||
| `--iwb-font-xl` | 17px | 16, 17.5, **18** | 面板标题、侧栏标题、图标字形 |
|
||||
| `--iwb-font-2xl` | 20px | 18, 19, 22 | 页面大标题 |
|
||||
| `--iwb-font-display` | 24px | **26, 28, 30** | 展示级标题:页面/视图主标题(全仓 ≤5 处) |
|
||||
|
||||
> **为什么补第 7 档(B3 归并 26px 时定的)**:首页主标题原本 26px,压到 `2xl(20)` 会与面板标题同级,
|
||||
> 页面层级直接塌掉(用户看到的是「标题变小了」而不是「变整齐了」)。`display` 只给**页面级**标题用,
|
||||
> 与 `2xl`(区块级)隔一档;全仓当前只有 26/28/30px 三处候选,不构成新的散值来源。
|
||||
> 反向约束:**`display` 不许用在卡片、面板、列表里**,只出现在「这个视图叫什么名字」的位置。
|
||||
|
||||
> **与初版计划的偏差**:原计划 8 档语义名(`caption/label/body/body-lg/title-sm/title/heading/display`)。
|
||||
> 落地改为 6 档 + 短名,原因同上(两层名字增加查找成本)。B3 归并结论:**14→`md`、16→`lg`、18→`xl`**
|
||||
> (18 是侧栏标题与图标字形,向上取到 20 会让侧栏标题比导航项大太多,所以走 17);设置页的 16px 标题
|
||||
> 按同一规则归 `lg`,B4 里若观感变差再单独提。
|
||||
>
|
||||
> **B4 已执行这条待定项**:设置页 `16px` 标题(工具条标题、插件设置页标题)统一归 `lg(15)`,
|
||||
> 与同屏的 `section-title(15)` 落到同一档 —— 原来标题 16 / 分节 15 差 1px,是两个「差不多大」的层级,
|
||||
> 读起来分不出谁更重要。B4 范围内半像素字号(13.5 ×8、12.5 ×2)全部并入 `md(13)` / `sm(12)`。
|
||||
|
||||
- 行高:`--iwb-lh-tight:1.25` / `--iwb-lh-normal:1.45` / `--iwb-lh-loose:1.6`(正文 1.45,单行控件 1.25)
|
||||
- 字重:`--iwb-fw-regular:400` / `-medium:500` / `-semibold:600` / `-bold:700`
|
||||
- **半像素字号一律禁止**(10.5/11.5/12.5/13.5),Windows 下会发虚
|
||||
- 括号里的归并顺序:**正文向下取(12.5→12),标题向上取(17→18)**,保证「标题仍像标题」
|
||||
|
||||
### 3.4 圆角
|
||||
|
||||
**已落地(v3.26.44,M4-B1)**:6 档,全部在 `SCALE` 表里。
|
||||
|
||||
| token | 值 | 用在哪 | 归并掉 |
|
||||
|---|---|---|---|
|
||||
| `--iwb-radius-chip` | 6px | 胶囊、小标签 | 1,2,3,4,5 |
|
||||
| `--iwb-radius-control` | 8px | 按钮、输入框、菜单项 | 7,9 |
|
||||
| `--iwb-radius-card` | 10px | 卡片、toast、列表项、浮层内小卡 | 11 |
|
||||
| `--iwb-radius-panel` | 12px | 面板、工具栏、命令面板、右键菜单 | 12,13 |
|
||||
| `--iwb-radius-popover` | 14px | 弹窗、全窗口面板、锚定浮层、节点 | 16,18,20,22 |
|
||||
| `--iwb-radius-full` | 999px | 药丸、开关、头像 | — |
|
||||
|
||||
> **与初版计划的偏差**:计划里 `control 6 / card 8 / popover 10 / panel 14`,落地按**现状分布**定档
|
||||
> (12px 与 14px 是既有主力,先认它们为 panel/popover 再往上收),否则 B1 就不是等值迁移而是重画。
|
||||
> 实际使用频次(`grep -c 'border-radius: 1[0-9]px'`)也支持这个分档:12px 最多。
|
||||
> 节点圆角是**用户可调项**(`--iwb-node-radius`,外观 → 画布),不进 L2 闭集。
|
||||
|
||||
### 3.5 高度(elevation)
|
||||
|
||||
**已落地(v3.26.45,M4-B2)**:4 档,按「离内容多远」分,不按组件分。
|
||||
|
||||
| token | 亮色 | 暗色 | 用在哪 |
|
||||
|---|---|---|---|
|
||||
| `--iwb-elevation-1` | `0 2px 8px rgba(0,0,0,.12)` | α `.40` | 贴面浮层:浮动条、状态栏、HUD |
|
||||
| `--iwb-elevation-2` | `0 10px 30px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.10)` | α `.55/.40` | 浮窗、菜单、右键、toast |
|
||||
| `--iwb-elevation-3` | `0 18px 56px rgba(0,0,0,.26)` | α `.62` | 命令面板、锚定大浮层、确认框 |
|
||||
| `--iwb-elevation-4` | `0 24px 64px rgba(0,0,0,.30)` | α `.70` | 弹窗、全窗口面板 |
|
||||
|
||||
值写在 `scripts/gen-tokens.js` 的 `LIGHT_SHADOW` / `DARK_SHADOW` 常量表里(与 `--sh-*` 同一机制:
|
||||
它们是「主题皮肤」而不是派生色,所以不进 `derive()`,见 §1.8 已知限制)。
|
||||
|
||||
> **与初版计划的偏差**:计划是 5 档(含 `elevation-0: none`)。落地去掉 0 档 —— 「没有阴影」不需要
|
||||
> token,写 `box-shadow: none` 更清楚。档数从 5 降到 4 也符合实测分布:现有 46 种阴影写法里,
|
||||
> 真正表达「不同层深」的只有 4 组,其余是同一档的手抖差异(`.12/.14/.15`、`28px/30px/32px`)。
|
||||
>
|
||||
> **暗色必须靠描边**:暗色下 `rgba(0,0,0,.x)` 画不出形(底已近黑),所以浮层一律带
|
||||
> `border: 1px solid var(--iwb-border)` —— 这不是额外美化,是暗色能分辨层级的唯一手段。
|
||||
|
||||
### 3.6 层级(z-index)
|
||||
|
||||
**已落地(v3.26.45,M4-B2)**:14 档,数值只在 `SCALE` 表里写一次,组件引名字。
|
||||
|
||||
| token | 值 | 谁用 |
|
||||
|---|---|---|
|
||||
| `--iwb-z-ctx` | 90 | 右键遮罩 `.iwb-ctxmask` |
|
||||
| `--iwb-z-ctx-menu` | 91 | 右键菜单 `.iwb-ctxmenu` |
|
||||
| `--iwb-z-curtain` | 100 | 应用遮罩 `.iwb-overlay`、图片预览底 |
|
||||
| `--iwb-z-command` | 120 | 命令面板 `.iwb-command-mask` |
|
||||
| `--iwb-z-sheet` | 260 | 全窗口面板 `.iwb-fullmask`(资源中心) |
|
||||
| `--iwb-z-sheet-menu` | 270 | 面板内 portal 菜单(提示词/节点组「移动到分组」) |
|
||||
| `--iwb-z-modal` | 300 | 弹窗 `.iwb-modal-mask` |
|
||||
| `--iwb-z-modal-menu` | 310 | 侧栏里挂 body 的菜单 `.iwb-ws-more` |
|
||||
| `--iwb-z-splash` | 400 | 启动页 |
|
||||
| `--iwb-z-toast` | 500 | toast(**必须高于 modal**,见 §1.10) |
|
||||
| `--iwb-z-preview` | 800 | 图片预览 |
|
||||
| `--iwb-z-anchor` | 3200 | 锚定浮层 `.iwb-pop-anchor`(外观面板挂在设置弹窗里) |
|
||||
| `--iwb-z-palette` | 3300 | 背景色板 host |
|
||||
| `--iwb-z-alert` | 4000 | 确认框 / 崩溃屏(最后一道) |
|
||||
|
||||
三条硬关系(`tests/overlay-layer-test.js` 逐条断言,改数值前先读):
|
||||
|
||||
1. `ctx-menu(91) < sheet(260) < modal(300)` —— 层越上数字越大,不许交叉;
|
||||
2. `toast(500) > modal(300)` —— 提示条永远在最上面,否则「操作成功」等于没提示;
|
||||
3. `sheet-menu(270)` 卡在 sheet 与 modal 之间 —— 它是面板的子菜单,不该越到弹窗之上。
|
||||
|
||||
> **与初版计划的偏差**:计划是 9 档(`base/node/chrome/panel/popover/modal/toast/debug`),且要让
|
||||
> 裸 z-index 归零。落地保留 14 档、且只覆盖**浮层族**,两条理由:
|
||||
> ① 计划里的 `node/chrome/panel` 三档在实现里是 20–36 的一段连续值(停靠栏 20/22/24/25、导航 35、标签条 36),
|
||||
> 硬压成 3 个值等于重排队一次堆叠,收益为零、风险不小;
|
||||
> ② 1000 段还有未迁移的 `home-menu(1000/1001)`,把高段位压到 1000 会与它交错,所以 `anchor/palette/alert`
|
||||
> 保留历史数值(3200/3300/4000),等 M5 的 token-lint 把裸值清零后再统一。
|
||||
|
||||
### 3.7 动效
|
||||
|
||||
| token | 值 | 用途 |
|
||||
|---|---|---|
|
||||
| `--iwb-dur-fast` | 100ms | hover、颜色 |
|
||||
| `--iwb-dur-base` | 150ms | 展开、位移 |
|
||||
| `--iwb-dur-slow` | 200ms | 面板进出 |
|
||||
| `--iwb-dur-xslow` | 300ms | 模态、大位移 |
|
||||
| `--iwb-ease-standard` | `cubic-bezier(.2,0,0,1)` | 默认 |
|
||||
| `--iwb-ease-out` | `cubic-bezier(0,0,.2,1)` | 进入 |
|
||||
|
||||
必须包 `@media (prefers-reduced-motion: reduce)` 关闭(现状已有部分,未统一)。
|
||||
|
||||
### 3.8 图标与命中区
|
||||
|
||||
- 尺寸闭集:12 / 14 / 16 / 20(现状 13/15 归并到 14/16)
|
||||
- 描边:`stroke-width: 1.6`,`stroke-linecap: round`
|
||||
- 命中区:**≥28×28**(现状气泡按钮 30×28 合规;`--iwb-tab-new` 等 28 高合规)
|
||||
|
||||
### 3.9 组件契约(L3,白名单制)
|
||||
|
||||
只有「整体换肤需要」才建,且必须有 ≥2 个消费者:
|
||||
|
||||
| token | 值 | 消费者 |
|
||||
|---|---|---|
|
||||
| `--iwb-tab-h` | 28px | 全部 5 套 tab(收敛后只剩 1 套) |
|
||||
| `--iwb-control-h` | 30px | 设置页输入框 + 设置页默认按钮(B4 落地) |
|
||||
| `--iwb-radius-panel` | 14px | 面板/弹窗 |
|
||||
| `--iwb-node-radius` | 用户可调 14px | 画布节点 |
|
||||
|
||||
**`--iwb-control-h` 的由来(B4 实测)**:设置页同一行里输入框 33px、按钮 24px —— 差 9px,肉眼就是「高低不齐」。
|
||||
两者都写死高度没意义,必须是**同一个数**。取 30 而不是 33:输入框竖内边距从 7 收到 6(13px 字 + 6×2 + 描边 2 = 30),
|
||||
按钮从 24 涨到 30(`align-items: center` 自动居中文字,不用改内边距)。
|
||||
`tests/settings-scope-test.js` 钉死「这两条规则必须写 `height: var(--iwb-control-h)`」,
|
||||
防止以后有人单独给其中一个加 `padding` 又把高度差拉开。
|
||||
|
||||
**B6 裁定:`--iwb-control-h` 不扩到全局控件。** 全局 `.iwb-input` 是「内容撑高」而非固定高度
|
||||
(12px 字 + 6px 竖内边距 + 1px 描边,实测 28px),它服务的是画布、节点卡、停靠栏里的**紧凑控件**;
|
||||
`control-h` 要解决的是「输入框与按钮并排时的高低不齐」,而那种并排只发生在设置页表单里。
|
||||
强行统一到 30px 会让画布与节点里的每个输入框长 2px —— 节点总高、面板行距、浮条位置全跟着动,
|
||||
与 B6「零观感」的前提冲突,收益却只是两个场景同高。所以分工保留:
|
||||
**并排表单 → `control-h`;成组紧凑控件 → 内容撑高**。判据不是「哪个更大」,而是「有没有并排的另一半」。
|
||||
若将来画布里也出现输入框与按钮并排,就地用 `control-h`,不要反过来把全局撑大。
|
||||
|
||||
### 3.10 插件子集与私有皮肤(B6 定稿)
|
||||
|
||||
插件不能全量使用 L2,只能用一个子集;而「子集」不等于「白名单文件」—— 那是旧机制。
|
||||
|
||||
**三类颜色,三种处理**(守门在 `tests/plugin-theme-contract-test.js`):
|
||||
|
||||
| 类别 | 判据 | 规则 |
|
||||
|---|---|---|
|
||||
| 表面 / 文字 / 边框 | chroma(`max-min` of RGB)**< 24**,即看起来是「灰」 | 必须 `var(--iwb-*)`。写死在暗色下必然白板或黑洞 |
|
||||
| 强调 / 状态色 | chroma **≥ 24**,有明确色相 | 允许写死。亮暗两端都读得出来,属插件自己的设计语言 |
|
||||
| 私有皮肤 | manifest 里 `skin: 'private'` | 颜色全部放行,**但不得引用宿主颜色 token** |
|
||||
| 内容色 | 行内 `/*iwb:content*/` | 每处显式声明。看片台白底、画布填充属于内容,不属于主题 |
|
||||
|
||||
**为什么用 chroma 而不是维护一张允许色表**:表会过期(旧 `ALLOW_FILES` 6 条里 2 条早就可删,没人回来删),
|
||||
也会被人顺手往里加。chroma 是颜色自身的属性,不需要维护。
|
||||
|
||||
**为什么私有皮肤要付代价**:`image-annotate`(Catppuccin 470 处)与 `image-vectorize`(58 处)是自带整套调色板的
|
||||
深色专业工具 UI,硬塞进宿主 token 会毁掉设计。但它们一旦「一半跟主题、一半写死」,暗色下就会花屏 ——
|
||||
所以声明 private 的同时,必须**完全自洽**:不得引用宿主颜色 token(布局尺寸如 `--iwb-side-w` 例外,需在测试里登记)。
|
||||
宿主的 `plugin-host.js` 对未知 manifest 字段不做严格校验,`skin` 会被原样保留,不影响加载。
|
||||
|
||||
**内容色为什么要行内标记**:同一个 `#fff`,在面板上写死是 bug(暗色白板),在画布/看片台上是内容(必须白)。
|
||||
值分不出来,上下文才分得出来,所以豁免粒度从「文件」降到「这一条声明」。
|
||||
|
||||
---
|
||||
|
||||
## 4. 落地路线
|
||||
|
||||
四个阶段,每阶段**独立可验收、可回滚**。S0/S1 视觉零变化,S2 逐批等值替换,S3 才上闸门。
|
||||
|
||||
> **顺序修正(按 §1.6)**:色彩模型(D1–D8)必须早于尺度迁移(§3)。所以 S1 拆成 S1a(色彩模型)与 S1b(静态尺度层),S2 的六批迁移只做尺度。
|
||||
|
||||
### S0 清账(约 0.5 天,零风险)
|
||||
|
||||
1. 修 7 个未定义变量:`--iwb-accent` → 所在两条规则**已删**(类无生产者,见 §1.7);`--sp-panel/line/text`、`--rd-12`、`--fs-12/13` → 换成对应真值(`--iwb-panel/border/text`、`--rd-lg`、`--fs-md/lg`,视觉等值)
|
||||
2. 删 `var(--iwb-err, var(--iwb-err))` 自引用
|
||||
3. 28 个死 token:`--sp-*`/`--rd-*`/`--fs-*` 保留(S1 会被新 L1 替代),其余标 `/* @deprecated since 3.26.42 */`
|
||||
4. 提交 `scripts/token-audit.js` 与本文
|
||||
|
||||
**验收**:`token-audit` 的「引用了但从未定义」= **0**。
|
||||
|
||||
### S1a 色彩模型(约 1 天,**有可见变化**,需逐项确认)
|
||||
|
||||
按 §1.5 的编号逐条修(D1–D9),每条独立可回滚:
|
||||
|
||||
| 修 | 动作 | 观感影响 |
|
||||
|---|---|---|
|
||||
| D1 | 删 `.theme-dark` 里与 derive 重名的静态值,只保留 `--iwb-anim-*` 与 `--sh-*`;`applyTheme()` 里补 `applyAppearance()` 调用,或让 mq 监听同时改 React state | 消除首屏闪变与「系统转暗不生效」 |
|
||||
| D3 | `clampText` 改为**对全部表面取最小值**夹紧(bg/panel/layer/nodeBg/pluginCard 各算一次,取最严) | 暗色正文略提亮 |
|
||||
| D4 | `text2` 的 3.2 提到 **4.5**;确需弱化的文字改用显式的 `text-tertiary`(3:1,且只允许非正文) | 次要文字变深,信息层级略收紧 |
|
||||
| D5 | `textDim` 的 0.35 系数改为落在 3:1 上(约 0.2) | 占位符可读 |
|
||||
| D6 | `layer` 在暗色改为**比 panel 更暗**(内嵌语义两主题一致) | 暗色内嵌块不再凸起 |
|
||||
| D7 | `--iwb-brand` 脱离 `--iwb-text2`,由 `seedAccent` 单独给值;同步修 `--iwb-edge-hot` | 品牌色恢复识别度 |
|
||||
| D8 | 补 `--iwb-state-hover/-pressed/-disabled/-selected` 与 `--iwb-focus-ring`(2px + 2px offset) | 键盘导航出现焦点环 |
|
||||
| D9 | 24 条 `.theme-dark` 硬编码换成对应 L2 token;批量改色不再分亮暗两套 | 暗色跟随自定义种子 |
|
||||
|
||||
**验收**:`token-lint` 的对比度断言全绿(D3/D4/D5 可写成测试);亮/暗各 6 张关键界面截图人工确认;`prefers-color-scheme` 切换后 3 秒内无残留旧色。
|
||||
|
||||
### S1b 建立静态单一源(约 0.5 天,零视觉变化)
|
||||
|
||||
1. 新建 `src/design-tokens.css`:只放 L1 + L2 静态值 + legacy 别名,**不含任何 JS 逻辑**
|
||||
2. 构建顺序:`design-tokens.css` 拼在 `style.css` 之前(Tauri 打包需内联,用构建拼接,不能用 `@import`)
|
||||
3. `theme-tokens.js` 只写**颜色**、不再写 CSS 已能算出的 `chrome/dock/home`(消除第二套公式)
|
||||
4. 构建额外产出 `dist/tokens.json`(DTCG 格式:`{$value,$type}`),供设计侧导入 Penpot / Figma Variables——**这是「设计-代码同源」的落点**
|
||||
|
||||
**验收**:亮/暗两张截图 0 像素差异;`--iwb-space-8` 等在 DevTools 里有值;`tokens.json` 能被 Penpot 导入。
|
||||
|
||||
### S2 分批迁移(每批 1 个 PR,视觉零 diff)
|
||||
|
||||
顺序按「改动风险从低到高、收益从高到低」:
|
||||
|
||||
| 批次 | 范围 | 主要动作 | 预估 |
|
||||
|---|---|---|---|
|
||||
| **B1 壳层** | `.iwb-tabstrip` `.iwb-tab` `.iwb-dock-*` `.iwb-toolbar*` `.iwb-statusbar` | 5 套 tab 收敛为 1 套(单框扁平 + 品牌高亮);圆角/间距/字号换 token | 0.5 天 |
|
||||
| **B2 浮层** | `.iwb-modal` `.iwb-fullmask` `.iwb-command` `.iwb-ctxmenu` `.iwb-toast` `.iwb-pop*` | 圆角统一 → `radius-panel/popover`;阴影 → `elevation-2/3/4`;z-index → `--iwb-z-*` | 0.5 天 |
|
||||
| **B3 首页/画布库** | `.iwb-home-*` `.iwb-lib-*` `.iwb-res-*` | 间距归并、字号归并 | 0.5 天 |
|
||||
| **B4 设置/外观** ✅ | `.iwb-settings-modal` `.iwb-appear-*` `.iwb-set*` | 控件统一 `control-h`(输入框与按钮等高);半像素字号清零;删 21 条死规则 | 0.5 天 |
|
||||
| **B5 节点** ✅ | `.iwb-node*` `.iwb-gen-*` `.iwb-port` | 节点卡内部表面统一 `field`(修端口黑洞)、字号 12/15 归口、圆角归并 | 1 天 | 画布截图 + 计算样式 diff |
|
||||
| **B6 插件** | `plugins/**` + 插件源码仓库 | 硬编码 → `--iwb-*`;`ALLOW_FILES` 逐项清零 | 配合插件发版 |
|
||||
|
||||
**每批验收**(三条同时满足):
|
||||
1. 亮色 / 暗色 / 窄屏(≤790px)三张截图与迁移前 **0 像素差异**(等值替换的批必须 0 diff)
|
||||
2. `token-audit.js` 对应计数下降(例如 B2 后 `box-shadow 声明` 从 79 降到 ≈50)
|
||||
3. `npm run verify:ci` 全绿
|
||||
|
||||
### S3 上闸门(约 0.5 天)
|
||||
|
||||
新增 `tests/design-token-ratchet-test.js` + `scripts/token-lint.js`,接入 `verify:ci`:
|
||||
|
||||
| 闸门 | 规则 | 失败示例 |
|
||||
|---|---|---|
|
||||
| **棘轮** | 硬编码计数不得超过基线(只降不升) | 基线 `font-size 写死 281`,新 PR 变成 282 → 失败 |
|
||||
| **禁新增** | diff 新增行里出现裸 `#hex` / 裸 `px`(font-size、border-radius、padding、gap)→ 失败 | `padding: 13px` |
|
||||
| **完整性** | 所有 `var(--iwb-*)` 必须有定义;禁止 `var(--x, var(--x))` | §1.3-②③ |
|
||||
| **层级** | 禁止裸数字 `z-index`;插件不超过 40 | `z-index: 9999` |
|
||||
| **插件契约** | **没有文件级豁免**。颜色按角色分三类:中性色(chroma < 24)必须用 token;强调色(chroma ≥ 24)允许写死;自带整套皮肤的在 manifest 声明 `skin: 'private'`,代价是不得引用宿主颜色 token。内容色用行内 `/*iwb:content*/` 标记 | §3.10 |
|
||||
|
||||
**棘轮是这套方案能不能活下来的关键**:没有它,三个月后又是一次 281 个字号。
|
||||
|
||||
### S4 长期治理(流程,见 §5)
|
||||
|
||||
---
|
||||
|
||||
## 5. 流程规定
|
||||
|
||||
### 5.1 新增 token 的 RFC(5 问,缺一不批)
|
||||
|
||||
> 提 PR 时贴进描述,评审人:设计 owner + 前端 owner 各 1 人。
|
||||
|
||||
1. **替代什么**:现在用什么值?为什么现有 L2 不够用?(能复用现有 token 的一律驳回)
|
||||
2. **属于哪层**:L1 值 / L2 角色 / L3 组件?L3 需给出 ≥2 个消费者
|
||||
3. **两套值**:亮色、暗色分别是什么?暗色是否只是提亮一档?
|
||||
4. **对比度**:正文 ≥4.5:1、次要 ≥3.2:1、非文字 ≥3:1,贴实测数字
|
||||
5. **谁消费**:`file:line` 列表;没有消费者的 token 不许加
|
||||
|
||||
### 5.2 新增模块 / 插件的 9 步
|
||||
|
||||
1. 先翻 §3 找现成 L2,**80% 的情况不需要新 token**
|
||||
2. 颜色只用 `--iwb-color-*`,不写 `#hex`/`rgba()`
|
||||
3. 间距只用 `--iwb-gap-*` / `--iwb-pad-*`
|
||||
4. 字号只用 `--iwb-font-*`(禁止 10.5/11.5/12.5/13.5)
|
||||
5. 圆角只用 `--iwb-radius-*`
|
||||
6. 浮层阴影用 `--iwb-elevation-*`,暗色另有描边
|
||||
7. z-index 用 `--iwb-z-*`,插件不超 40
|
||||
8. 动效用 `--iwb-dur-*` + `--iwb-ease-*`,并支持 reduced-motion
|
||||
9. 亮/暗各截一张图放进 PR
|
||||
|
||||
### 5.3 token 变更的版本与弃用
|
||||
|
||||
| 变更 | 版本位 | 要求 |
|
||||
|---|---|---|
|
||||
| 新增 L1/L2 | minor | 走 RFC |
|
||||
| 改 L2 的值 | patch(但必须截图回归) | 影响面 ≥3 处需单独 PR |
|
||||
| 重命名 | **major** | 旧名标 `@deprecated`,**保留 ≥2 个 minor 版本**后再删 |
|
||||
| 删除 | major | 需 `token-audit` 证明引用数 = 0 |
|
||||
| 改 L1 值 | minor | L1 只允许在 L2 里被引用,改动面可控 |
|
||||
|
||||
**弃用窗口的硬要求**:插件已发布的变量永不立即删除——插件更新周期不受我们控制。
|
||||
|
||||
### 5.4 PR 评审清单(三问)
|
||||
|
||||
- [ ] 这个 PR 新增了硬编码数值吗?(有 → 为什么不能进 token)
|
||||
- [ ] 亮色/暗色都看过了吗?(截图)
|
||||
- [ ] 如果改了 token:`design-tokens.md` 同步了吗?需要弃用窗口吗?
|
||||
|
||||
### 5.5 例外登记
|
||||
|
||||
任何 `ALLOW` 白名单条目必须写成:
|
||||
|
||||
```js
|
||||
// owner: @xxx · 到期: 3.28.0 · 原因: 画笔颜色属用户内容,不是主题表面色
|
||||
```
|
||||
|
||||
无 owner 或无到期版本的例外,S3 闸门直接失败。
|
||||
|
||||
---
|
||||
|
||||
## 6. 现有页面统一清单(按优先级)
|
||||
|
||||
> **进度(2026-11-23,v3.26.46)**:P0 六项已全部完成(3.26.43–3.26.44);P1 的页签/圆角/阴影三项完成(B1–B2);
|
||||
> P1 字号与 P2 间距完成「首页/库」一批(B3),其余批次见 `docs/plans/design-tokens-rollout.md`。
|
||||
> 下表保留当时的**诊断原貌**,不逐行改状态 —— 改状态会让「当初为什么这么排优先级」丢失。
|
||||
> 其中 `.iwb-lib-tab` / `.iwb-rail-tab` / `.iwb-drawer-tab` / `.iwb-res-tab` 已随 B1/B3 **删除**。
|
||||
|
||||
| 优先级 | 位置 | 现状 | 目标 | 风险 |
|
||||
|---|---|---|---|---|
|
||||
| **P0** | `style.css:690,691` | `var(--iwb-accent)` 未定义 + 两个类无生产者 | **删两条死规则**(复核后确认无生产者,不是变色修复) | 无 |
|
||||
| **P0** | `style.css:1046` | 自引用 fallback | 改 `--iwb-color-err` | 无 |
|
||||
| **P0** | `style.css:1034-1046` | 4 个不存在的 `--sp-*` / `--rd-12` / `--fs-12` | 换真 token | 低 |
|
||||
| **P0** | `style.css:580` vs `2011` | toast(200) 被确认框(9999) 覆盖 | 全量换 `--iwb-z-*` | 低 |
|
||||
| **P1** | `.iwb-tab` / `.iwb-drawer-tab` / `.iwb-lib-tab` / `.iwb-rail-tab` / `.iwb-res-tab` | 5 套圆角 7/8/8/8 与 4 种 active 表达 | 收敛为 1 套:单框扁平 + 品牌高亮(§12.4) | 中(影响所有页签,需全量截图) |
|
||||
| **P1** | `.iwb-modal`(14) / `.iwb-cpick-pop`(10) / `.iwb-toolbar`(12) | 同层圆角三值 | `radius-panel` / `radius-popover` | 低 |
|
||||
| **P1** | `.iwb-toolbar` / `.iwb-history` / `.iwb-command` | 三种硬编码阴影 | `elevation-2/3/4` | 低(暗色观感会变好) |
|
||||
| **P1** | `style.css` 19 档字号 | 含 4 个半像素档 | 8 档闭集 | 中(个别文案换行) |
|
||||
| **P2** | 644 处间距 | 30 档 | 14 档 L1 + 8 个 L2 | 中(布局微移,需逐批截图) |
|
||||
| **P2** | `.iwb-gen-cell .iwb-input` 15px | 节点参数与 UI 正文(12)不一致 | 保留 15px,但归口为 `--iwb-font-title` 并注明「画布可读性」 | 无 |
|
||||
| **P2** | 42 档 z-index | 含 3200/3300/4000/9999 | 9 个 `--iwb-z-*` | 低 |
|
||||
| **P2** | `plugins/**` 4 个白名单文件 | 399/77/15/8 处硬编码 | 清零(分 2 个插件版本) | 高(需插件源码仓库发版) |
|
||||
| **P3** | `site/assets/style.css` | 5 个独立变量,与客户端零共享 | 从 `dist/tokens.json` 取品牌色/字号/圆角 | 低(官网独立,可先只共享品牌色) |
|
||||
| **P3** | `--sh-sm/md/lg` 与 `--iwb-elevation-*` | 两套阴影命名 | 后者取代前者 | 低 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 验收指标
|
||||
|
||||
| 指标 | 现状 | S2 结束目标 | 长期 |
|
||||
|---|---|---|---|
|
||||
| 未定义却引用的变量 | **0**(M1 已达成) | 0 | 0(闸门保证) |
|
||||
| `--sp-*` 采用次数 | 0 | ≥300 | — |
|
||||
| 字号写死处数 | 281 | ≤60 | ≤20 |
|
||||
| 圆角写死处数 | 164 | ≤40 | ≤10 |
|
||||
| 间距写死处数 | 644 | ≤200 | ≤80 |
|
||||
| 阴影写法种类 | 52 | ≤8 | 5 |
|
||||
| z-index 取值种类 | 42 | 9 | 9 |
|
||||
| 字号档数 | 19 | 8 | 8 |
|
||||
| 插件白名单文件 | 4 | 2 | 0 |
|
||||
| 亮/暗截图回归 | **12 张基线**(M0 已建立) | 每批 0 diff | 持续 |
|
||||
|
||||
---
|
||||
|
||||
## 8. 风险与「不做的事」
|
||||
|
||||
**风险**
|
||||
|
||||
1. **半像素字号归并**会让个别文案换行 → 逐批截图,B3 之后单独看首页。
|
||||
2. **面板圆角 14→12/14 的决策**会影响所有弹窗观感 → 见 §9-①。
|
||||
3. **暗色阴影改描边**是观感变化,不是等值替换 → 单列一个 commit,可单独回滚。
|
||||
4. **插件白名单清零**依赖插件源码仓库发版,客户端不能单方面改。
|
||||
5. ~~`--iwb-accent` 修复会改变工具栏按钮的高亮色~~ → **已证伪并作废**:那两个类没有生产者,删规则即完成(§1.7)。
|
||||
|
||||
**不做**
|
||||
|
||||
- 不引入 Tailwind / CSS-in-JS / Style Dictionary 完整工具链
|
||||
- 不重命名现有 66 个 `--iwb-*`(插件兼容优先)
|
||||
- 不做 Figma 双向同步(只做 `tokens.json` 单向导出)
|
||||
- 不给每个组件建 token(L3 白名单制)
|
||||
- 不在本次改动里调整任何布局结构
|
||||
|
||||
---
|
||||
|
||||
## 9. 已拍板的 4 个决定(2026-11-23)
|
||||
|
||||
| # | 决定 | 裁定 | 影响与执行口径 |
|
||||
|---|---|---|---|
|
||||
| ① | 面板圆角 | **14px**(`radius-panel`) | 浮层(modal/fullmask/菜单/命令面板)统一 14;`popover` 用 12,`control` 用 8,`chip` 用 6,`round` 用 999。节点保持 `--iwb-node-radius`(默认 14)不受影响 |
|
||||
| ② | 半像素字号 | **并入整数档**(10.5→11、11.5→12、12.5→12、13.5→13)|**已执行**:B3 清首页/库、B4 清设置/外观、**B6 清剩余 16 处** | 闭集落在 7 档:11 / 12 / 13 / 15 / 17 / 20 / 24。迁移时逐条看换行,只允许「文案变短一行」不允许「挤出容器」。B6 全部清零:备份页 2、右键菜单 1、操作日志 1、确认框 1、插件市场卡 9、资源浮标/继承条各 1;其中市场卡的 `.iwb-mk-card .iwb-mk-name/.iwb-mk-sub` 两条归并后与全局同档,作为重复声明删除 |
|
||||
| ③ | 间距迁移 | **先等值替换**,收敛另起一轮 | M4 只换写法不换值(0 diff);30 档 → 16 档的收敛放到 M4 之后单独一批,届时逐屏对照 |
|
||||
| ④ | 色彩模型修复范围 | **全修 D1–D9**,但**分两版**:3.26.43 只放 D1(零观感),D3/D4/D5/D6/D7/D8/D9 放 3.26.44 | D1 = 单一写入点(消闪变、修系统转暗不生效),观感零风险;其余会改变暗色观感,单独发版并附亮/暗对比图 |
|
||||
|
||||
裁定后本文状态为「生效」,`docs/plans/design-tokens-rollout.md` 的 M0 决策项视为完成。
|
||||
|
||||
**执行进度**:决定 ④ 的两个版本都已落地 —— 3.26.43 放 D1③(系统跟随重算)+ M1 清账;3.26.44 放 D1①②/D2–D9。详见 §1.7、§1.8。
|
||||
决定 ③(间距)在 3.26.46 的 B3 批次上**提前做了收敛**(就近下取),原因与观感核对结果见 §3.2 的「B3 落地」。
|
||||
|
||||
---
|
||||
|
||||
## 附:复核命令
|
||||
|
||||
```bash
|
||||
node scripts/token-audit.js # 表格报告(§1.1–1.4)
|
||||
node scripts/token-audit.js --contrast # 对比度矩阵 + 静态/派生差异(§1.5)
|
||||
node scripts/token-audit.js --json # 机器可读,供闸门对比基线
|
||||
```
|
||||
@@ -0,0 +1,166 @@
|
||||
# Image Workbench 插件开发规范
|
||||
|
||||
> 版本:v1(2026-11-22)。面向官方与第三方插件;示例以 promptlib(提示词库)与 style-source(风格库)为准。
|
||||
> 相关文档:plugin-node-drag.md(节点拖入/指针交互踩坑)、plugin-node-outkind.md(下游连线声明)、plugin-theme.md(主题契约)。
|
||||
|
||||
## 1. 目录与基本结构
|
||||
|
||||
插件是「一个目录 + 一个 IIFE 入口」,由宿主在启用时动态加载并调用 register。
|
||||
|
||||
my-plugin/
|
||||
package.json # 版本 + ibwPlugin 元数据
|
||||
src/index.js # 入口(IIFE,末尾 IWBPluginHost.register)
|
||||
styles.css # 样式(必须自包含)
|
||||
README.md
|
||||
|
||||
package.json:
|
||||
|
||||
{
|
||||
"name": "@iwb-plugin/my-plugin",
|
||||
"version": "1.0.0",
|
||||
"ibwPlugin": { "id": "my-plugin", "entry": "src/index.js", "apiVersion": 1 }
|
||||
}
|
||||
|
||||
入口骨架:
|
||||
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
if (!global.IWBPluginHost) return
|
||||
global.IWBPluginHost.register({
|
||||
id: 'my-plugin',
|
||||
name: '我的插件',
|
||||
version: '1.0.0',
|
||||
capabilities: ['panels', 'canvas', 'canvasWrite'],
|
||||
settings: { panel: { type: 'custom', label: '设置', render: renderSettings } },
|
||||
mount: mount,
|
||||
unmount: unmount,
|
||||
}, function (ctx) {
|
||||
// setup:注册面板/节点/命令
|
||||
return { dispose () {} }
|
||||
})
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
|
||||
## 2. 能力(capabilities)与 ctx 映射
|
||||
|
||||
只申请用到的能力;能力名与 ctx 键不同:
|
||||
|
||||
| capability | ctx 键 | 用途 |
|
||||
|---|---|---|
|
||||
| panels | ctx.ui | 侧栏/独立面板注册 |
|
||||
| promptlib | ctx.promptlib | 提示词库数据 + 文件 + 备份 |
|
||||
| nodeTypes | ctx.nodes | 画布节点类型注册 |
|
||||
| canvas | ctx.canvas | 只读:getNodes / getSelectedNode / screenToWorld |
|
||||
| canvasWrite | ctx.canvasWrite | 写入:createNode / createImageNode / setNodeImage |
|
||||
| nodeActions | ctx.nodeActions | 节点右键/气泡动作 |
|
||||
| commands | ctx.commands | 命令面板 |
|
||||
| settings | ctx.settings | KV 配置 |
|
||||
| data | ctx.data | 插件数据文件 |
|
||||
|
||||
**注意**:createNode 在 ctx.canvasWrite,不在 ctx.canvas。调错只会提示“宿主不支持”。
|
||||
|
||||
## 3. 面板
|
||||
|
||||
ctx.ui.registerPanel({
|
||||
id: 'my-panel',
|
||||
title: '我的插件',
|
||||
mount (host) { /* 渲染到 host */ },
|
||||
unmount (host) { /* 清理定时器/监听 */ }
|
||||
})
|
||||
|
||||
- mount 只调用一次,内部自己管理重渲染。
|
||||
- 面板宽度可变:使用栅格/瀑布流,不要写死 px 宽度。
|
||||
- 面板内所有 DOM 事件在 unmount 时移除。
|
||||
|
||||
## 4. 节点类型
|
||||
|
||||
ctx.nodes.register({
|
||||
id: 'tpl',
|
||||
title: '模板节点',
|
||||
defaults: { outKind: 'prompt' },
|
||||
ports: { in: false, out: true },
|
||||
height: 360,
|
||||
render (node, props, host) { /* 首次建 DOM,之后 sync */ }
|
||||
})
|
||||
|
||||
宿主会生成类型 plugin:<插件id>:<变体id>。
|
||||
|
||||
**必须遵守**:
|
||||
|
||||
1. 输出文本/提示词 → data.outKind = 'prompt'(注册默认值、拖入数据、旧节点在 render 里自愈)。
|
||||
2. 拖入画布用指针拖拽,不用原生 HTML5 DnD:
|
||||
|
||||
pointerdown → pointermove(>5px) 幽灵卡片
|
||||
→ pointerup → ctx.canvas.screenToWorld(x,y)
|
||||
→ ctx.canvasWrite.createNode('tpl', wx, wy, data)
|
||||
|
||||
3. 输入框:未选中时 pointer-events: none,选中后才可编辑;只读 textarea 同样处理。
|
||||
4. 单击 = 选中/拖动,双击 = 编辑;不要用单击打开详情。
|
||||
5. 节点 render 必须可增量 sync,避免整块重建(输入框会丢焦点)。
|
||||
|
||||
## 5. 数据与文件
|
||||
|
||||
- 小数据:ctx.promptlib(或 ctx.data)JSON,单文件 < 1MB。
|
||||
- 大文件(封面/图片):ctx.promptlib.filePut/fileGet/fileList,落地在 plugin-data/<id>/files/。
|
||||
- dataUrlToBytes() 返回 { mime, bytes },不是 Uint8Array。
|
||||
- 备份:提供导出/导入 JSON;导入按 id 合并,提供“覆盖同 id”选项。
|
||||
- 迁移:旧格式在 setup 里做一次性迁移,失败要提示而不是静默丢数据。
|
||||
|
||||
## 6. 设置页面
|
||||
|
||||
宿主设置页内嵌渲染,不弹独立页面:
|
||||
|
||||
settings: {
|
||||
panel: { type: 'custom', label: '分组与备份', render: renderSettings }
|
||||
}
|
||||
|
||||
render 返回 DOM;宿主负责挂载/卸载。设置页适合放:
|
||||
|
||||
- 分组管理(新建/改名/排序/删除)
|
||||
- 数据备份(导出/导入)
|
||||
- 数据位置(打开数据目录)
|
||||
- 插件级开关/默认值
|
||||
|
||||
## 7. 样式规范
|
||||
|
||||
1. **自包含**:宿主基础样式会变;用到的宿主类按作用域复制一份(.iwb-myplugin …)。
|
||||
2. 统一前缀:面板/节点类名 my-plugin-*,避免与宿主 .iwb-* 冲突。
|
||||
3. 颜色走 CSS 变量:var(--iwb-text)、--iwb-panel、--iwb-border、--iwb-plugin-accent。
|
||||
4. 动画克制:只做 hover/press 反馈;不使用持续浮动动画。
|
||||
5. 深色主题:不写死 #fff/#000;主题契约测试会扫描。
|
||||
6. 悬停放大只缩放内层背景,不缩放卡片本体(避免命中区域漂移/闪烁)。
|
||||
7. 图片/封面 pointer-events: none,点击永远落到卡片。
|
||||
|
||||
## 8. 错误处理与提示
|
||||
|
||||
- 所有用户可见错误用 ctx.promptlib.notify / ctx.ui.toast,文案给“下一步怎么办”。
|
||||
- 异步链必须有 catch;不要吞掉错误后静默。
|
||||
- 崩溃日志:window.onerror 由宿主统一采集,插件不要自己覆盖。
|
||||
- 定时器/监听在 unmount/dispose 清理,避免面板切换后重复执行。
|
||||
|
||||
## 9. 测试与门禁
|
||||
|
||||
提交前至少:
|
||||
|
||||
node scripts/validate-plugins.js # manifest/能力/入口校验
|
||||
node scripts/theme-contract-test.js # 主题变量
|
||||
node tests/plugin-<id>-render-test.js # jsdom 渲染/交互
|
||||
|
||||
jsdom 可覆盖:面板渲染、节点 render/sync、拖拽插入(stub screenToWorld/createNode)、双击详情、保存回详情、封面 img。
|
||||
|
||||
## 10. 发布与市场
|
||||
|
||||
1. 改 package.json version 与入口 version(两处一致)。
|
||||
2. node scripts/sync-plugins-from-repo.js(同步到客户端 plugins/)
|
||||
3. node scripts/gen-market.js(生成 market/ 与 zip)
|
||||
4. 上传 market 到 NAS(tar + scp + 解压)
|
||||
5. 客户端发版:set-version → CHANGELOG → 锚点 → verify:ci → build → publish-update → releases/site → tag/push
|
||||
|
||||
## 11. 常见坑(务必先读)
|
||||
|
||||
- 原生 HTML5 拖放:WKWebView 吞 pointerup,节点落地后第一次点击异常 → 用指针拖拽。
|
||||
- ctx.canvas 没有 createNode → 用 ctx.canvasWrite。
|
||||
- 输入框拦截拖动 → 未选中时 pointer-events:none。
|
||||
- 只读 textarea 仍可选中文本 → pointer-events:none。
|
||||
- dataUrlToBytes 返回对象 → 取 .bytes。
|
||||
- 封面直接存 dataURL 会让 JSON 膨胀 → 迁移到文件,只存 { img }。
|
||||
- 插件节点不声明 outKind → 只能中继,无法直连生图。
|
||||
@@ -0,0 +1,55 @@
|
||||
# 插件节点:拖入、渲染与指针交互踩坑记录(promptlib 实战)
|
||||
|
||||
> 来源:提示词库 1.6.x 接入画布节点时连续踩到的问题。新增「带变量的插件节点」前先读一遍。
|
||||
|
||||
## 1. 拖入画布:不要用原生 HTML5 drag&drop
|
||||
|
||||
**现象**:节点拖进画布后,第一次点击要么选中文本、要么拖不动;点一下空白再点节点才正常。
|
||||
|
||||
**原因**:WKWebView 在原生拖放期间吞掉 pointerup/mouseup,落点节点带着焦点/手势残留。宿主很难在 drop 后完全复位。
|
||||
|
||||
**正确做法**(对齐风格库):自己实现指针拖拽:
|
||||
|
||||
pointerdown → pointermove(>5px) → 出现跟手幽灵卡片
|
||||
pointerup → ctx.canvas.screenToWorld(x, y) → ctx.canvasWrite.createNode(type, x, y, data)
|
||||
|
||||
- 不要 draggable=true,不要 dataTransfer
|
||||
- 不要 preventDefault() pointerdown(会吞掉 click/dblclick)
|
||||
- 卡片加 user-select:none,避免拖拽选中标题文字
|
||||
|
||||
## 2. 宿主能力是拆开的:canvas / canvasWrite
|
||||
|
||||
| 能力 | 方法 |
|
||||
|---|---|
|
||||
| ctx.canvas | 只读:getNodes / getSelectedNode / screenToWorld |
|
||||
| ctx.canvasWrite | 写入:createNode / createImageNode / setNodeImage |
|
||||
|
||||
createNode **不在** ctx.canvas 上;调错只会得到“宿主不支持”的提示。manifest 的 capabilities 要同时声明 canvas 与 canvasWrite。
|
||||
|
||||
## 3. 新建节点交给宿主创建,不要手工 commit
|
||||
|
||||
宿主 addPluginNode 会:拼 plugin:<id>:<variant> 类型、按变体宽度、**先选中再提交**。手工 commitCanvas 容易漏选中/漏默认值,还会让第一次点击变成“先选中”。
|
||||
|
||||
## 4. 连线能力:声明 outKind
|
||||
|
||||
节点要直连生图/润色/文本/组合,必须 data.outKind = 'prompt'(注册默认值 + 拖入数据 + 旧节点自愈三处),详见 plugin-node-outkind.md。
|
||||
|
||||
## 5. 输入框与拖动
|
||||
|
||||
- 节点内的 <input> 会让宿主只选中、不拖动(宿主把 input 视为可交互控件)
|
||||
- 未选中时给输入框 pointer-events: none,让点击/拖动落到节点本体;选中后再允许输入
|
||||
- 只读 <textarea> 也要 pointer-events: none,否则单击会选中文本
|
||||
|
||||
## 6. 插件样式必须自包含
|
||||
|
||||
宿主基础样式会变。插件需要把用到的宿主类按作用域复制一份(.iwb-promptlib …),不要假设宿主类名/结构长期稳定。
|
||||
|
||||
## 7. 文件与 dataURL
|
||||
|
||||
- dataUrlToBytes() 返回 { mime, bytes },不是 Uint8Array
|
||||
- 封面等大字段迁移到 plugin-data/<id>/files/,JSON 只留 { img: 文件名 }
|
||||
- 读文件走 ctx.promptlib.fileGet(能力声明 promptlib),不要依赖 ctx.files
|
||||
|
||||
## 8. 图片被覆盖后如何保留原图
|
||||
|
||||
宿主 canvasWrite.setNodeImage 覆盖前会把原图备份到 data.orig;右键节点可「还原替换前原图」。插件侧覆盖时不要自己清除 data.orig。
|
||||
@@ -0,0 +1,34 @@
|
||||
# 插件节点的下游连线声明(outKind)
|
||||
|
||||
> 适用:任何需要在画布上输出「一段文本/提示词」的插件节点(示例:风格库样式节点、提示词库模板节点)。
|
||||
|
||||
## 1. 为什么需要声明
|
||||
|
||||
宿主的连线白名单(`src/canvas-geometry.js`)按**节点语义**判断能否连到下游(生图 / 润色 / 文本 / 组合 / 连接)。
|
||||
插件节点的 `type` 是运行时注册的 `plugin:<插件id>:<变体id>`,宿主静态表里没有,无法预知它输出什么。
|
||||
|
||||
因此约定一个显式声明:
|
||||
|
||||
```js
|
||||
node.data.outKind = 'prompt' // 这一路输出的是提示词
|
||||
```
|
||||
|
||||
声明后,该节点在连线规则里**等同内置提示词节点**:可直接连到生图 / 润色 / 文本 / 组合 / 连接;
|
||||
不声明则只能通过「中继」节点转接。
|
||||
|
||||
## 2. 怎么声明(插件侧)
|
||||
|
||||
三处都要覆盖,缺一处就会出现「新拖的能连、旧节点不能连」:
|
||||
|
||||
1. **注册默认值**(所有 `ctx.canvas.createNode` 路径生效):
|
||||
```js
|
||||
ctx.nodes.register({ id: 'ptpl', defaults: { outKind: 'prompt' }, … })
|
||||
```
|
||||
2. **宿主拖拽落点**:拖拽 payload 里带 `outKind`,宿主创建节点时写入 `data.outKind`。
|
||||
3. **旧节点自愈**:节点 `render` 时若 `data.outKind !== 'prompt'`,调 `props.onUpdate(id, { outKind: 'prompt' })` 补一次。
|
||||
|
||||
## 3. 宿主侧约束
|
||||
|
||||
- 白名单数组(`canvas-geometry.js` 的 7 条规则)是**宿主所有**,插件不得修改;插件只声明语义。
|
||||
- `outKind` 目前只支持 `'prompt'`;新增语义(如图片、分组)需先在宿主补规则并写测试。
|
||||
- 声明缺失时行为保持旧状(只能中继),不会破坏已有画布。
|
||||
@@ -62,3 +62,7 @@
|
||||
## 相关规范
|
||||
|
||||
- 原生浮层(面板内嵌浏览器 / 画布网页节点)的生命周期见 `docs/standards/native-overlay-lifecycle.md`(先 park 再 close,禁止把隐藏放进定时器)。
|
||||
|
||||
## 相关规范
|
||||
|
||||
- 插件节点要直连下游(生图/润色/文本…)需声明 `data.outKind = 'prompt'`,见 `docs/standards/plugin-node-outkind.md`。
|
||||
@@ -338,8 +338,10 @@ dist/ += favicon.svg / _headers / THIRD_PARTY_NOTICES.md
|
||||
|
||||
### 12.4 UI 设计语言(统一 token 与结构)
|
||||
|
||||
- **Tab(页签)一律「单框扁平」**:外层容器透明无边框(只留间距),active 用**品牌色扁平高亮**(`color-mix(in srgb, var(--iwb-brand) N%, transparent)`),hover 用浅色底。**禁止「容器 pill + 页签 pill」嵌套双层框**。已统一:`.iwb-res-tabs` / `.iwb-tabstrip`+`.iwb-tab`;其余变体(`.iwb-drawer-tab` / `.iwb-lib-tab` / `.iwb-rail-tab` / `.iwb-ws-tab`)应逐步对齐;新增 tab 必须用该样式。
|
||||
- **颜色/间距一律走 CSS 变量**(`var(--iwb-text2)` / `var(--iwb-brand)` / `var(--iwb-border)`…),不写死色值;高亮态用 `color-mix` 派生透明底。
|
||||
> **数值以 [`design-tokens.md`](design-tokens.md) 为准**:颜色、间距、字号、圆角、阴影、层级、动效的取值与新增流程都在那里;本节只管行为与结构,不重复定义值。
|
||||
|
||||
- **Tab(页签)一律「单框扁平」**:外层容器透明无边框(只留间距),active 用**品牌色扁平高亮**(`color-mix(in srgb, var(--iwb-brand) N%, transparent)`),hover 用浅色底。**禁止「容器 pill + 页签 pill」嵌套双层框**。现**只剩一套**:`.iwb-tabstrip` + `.iwb-tab`(v3.26.44 起)。历史变体 `.iwb-drawer-tab` / `.iwb-lib-tab` / `.iwb-rail-tab` / `.iwb-res-tab` 已随 B1/B3 批次删除 —— **不得复活**,新增 tab 必须用 `.iwb-tab` 样式。
|
||||
- **颜色/字号/间距/圆角一律走 token**(`var(--iwb-text2)` / `--iwb-font-*` / `--iwb-space-*` / `--iwb-radius-*`),不写死色值与 px;高亮态用 `color-mix` 派生透明底。删除样式规则前先查 `dist/app.js` **和 `plugins/**`** —— 插件面板直接复用宿主类名(如 `.iwb-lib-*`),只看产物计数会把插件契约当成死代码删掉。
|
||||
- **预览大图** `.iwb-imgpreview img` 必须**同时**约束宽高(`max-width:92vw; max-height:88vh; width/height:auto; object-fit:contain`),保持比例居中不溢出;该类**只保留一份**权威定义,禁止复制第二份。
|
||||
|
||||
### 12.5 图库(资源中心·图库页)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# promptlib 迭代复盘(2026-11-22)
|
||||
|
||||
> 记录本轮提示词库 1.6.6 → 1.8.8 迭代中遇到的问题、根因与必须遵守的做法。
|
||||
|
||||
## 1. 发布纪律(最大教训)
|
||||
|
||||
- 每次改动同时做三件事:插件 package.json version、入口 version、市场发布(gen-market + 上传 NAS)。
|
||||
- 只在本机手工替换 manifest 不上市场,用户端永远是旧版本。
|
||||
- 发布前必须 node --check;1.8.5 曾因转义把正则写成真实换行,语法损坏。
|
||||
- 上市场后让用户「刷新市场 → 更新」,必要时重启。
|
||||
|
||||
## 2. 拖入画布(不要用原生 HTML5 DnD)
|
||||
|
||||
- 原生 drag&drop 在 WKWebView 吞掉 pointerup,落点节点带焦点残留。
|
||||
- 用 pointerdown → pointermove(>5px) 幽灵 → pointerup → canvas.screenToWorld → canvasWrite.createNode。
|
||||
- 落点 = 鼠标位置 = 节点左上角(对齐风格库),不要居中偏移。
|
||||
- 拖拽期间 body 加 user-select:none。
|
||||
|
||||
## 3. 详情插入:两步放置
|
||||
|
||||
- 点插入后关闭详情 → 跟手灰色小方框(112×112,左上角对齐鼠标)→ 点击画布落点;Esc 取消。
|
||||
|
||||
## 4. 编辑面板
|
||||
|
||||
- 三栏:左 236 固定 / 中自适应 / 右可变(默认 300,190–460),分割条 6px。
|
||||
- 正文 flex:1 到底;变量区独立滚动。
|
||||
- 变量 = 单个输入框,与正文双向同步;重名阻止并回退。
|
||||
- i 按钮展开说明,可多开、各自收起;说明透明背景 + 虚线框。
|
||||
- 正文变量高亮覆盖层与 textarea 的字体/行高/内边距必须一致,否则光标错位;程序改 value 后手动重绘。
|
||||
- 标签用输入框 + 加号生成 chips,可删除。
|
||||
|
||||
## 5. 详情面板
|
||||
|
||||
- 左卡片:封面 contain 完整展示 → 标题 14px → 分割线 → 分组/标签/字数(去底色、带冒号、行间浅线)。
|
||||
- 右卡片:标题 + 正文独立滚动(flex + min-height:0 + overflow:auto)。
|
||||
- 左右卡片等距等高,align-items: stretch,否则右侧没有滚动条。
|
||||
- 右上角编辑 + 关闭;底部插入沿用两步放置;编辑取消回到详情。
|
||||
|
||||
## 6. 节点与输出
|
||||
|
||||
- 变量输入框 placeholder = 说明文字。
|
||||
- 节点保存 tpl(含变量,供编辑)与 text(填值后剔除未填占位,供下游/生图)。
|
||||
- 旧节点 render 时自愈 text。
|
||||
|
||||
## 7. 样式
|
||||
|
||||
- 输入框比底色更亮 + 极浅描边,聚焦纯白 + 淡紫光圈;不要深灰条。
|
||||
- 变量行不要套边框;说明透明 + 虚线。
|
||||
- 插件样式自包含;参考 docs/standards/plugin-development.md 与 plugin-node-drag.md。
|
||||
|
||||
## 8. 版本记录
|
||||
|
||||
1.6.6 封面文件化 / 1.6.7 outKind / 1.6.15 指针拖拽 / 1.6.18–19 落点 / 1.6.20 封面插入 / 1.6.21 两步放置 / 1.6.22–23 放置框 / 1.7.0 三栏编辑 / 1.7.1 视觉精修 / 1.7.2 变量黑粗 / 1.7.3 正文显示 / 1.7.4 名称可拖高 / 1.7.5–1.7.6 封面 contain + 取消回详情 / 1.7.7 字体度量 / 1.7.8 重绘 / 1.7.9 滚动 / 1.8.0 标题下移 + 标签编辑器 / 1.8.1 元信息 / 1.8.2 卡片化 / 1.8.3–1.8.4 布局 / 1.8.5–1.8.6 输出剔除变量 / 1.8.7–1.8.8 细节。
|
||||
@@ -0,0 +1,38 @@
|
||||
# promptlib 样式基线与插入变量规则(2026-11-23 定稿)
|
||||
|
||||
## 一、正确的样式基线
|
||||
|
||||
- **样式基线 = promptlib v1.8.8**(插件仓 commit `178b36c`)
|
||||
- 当前版本 v1.8.17 的 `styles.css` 与 1.8.8 视觉一致,仅在颜色值外做了无副作用的 `var(--plp-cN, #原色)` 兜底包装
|
||||
- 以后任何 UI 调整都以此基线为起点,先 `git diff 178b36c -- promptlib/styles.css` 看差异
|
||||
|
||||
回滚命令:
|
||||
|
||||
```bash
|
||||
cd iwb-plugins-desktop
|
||||
git checkout 178b36c -- promptlib/styles.css promptlib/src/index.js
|
||||
```
|
||||
|
||||
## 二、这次错误的根因(禁止重犯)
|
||||
|
||||
1. **不要批量替换颜色 token**:为了过主题契约,曾用脚本把 `color/border/background` 统一替换成 `--iwb-plugin-*`,结果把文字色换成了边框色 → 变量/输入框文字不可见、灰块。
|
||||
2. **不要用脚本重写 CSS 声明**:多声明一行、伪类(`:focus`)都会被破坏;曾出现 `: focus` 导致焦点样式全失效。
|
||||
3. **修改后必须先做视觉验证**:静态 HTML + Playwright 截图,或真机截图,再上市场;不要连续猜着发版。
|
||||
4. **主题契约的安全做法**:只把颜色包成 `var(--plp-cN, #原色)`(不定义变量,保留原色),或 `var(--iwb-*, #原色)` 且确保语义正确;禁止改变视觉。
|
||||
|
||||
## 三、插入变量的正确实现
|
||||
|
||||
- 工具栏按钮 `pointerdown` 必须 `preventDefault()`,避免抢走 textarea 焦点/选区
|
||||
- 记录选区只在 `keyup / mouseup / input / select`,**绝对不要在 `blur` 记录**(WebKit 失焦会重置选区 → 插入到前一个字符)
|
||||
- 点击时先 `focus()` → 用 `lastSel` 计算插入点,直接 `value.slice` 拼接(确定性 splice)
|
||||
- 插入后 `setSelectionRange` 选中变量名,并同步 `lastSel`
|
||||
- **不要用「透明 textarea + 高亮层」做编辑区**:两层即使字体相同,变量加粗/换行差异也会让点击位置逐次左移(v1.8.18 实测:第 1 次对、第 2 次偏 1 字、第 3 次偏 2 字)。编辑正文直接由 textarea 渲染(v1.8.20)
|
||||
- **不要用 `document.execCommand("insertText")`**:WKWebView 内部光标与 `selectionStart` 会漂移,第一次正常、第二次起偏移一个字符(v1.8.16 实测)
|
||||
|
||||
## 四、发布前检查清单
|
||||
|
||||
1. `node --check src/index.js`
|
||||
2. 同步客户端后跑 `tests/plugin-theme-contract-test.js`
|
||||
3. 静态渲染截图核对:编辑弹窗 / 详情弹窗(颜色、滚动、输入框描边)
|
||||
4. 再 bump 版本 + 上市场(gen-market + 上传 NAS)
|
||||
5. 版本号三处一致;市场 index.json 版本正确
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.37",
|
||||
"version": "3.26.49",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
@@ -10,15 +10,21 @@
|
||||
"app:build": "tauri build",
|
||||
"lint": "eslint src app.js",
|
||||
"test": "node tests/relay-task-graph-fixture-test.js && node tests/plugin-style-node-test.js && node tests/inherit-text-test.js",
|
||||
"test:unit": "node tests/plugin-archive-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/storage-config-shape-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/image-blob-store-test.js && node tests/image-preview-derive-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js",
|
||||
"test:unit": "node tests/plugin-archive-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/storage-config-shape-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/image-blob-store-test.js && node tests/image-preview-derive-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js",
|
||||
"test:diagnostics": "node tests/runtime-diagnostics-hotpath-test.js",
|
||||
"test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js",
|
||||
"plugins:gc": "node scripts/plugins-publish.mjs --gc",
|
||||
"coverage:browser": "npm run build && node scripts/coverage-browser.js",
|
||||
"audit:pins": "node scripts/audit-source-pins.js",
|
||||
"tokens:write": "node scripts/gen-tokens.js --write",
|
||||
"tokens:check": "node scripts/gen-tokens.js --check",
|
||||
"audit:tokens": "node scripts/token-audit.js",
|
||||
"audit:tokens:contrast": "node scripts/token-audit.js --contrast",
|
||||
"test:visual": "npx playwright test _visual-tokens",
|
||||
"test:visual:update": "npx playwright test _visual-tokens --update-snapshots",
|
||||
"test:e2e": "npm run build && node scripts/serve-test.js",
|
||||
"test:e2e:local": "node scripts/serve-test.js",
|
||||
"verify:ci": "npm run build && node --check app.js && node --check dist/app.js && node scripts/check-dist.js && npm run lint && npm run typecheck && npm run test:unit && npm test && npm run test:facts",
|
||||
"verify:ci": "npm run build && node --check app.js && node --check dist/app.js && node scripts/check-dist.js && npm run tokens:check && npm run lint && npm run typecheck && npm run test:unit && npm test && npm run test:facts",
|
||||
"verify": "npm run verify:ci && npm run test:e2e",
|
||||
"verify:release": "node scripts/verify-release.js",
|
||||
"coverage:e2e": "node scripts/coverage-e2e.js",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[
|
||||
{
|
||||
"id": "batch-export",
|
||||
"file": "plugin-batch-export.b7d13ba66cf9.js",
|
||||
"version": "1.2.0",
|
||||
"integrity": "sha256-t9E7pmz5f/ZelDBTKBg6GjtaRbA5Pzpj939re0Z5U4k="
|
||||
"file": "plugin-batch-export.4beb9bc20c26.js",
|
||||
"version": "1.2.1",
|
||||
"integrity": "sha256-S+ubwgwmP+6V2GNX1sWsL/QpV3kx9+qCo5SYl4a1NFA="
|
||||
},
|
||||
{
|
||||
"id": "blank-canvas",
|
||||
@@ -13,9 +13,9 @@
|
||||
},
|
||||
{
|
||||
"id": "browser",
|
||||
"file": "plugin-browser.8161a82890d9.js",
|
||||
"version": "1.7.0",
|
||||
"integrity": "sha256-gWGoKJDZZyTZCirpyJSdN6+S+UuUTNUlrcB7ZbXqtPQ="
|
||||
"file": "plugin-browser.8f2a263e02ef.js",
|
||||
"version": "1.7.1",
|
||||
"integrity": "sha256-jyomPgLvCIztHM8MJ1/s6472N7q+q5aHsl128vH50rQ="
|
||||
},
|
||||
{
|
||||
"id": "gallery",
|
||||
@@ -44,23 +44,23 @@
|
||||
"dir": "promptlib",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.6.6",
|
||||
"version": "1.8.21",
|
||||
"files": {
|
||||
"main.js": "530b4bc021e0730f14505f666203c8c9c165bf9ea6bef9765ec7e9ebcda95c54",
|
||||
"styles.css": "872ceeded7eb67599dfa159c86be1b1e1724f7cd1e04cae1d79d939bb0e1ebdf"
|
||||
"main.js": "125e02a618e37505836f964dbe21a3637e3043ee355d9606c538a54eed4243ad",
|
||||
"styles.css": "84ad2314d016c7d2351eb7cf2044ee8cc703992d40a76002ff644d34eb48838a"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "image-annotate",
|
||||
"file": "plugin-image-annotate.7a865c7c353c.js",
|
||||
"version": "1.20.6",
|
||||
"integrity": "sha256-eoZcfDU8P7yqxVGorrWs0b9iTKJfEE25b85JPDCEsk8="
|
||||
"file": "plugin-image-annotate.fc04e57a7603.js",
|
||||
"version": "1.20.7",
|
||||
"integrity": "sha256-/ATlenYDu6SgZkSG7CEmN0DdcY1bo1jasNMCAjdzZjQ="
|
||||
},
|
||||
{
|
||||
"id": "image-vectorize",
|
||||
"file": "plugin-image-vectorize.7014982f60e6.js",
|
||||
"version": "0.6.0",
|
||||
"integrity": "sha256-cBSYL2DmBeNJCZhqwMNyGV5hMBKeKakn1tQaFAVXnp8="
|
||||
"file": "plugin-image-vectorize.0e5a7fa018b2.js",
|
||||
"version": "0.6.1",
|
||||
"integrity": "sha256-Dlp/oBiy6d5wX5ESJyrQLc8Ye1NhaW9/wKEqk8TyDU4="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
@@ -95,6 +95,12 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 提交给下游/生图的文本:填完变量后,把未填的 {占位} 从输出里剔除(只在编辑器里展示)。
|
||||
function outputText (tpl, vals) {
|
||||
var s = fillTpl(tpl, vals)
|
||||
return s.replace(/[{][^{}]{1,24}[}]/g, ' ').replace(/[ ]{2,}/g, ' ').trim()
|
||||
}
|
||||
|
||||
function varsOf (p) {
|
||||
if (!p) return []
|
||||
if (Array.isArray(p.vars) && p.vars.length) {
|
||||
@@ -313,6 +319,13 @@
|
||||
var modalHost = null
|
||||
var loadError = ''
|
||||
var saveTimer = 0
|
||||
// 拖拽结束/窗口失焦时清理视觉态,避免卡住
|
||||
try {
|
||||
global.addEventListener('blur', function () {
|
||||
var d = wrap.querySelectorAll('.iwb-plp-card.is-dragging, .iwb-plp-card.is-pressed')
|
||||
for (var i = 0; i < d.length; i++) { d[i].classList.remove('is-dragging'); d[i].classList.remove('is-pressed') }
|
||||
})
|
||||
} catch (e) { /* ignore */ }
|
||||
|
||||
function notify (t, ty) { try { api.notify && api.notify(t, ty || 'ok') } catch (e) { /* ignore */ } }
|
||||
|
||||
@@ -714,6 +727,170 @@
|
||||
for (var i = 0; i < str.length; i++) h = (h * 31 + str.charCodeAt(i)) % 360
|
||||
return 'linear-gradient(135deg, hsl(' + h + ' 52% 66%), hsl(' + ((h + 36) % 360) + ' 52% 44%))'
|
||||
}
|
||||
// v1.6.9:拖拽时跟手的「虚拟卡片」——让用户明确看到拖拽已开始、会插入什么
|
||||
function makeDragGhost (p) {
|
||||
var g = el('div', { class: 'iwb-plp-dragghost' })
|
||||
var url = coverOf(p)
|
||||
if (url) g.appendChild(el('img', { class: 'iwb-plp-ghostcov', src: url, alt: '', draggable: 'false' }))
|
||||
var box = el('div', { class: 'iwb-plp-ghosttxt' })
|
||||
box.appendChild(el('div', { class: 'iwb-plp-ghostname', text: p.name || '未命名' }))
|
||||
var vd = varsOf(p)
|
||||
box.appendChild(el('div', { class: 'iwb-plp-ghosthint', text: vd.length ? ('模板节点 · ' + vd.length + ' 个变量') : '文本节点' }))
|
||||
g.appendChild(box)
|
||||
g.style.position = 'fixed'; g.style.left = '-9999px'; g.style.top = '0'
|
||||
g.classList.add('is-live')
|
||||
document.body.appendChild(g)
|
||||
return g
|
||||
}
|
||||
|
||||
// v1.6.15:改成和风格库一样的「指针拖拽插入」,不再用原生 HTML5 drag&drop。
|
||||
// 原生拖放在 WKWebView 里会吞掉 pointerup,落点节点会带着“焦点/编辑态”,第一次点击拖不动。
|
||||
var cardDrag = null
|
||||
function moveGhostTo (x, y) {
|
||||
if (!cardDrag || !cardDrag.ghost) return
|
||||
cardDrag.ghost.style.left = (x + 14) + 'px'
|
||||
cardDrag.ghost.style.top = (y + 14) + 'px'
|
||||
}
|
||||
function endCardDrag (commit, x, y) {
|
||||
var st = cardDrag
|
||||
if (!st) return
|
||||
cardDrag = null
|
||||
try {
|
||||
global.removeEventListener('pointermove', st.onMove, true)
|
||||
global.removeEventListener('pointerup', st.onUp, true)
|
||||
global.removeEventListener('pointercancel', st.onCancel, true)
|
||||
} catch (e) { /* ignore */ }
|
||||
if (st.ghost && st.ghost.parentNode) st.ghost.parentNode.removeChild(st.ghost)
|
||||
try { document.body.classList.remove('iwb-plp-dragging') } catch (e) { /* ignore */ }
|
||||
try { st.card.classList.remove('is-dragging'); st.card.classList.remove('is-pressed') } catch (e) { /* ignore */ }
|
||||
if (!commit || !st.active) return
|
||||
try {
|
||||
var api2 = ctx.canvasWrite || ctx.canvas
|
||||
var sw = ctx.canvas && typeof ctx.canvas.screenToWorld === 'function' ? ctx.canvas.screenToWorld : null
|
||||
var cnv = document.querySelector('.iwb-canvas')
|
||||
if (cnv) {
|
||||
var rc = cnv.getBoundingClientRect()
|
||||
if (x < rc.left || x > rc.right || y < rc.top || y > rc.bottom) return
|
||||
}
|
||||
if (!api2 || typeof api2.createNode !== 'function' || !sw) { notify('当前宿主不支持拖拽插入', 'err'); return }
|
||||
var w = sw(x, y)
|
||||
if (!w) return
|
||||
var vd = varsOf(st.p)
|
||||
if (vd.length) {
|
||||
api2.createNode('ptpl', w.x, w.y, { promptId: '', name: st.p.name || '提示词模板', tpl: st.p.text || '', vdefs: vd, vars: {}, cover: st.p.cover || '', refOn: false, text: outputText(st.p.text || '', {}), outKind: 'prompt' })
|
||||
notify('已插入模板节点:' + (st.p.name || ''))
|
||||
} else {
|
||||
api2.createNode('prompt', w.x, w.y, { text: st.p.text || '', title: st.p.name || '' })
|
||||
notify('已插入提示词:' + (st.p.name || ''))
|
||||
}
|
||||
} catch (err) { notify('拖拽插入失败:' + ((err && err.message) || err), 'err') }
|
||||
}
|
||||
// 详情里插入节点:落到画布可视区域中心,而不是被 findSpot 丢到左侧面板下面
|
||||
function canvasCenter (w, h) {
|
||||
try {
|
||||
var c = document.querySelector('.iwb-canvas')
|
||||
var sw = ctx.canvas && typeof ctx.canvas.screenToWorld === 'function' ? ctx.canvas.screenToWorld : null
|
||||
if (!c || !sw) return null
|
||||
var r = c.getBoundingClientRect()
|
||||
var pt = sw(r.left + r.width / 2, r.top + r.height / 2)
|
||||
return pt ? { x: pt.x - (w || 0) / 2, y: pt.y - (h || 0) / 2 } : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
// v1.6.21:详情里的「插入」改成两步放置:先出现跟手幽灵,再点画布落点。
|
||||
var placement = null
|
||||
function cancelPlacement () {
|
||||
var st = placement
|
||||
if (!st) return
|
||||
placement = null
|
||||
try {
|
||||
global.removeEventListener('pointermove', st.move, true)
|
||||
global.removeEventListener('pointerdown', st.down, true)
|
||||
global.removeEventListener('keydown', st.key, true)
|
||||
} catch (e) { /* ignore */ }
|
||||
if (st.ghost && st.ghost.parentNode) st.ghost.parentNode.removeChild(st.ghost)
|
||||
try { document.body.style.cursor = '' } catch (e) { /* ignore */ }
|
||||
}
|
||||
// v1.6.22:放置指示改成半透明矩形框(跟手、左上角对齐落点),不再用卡片式幽灵。
|
||||
function makePlaceGhost (kind) {
|
||||
var dims = { w: 112, h: 112 }
|
||||
var box = el('div', { class: 'iwb-plp-placebox' })
|
||||
box.style.width = dims.w + 'px'
|
||||
box.style.height = dims.h + 'px'
|
||||
box.appendChild(el('div', { class: 'iwb-plp-placebox-t', text: '点击放置' }))
|
||||
return box
|
||||
}
|
||||
function beginPlacement (kind, payload) {
|
||||
cancelPlacement()
|
||||
var ghost = makePlaceGhost(kind)
|
||||
document.body.appendChild(ghost)
|
||||
var st = { ghost: ghost, kind: kind, payload: payload }
|
||||
st.move = function (e) {
|
||||
ghost.style.left = e.clientX + 'px'
|
||||
ghost.style.top = e.clientY + 'px'
|
||||
}
|
||||
st.down = function (e) {
|
||||
var c = document.querySelector('.iwb-canvas')
|
||||
if (!c || !c.contains(e.target)) return
|
||||
e.preventDefault(); e.stopPropagation()
|
||||
st.move(e)
|
||||
placeAt(st.kind, st.payload, e.clientX, e.clientY)
|
||||
}
|
||||
st.key = function (e) { if (e.key === 'Escape') { e.preventDefault(); cancelPlacement(); notify('已取消放置') } }
|
||||
global.addEventListener('pointermove', st.move, true)
|
||||
global.addEventListener('pointerdown', st.down, true)
|
||||
global.addEventListener('keydown', st.key, true)
|
||||
placement = st
|
||||
try { document.body.style.cursor = 'copy' } catch (e) { /* ignore */ }
|
||||
notify('移动鼠标到目标位置后单击放置(Esc 取消)')
|
||||
}
|
||||
function placeAt (kind, payload, cx, cy) {
|
||||
try {
|
||||
var sw = ctx.canvas && typeof ctx.canvas.screenToWorld === 'function' ? ctx.canvas.screenToWorld(cx, cy) : null
|
||||
var cw = ctx.canvasWrite || ctx.canvas
|
||||
if (!sw || !cw) { notify('当前宿主不支持放置', 'err'); cancelPlacement(); return }
|
||||
if (kind === 'img') {
|
||||
var iid = cw.createImageNode({ dataUrl: payload.dataUrl, name: payload.name || '封面图片', x: sw.x, y: sw.y })
|
||||
if (!iid) { notify('插入封面失败', 'err'); cancelPlacement(); return }
|
||||
notify('已插入封面图片')
|
||||
} else if (kind === 'ptpl') {
|
||||
var p = payload
|
||||
var id2 = cw.createNode('ptpl', sw.x, sw.y, { promptId: p.id, name: p.name || '提示词模板', tpl: p.text || '', vdefs: varsOf(p), vars: {}, outKind: 'prompt', cover: p.cover || coverNameOf(p), refOn: false, text: outputText(p.text || '', {}) })
|
||||
if (!id2) { notify('插入失败', 'err'); cancelPlacement(); return }
|
||||
notify('已插入模板节点')
|
||||
} else {
|
||||
var id3 = cw.createNode('prompt', sw.x, sw.y, { text: payload.text || '', title: payload.name || '' })
|
||||
if (!id3) { notify('插入失败', 'err'); cancelPlacement(); return }
|
||||
notify('已插入提示词')
|
||||
}
|
||||
} catch (err) { notify('插入失败:' + ((err && err.message) || err), 'err') }
|
||||
cancelPlacement()
|
||||
}
|
||||
function startCardDrag (e, p, card) {
|
||||
if (e.button !== 0) return
|
||||
// 不用 preventDefault:否则 WebKit 可能吞掉 click/dblclick(双击详情失效)
|
||||
card.classList.add('is-pressed')
|
||||
try { document.body.classList.add('iwb-plp-dragging') } catch (err) { /* ignore */ }
|
||||
var st = { card: card, p: p, sx: e.clientX, sy: e.clientY, active: false, ghost: null }
|
||||
st.onMove = function (ev) {
|
||||
var dx = ev.clientX - st.sx, dy = ev.clientY - st.sy
|
||||
if (!st.active && Math.hypot(dx, dy) < 5) return
|
||||
if (!st.active) {
|
||||
st.active = true
|
||||
card.classList.add('is-dragging')
|
||||
try { st.ghost = makeDragGhost(p) } catch (err) { st.ghost = null }
|
||||
}
|
||||
moveGhostTo(ev.clientX, ev.clientY)
|
||||
}
|
||||
st.onUp = function (ev) { endCardDrag(true, ev.clientX, ev.clientY) }
|
||||
st.onCancel = function () { endCardDrag(false, 0, 0) }
|
||||
try {
|
||||
global.addEventListener('pointermove', st.onMove, true)
|
||||
global.addEventListener('pointerup', st.onUp, true)
|
||||
global.addEventListener('pointercancel', st.onCancel, true)
|
||||
} catch (err) { /* ignore */ }
|
||||
cardDrag = st
|
||||
}
|
||||
|
||||
function openDetail (id) { view.mode = 'detail'; view.id = String(id || ''); render(); try { scrollBox.scrollTop = 0 } catch (e) { /* ignore */ } }
|
||||
function backToList () { view.mode = 'list'; view.id = ''; render() }
|
||||
|
||||
@@ -797,54 +974,69 @@
|
||||
|
||||
// ===== v1.5.0:变量编辑器(新建/编辑弹窗用)=====
|
||||
// 变量来自正文的 {名字}:自动检测、可改标签/默认值/说明;留空时渲染保留 {原名}。
|
||||
function makeVarsEditor (text, initial) {
|
||||
function makeVarsEditor (text, initial, onTextChange) {
|
||||
var box = el('div', { class: 'iwb-plp-vars' })
|
||||
var head = el('div', { class: 'iwb-plp-vhead' })
|
||||
head.appendChild(el('span', { text: '变量' }))
|
||||
head.appendChild(el('span', { class: 'iwb-plp-vhint', text: '从正文 {…} 自动检测,可改标签 / 默认值 / 说明' }))
|
||||
var chips = el('div', { class: 'iwb-plp-vchips' })
|
||||
var head = el('div', { class: 'iwb-plp-vhead' },
|
||||
el('span', { text: '变量' }),
|
||||
el('span', { class: 'iwb-plp-vhint', text: '与正文双向同步 · 点 i 写说明' }))
|
||||
var rows = el('div', { class: 'iwb-plp-vrows' })
|
||||
var prev = el('div', { class: 'iwb-plp-vprev' })
|
||||
box.appendChild(head); box.appendChild(chips); box.appendChild(rows); box.appendChild(prev)
|
||||
box.appendChild(head); box.appendChild(rows)
|
||||
var list = []
|
||||
if (Array.isArray(initial) && initial.length) list = initial.map(function (v) { return { key: String(v.key || ''), label: String(v.label || v.key || ''), desc: String(v.desc || ''), def: String(v.def || '') } })
|
||||
var open = {}
|
||||
var norm = function (v) { return { key: String(v.key || ''), desc: String(v.desc || ''), def: String(v.def || '') } }
|
||||
if (Array.isArray(initial) && initial.length) list = initial.filter(function (v) { return v && v.key }).map(norm)
|
||||
function values () {
|
||||
var m = {}
|
||||
list.forEach(function (v) { if (v.def) m[v.key] = v.def })
|
||||
return m
|
||||
}
|
||||
function paint () {
|
||||
clear(chips); clear(rows)
|
||||
clear(rows)
|
||||
list.forEach(function (v) {
|
||||
var chip = el('span', { class: 'iwb-plp-vchip', text: v.label || v.key })
|
||||
var x = el('i', { class: 'iwb-plp-vx', text: '×', title: '忽略这个变量' })
|
||||
x.addEventListener('click', function () { list = list.filter(function (z) { return z.key !== v.key }); paint() })
|
||||
chip.appendChild(x)
|
||||
chips.appendChild(chip)
|
||||
var row = el('div', { class: 'iwb-plp-vrow' })
|
||||
row.appendChild(el('span', { class: 'iwb-plp-vk', text: '{' + v.key + '}' }))
|
||||
var def = el('input', { class: 'iwb-input iwb-plp-vin', placeholder: '默认值(可留空)' })
|
||||
def.value = v.def || ''
|
||||
def.addEventListener('input', function () { v.def = def.value; paintPrev() })
|
||||
var desc = el('input', { class: 'iwb-input iwb-plp-vin', placeholder: '说明(如:如「11.9」)' })
|
||||
desc.value = v.desc || ''
|
||||
desc.addEventListener('input', function () { v.desc = desc.value })
|
||||
row.appendChild(def); row.appendChild(desc)
|
||||
rows.appendChild(row)
|
||||
var item = el('div', { class: 'iwb-plp-vitem' })
|
||||
var row = el('div', { class: 'iwb-plp-vrow2' })
|
||||
var nameIn = el('input', { class: 'iwb-input iwb-plp-vname', placeholder: '变量名' })
|
||||
nameIn.value = v.key
|
||||
var iBtn = el('button', { class: 'iwb-plp-vi' + (open[v.key] ? ' is-open' : ''), type: 'button', title: '说明', text: 'i' })
|
||||
iBtn.addEventListener('click', function () { open[v.key] = !open[v.key]; paint() })
|
||||
nameIn.addEventListener('blur', function () { renameTo(v, nameIn.value) })
|
||||
nameIn.addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); nameIn.blur() } })
|
||||
row.appendChild(nameIn); row.appendChild(iBtn)
|
||||
item.appendChild(row)
|
||||
if (open[v.key]) {
|
||||
var d = el('input', { class: 'iwb-input iwb-plp-vdesc', placeholder: '说明(会作为节点输入框的占位提示)' })
|
||||
d.value = v.desc || ''
|
||||
d.addEventListener('input', function () { v.desc = d.value })
|
||||
item.appendChild(d)
|
||||
}
|
||||
rows.appendChild(item)
|
||||
})
|
||||
if (!list.length) rows.appendChild(el('div', { class: 'iwb-hint', text: '正文里没有 {变量};写入 {产品名} 这样的大括号即会被识别。' }))
|
||||
paintPrev()
|
||||
if (!list.length) rows.appendChild(el('div', { class: 'iwb-hint', text: '正文里没有 {变量};输入 {产品名} 即会被识别。' }))
|
||||
}
|
||||
function renameTo (v, raw) {
|
||||
var next = String(raw || '').replace(/[{}]/g, '').trim()
|
||||
if (!next || next === v.key) { paint(); return }
|
||||
if (list.some(function (x) { return x !== v && x.key === next })) { notify('变量名重复:' + next, 'err'); paint(); return }
|
||||
var old = v.key
|
||||
v.key = next
|
||||
if (open[old] !== undefined) { open[next] = open[old]; delete open[old] }
|
||||
var nt = String(text || '').split('{' + old + '}').join('{' + next + '}')
|
||||
text = nt
|
||||
if (typeof onTextChange === 'function') onTextChange(nt)
|
||||
paint()
|
||||
}
|
||||
function paintPrev () { prev.textContent = fillTpl(text, values()) }
|
||||
function sync (nextText) {
|
||||
text = String(nextText || '')
|
||||
var found = detectVars(text)
|
||||
var old = {}
|
||||
list.forEach(function (v) { old[v.key] = v })
|
||||
list = found.map(function (v) { return old[v.key] ? Object.assign({}, v, old[v.key]) : v })
|
||||
list = found.map(function (v) {
|
||||
var prev = old[v.key]
|
||||
return { key: v.key, desc: prev ? prev.desc : v.desc, def: prev ? prev.def : '' }
|
||||
})
|
||||
paint()
|
||||
}
|
||||
if (!list.length) list = detectVars(text)
|
||||
if (!list.length) list = detectVars(text).map(norm)
|
||||
paint()
|
||||
return { node: box, sync: sync, list: function () { return list }, values: values }
|
||||
}
|
||||
@@ -1160,46 +1352,55 @@
|
||||
var closeBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '关闭', text: '✕' })
|
||||
var dlg = openDialog({
|
||||
key: 'detail',
|
||||
title: p.name || '未命名',
|
||||
width: 880, height: 640,
|
||||
title: '提示词详情',
|
||||
width: 1180, height: 720,
|
||||
actions: [edit, closeBtn],
|
||||
build: function (bodyEl, footEl) {
|
||||
var cov = el('div', { class: 'iwb-plp-dcov' })
|
||||
paintCoverInto(cov, p)
|
||||
var leftCol = el('div', { class: 'iwb-plp-dleftcol' })
|
||||
leftCol.appendChild(cov)
|
||||
leftCol.appendChild(el('div', { class: 'iwb-plp-dtitle', text: p.name || '未命名' }))
|
||||
var meta = el('div', { class: 'iwb-plp-dmeta' })
|
||||
function metaRow (label, nodes) {
|
||||
var row = el('div', { class: 'iwb-plp-dmrow' })
|
||||
row.appendChild(el('span', { class: 'iwb-plp-dmk', text: label }))
|
||||
var val = el('div', { class: 'iwb-plp-dmv' })
|
||||
;(Array.isArray(nodes) ? nodes : [nodes]).forEach(function (n) { val.appendChild(n) })
|
||||
row.appendChild(val)
|
||||
return row
|
||||
}
|
||||
meta.appendChild(metaRow('分组:', el('span', { class: 'iwb-plp-dgroup', text: p.group || '未分组' })))
|
||||
var tagNodes = (p.tags || []).map(function (t) { return el('span', { class: 'iwb-plp-dtag', text: '#' + t }) })
|
||||
if (!tagNodes.length) tagNodes = [el('span', { class: 'iwb-plp-dempty', text: '无' })]
|
||||
meta.appendChild(metaRow('标签:', tagNodes))
|
||||
meta.appendChild(metaRow('字数:', el('span', { class: 'iwb-plp-dlen', text: String(p.text || '').length + ' 字' })))
|
||||
leftCol.appendChild(meta)
|
||||
var right = el('div', { class: 'iwb-plp-dright' })
|
||||
right.appendChild(el('div', { class: 'iwb-hint', text: [p.group || '未分组'].concat(p.tags || []).join(' · ') + ' · ' + String(p.text || '').length + ' 字' }))
|
||||
var vlist = varsOf(p)
|
||||
var vals = {}
|
||||
var txt = el('div', { class: 'iwb-plp-dtext', text: p.text || '' })
|
||||
var txt = el('div', { class: 'iwb-plp-dtext' })
|
||||
;(function paintText () {
|
||||
var str = String(p.text || '')
|
||||
var re = /[{]([^{}]{1,24})[}]/g, last = 0, m
|
||||
while ((m = re.exec(str))) {
|
||||
if (m.index > last) txt.appendChild(document.createTextNode(str.slice(last, m.index)))
|
||||
txt.appendChild(el('span', { class: 'iwb-plp-dvar', text: m[0] }))
|
||||
last = m.index + m[0].length
|
||||
}
|
||||
if (last < str.length) txt.appendChild(document.createTextNode(str.slice(last)))
|
||||
})()
|
||||
function filled () { return vlist.length ? fillTpl(p.text, vals) : String(p.text || '') }
|
||||
if (vlist.length) {
|
||||
var vbox = el('div', { class: 'iwb-plp-dvars' })
|
||||
vlist.forEach(function (v) {
|
||||
var row = el('div', { class: 'iwb-plp-vrow' })
|
||||
row.appendChild(el('span', { class: 'iwb-plp-vk', text: v.label || v.key }))
|
||||
var inp = el('input', { class: 'iwb-input iwb-plp-vin', placeholder: v.desc || v.def || '' })
|
||||
inp.value = v.def || ''
|
||||
inp.addEventListener('input', function () { vals[v.key] = inp.value; txt.textContent = filled() })
|
||||
row.appendChild(inp)
|
||||
vbox.appendChild(row)
|
||||
})
|
||||
right.appendChild(vbox)
|
||||
right.appendChild(el('div', { class: 'iwb-hint', text: '预览(留空的变量保留 {原名})' }))
|
||||
}
|
||||
right.appendChild(el('div', { class: 'iwb-plp-dsec', text: '提示词内容' }))
|
||||
right.appendChild(txt)
|
||||
bodyEl.appendChild(cov); bodyEl.appendChild(right)
|
||||
bodyEl.appendChild(leftCol); bodyEl.appendChild(right)
|
||||
var del = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-danger', text: '删除' })
|
||||
var cp = el('button', { class: 'iwb-btn iwb-btn-sm', text: '复制全文' })
|
||||
var insTpl = null
|
||||
if (ctx.nodes && ctx.canvas && typeof ctx.canvas.createNode === 'function') {
|
||||
var cw = ctx.canvasWrite || ctx.canvas
|
||||
if (ctx.nodes && cw && typeof cw.createNode === 'function') {
|
||||
insTpl = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', title: '插入可填变量的模板节点', text: '插入模板节点' })
|
||||
insTpl.addEventListener('click', function () {
|
||||
var id = ctx.canvas.createNode('ptpl', null, null, {
|
||||
promptId: p.id, name: p.name || '提示词模板', tpl: p.text || '', vdefs: vlist, vars: vals,
|
||||
cover: p.cover || coverNameOf(p), refOn: false, text: filled(),
|
||||
})
|
||||
if (id) { notify('已插入模板节点'); dlg.close() } else notify('插入失败', 'err')
|
||||
})
|
||||
insTpl.addEventListener('click', function () { dlg.close(); beginPlacement('ptpl', p) })
|
||||
}
|
||||
var ins = el('button', { class: 'iwb-btn iwb-btn-sm', text: '插入画布' })
|
||||
del.addEventListener('click', function () {
|
||||
@@ -1210,17 +1411,17 @@
|
||||
})
|
||||
})
|
||||
cp.addEventListener('click', function () { Promise.resolve(api.copy(filled())).then(function (r) { if (r && r.ok === false) notify('复制失败', 'err'); else notify('已复制全文') }) })
|
||||
ins.addEventListener('click', function () { Promise.resolve(api.insert(filled(), p.name || '')).then(function () { notify('已插入画布:' + (p.name || '提示词')); dlg.close() }).catch(function () { notify('插入画布失败', 'err') }) })
|
||||
ins.addEventListener('click', function () { dlg.close(); beginPlacement('prompt', { text: filled(), name: p.name || '' }) })
|
||||
var insImg = null
|
||||
if (p.cover) {
|
||||
insImg = el('button', { class: 'iwb-btn iwb-btn-sm', title: '把这条提示词的封面作为参考图插入画布', text: '插入图片' })
|
||||
insImg.addEventListener('click', function () {
|
||||
var covName = coverNameOf(p)
|
||||
var covData = (covName && FILEAPI) ? Promise.resolve(FILEAPI.get(covName)).then(function (x) { return x && x.ok ? x.url : '' }).catch(function () { return '' }) : Promise.resolve(typeof p.cover === 'string' ? p.cover : '')
|
||||
covData.then(function (u) { return api.insertImage(u, p.name || '') }).then(function (r) {
|
||||
if (r && r.ok === false) { notify((r && r.error) || '插入封面失败', 'err'); return }
|
||||
notify('已插入封面图片')
|
||||
covData.then(function (u) {
|
||||
if (!u) { notify('封面文件读取失败(可能文件已丢失)', 'err'); return }
|
||||
dlg.close()
|
||||
beginPlacement('img', { dataUrl: u, name: p.name || '封面图片' })
|
||||
}).catch(function () { notify('插入封面失败', 'err') })
|
||||
})
|
||||
}
|
||||
@@ -1281,43 +1482,115 @@
|
||||
})
|
||||
delCover.addEventListener('click', function () { draft.cover = ''; dirty = true; Object.keys(coverCache).forEach(function (k) { if (k.indexOf(draft.id + '|') === 0) delete coverCache[k] }); repaint() })
|
||||
left.appendChild(cov); left.appendChild(el('div', { class: 'iwb-row' }, upBtn, delCover)); left.appendChild(fileIn)
|
||||
var nameIn = el('input', { class: 'iwb-input', placeholder: '名称', value: draft.name || '' })
|
||||
var nameIn = el('textarea', { class: 'iwb-input iwb-plp-namebox', placeholder: '名称', rows: '1' })
|
||||
nameIn.value = draft.name || ''
|
||||
var groupIn = el('input', { class: 'iwb-input', placeholder: '分组', value: draft.group || '' })
|
||||
var tagsIn = el('input', { class: 'iwb-input', placeholder: '标签,逗号分隔', value: (draft.tags || []).join(', ') })
|
||||
;[nameIn, groupIn, tagsIn].forEach(function (i) { i.addEventListener('input', function () { dirty = true }) })
|
||||
var tags = (draft.tags || []).slice()
|
||||
var tagWrap = el('div', { class: 'iwb-plp-tagwrap' })
|
||||
var tagChips = el('div', { class: 'iwb-plp-tagchips' })
|
||||
var tagIn = el('input', { class: 'iwb-input iwb-plp-tagin', placeholder: '添加标签' })
|
||||
var tagAdd = el('button', { class: 'iwb-btn iwb-btn-sm iwb-plp-tagadd', type: 'button', text: '+' })
|
||||
function paintTags () {
|
||||
tagChips.textContent = ''
|
||||
tags.forEach(function (t, ti) {
|
||||
var chip = el('span', { class: 'iwb-plp-tagchip' })
|
||||
chip.appendChild(document.createTextNode(t))
|
||||
var x = el('i', { class: 'iwb-plp-tagx', text: '×', title: '移除标签' })
|
||||
x.addEventListener('click', function () { tags.splice(ti, 1); dirty = true; paintTags() })
|
||||
chip.appendChild(x)
|
||||
tagChips.appendChild(chip)
|
||||
})
|
||||
}
|
||||
function addTag () {
|
||||
var t = String(tagIn.value || '').trim()
|
||||
if (!t) return
|
||||
if (!tags.some(function (x) { return x === t })) tags.push(t)
|
||||
tagIn.value = ''
|
||||
dirty = true
|
||||
paintTags()
|
||||
}
|
||||
tagAdd.addEventListener('click', addTag)
|
||||
tagIn.addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); addTag() } })
|
||||
;[nameIn, groupIn, tagIn].forEach(function (i) { i.addEventListener('input', function () { dirty = true }) })
|
||||
tagWrap.appendChild(tagChips); tagWrap.appendChild(el('div', { class: 'iwb-plp-tagrow' }, tagIn, tagAdd))
|
||||
paintTags()
|
||||
left.appendChild(el('label', { class: 'iwb-plp-lrow' }, el('span', { text: '名称' }), nameIn))
|
||||
left.appendChild(el('label', { class: 'iwb-plp-lrow' }, el('span', { text: '分组' }), groupIn))
|
||||
left.appendChild(el('label', { class: 'iwb-plp-lrow' }, el('span', { text: '标签' }), tagsIn))
|
||||
left.appendChild(el('div', { class: 'iwb-plp-lrow iwb-plp-lrow-tags' }, el('span', { text: '标签' }), tagWrap))
|
||||
var textIn = el('textarea', { class: 'iwb-input iwb-plp-etext', placeholder: '提示词正文' })
|
||||
var hl = el('div', { class: 'iwb-plp-hl' })
|
||||
var textWrap = el('div', { class: 'iwb-plp-ewrap' })
|
||||
textWrap.appendChild(hl); textWrap.appendChild(textIn)
|
||||
function paintHl () {
|
||||
var v = textIn.value || ''
|
||||
hl.textContent = ''
|
||||
var re = /[{]([^{}]{1,24})[}]/g, last = 0, m
|
||||
while ((m = re.exec(v))) {
|
||||
if (m.index > last) hl.appendChild(document.createTextNode(v.slice(last, m.index)))
|
||||
hl.appendChild(el('span', { class: 'iwb-plp-hlvar', text: m[0] }))
|
||||
last = m.index + m[0].length
|
||||
}
|
||||
if (last < v.length) hl.appendChild(document.createTextNode(v.slice(last)))
|
||||
hl.appendChild(document.createTextNode('\n'))
|
||||
}
|
||||
textIn.addEventListener('scroll', function () { hl.scrollTop = textIn.scrollTop })
|
||||
textIn.value = draft.text || ''
|
||||
var varEd = makeVarsEditor(draft.text || '', draft.vars || [])
|
||||
paintHl()
|
||||
var varEd = makeVarsEditor(draft.text || '', draft.vars || [], function (nt) { textIn.value = nt; dirty = true; paintHl() })
|
||||
var syncTimer = 0
|
||||
textIn.addEventListener('input', function () {
|
||||
dirty = true
|
||||
paintHl()
|
||||
if (syncTimer) clearTimeout(syncTimer)
|
||||
syncTimer = setTimeout(function () { varEd.sync(textIn.value) }, 200)
|
||||
})
|
||||
// v1.6.2:正文上方「插入变量」——在光标处插入 {变量} 并选中变量名,直接打字即可替换
|
||||
var lastSel = { s: 0, e: 0 }
|
||||
function rememberSel () {
|
||||
lastSel.s = typeof textIn.selectionStart === 'number' ? textIn.selectionStart : 0
|
||||
lastSel.e = typeof textIn.selectionEnd === 'number' ? textIn.selectionEnd : lastSel.s
|
||||
}
|
||||
;['keyup', 'mouseup', 'input', 'select'].forEach(function (ev) { textIn.addEventListener(ev, rememberSel) })
|
||||
var insVarBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-plp-insvar', title: '在光标处插入 {变量}', text: '+ 插入变量' })
|
||||
// 按钮按下时不要抢走 textarea 的焦点/选区(否则插入点会漂移到上一次位置)
|
||||
insVarBtn.addEventListener('pointerdown', function (e) { e.preventDefault(); rememberSel() })
|
||||
insVarBtn.addEventListener('click', function () {
|
||||
var v = textIn.value
|
||||
var s = (typeof textIn.selectionStart === 'number') ? textIn.selectionStart : v.length
|
||||
var e = (typeof textIn.selectionEnd === 'number') ? textIn.selectionEnd : v.length
|
||||
var s = Math.min(Math.max(lastSel.s || 0, 0), v.length)
|
||||
var e = Math.min(Math.max(lastSel.e == null ? s : lastSel.e, s), v.length)
|
||||
var name = s !== e ? String(v.slice(s, e)).replace(/\s+/g, '').slice(0, 24) : '新变量'
|
||||
if (!name) name = '新变量'
|
||||
var ins = '{' + name + '}'
|
||||
textIn.value = v.slice(0, s) + ins + v.slice(e)
|
||||
textIn.selectionStart = s + 1
|
||||
textIn.selectionEnd = s + 1 + name.length
|
||||
textIn.focus()
|
||||
textIn.value = v.slice(0, s) + ins + v.slice(e)
|
||||
textIn.setSelectionRange(s + 1, s + 1 + name.length)
|
||||
lastSel = { s: s + 1, e: s + 1 + name.length }
|
||||
dirty = true
|
||||
paintHl()
|
||||
varEd.sync(textIn.value)
|
||||
})
|
||||
var mid = el('div', { class: 'iwb-plp-emid' })
|
||||
mid.appendChild(el('div', { class: 'iwb-plp-etool' }, insVarBtn, el('span', { class: 'iwb-hint', text: '在光标处插入 {变量},并自动聚焦变量名' })))
|
||||
mid.appendChild(textIn)
|
||||
mid.appendChild(varEd.node)
|
||||
bodyEl.appendChild(left); bodyEl.appendChild(mid)
|
||||
mid.appendChild(textWrap)
|
||||
var split = el('div', { class: 'iwb-plp-esplit', title: '拖动调整变量列宽度' })
|
||||
var right = el('div', { class: 'iwb-plp-eright' })
|
||||
right.appendChild(varEd.node)
|
||||
split.addEventListener('pointerdown', function (e) {
|
||||
e.preventDefault()
|
||||
var startX = e.clientX
|
||||
var startW = right.getBoundingClientRect().width
|
||||
function mv (ev) {
|
||||
var w = Math.max(190, Math.min(460, startW + (startX - ev.clientX)))
|
||||
right.style.width = w + 'px'
|
||||
}
|
||||
function up () {
|
||||
document.removeEventListener('pointermove', mv, true)
|
||||
document.removeEventListener('pointerup', up, true)
|
||||
}
|
||||
document.addEventListener('pointermove', mv, true)
|
||||
document.addEventListener('pointerup', up, true)
|
||||
})
|
||||
bodyEl.appendChild(left); bodyEl.appendChild(mid); bodyEl.appendChild(split); bodyEl.appendChild(right)
|
||||
var dupBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '另存副本' })
|
||||
var insBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '插入画布' })
|
||||
footEl.appendChild(dupBtn); footEl.appendChild(el('span', { class: 'iwb-drawer-spacer' })); footEl.appendChild(insBtn)
|
||||
@@ -1326,7 +1599,7 @@
|
||||
id: draft.id,
|
||||
name: nameIn.value,
|
||||
group: groupIn.value,
|
||||
tags: String(tagsIn.value || '').split(',').map(function (s) { return s.trim() }).filter(Boolean),
|
||||
tags: tags.slice(),
|
||||
text: textIn.value,
|
||||
cover: draft.cover || '',
|
||||
vars: varEd.list().filter(function (v) { return v && v.key }),
|
||||
@@ -1342,10 +1615,13 @@
|
||||
var gs = groupsOf().slice()
|
||||
if (item.group && !gs.some(function (g) { return g.name === item.group })) gs.push(groupRef(item.group))
|
||||
close()
|
||||
save(list, gs).then(function () { notify(isNew ? '已创建' : '已保存') })
|
||||
save(list, gs).then(function () {
|
||||
notify(isNew ? '已创建' : '已保存')
|
||||
if (!isNew) { try { openDetailModal(item) } catch (e) { /* ignore */ } }
|
||||
})
|
||||
}
|
||||
saveBtn.addEventListener('click', doSave)
|
||||
cancelBtn.addEventListener('click', function () { close() })
|
||||
cancelBtn.addEventListener('click', function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } })
|
||||
dupBtn.addEventListener('click', function () {
|
||||
var c = collect()
|
||||
var copy = Object.assign({}, c, { id: uid('q'), name: (String(c.name || '提示词').trim()) + ' 副本' })
|
||||
@@ -1445,26 +1721,14 @@
|
||||
items.forEach(function (p) {
|
||||
var starred = (p.group || '') === '收藏'
|
||||
var coverUrl = coverOf(p)
|
||||
var card = el('div', { class: 'iwb-plp-card' + (p.cover ? ' has-cover' : ' no-cover'), draggable: 'true', title: '单击查看详情 · 拖到画布插入 · 右键移动到分组' })
|
||||
card.style.background = coverUrl ? 'var(--iwb-plugin-inset)' : gradOf(p)
|
||||
if (coverUrl) card.appendChild(el('img', { class: 'iwb-plp-cover', src: coverUrl, alt: '', draggable: 'false' }))
|
||||
var card = el('div', { class: 'iwb-plp-card' + (p.cover ? ' has-cover' : ' no-cover'), title: '双击查看详情 · 拖到画布插入 · 右键移动到分组' })
|
||||
var bg = el('div', { class: 'iwb-plp-bg' })
|
||||
bg.style.background = coverUrl ? 'var(--iwb-plugin-inset)' : gradOf(p)
|
||||
if (coverUrl) bg.appendChild(el('img', { class: 'iwb-plp-cover', src: coverUrl, alt: '', draggable: 'false' }))
|
||||
card.appendChild(bg)
|
||||
card.appendChild(el('div', { class: 'iwb-plp-t', text: p.name || '未命名' }))
|
||||
card.addEventListener('dragstart', function (e) {
|
||||
try {
|
||||
e.stopPropagation()
|
||||
var vd = varsOf(p)
|
||||
e.dataTransfer.setData('application/x-iwb-prompt', JSON.stringify({
|
||||
text: p.text || '', name: p.name || '',
|
||||
vars: vd.map(function (v) { return v.key }),
|
||||
vdefs: vd,
|
||||
cover: p.cover || '', pluginId: ctx.id, nodeType: 'ptpl',
|
||||
}))
|
||||
e.dataTransfer.setData('application/x-iwb-promptid', p.id)
|
||||
e.dataTransfer.setData('text/plain', (p.text || '').slice(0, 200))
|
||||
e.dataTransfer.effectAllowed = 'copy'
|
||||
} catch (err) { /* ignore */ }
|
||||
})
|
||||
card.addEventListener('click', function (e) { e.stopPropagation(); try { openDetailModal(p) } catch (err) { notify('详情打开失败:' + ((err && err.message) || err), 'err'); console.error('[promptlib] detail failed', err) } })
|
||||
card.addEventListener('pointerdown', function (e) { startCardDrag(e, p, card) })
|
||||
card.addEventListener('dblclick', function (e) { e.stopPropagation(); try { openDetailModal(p) } catch (err) { notify('详情打开失败:' + ((err && err.message) || err), 'err') } })
|
||||
card.addEventListener('contextmenu', function (e) { openMenu(e, p) })
|
||||
cards.appendChild(card)
|
||||
})
|
||||
@@ -1499,9 +1763,9 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'promptlib',
|
||||
name: '提示词库',
|
||||
version: '1.6.6',
|
||||
version: '1.8.21',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvasWrite'],
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
|
||||
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
|
||||
settings: { panel: { type: 'custom', label: '分组与备份', render: renderPluginSettings } },
|
||||
}, function (ctx) {
|
||||
@@ -1562,9 +1826,14 @@
|
||||
// ===== v1.5.0:提示词模板节点(与风格节点同一套机制)=====
|
||||
// 只出不入:被连入边会让上游文本顶掉模板;变量填完由下游生图节点取 data.text。
|
||||
function renderTplNode (node, props, host) {
|
||||
// 旧节点缺少 outKind ⇒ 宿主连线白名单只当普通插件节点(只能中继)。这里自愈,无需用户重拖。
|
||||
if (node && node.data && node.data.outKind !== 'prompt') {
|
||||
try { props.onUpdate(node.id, { outKind: 'prompt' }) } catch (e) { /* ignore */ }
|
||||
}
|
||||
var st = host.__plp
|
||||
if (!st) { host.textContent = ''; st = host.__plp = buildTplSkeleton(host) }
|
||||
st.node = node
|
||||
if (st.root && props) st.root.classList.toggle('is-selected', !!props.selected)
|
||||
st.props = props
|
||||
syncTplNode(st, (node && node.data) || {})
|
||||
}
|
||||
@@ -1626,7 +1895,7 @@
|
||||
defs.forEach(function (v) {
|
||||
var row = el('div', { class: 'iwb-plp-nrow' })
|
||||
row.appendChild(el('span', { class: 'iwb-plp-nk', text: v.label || v.key }))
|
||||
var inp = el('input', { class: 'iwb-input iwb-plp-nin', placeholder: v.def || ('填写 ' + (v.label || v.key)) })
|
||||
var inp = el('input', { class: 'iwb-input iwb-plp-nin', placeholder: v.desc || v.def || ('填写 ' + (v.label || v.key)) })
|
||||
inp.value = String((d.vars && d.vars[v.key]) || v.def || '')
|
||||
inp.addEventListener('input', function () { scheduleUpdate(st, d) })
|
||||
st.inputs[v.key] = inp
|
||||
@@ -1634,6 +1903,12 @@
|
||||
st.vars.appendChild(row)
|
||||
})
|
||||
if (!defs.length) st.vars.appendChild(el('div', { class: 'iwb-plp-nempty', text: '正文里没有 {变量}' }))
|
||||
try {
|
||||
var vv = {}
|
||||
Object.keys(st.inputs).forEach(function (k) { vv[k] = st.inputs[k].value })
|
||||
var clean = outputText(String(d.tpl || ''), vv)
|
||||
if (d.text !== clean && props && typeof props.onUpdate === 'function') props.onUpdate(node.id, { text: clean })
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
// 缩略图:封面可能是 dataURL,也可能是插件文件引用
|
||||
var cover = d.cover
|
||||
@@ -1662,13 +1937,13 @@
|
||||
st.timer = setTimeout(function () {
|
||||
var vals = {}
|
||||
Object.keys(st.inputs).forEach(function (k) { vals[k] = st.inputs[k].value })
|
||||
var patch = { vars: vals, text: fillTpl(String(d.tpl || ''), vals) }
|
||||
var patch = { vars: vals, text: outputText(String(d.tpl || ''), vals) }
|
||||
try { st.props.onUpdate(st.node.id, patch) } catch (e) { /* ignore */ }
|
||||
}, 300)
|
||||
}
|
||||
if (ctx.nodes && typeof ctx.nodes.register === 'function') {
|
||||
try {
|
||||
ctx.nodes.register({ id: 'ptpl', title: '提示词模板', defaults: {}, ports: { in: false, out: true }, height: 360, render: renderTplNode })
|
||||
ctx.nodes.register({ id: 'ptpl', title: '提示词模板', defaults: { outKind: 'prompt' }, ports: { in: false, out: true }, height: 360, render: renderTplNode })
|
||||
} catch (e) {
|
||||
try { ctx.storage && ctx.storage.set('lastError', 'node:' + String((e && e.message) || e)) } catch (e2) { /* ignore */ }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "promptlib",
|
||||
"name": "提示词库",
|
||||
"version": "1.6.6",
|
||||
"version": "1.8.21",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"提示词"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "530b4bc021e0730f14505f666203c8c9c165bf9ea6bef9765ec7e9ebcda95c54",
|
||||
"styles.css": "872ceeded7eb67599dfa159c86be1b1e1724f7cd1e04cae1d79d939bb0e1ebdf"
|
||||
"main.js": "125e02a618e37505836f964dbe21a3637e3043ee355d9606c538a54eed4243ad",
|
||||
"styles.css": "84ad2314d016c7d2351eb7cf2044ee8cc703992d40a76002ff644d34eb48838a"
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
.iwb-plp-t {
|
||||
position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 7px 6px;
|
||||
background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,.66));
|
||||
color: #fff; font-size: 10.5px; line-height: 1.35; max-height: 48%;
|
||||
color: var(--plp-c1, #fff); font-size: 10.5px; line-height: 1.35; max-height: 48%;
|
||||
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
|
||||
text-shadow: 0 1px 2px rgba(0,0,0,.35);
|
||||
}
|
||||
@@ -351,3 +351,211 @@ margin-top: 2px;
|
||||
.iwb-plp-mask.iwb-mask-ghost .iwb-settings-modal {
|
||||
box-shadow: 0 24px 60px rgba(0,0,0,.32);
|
||||
}
|
||||
|
||||
/* v1.6.7:卡片长按可拖的视觉反馈 */
|
||||
.iwb-plp-card{cursor:grab}
|
||||
.iwb-plp-card.is-armed{border-color:var(--iwb-plp-accent,#7c4dff);box-shadow:0 0 0 2px color-mix(in srgb,var(--iwb-plp-accent,#7c4dff) 20%,transparent)}
|
||||
.iwb-plp-card.is-dragging{opacity:.55;transform:scale(.98);cursor:grabbing}
|
||||
|
||||
/* v1.6.8:卡片悬停放大 + 按下/拖拽反馈 */
|
||||
.iwb-plp-card{transition:transform .14s ease, box-shadow .14s ease, border-color .14s ease, opacity .14s ease}
|
||||
.iwb-plp-card:hover{transform:scale(1.03);box-shadow:0 8px 22px rgba(0,0,0,.14);z-index:2}
|
||||
.iwb-plp-card.is-pressed{border-color:var(--iwb-plp-accent,#7c4dff);box-shadow:0 0 0 2px color-mix(in srgb,var(--iwb-plp-accent,#7c4dff) 22%,transparent)}
|
||||
.iwb-plp-card.is-dragging{opacity:.55;transform:scale(.98)}
|
||||
|
||||
/* v1.6.9:拖拽虚拟卡片(跟手预览) */
|
||||
.iwb-plp-dragghost{width:168px;display:flex;align-items:center;gap:8px;padding:8px 10px;background:var(--iwb-panel,#fff);border:2px solid var(--iwb-plp-accent,#7c4dff);border-radius:11px;box-shadow:0 12px 28px rgba(0,0,0,.22);font-size:12px;pointer-events:none;z-index:99999}
|
||||
.iwb-plp-ghostcov{width:38px;height:38px;border-radius:8px;object-fit:cover;flex:0 0 auto;background:var(--iwb-plugin-inset,#eef0f2)}
|
||||
.iwb-plp-ghosttxt{min-width:0;display:flex;flex-direction:column;gap:2px}
|
||||
.iwb-plp-ghostname{font-weight:600;color:var(--iwb-text,#1c2333);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.iwb-plp-ghosthint{font-size:10.5px;color:var(--iwb-plp-accent,#5a4bd0)}
|
||||
|
||||
/* v1.6.10:悬停放大改为「内层背景层缩放」——卡片命中区域不变,渐变卡不再闪烁 */
|
||||
.iwb-plp-bg{position:absolute;inset:0;overflow:hidden;border-radius:inherit;transition:transform .16s ease;will-change:transform;backface-visibility:hidden}
|
||||
.iwb-plp-card:hover .iwb-plp-bg{transform:scale(1.045)}
|
||||
.iwb-plp-card:hover{border-color:var(--iwb-border2,#b9bfca);box-shadow:0 8px 22px rgba(0,0,0,.14)}
|
||||
/* 取消卡片本体的缩放/层级切换(闪烁与边缘点击丢失的来源) */
|
||||
.iwb-plp-card{transform:none}
|
||||
.iwb-plp-card:hover{transform:none;z-index:auto}
|
||||
.iwb-plp-card.is-dragging{opacity:.55}
|
||||
.iwb-plp-bg,.iwb-plp-cover{pointer-events:none}
|
||||
|
||||
/* v1.6.11:封面卡瀑布流高度由图片决定 —— 背景层必须是普通流,不能绝对定位(否则卡塌成一条线) */
|
||||
.iwb-plp-bg{position:relative;inset:auto;width:100%}
|
||||
.iwb-plp-card.no-cover .iwb-plp-bg{position:absolute;inset:0}
|
||||
.iwb-plp-bg .iwb-plp-cover{width:100%;height:auto;object-fit:contain;display:block}
|
||||
|
||||
/* v1.6.13:未选中时变量输入框不拦截指针 —— 单击节点=选中/可拖动;选中后再点输入框编辑 */
|
||||
.iwb-plp-node:not(.is-selected) input{pointer-events:none}
|
||||
.iwb-plp-card{user-select:none}
|
||||
body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webkit-user-select:none!important}
|
||||
.iwb-plp-placeghost{border-style:dashed!important;pointer-events:none}
|
||||
.iwb-plp-placehint{font-size:10.5px;color:var(--iwb-plp-accent,#5a4bd0);margin-top:2px}
|
||||
.iwb-plp-placebox{position:fixed;left:-9999px;top:0;z-index:99999;pointer-events:none;border:2px dashed var(--iwb-plp-accent,#6b4dff);border-radius:12px;background:color-mix(in srgb,var(--iwb-plp-accent,#6b4dff) 9%,transparent);display:flex;align-items:center;justify-content:center;box-shadow:0 10px 26px rgba(30,20,80,.10)}
|
||||
.iwb-plp-placebox-t{font-size:12px;color:var(--iwb-plp-accent,#5a3fd0);background:rgba(255,255,255,.82);border-radius:999px;padding:3px 10px}
|
||||
/* v1.6.23:放置指示改为灰色小方框 */
|
||||
.iwb-plp-placebox{border: 2px dashed var(--plp-c2, #9aa3ad);border-radius:10px;background:rgba(122,130,142,.10);box-shadow:none}
|
||||
.iwb-plp-placebox-t{font-size:11px;color: var(--plp-c3, #6b7280);background:rgba(255,255,255,.75);padding:2px 8px}
|
||||
/* v1.7.0:编辑面板三栏 + 可拖宽;详情封面放大、变量高亮 */
|
||||
.iwb-plp-eleft{flex:0 0 236px;width:236px}
|
||||
.iwb-plp-emid{flex:1 1 auto;min-width:220px;display:flex;flex-direction:column;min-height:0}
|
||||
.iwb-plp-emid .iwb-plp-etext{flex:1 1 auto;min-height:0;resize:none}
|
||||
.iwb-plp-esplit{flex:0 0 10px;cursor:col-resize;display:flex;align-items:center;justify-content:center;border-radius:6px;background:var(--iwb-plugin-inset,#f3f4f7)}
|
||||
.iwb-plp-esplit:hover{background:var(--iwb-plugin-hover,#e9ecf1)}
|
||||
.iwb-plp-eright{flex:0 0 auto;width:300px;min-width:190px;max-width:460px;display:flex;flex-direction:column;min-height:0;background:var(--iwb-plugin-surface,#fafbfc);border:1px solid var(--iwb-border,#e6e8ec);border-radius:10px;padding:8px}
|
||||
.iwb-plp-vars{flex:1 1 auto;min-height:0;display:flex;flex-direction:column}
|
||||
.iwb-plp-vrows{flex:1 1 auto;min-height:0;overflow:auto}
|
||||
.iwb-plp-vitem{padding:4px 0;border-bottom:1px dashed var(--iwb-border,#eceef2)}
|
||||
.iwb-plp-vrow2{display:flex;align-items:center;gap:6px}
|
||||
.iwb-plp-vname{flex:1 1 auto;min-width:0;height:32px}
|
||||
.iwb-plp-vi{flex:0 0 auto;width:24px;height:24px;padding:0;border-radius:50%;border:1px solid var(--iwb-border,#dfe3e9);background: var(--plp-c1, #fff);color: var(--plp-c4, #9aa1ac);font-size:11px;line-height:22px;text-align:center}
|
||||
.iwb-plp-vi.is-open{background: var(--plp-c5, #f1ecff);border-color: var(--plp-c6, #d8cbff);color: var(--plp-c7, #5a3fd0)}
|
||||
.iwb-plp-vdesc{width:100%;height:28px;margin-top:5px;border-style:dashed;background: var(--plp-c8, #fbfcfd);font-size:11.5px;color: var(--plp-c3, #6b7280)}
|
||||
.iwb-plp-dcov{flex:0 0 auto;width:180px;height:180px;border-radius:12px;overflow:hidden}
|
||||
.iwb-plp-dvar{background: var(--plp-c5, #f1ecff);color: var(--plp-c7, #5a3fd0);border-radius:4px;padding:0 4px;font-weight:500}
|
||||
/* v1.7.1:编辑面板视觉精修——输入框比底色更亮、去多余边框、细分隔线 */
|
||||
.iwb-plp-dialog .iwb-plp-dbody{gap:10px;padding:12px;background: var(--plp-c9, #f4f5f7)}
|
||||
.iwb-plp-dialog .iwb-plp-eleft{flex:0 0 236px;width:236px;background: var(--plp-c1, #fff);border: 1px solid var(--plp-c10, #e6e8ec);border-radius:12px;padding:12px}
|
||||
.iwb-plp-dialog .iwb-plp-emid{background: var(--plp-c1, #fff);border: 1px solid var(--plp-c10, #e6e8ec);border-radius:12px;padding:10px 12px 12px}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext{border: 1px solid var(--plp-c11, #eef0f3);background: var(--plp-c8, #fbfcfd);border-radius:9px;padding:10px 12px}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext:focus{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
|
||||
.iwb-plp-dialog .iwb-plp-esplit{flex:0 0 6px;background:transparent;border-radius:4px}
|
||||
.iwb-plp-dialog .iwb-plp-esplit:hover{background: var(--plp-c13, #e7e9ee)}
|
||||
.iwb-plp-dialog .iwb-plp-esplit::before{content:'';display:block;width:2px;height:30px;border-radius:2px;background: var(--plp-c14, #d7dbe2)}
|
||||
.iwb-plp-dialog .iwb-plp-eright{background:transparent;border:0;padding:2px 0 0}
|
||||
.iwb-plp-dialog .iwb-plp-vitem{border:0;padding:2px 0}
|
||||
.iwb-plp-dialog .iwb-plp-vrow2{gap:6px}
|
||||
.iwb-plp-dialog .iwb-plp-vname{background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c15, #eceef2);border-radius:8px;height:32px;padding:0 10px;font-size:12.5px;color: var(--plp-c16, #33383f)}
|
||||
.iwb-plp-dialog .iwb-plp-vname:focus{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
|
||||
.iwb-plp-dialog .iwb-plp-vi{background:transparent;border:0;color: var(--plp-c17, #aab0ba);width:22px;height:22px;line-height:20px}
|
||||
.iwb-plp-dialog .iwb-plp-vi:hover{background: var(--plp-c18, #eef0f4);color: var(--plp-c3, #6b7280)}
|
||||
.iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--plp-c5, #f1ecff);color: var(--plp-c7, #5a3fd0)}
|
||||
.iwb-plp-dialog .iwb-plp-vdesc{background: var(--plp-c8, #fbfcfd);border: 1px dashed var(--plp-c19, #e2e6ec);border-radius:7px;height:28px;margin-top:4px}
|
||||
.iwb-plp-dialog .iwb-plp-lrow span{color: var(--plp-c20, #8a919c);font-size:11.5px}
|
||||
.iwb-plp-dialog .iwb-plp-lrow .iwb-input{background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c15, #eceef2);border-radius:8px;height:32px}
|
||||
.iwb-plp-dialog .iwb-plp-lrow .iwb-input:focus{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff)}
|
||||
/* v1.7.2:正文变量高亮(黑粗)+ 说明灰按钮 + 说明背景回归面板底 */
|
||||
.iwb-plp-ewrap{position:relative;flex:1 1 auto;min-height:0;display:flex;border-radius:9px;background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c11, #eef0f3)}
|
||||
.iwb-plp-ewrap:focus-within{background: var(--plp-c1, #fff);border-color: var(--plp-c12, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
|
||||
.iwb-plp-ewrap .iwb-plp-etext{flex:1 1 auto;min-height:0;border:0;background:transparent;box-shadow:none;color:transparent;caret-color:var(--plp-c22, #1d2129);position:relative;z-index:1;resize:none}
|
||||
.iwb-plp-ewrap .iwb-plp-etext:focus{background:transparent;border:0;box-shadow:none}
|
||||
.iwb-plp-hl{position:absolute;inset:0;padding:10px 12px;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;font-size:13px;line-height:1.9;color: var(--plp-c21, #5b6472);pointer-events:none;z-index:0}
|
||||
.iwb-plp-hlvar{color: var(--plp-c22, #1d2129);font-weight:600}
|
||||
.iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--plp-c11, #eef0f3);color: var(--plp-c21, #5b6472)}
|
||||
.iwb-plp-dialog .iwb-plp-vdesc{background:transparent;border: 1px dashed var(--plp-c23, #dfe3e9)}
|
||||
.iwb-plp-dvar{background:transparent;color: var(--plp-c22, #1d2129);font-weight:600;padding:0}
|
||||
.iwb-plp-hres{height:6px;margin:-3px 0 0;cursor:ns-resize;flex:0 0 auto;border-radius:3px}
|
||||
.iwb-plp-hres:hover{background: var(--plp-c13, #e7e9ee)}
|
||||
/* 正文可见性:textarea 透明,显示下方高亮层 */
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap{flex:1 1 auto;min-height:0;position:relative;display:flex;background: var(--plp-c8, #fbfcfd);border: 1px solid var(--plp-c11, #eef0f3);border-radius:9px}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{background:transparent!important;color:transparent!important;border:0!important;box-shadow:none!important;padding:10px 12px}
|
||||
.iwb-plp-dialog .iwb-plp-hl{padding:10px 12px;font-size:13px;line-height:1.9}
|
||||
.iwb-plp-namebox{min-height:34px;height:34px;line-height:1.45;padding:7px 10px;resize:vertical;overflow:auto;font-size:12.5px}
|
||||
.iwb-plp-insvar{color: var(--plp-c22, #1d2129)!important;background: var(--plp-c1, #fff)!important;border-color: var(--plp-c19, #e2e6ec)!important}
|
||||
.iwb-plp-insvar:hover{background: var(--plp-c24, #f4f6f9)!important}
|
||||
/* v1.7.5:编辑封面卡在框内;详情封面放大 */
|
||||
.iwb-plp-dialog .iwb-plp-ecov{width:100%;height:250px;overflow:hidden;border-radius:12px;background:var(--iwb-plugin-inset,#f3f4f7)}
|
||||
.iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{width:100%;height:100%;object-fit:cover;object-position:center;display:block;border-radius:12px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dbody{align-items:flex-start}
|
||||
.iwb-plp-dialog .iwb-plp-dcov{width:264px;height:264px;flex:0 0 auto;overflow:hidden;border-radius:12px;background:var(--iwb-plugin-inset,#f3f4f7)}
|
||||
.iwb-plp-dialog .iwb-plp-dcov .iwb-plp-cover{width:100%;height:100%;object-fit:cover;object-position:center;display:block;border-radius:12px}
|
||||
/* v1.7.6:封面完整展示(contain),不裁剪 */
|
||||
.iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{object-fit:contain;background:transparent}
|
||||
.iwb-plp-dialog .iwb-plp-dcov .iwb-plp-cover{object-fit:contain;background:transparent}
|
||||
.iwb-plp-dialog .iwb-plp-ecov{background:var(--iwb-plugin-inset,#f3f4f7)}
|
||||
.iwb-plp-dialog .iwb-plp-dcov{background:var(--iwb-plugin-inset,#f3f4f7)}
|
||||
/* v1.7.7:编辑区文字层与高亮层使用完全一致的字体度量,修复光标/选区错位 */
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext,
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-hl{
|
||||
font-family:-apple-system,BlinkMacSystemFont,'PingFang SC','Helvetica Neue',system-ui,sans-serif!important;
|
||||
font-size:13px!important;
|
||||
line-height:1.85!important;
|
||||
letter-spacing:0!important;
|
||||
padding:10px 12px!important;
|
||||
margin:0!important;
|
||||
border:0!important;
|
||||
box-sizing:border-box!important;
|
||||
white-space:pre-wrap!important;
|
||||
overflow-wrap:break-word!important;
|
||||
word-break:break-word!important;
|
||||
tab-size:4!important;
|
||||
}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{overflow-y:auto!important;scrollbar-gutter:stable}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-hl{overflow:hidden!important}
|
||||
/* v1.7.9:详情正文独立滚动,长文不再压到底部按钮 */
|
||||
.iwb-plp-dialog-detail .iwb-plp-dbody{overflow:hidden;align-items:stretch}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow:auto;padding-right:10px;margin-bottom:6px}
|
||||
/* v1.8.0:详情标题/分组/标签移到封面下方;编辑标签改为输入+加号 */
|
||||
.iwb-plp-dialog-detail .iwb-plp-dbody{align-items:flex-start}
|
||||
.iwb-plp-dleftcol{flex:0 0 264px;width:264px;display:flex;flex-direction:column;min-width:0}
|
||||
.iwb-plp-dtitle{font-size:18px;font-weight:650;line-height:1.35;margin-top:14px;color:var(--iwb-text,#1d2129)}
|
||||
.iwb-plp-dmeta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:8px}
|
||||
.iwb-plp-dgroup{font-size:11.5px;background: var(--plp-c18, #eef0f4);color: var(--plp-c21, #5b6472);border-radius:999px;padding:2px 9px}
|
||||
.iwb-plp-dtag{font-size:11.5px;background: var(--plp-c25, #f4f0ff);color: var(--plp-c7, #5a3fd0);border-radius:999px;padding:2px 9px}
|
||||
.iwb-plp-dlen{font-size:11.5px;color: var(--plp-c4, #9aa1ac)}
|
||||
.iwb-plp-tagwrap{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}
|
||||
.iwb-plp-tagchips{display:flex;flex-wrap:wrap;gap:5px}
|
||||
.iwb-plp-tagchip{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;background: var(--plp-c18, #eef0f4);border-radius:999px;padding:2px 8px;color: var(--plp-c26, #3f4450)}
|
||||
.iwb-plp-tagx{cursor:pointer;color: var(--plp-c4, #9aa1ac);font-style:normal}
|
||||
.iwb-plp-tagx:hover{color: var(--plp-c27, #c0392b)}
|
||||
.iwb-plp-tagrow{display:flex;gap:6px}
|
||||
.iwb-plp-tagin{flex:1;min-width:0;height:30px}
|
||||
.iwb-plp-lrow-tags{align-items:flex-start}
|
||||
.iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;font-size:15px;line-height:28px}
|
||||
/* v1.8.1:详情标题/分组/标签左对齐并带标题;标签加号对齐修复 */
|
||||
.iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top:16px;color:var(--iwb-text,#1d2129)}
|
||||
.iwb-plp-dmeta{display:flex;flex-direction:column;gap:7px;margin-top:12px;align-items:flex-start}
|
||||
.iwb-plp-dmrow{display:flex;align-items:center;gap:10px;width:100%}
|
||||
.iwb-plp-dmk{flex:0 0 30px;width:30px;font-size:11.5px;color: var(--plp-c4, #9aa1ac)}
|
||||
.iwb-plp-dmv{display:flex;flex-wrap:wrap;align-items:center;gap:5px;min-width:0}
|
||||
.iwb-plp-dgroup{font-size:12px;color: var(--plp-c26, #3f4450);background: var(--plp-c28, #f2f4f7);border-radius:6px;padding:2px 9px}
|
||||
.iwb-plp-dtag{font-size:11.5px;color: var(--plp-c7, #5a3fd0);background: var(--plp-c25, #f4f0ff);border-radius:6px;padding:2px 9px}
|
||||
.iwb-plp-dempty{font-size:12px;color: var(--plp-c29, #b3b9c2)}
|
||||
.iwb-plp-dlen{font-size:12px;color: var(--plp-c20, #8a919c)}
|
||||
.iwb-plp-tagrow{display:flex;align-items:center;gap:6px}
|
||||
.iwb-plp-tagin{height:30px;border-radius:8px}
|
||||
.iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;border-radius:8px;background: var(--plp-c28, #f2f4f7);border: 1px solid var(--plp-c19, #e2e6ec);color: var(--plp-c21, #5b6472);font-size:16px;line-height:1;display:inline-flex;align-items:center;justify-content:center}
|
||||
.iwb-plp-tagadd:hover{background: var(--plp-c30, #e9ecf1)}
|
||||
/* v1.8.2:详情左右两栏卡片化 + 分割线 */
|
||||
.iwb-plp-dialog-detail .iwb-plp-dbody{gap:14px;padding:16px;background: var(--plp-c9, #f4f5f7)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dleftcol{flex:0 0 300px;width:300px;padding:12px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff);align-self:flex-start}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dcov{width:100%;height:270px;border-radius:10px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top:14px;color:var(--iwb-text,#1d2129)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top:12px;border-top: 1px solid var(--plp-c11, #eef0f3);gap:8px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;display:flex;flex-direction:column;padding:14px 16px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff);overflow:hidden}
|
||||
.iwb-plp-dsec{font-size:11.5px;font-weight:600;color: var(--plp-c20, #8a919c);letter-spacing:.04em;padding-bottom:8px;margin-bottom:8px;border-bottom: 1px solid var(--plp-c11, #eef0f3);flex:0 0 auto}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow:auto;padding-right:10px;font-size:13.5px;line-height:2;color: var(--plp-c32, #3a4048)}
|
||||
/* v1.8.3:详情左卡片撑到底、四边等距;正文恢复滚动不被底部遮挡 */
|
||||
.iwb-plp-dialog-detail{display:flex;flex-direction:column;overflow:hidden}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dbody{display:flex;flex:1 1 auto;min-height:0;overflow:hidden;gap:14px;padding:16px;background: var(--plp-c9, #f4f5f7)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dleftcol{align-self:stretch;display:flex;flex-direction:column;overflow:auto;padding:12px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dright{flex:1 1 auto;min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column;padding:14px 16px;border: 1px solid var(--plp-c31, #e8eaee);border-radius:14px;background: var(--plp-c1, #fff)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;padding-right:8px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dfooter{flex:0 0 auto}
|
||||
/* v1.8.4:右卡片纵向拉伸填满,正文出现滚动条 */
|
||||
.iwb-plp-dialog-detail .iwb-plp-dbody{align-items:stretch!important}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dright{align-self:stretch!important;height:100%;max-height:100%;overflow:hidden!important}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtext{flex:1 1 0;min-height:0;overflow-y:auto!important;overflow-x:hidden}
|
||||
/* v1.8.7:详情标题缩小;分组/标签去底色;元信息加分割线与行高 */
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:17px!important;font-weight:650;margin-top:12px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top:14px;border-top: 1px solid var(--plp-c11, #eef0f3);gap:10px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmrow{gap:6px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmk{flex:0 0 auto;width:auto;font-size:12px;line-height:1.6;color: var(--plp-c4, #9aa1ac)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dgroup,.iwb-plp-dialog-detail .iwb-plp-dtag{background:transparent!important;padding:0!important;border-radius:0!important;font-size:12.5px;line-height:1.6;color: var(--plp-c33, #2f3540)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtag{color: var(--plp-c7, #5a3fd0);}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dlen{font-size:12.5px;line-height:1.6;color: var(--plp-c33, #2f3540)}
|
||||
/* v1.8.8:详情标题 14px;元信息行间浅分割线;封面底色更接近白色(编辑/详情统一) */
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:14px!important;font-weight:650;line-height:1.5;margin-top:12px}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmeta{gap:0}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmrow{padding:7px 0;border-bottom: 1px solid var(--plp-c34, #f3f5f8)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmrow:last-child{border-bottom:0}
|
||||
.iwb-plp-dialog .iwb-plp-dcov,.iwb-plp-dialog .iwb-plp-ecov{background: var(--plp-c35, #fcfcfd)!important}
|
||||
.iwb-plp-dialog .iwb-plp-dcov .iwb-plp-cover,.iwb-plp-dialog .iwb-plp-ecov .iwb-plp-cover{background:transparent!important}
|
||||
/* v1.8.19:编辑区高亮变量不得加粗——加粗会改变字形宽度,导致点击位置逐次向左偏移 */
|
||||
.iwb-plp-hlvar{font-weight:400!important;letter-spacing:normal!important}
|
||||
/* v1.8.20:编辑区不再用透明 textarea+高亮层(两层字体/换行差异会让点击坐标逐次偏移);正文直接由 textarea 渲染,插入点 100% 对应光标 */
|
||||
.iwb-plp-ewrap .iwb-plp-hl{display:none!important}
|
||||
.iwb-plp-ewrap .iwb-plp-etext{color:var(--iwb-text,#2a2f36)!important;background:transparent!important}
|
||||
/* v1.8.21:高亮层隐藏后,正文文字必须可见(覆盖旧的 transparent !important) */
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-ewrap .iwb-plp-etext{color:var(--iwb-text,#2a2f36)!important;caret-color:var(--iwb-text,#2a2f36)!important;-webkit-text-fill-color:var(--iwb-text,#2a2f36)!important}
|
||||
@@ -467,14 +467,14 @@
|
||||
'.iwb-bx-empty{padding:24px 12px;text-align:center;color:var(--iwb-text2,#4d5668)}',
|
||||
// 缩略图:小方图(30px)常驻在行首,跑完换成产物本身,一眼能对上「哪张图、出了什么」
|
||||
'.iwb-bx-thumb{width:30px;height:30px;flex:0 0 auto;object-fit:contain;border-radius:5px;',
|
||||
'border:1px solid var(--iwb-border,#d5d9e0);background:#fff;cursor:zoom-in;padding:1px}',
|
||||
'border:1px solid var(--iwb-border,#d5d9e0);background:#fff/*iwb:content*/;cursor:zoom-in;padding:1px}',
|
||||
'.iwb-bx-thumb-out{border-color:#1d9e75;cursor:zoom-in}',
|
||||
'.iwb-bx-thumb-ph{background:var(--iwb-layer,#f0f1f4);cursor:default}',
|
||||
'.iwb-bx-done{display:none;align-items:center;gap:6px;padding:9px 12px;font-size:11px;',
|
||||
'color:#1d9e75;background:rgba(29,158,117,.08);border-top:1px solid var(--iwb-border,#d5d9e0)}',
|
||||
'.iwb-bx-zoom{position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;',
|
||||
'background:rgba(0,0,0,.72);cursor:zoom-out}',
|
||||
'.iwb-bx-zoom img{max-width:86vw;max-height:86vh;border-radius:8px;background:#fff}',
|
||||
'.iwb-bx-zoom img{max-width:86vw;max-height:86vh;border-radius:8px;background:#fff/*iwb:content*/}',
|
||||
// 双类选择器:单靠 .iwb-bx-btn-hot 会被后定义的 .iwb-bx-btn 背景覆盖(同特异性,后者胜)
|
||||
'.iwb-bx-btn.iwb-bx-btn-hot{background:#1d9e75;border-color:#1d9e75;color:#fff}',
|
||||
'.iwb-bx-foot{display:flex;align-items:center;gap:8px;padding:10px 12px;',
|
||||
@@ -500,7 +500,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'batch-export',
|
||||
name: '批量出图',
|
||||
version: '1.2.0',
|
||||
version: '1.2.1',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'canvas'],
|
||||
settings: {
|
||||
@@ -41,7 +41,7 @@
|
||||
'.iwb-browser-ctrl button:disabled{opacity:.4;cursor:default}' +
|
||||
'.iwb-browser-now{font-size:12px;color:var(--iwb-text-dim,#9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:120px}' +
|
||||
'.iwb-browser-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:#1d9e75;margin-right:6px;vertical-align:middle}' +
|
||||
'.iwb-browser-dot-off{background:#888780}' +
|
||||
'.iwb-browser-dot-off{background:var(--iwb-text-dim,#888780)}' +
|
||||
// 面板内嵌浏览器(2026-11-19):书签改成横排 chips,正文全留给网页
|
||||
'.iwb-browser-strip{display:flex;align-items:center;gap:6px;padding:5px 8px;flex:0 0 auto;overflow-x:auto;background:var(--iwb-layer,#f0f1f4);box-sizing:border-box}' +
|
||||
'.iwb-browser-chip{cursor:pointer;border:1px solid var(--iwb-border,#d5d9e0);border-radius:999px;background:var(--iwb-layer2,#fff);color:var(--iwb-text,#1c2333);font-size:11.5px;padding:4px 10px;white-space:nowrap}' +
|
||||
@@ -1133,7 +1133,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'browser',
|
||||
name: '应用内浏览器',
|
||||
version: '1.7.0',
|
||||
version: '1.7.1',
|
||||
apiVersion: 1,
|
||||
// canvasWrite:面板里的「↗」用它把当前页变成画布上的网页节点(需要客户端 v3.25.30+)
|
||||
capabilities: ['panels', 'nodeTypes', 'canvasWrite'],
|
||||
@@ -6,11 +6,14 @@
|
||||
// ⚠️ 因此本文件的注释里不要写出那种字面量形态(会抢先匹配),要描述就直接说「id 字面量」。
|
||||
//
|
||||
// 版本占位符由构建脚本用 package.json 的 version 替换,保证两处永不漂移。
|
||||
// skin: 'private' = 本插件自带整套调色板(Catppuccin 深色工具 UI),不跟随宿主主题。
|
||||
// 代价由宿主契约测试钉死:声明 private 的插件不得引用宿主颜色 var(--iwb-*),只能自洽。
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.20.6',
|
||||
version: '1.20.7',
|
||||
apiVersion: 1,
|
||||
skin: 'private',
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
exportPreset: { type: 'string', default: 'original' },
|
||||
@@ -6,11 +6,14 @@
|
||||
// ⚠️ 因此本文件的注释里不要写出那种字面量形态(会抢先匹配),要描述就直接说「id 字面量」。
|
||||
//
|
||||
// 版本占位符由构建脚本用 package.json 的 version 替换,保证两处永不漂移。
|
||||
// skin: 'private' = 自绘深色工具 UI(#1b1b22 系列),不跟随宿主主题。
|
||||
// 代价由宿主契约测试钉死:声明 private 的插件不得引用宿主颜色 var(--iwb-*),只能自洽。
|
||||
var __IWB_VECTORIZE_MANIFEST__ = {
|
||||
id: 'image-vectorize',
|
||||
name: '位图转矢量',
|
||||
version: '0.6.0',
|
||||
version: '0.6.1',
|
||||
apiVersion: 1,
|
||||
skin: 'private',
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
preset: { type: 'string', default: 'text' },
|
||||
@@ -182,7 +182,24 @@ if (sourcemap) {
|
||||
appBundle = '/*! IWB ' + version + ' */\n' + appBundle
|
||||
fs.writeFileSync(path.join(dist, 'app.js'), appBundle)
|
||||
|
||||
const minifiedCss = transformSync(fs.readFileSync(path.join(root, 'style.css'), 'utf8'), {
|
||||
/* 设计 token 必须排在最前:src/design-tokens.css 是生成的静态快照(:root / .theme-dark),
|
||||
* 组件规则靠它里面的变量。Tauri 的 CSP 不做 @import 兜底,所以这里是**拼接**而不是 @import ——
|
||||
* 顺序 = design-tokens.css → style.css,改顺序会让静态快照失效(首帧变量全空)。
|
||||
* 顺带做两件事:① 校验它没和 derive() 漂移(漂了就 build 失败,杜绝发出去的包用旧色板);
|
||||
* ② 把 DTCG 版 token 写到 dist/tokens.json 供设计工具导入。 */
|
||||
const { build: buildTokens } = require('./gen-tokens')
|
||||
const tokensBuilt = buildTokens()
|
||||
const tokensCssPath = path.join(root, 'src/design-tokens.css')
|
||||
const tokensCss = fs.readFileSync(tokensCssPath, 'utf8')
|
||||
if (tokensCss !== tokensBuilt.css) {
|
||||
console.error('FAIL src/design-tokens.css 与 src/theme-tokens.js 的 derive() 不一致')
|
||||
console.error(' → 先跑 npm run tokens:write(改了配色公式/种子却没重新生成快照)')
|
||||
process.exit(1)
|
||||
}
|
||||
fs.writeFileSync(path.join(dist, 'tokens.json'), tokensBuilt.json)
|
||||
const cssSources = ['src/design-tokens.css', 'style.css']
|
||||
const cssRaw = cssSources.map((f) => fs.readFileSync(path.join(root, f), 'utf8')).join('\n')
|
||||
const minifiedCss = transformSync(cssRaw, {
|
||||
loader: 'css',
|
||||
minify: true,
|
||||
target: ['chrome100', 'firefox100', 'safari15'],
|
||||
|
||||
@@ -55,6 +55,8 @@ const html = `<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>${esc(data.app)} · 下载</title>
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=" + encodeURIComponent(latest.version + '-' + Date.now().toString(36)) + "">
|
||||
<style>
|
||||
*{box-sizing:border-box}
|
||||
@@ -85,11 +87,12 @@ const html = `<!doctype html>
|
||||
</head>
|
||||
<body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
<div class="links">
|
||||
<a href="/">首页</a>
|
||||
<a href="/download/" class="on">下载</a>
|
||||
<a href="/plugins/">插件</a>
|
||||
<a href="/dev/">开发</a>
|
||||
<a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
|
||||
@@ -23,11 +23,12 @@ const plugins = Array.isArray(market.plugins) ? market.plugins : []
|
||||
|
||||
const nav = (active) => [
|
||||
'<nav><div class="wrap inner">',
|
||||
' <a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>',
|
||||
' <a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>',
|
||||
' <div class="links">',
|
||||
' <a href="/"' + (active === 'home' ? ' class="on"' : '') + '>首页</a>',
|
||||
' <a href="/download/"' + (active === 'download' ? ' class="on"' : '') + '>下载</a>',
|
||||
' <a href="/plugins/"' + (active === 'plugins' ? ' class="on"' : '') + '>插件</a>',
|
||||
' <a href="/dev/"' + (active === 'dev' ? ' class="on"' : '') + '>开发</a>',
|
||||
' <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>',
|
||||
' </div>',
|
||||
' <div class="right">',
|
||||
@@ -83,6 +84,69 @@ const tags = []
|
||||
for (const p of plugins) for (const t of (p.tags || [])) if (tags.indexOf(t) < 0) tags.push(t)
|
||||
const tagChips = tags.map((t) => '<button class="tag" data-tag="' + esc(t) + '" style="cursor:pointer;padding:5px 12px">' + esc(t) + '</button>').join('\n ')
|
||||
|
||||
function mdToHtml (md) {
|
||||
const esc2 = (s) => String(s).replace(/[&<>]/g, (c) => ({ '&': '&', '<': '<', '>': '>' }[c]))
|
||||
const inline = (s) => esc2(s)
|
||||
.replace(/`([^`]+)`/g, '<code>$1</code>')
|
||||
.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
|
||||
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>')
|
||||
const lines = String(md).split('\n')
|
||||
const out = []
|
||||
let i = 0
|
||||
let inCode = false
|
||||
let code = []
|
||||
let inList = ''
|
||||
const closeList = () => { if (inList) { out.push('</' + inList + '>'); inList = '' } }
|
||||
while (i < lines.length) {
|
||||
const line = lines[i]
|
||||
if (line.trim().indexOf('```') === 0) {
|
||||
if (!inCode) { inCode = true; code = [] } else {
|
||||
inCode = false
|
||||
out.push('<pre><code>' + esc2(code.join('\n')) + '</code></pre>')
|
||||
}
|
||||
i++; continue
|
||||
}
|
||||
if (inCode) { code.push(line); i++; continue }
|
||||
if (!line.trim()) { closeList(); i++; continue }
|
||||
if (/^---+$/.test(line.trim())) { closeList(); out.push('<hr>'); i++; continue }
|
||||
const h = line.match(/^(#{1,4})\s+(.*)$/)
|
||||
if (h) { closeList(); out.push('<h' + h[1].length + '>' + inline(h[2]) + '</h' + h[1].length + '>'); i++; continue }
|
||||
if (line.trim().indexOf('|') === 0) {
|
||||
const rows = []
|
||||
while (i < lines.length && lines[i].trim().indexOf('|') === 0) rows.push(lines[i++])
|
||||
const cells = rows.map((r) => r.trim().replace(/^\||\|$/g, '').split('|').map((c) => c.trim()))
|
||||
if (cells.length > 1) {
|
||||
out.push('<table><thead><tr>' + cells[0].map((c) => '<th>' + inline(c) + '</th>').join('') + '</tr></thead><tbody>')
|
||||
for (let r = 2; r < cells.length; r++) out.push('<tr>' + cells[r].map((c) => '<td>' + inline(c) + '</td>').join('') + '</tr>')
|
||||
out.push('</tbody></table>')
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (/^ \S/.test(line)) {
|
||||
closeList()
|
||||
const block = []
|
||||
while (i < lines.length && (/^ /.test(lines[i]) || !lines[i].trim())) { block.push(lines[i].replace(/^ /, '')); i++ }
|
||||
while (block.length && !block[block.length - 1].trim()) block.pop()
|
||||
out.push('<pre><code>' + esc2(block.join('\n')) + '</code></pre>')
|
||||
continue
|
||||
}
|
||||
const li = line.match(/^\s*[-*]\s+(.*)$/)
|
||||
if (li) {
|
||||
if (inList !== 'ul') { closeList(); out.push('<ul>'); inList = 'ul' }
|
||||
out.push('<li>' + inline(li[1]) + '</li>'); i++; continue
|
||||
}
|
||||
const ol = line.match(/^\s*\d+\.\s+(.*)$/)
|
||||
if (ol) {
|
||||
if (inList !== 'ol') { closeList(); out.push('<ol>'); inList = 'ol' }
|
||||
out.push('<li>' + inline(ol[1]) + '</li>'); i++; continue
|
||||
}
|
||||
closeList(); out.push('<p>' + inline(line) + '</p>'); i++
|
||||
}
|
||||
closeList()
|
||||
if (inCode) out.push('<pre><code>' + esc2(code.join('\n')) + '</code></pre>')
|
||||
return out.join('\n')
|
||||
}
|
||||
|
||||
function render(tpl, map) {
|
||||
let out = fs.readFileSync(path.join(site, tpl), 'utf8')
|
||||
for (const k of Object.keys(map)) out = out.split('<!--' + k + '-->').join(map[k])
|
||||
@@ -113,4 +177,16 @@ pluginsPage = pluginsPage.replace('/assets/style.css', '/assets/style.css?v=' +
|
||||
fs.writeFileSync(path.join(site, 'plugins', 'index.html'), pluginsPage)
|
||||
fs.writeFileSync(path.join(site, 'plugins-index.json'), JSON.stringify(market, null, 2) + '\n')
|
||||
|
||||
// 插件开发规范(由 docs/standards/plugin-development.md 生成)
|
||||
const devMdPath = path.join(root, 'docs', 'standards', 'plugin-development.md')
|
||||
if (fs.existsSync(devMdPath)) {
|
||||
const devPage = render('_dev.tpl.html', {
|
||||
NAV: nav('dev'),
|
||||
FOOTER: footer,
|
||||
DEV_CONTENT: mdToHtml(fs.readFileSync(devMdPath, 'utf8')),
|
||||
}).replace('/assets/style.css', '/assets/style.css?v=' + STAMP)
|
||||
fs.mkdirSync(path.join(site, 'dev'), { recursive: true })
|
||||
fs.writeFileSync(path.join(site, 'dev', 'index.html'), devPage)
|
||||
}
|
||||
|
||||
console.log('站点已生成:首页 / 插件页(' + plugins.length + ' 个插件,' + tags.length + ' 个标签,版本 v' + V + ')')
|
||||
@@ -0,0 +1,443 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
/* gen-tokens.js —— 设计 token 的单一源 → 产物生成(v3.26.44 / M3)
|
||||
|
||||
* 为什么要有这个脚本(D1 的终极修法):
|
||||
* 颜色此前写在两个地方 —— `src/theme-tokens.js` 的 derive()(运行时)与 `style.css` 的
|
||||
* `:root`/`.theme-dark`(JS 执行前那一帧)。两份必须逐值相等,靠人同步,于是历史上反复错位
|
||||
* (D2:暗色两套值;M2 期间我自己就漏同步过 nodeBg 与 brand-text)。
|
||||
*
|
||||
* 现在改成:**theme-tokens.js 是唯一源,design-tokens.css 是产物**。
|
||||
* - `node scripts/gen-tokens.js --write` 重新生成 CSS 与 tokens.json
|
||||
* - `node scripts/gen-tokens.js --check` 只比对,不一致就退出 1(进 verify:ci)
|
||||
*
|
||||
* 产物:
|
||||
* src/design-tokens.css 静态快照(:root / .theme-dark / 亮色动效),build 时会内联到 style.css 前面
|
||||
* dist/tokens.json DTCG({$value,$type})格式,可导入 Penpot / Figma Variables
|
||||
*
|
||||
* 三条约束:
|
||||
* ① 这里**不许**出现新的颜色常量 —— 颜色只能来自 derive();
|
||||
* ② 结构层(chrome/home/dock)用 color-mix 表达关系式,切主题自动跟随(D1 第二刀);
|
||||
* ③ 尺度(间距/圆角/字号/阴影/动效)写在下面的 SCALE 里,也只写一次。
|
||||
*/
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const CSS_OUT = path.join(ROOT, 'src/design-tokens.css')
|
||||
const JSON_OUT = path.join(ROOT, 'dist/tokens.json')
|
||||
|
||||
// 载入 theme-tokens(UMD:挂到传入对象上)
|
||||
const sandbox = {}
|
||||
new Function('window', fs.readFileSync(path.join(ROOT, 'src/theme-tokens.js'), 'utf8'))(sandbox)
|
||||
const T = sandbox.IWBThemeTokens
|
||||
|
||||
const LIGHT = T.derive(T.DEFAULTS, false)
|
||||
const DARK = T.derive(T.DEFAULTS, true)
|
||||
|
||||
/* derive 的键 → CSS 变量名(去掉 --iwb- 前缀)。特例写在 ALIAS 里。 */
|
||||
const ALIAS = {
|
||||
canvasText: 'color-text-on-canvas',
|
||||
menuBg: 'bg-menu',
|
||||
canvasBg: 'canvas-bg',
|
||||
nodeBg: 'node-bg',
|
||||
nodeText: 'node-text',
|
||||
nodeText2: 'node-text2',
|
||||
textDim: 'text-dim',
|
||||
homeBg: 'home-bg',
|
||||
dockBg: 'dock-bg',
|
||||
dockHeadBg: 'dock-head-bg',
|
||||
brandText: 'brand-text',
|
||||
onBrand: 'on-brand',
|
||||
pluginSurface: 'plugin-surface',
|
||||
pluginCard: 'plugin-card',
|
||||
pluginInset: 'plugin-inset',
|
||||
pluginHover: 'plugin-hover',
|
||||
gridDot: 'grid-dot',
|
||||
edgeHot: 'edge-hot',
|
||||
}
|
||||
const varName = (k) => '--iwb-' + (ALIAS[k] || k.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()))
|
||||
|
||||
/* 一个 token 在 CSS 里出现的顺序(= 阅读顺序:先表面、再描边、再文字、再品牌、再插件) */
|
||||
const COLOR_ORDER = [
|
||||
'bg', 'canvasBg', 'layer', 'layer2', 'panel', 'nodeBg', 'field',
|
||||
'border', 'border2',
|
||||
'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint',
|
||||
'brand', 'brandText', 'onBrand', 'edge', 'edgeHot', 'gridDot',
|
||||
'surface', 'hover', 'menuBg',
|
||||
'pluginSurface', 'pluginCard', 'pluginInset', 'pluginHover',
|
||||
'err', 'ok', 'warn',
|
||||
]
|
||||
|
||||
/* 尺度层(L1):只在这里定义一次。@deprecated 的名字保留到 M4 迁移结束。 */
|
||||
const SCALE = [
|
||||
['--sp-1', '4px', '@deprecated 全部 5 个 → M3 的 --iwb-space-4/8/12/16/24'],
|
||||
['--sp-2', '8px', null],
|
||||
['--sp-3', '12px', null],
|
||||
['--sp-4', '16px', null],
|
||||
['--sp-5', '24px', null],
|
||||
['--rd-sm', '6px', '@deprecated rd-sm/rd-md/rd-lg → M3 的 --iwb-radius-chip/control/popover'],
|
||||
['--rd', '8px', null],
|
||||
['--rd-md', '10px', null],
|
||||
['--rd-lg', '12px', null],
|
||||
['--fs-xs', '10px', '@deprecated fs-xs/fs-md/fs-lg/fs-xl → M3 的 --iwb-font-*(fs-sm 仍被引用)'],
|
||||
['--fs-sm', '11px', null],
|
||||
['--fs-md', '12px', null],
|
||||
['--fs-lg', '13px', null],
|
||||
['--fs-xl', '14px', null],
|
||||
['--tr-fast', '0.1s ease-out', null],
|
||||
['--tr-base', '0.2s ease-out', '@deprecated tr-base/tr-slow → M3 的 --iwb-motion-*(tr-fast 仍被引用)'],
|
||||
['--tr-slow', '0.3s ease-out', null],
|
||||
|
||||
/* ── M4 公共接口(2026-11-23)─────────────────────────────────────────
|
||||
* 上面那批平铺名(`--sp-1` 这类、rd / fs 同)是 legacy,长期保留给插件与既有代码。
|
||||
* 新代码只用下面这组**语义名**:改一档就全局一致,不用再猜「这处 12px 是间距还是字号」。
|
||||
*/
|
||||
/* 命名用**像素值**而不是序号:`--iwb-space-12` 一眼知道是 12px,`--iwb-space-3` 得背。
|
||||
* 14 档与规范 §3.2 一致;不加 L2 语义别名层(gap-*),避免每个尺寸多一个没人用的名字。 */
|
||||
['--iwb-space-2', '2px', null],
|
||||
['--iwb-space-4', '4px', null],
|
||||
['--iwb-space-6', '6px', null],
|
||||
['--iwb-space-8', '8px', null],
|
||||
['--iwb-space-10', '10px', null],
|
||||
['--iwb-space-12', '12px', null],
|
||||
['--iwb-space-16', '16px', null],
|
||||
['--iwb-space-20', '20px', null],
|
||||
['--iwb-space-24', '24px', null],
|
||||
['--iwb-space-32', '32px', null],
|
||||
['--iwb-space-40', '40px', null],
|
||||
['--iwb-space-48', '48px', null],
|
||||
['--iwb-space-64', '64px', null],
|
||||
['--iwb-radius-chip', '6px', 'M4 圆角:胶囊/标签'],
|
||||
['--iwb-radius-control', '8px', '输入框/按钮'],
|
||||
['--iwb-radius-card', '10px', '卡片/分组'],
|
||||
['--iwb-radius-panel', '12px', '面板/工具栏'],
|
||||
['--iwb-radius-popover', '14px', '浮层/菜单/右键'],
|
||||
['--iwb-radius-full', '999px', '圆形/药丸'],
|
||||
['--iwb-font-xs', '11px', 'M4 字号:状态栏/徽标'],
|
||||
['--iwb-font-sm', '12px', '标签/次要正文'],
|
||||
['--iwb-font-md', '13px', '正文/工具栏标题'],
|
||||
['--iwb-font-lg', '15px', '小标题/节点标题'],
|
||||
['--iwb-font-xl', '17px', '面板标题'],
|
||||
['--iwb-font-2xl', '20px', '页面大标题'],
|
||||
['--iwb-font-display', '24px', '展示级标题:页面/视图主标题(≤5 处)'],
|
||||
['--iwb-chrome-h', '36px', '顶部标签条高度:tabstrip / dockarea / home-panel 三处共用(原来各写一遍 36px)'],
|
||||
['--iwb-tab-h', '28px', '标签高度'],
|
||||
['--iwb-tab-radius', '7px', '标签圆角'],
|
||||
['--iwb-control-h', '30px', '表单控件高度:同一行里的输入框与默认按钮必须等高(设置页实测曾是 33 vs 24)'],
|
||||
|
||||
/* ── 层级表(M4-B2)───────────────────────────────────────────────
|
||||
* 迁移前 z-index 有 42 种取值,其中「谁盖谁」全靠散落在各处的数字对撞,出过两次真 bug:
|
||||
* ① toast(200) 低于弹窗(300) → 弹窗里点保存看不到提示;
|
||||
* ② 资源中心的右键菜单(91) 被全窗口面板(260) 盖住 → 只能挪到 270 打补丁。
|
||||
* 现在数值只在这张表里写,组件引名字。三条关系必须成立,改数字前先读这三条:
|
||||
* A. ctx-menu(91) < sheet(260) < modal(300):层越上,数字越大,不许交叉;
|
||||
* B. toast(500) > modal(300):提示条永远在最上面,否则「操作成功」等于没提示;
|
||||
* C. sheet-menu(270) 是「容器内 portal 菜单」,> sheet 且 < modal(它是面板的子菜单,不该越过弹窗)。
|
||||
* 高段位(3200/3300/4000)保留历史数值:1000 段还有未迁移的 home-menu(1000/1001),
|
||||
* 贸然压缩会和它交错,等 M5 的 token-lint 把裸 z-index 清零后再统一。
|
||||
*/
|
||||
['--iwb-z-ctx', '90', '右键遮罩'],
|
||||
['--iwb-z-ctx-menu', '91', '右键菜单'],
|
||||
['--iwb-z-curtain', '100', '应用遮罩 / 图片预览底'],
|
||||
['--iwb-z-command', '120', '命令面板(⌘K)'],
|
||||
['--iwb-z-sheet', '260', '全窗口面板(资源中心)'],
|
||||
['--iwb-z-sheet-menu', '270', '面板内 portal 菜单:> sheet、< modal'],
|
||||
['--iwb-z-modal', '300', '弹窗 + 遮罩'],
|
||||
['--iwb-z-modal-menu', '310', '侧栏/弹窗里挂 body 的菜单'],
|
||||
['--iwb-z-splash', '400', '启动页'],
|
||||
['--iwb-z-toast', '500', '提示条:必须高于弹窗'],
|
||||
['--iwb-z-preview', '800', '图片预览(全屏)'],
|
||||
['--iwb-z-anchor', '3200', '锚定浮层:挂 body 的面板/首页菜单'],
|
||||
['--iwb-z-palette', '3300', '背景色板 host(含锚定浮层)'],
|
||||
['--iwb-z-alert', '4000', '确认框 / 崩溃屏(最后一道)'],
|
||||
]
|
||||
|
||||
/* 只在亮色出现的结构/契约声明(暗色由 :root 的 color-mix 在 html 上重新求值,或单独覆盖) */
|
||||
const LIGHT_ONLY = [
|
||||
['--iwb-chrome', 'color-mix(in srgb, var(--iwb-bg) 60%, var(--iwb-canvas-bg) 40%)', '顶部 chrome 色:页面底与画布之间的过渡层(标签条用)'],
|
||||
['--iwb-home-bg', 'color-mix(in srgb, var(--iwb-bg) 35%, var(--iwb-canvas-bg) 65%)', '首页底色:画布色与顶栏色之间取 35/65'],
|
||||
['--iwb-hr', 'color-mix(in srgb, var(--iwb-border) 50%, var(--iwb-border2) 50%)', '首页上的细分隔线'],
|
||||
['--iwb-dock-bg', 'color-mix(in srgb, var(--iwb-chrome) 55%, var(--iwb-canvas-bg) 45%)', '左右停靠栏底色:排进 bg→chrome→home→canvas 灰阶'],
|
||||
['--iwb-dock-head-bg', 'color-mix(in srgb, var(--iwb-panel) 55%, var(--iwb-dock-bg))', '顶栏底色比停靠栏更浅一档'],
|
||||
['--iwb-plugin-bg', 'var(--iwb-bg)', 'v3.25.85 插件主题契约:插件只能用这组别名'],
|
||||
['--iwb-plugin-panel', 'var(--iwb-panel)', null],
|
||||
['--iwb-plugin-layer', 'var(--iwb-layer)', null],
|
||||
['--iwb-plugin-border', 'var(--iwb-border)', null],
|
||||
['--iwb-plugin-text', 'var(--iwb-text)', null],
|
||||
['--iwb-plugin-text2', 'var(--iwb-text2)', null],
|
||||
['--iwb-plugin-brand', 'var(--iwb-brand)', null],
|
||||
['--iwb-plugin-on-brand', 'var(--iwb-on-brand)', null],
|
||||
['--iwb-plugin-err', 'var(--iwb-err)', null],
|
||||
['--iwb-plugin-ok', 'var(--iwb-ok)', null],
|
||||
['--iwb-plugin-warn', 'var(--iwb-warn)', null],
|
||||
['--iwb-edge', 'var(--iwb-border2)', '连线默认色:跟随边框灰(主题色只用于选中/悬停/上游高亮)'],
|
||||
['--iwb-edge-hot', 'var(--iwb-brand)', null],
|
||||
['--iwb-focus-ring', '2px solid color-mix(in srgb, var(--iwb-brand-text) 70%, transparent)', '键盘焦点环(D8):颜色走 brand-text,暗色下 brand 画不出环'],
|
||||
['--iwb-edge-w', '1.8px', '外观自定义:由 src/ui-appearance.js 按配置写入,这里只给兜底默认值'],
|
||||
['--iwb-edge-dash', '4 3', null],
|
||||
['--iwb-node-radius', '14px', null],
|
||||
['--iwb-node-sel-w', '1px', null],
|
||||
['--iwb-grid-size', '1.4px', null],
|
||||
['--iwb-grid-gap', '22px', null],
|
||||
['--iwb-grid-on', '1', null],
|
||||
['--iwb-nav-w', '52px', '一级导航宽度:左停靠栏/工具栏让位都以它为基准'],
|
||||
]
|
||||
|
||||
/* 暗色独有的动效:亮色用品牌色,暗色必须用「亮色元素 + 深色轨道」 */
|
||||
const DARK_ANIM = [
|
||||
['--iwb-anim', '#ffffff'],
|
||||
['--iwb-anim-track', 'color-mix(in srgb, #ffffff 18%, transparent)'],
|
||||
['--iwb-anim-glow', 'rgba(255, 255, 255, 0.72)'],
|
||||
['--iwb-anim-tint', 'color-mix(in srgb, #ffffff 16%, transparent)'],
|
||||
['--iwb-anim-flow-a', 'color-mix(in srgb, #ffffff 26%, var(--iwb-layer))'],
|
||||
['--iwb-anim-flow-b', 'color-mix(in srgb, #ffffff 76%, var(--iwb-layer))'],
|
||||
]
|
||||
const LIGHT_ANIM = [
|
||||
['--iwb-anim', 'var(--iwb-brand)'],
|
||||
['--iwb-anim-track', 'color-mix(in srgb, var(--iwb-brand) 16%, transparent)'],
|
||||
['--iwb-anim-glow', 'color-mix(in srgb, var(--iwb-brand) 75%, transparent)'],
|
||||
['--iwb-anim-tint', 'color-mix(in srgb, var(--iwb-brand) 7%, transparent)'],
|
||||
['--iwb-anim-flow-a', 'color-mix(in srgb, var(--iwb-brand) 16%, var(--iwb-layer))'],
|
||||
['--iwb-anim-flow-b', 'color-mix(in srgb, var(--iwb-brand) 46%, var(--iwb-layer))'],
|
||||
]
|
||||
|
||||
const DARK_SHADOW = [
|
||||
['--sh-sm', '0 2px 8px rgba(0, 0, 0, 0.35)'],
|
||||
['--sh-md', '0 6px 20px rgba(0, 0, 0, 0.45)'],
|
||||
['--sh-lg', '0 12px 32px rgba(0, 0, 0, 0.6)'],
|
||||
/* 暗色下阴影本来就画不出形(底已经近黑),必须靠「更大的不透明度 + 更大的扩散」压出层次差 */
|
||||
['--iwb-elevation-1', '0 2px 8px rgba(0, 0, 0, 0.40)'],
|
||||
['--iwb-elevation-2', '0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.40)'],
|
||||
['--iwb-elevation-3', '0 18px 56px rgba(0, 0, 0, 0.62)'],
|
||||
['--iwb-elevation-4', '0 24px 64px rgba(0, 0, 0, 0.70)'],
|
||||
]
|
||||
const LIGHT_SHADOW = [
|
||||
['--sh-sm', '0 2px 8px rgba(0, 0, 0, 0.12)', '@deprecated → M3 的 --iwb-elevation-1'],
|
||||
['--sh-md', '0 6px 20px rgba(0, 0, 0, 0.16)', null],
|
||||
['--sh-lg', '0 12px 32px rgba(0, 0, 0, 0.24)', null],
|
||||
/* ── 阴影四档(M4-B2)────────────────────────────────────────────
|
||||
* 迁移前浮层有 8 种写法(52 种全局),同一层的两个菜单阴影不一样 —— 层深不再表达「离内容多远」。
|
||||
* 现在按「离内容多远」分四档,一档一个值:
|
||||
* 1 贴面(浮动条/状态栏/HUD)· 2 浮窗/菜单/toast · 3 命令面板/锚定大浮层 · 4 弹窗/全窗口面板
|
||||
* 只改形,不改色:颜色仍是中性黑(暗色另有覆盖)。
|
||||
*/
|
||||
['--iwb-elevation-1', '0 2px 8px rgba(0, 0, 0, 0.12)', '贴面浮层:浮动条 / 状态栏'],
|
||||
['--iwb-elevation-2', '0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.10)', '浮窗 / 菜单 / toast'],
|
||||
['--iwb-elevation-3', '0 18px 56px rgba(0, 0, 0, 0.26)', '命令面板 / 锚定大浮层'],
|
||||
['--iwb-elevation-4', '0 24px 64px rgba(0, 0, 0, 0.30)', '弹窗 / 全窗口面板'],
|
||||
]
|
||||
|
||||
function decl ([name, value, note]) {
|
||||
return ' ' + name + ': ' + value + ';' + (note ? ' /* ' + note + ' */' : '')
|
||||
}
|
||||
|
||||
function colorDecls (tokens, only) {
|
||||
return COLOR_ORDER
|
||||
.filter((k) => !only || only.includes(k))
|
||||
.map((k) => decl([varName(k), tokens[k]]))
|
||||
}
|
||||
|
||||
function buildCss () {
|
||||
const L = []
|
||||
L.push('/* 设计 token 静态快照 —— **生成文件,勿手改**')
|
||||
L.push(' *')
|
||||
L.push(' * 源:src/theme-tokens.js(derive() + 本文件生成器的 SCALE 表)')
|
||||
L.push(' * 生成:node scripts/gen-tokens.js --write (校验:--check,已进 verify:ci)')
|
||||
L.push(' *')
|
||||
L.push(' * 为什么要有这一层:JS 未执行的那一帧没有内联变量,用它顶住,避免首屏闪白/跳变。')
|
||||
L.push(' * 所以它必须逐值等于 derive() 的输出 —— 这条约束由 scripts/gen-tokens.js --check 强制。')
|
||||
L.push(' * 结构层(chrome/home/dock/edge/hr)刻意用 color-mix 表达关系式:换主题时 :root 的声明会在')
|
||||
L.push(' * html 元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值,天然跟随。')
|
||||
L.push(' */')
|
||||
L.push(':root {')
|
||||
L.push(' /* —— 表面阶(亮色往白里 mix) —— */')
|
||||
L.push(...colorDecls(LIGHT, ['bg', 'canvasBg', 'layer', 'layer2', 'panel', 'nodeBg', 'field']))
|
||||
L.push(' /* —— 结构层(公式与 derive 一致,见文件头) —— */')
|
||||
L.push(...LIGHT_ONLY.map(decl))
|
||||
L.push(' /* —— 描边 / 文字三级(目标对比度见 IWBThemeTokens.RATIO) —— */')
|
||||
L.push(...colorDecls(LIGHT, ['border', 'border2', 'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint']))
|
||||
L.push(' /* —— 品牌色:填充与文字是两个角色(D7) —— */')
|
||||
L.push(...colorDecls(LIGHT, ['brand', 'brandText', 'onBrand', 'gridDot']))
|
||||
L.push(' /* —— 插件表面四层(只提供取值,不做变量重指) —— */')
|
||||
L.push(...colorDecls(LIGHT, ['pluginSurface', 'pluginCard', 'pluginInset', 'pluginHover', 'surface', 'hover', 'menuBg']))
|
||||
L.push(' /* —— 语义色 —— */')
|
||||
L.push(...colorDecls(LIGHT, ['err', 'ok', 'warn']))
|
||||
L.push(' /* —— 尺度层(L1)—— */')
|
||||
L.push(...SCALE.map(decl))
|
||||
L.push(' /* —— 阴影 —— */')
|
||||
L.push(...LIGHT_SHADOW.map(decl))
|
||||
L.push('}')
|
||||
L.push('')
|
||||
L.push('/* 暗色主题:html.theme-dark')
|
||||
L.push(' * 同一套语义名,值来自 derive(DEFAULTS, true)。结构层不在这里重复定义 ——')
|
||||
L.push(' * :root 的 color-mix 公式会在本元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值。 */')
|
||||
L.push('.theme-dark {')
|
||||
L.push(' /* 生图动效在暗色下必须「发亮」:--iwb-brand 是中性灰,直接用会糊在深底里 */')
|
||||
L.push(...DARK_ANIM.map(decl))
|
||||
L.push(' /* —— 表面阶 —— */')
|
||||
L.push(...colorDecls(DARK, ['bg', 'canvasBg', 'layer', 'layer2', 'panel', 'nodeBg', 'field', 'border', 'border2']))
|
||||
L.push(' /* —— 文字 / 品牌 —— */')
|
||||
L.push(...colorDecls(DARK, ['text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint', 'brand', 'brandText', 'onBrand', 'gridDot']))
|
||||
L.push(' /* —— 插件表面 / 浮层 / 语义色 —— */')
|
||||
L.push(...colorDecls(DARK, ['pluginSurface', 'pluginCard', 'pluginInset', 'pluginHover', 'surface', 'hover', 'menuBg', 'err', 'ok', 'warn']))
|
||||
L.push(' /* —— 阴影 —— */')
|
||||
L.push(...DARK_SHADOW.map(decl))
|
||||
L.push('}')
|
||||
L.push('')
|
||||
L.push('/* 亮色主题的生图动效 token:与暗色同结构,色取品牌色 */')
|
||||
L.push(':root:not(.theme-dark) {')
|
||||
L.push(...LIGHT_ANIM.map(decl))
|
||||
L.push('}')
|
||||
L.push('')
|
||||
return L.join('\n')
|
||||
}
|
||||
|
||||
/* ── DTCG 导出 ──────────────────────────────────────────────
|
||||
* 解析生成好的 CSS(而不是再 derive 一遍):保证「导出的 JSON == 实际生效的 CSS」。
|
||||
* 关系式(color-mix / var)不是值,跳过 —— 它们在 Figma/Penpot 里没有对应概念。 */
|
||||
function parseBlocks (css) {
|
||||
const out = {}
|
||||
const re = /(:root:not\(\.theme-dark\)|:root|\.theme-dark)\s*\{([\s\S]*?)\n\}/g
|
||||
let m
|
||||
while ((m = re.exec(css))) {
|
||||
const body = m[2].replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const d = {}
|
||||
const dre = /(--[a-z0-9-]+)\s*:\s*([^;]+);/g
|
||||
let x
|
||||
while ((x = dre.exec(body))) d[x[1]] = x[2].trim()
|
||||
out[m[1]] = d
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function inferType (value, name) {
|
||||
if (/^#[0-9a-f]{3,8}$/i.test(value)) return 'color'
|
||||
if (/^rgba?\(/i.test(value)) return 'color'
|
||||
if (/^-?[\d.]+px$/.test(value)) return 'dimension'
|
||||
if (/^-?[\d.]+m?s$/.test(value)) return 'duration'
|
||||
if (/\d+px [\d.]+px/.test(value)) return 'shadow'
|
||||
// 层级是纯数字(z-index 认的是整数),DTCG 里就是 number
|
||||
if (/^--(?:iwb-)?z-/.test(name) && /^\d+$/.test(value)) return 'number'
|
||||
// 过渡是「时长 + 缓动」的复合值,DTCG 里是两种类型:时长给 $value,缓动放 $description
|
||||
if (/^--tr-/.test(name) && /^[\d.]+m?s\s+\S+$/.test(value)) return 'duration'
|
||||
return null
|
||||
}
|
||||
|
||||
// 变量名 → DTCG 分组
|
||||
function groupOf (name) {
|
||||
const n = name.replace(/^--(?:iwb-)?/, '')
|
||||
if (/^sp-/.test(n)) return 'legacy.space'
|
||||
if (/^space-/.test(n)) return 'space'
|
||||
if (/^rd(-|$)/.test(n)) return 'legacy.radius'
|
||||
if (/^radius-/.test(n)) return 'radius'
|
||||
if (/^fs-/.test(n)) return 'legacy.font'
|
||||
if (/^font-/.test(n)) return 'font.size'
|
||||
if (/^tr-/.test(n)) return 'motion'
|
||||
if (/^elevation-/.test(n)) return 'shadow.elevation'
|
||||
if (/^sh-/.test(n)) return 'shadow'
|
||||
if (/^z-/.test(n)) return 'z'
|
||||
if (n === 'grid-dot') return 'color'
|
||||
if (/^(grid-|nav-|node-radius|node-sel-w|edge-w|edge-dash|chrome-h|tab-h|tab-radius|control-h)/.test(n)) return 'layout'
|
||||
if (/^plugin-/.test(n)) return 'color.plugin'
|
||||
return 'color'
|
||||
}
|
||||
|
||||
function dtcgKey (name) {
|
||||
const n = name.replace(/^--(?:iwb-)?/, '')
|
||||
if (/^sp-/.test(n)) return n.slice(3)
|
||||
if (/^space-/.test(n)) return n.slice(6)
|
||||
if (/^radius-/.test(n)) return n.slice(7)
|
||||
if (n === 'rd-sm') return 'sm'
|
||||
if (n === 'rd') return 'base'
|
||||
if (/^rd-/.test(n)) return n.slice(3)
|
||||
if (/^fs-/.test(n)) return n.slice(3)
|
||||
if (/^font-/.test(n)) return n.slice(5)
|
||||
if (/^tr-/.test(n)) return n.slice(3)
|
||||
if (/^elevation-/.test(n)) return n.slice(10)
|
||||
if (/^sh-/.test(n)) return n.slice(3)
|
||||
if (/^z-/.test(n)) return n.slice(2)
|
||||
if (/^plugin-/.test(n)) return n.slice(7)
|
||||
return n
|
||||
}
|
||||
|
||||
function put (root, groupPath, key, node) {
|
||||
const parts = groupPath.split('.')
|
||||
let cur = root
|
||||
for (const p of parts) {
|
||||
if (!cur[p]) cur[p] = {}
|
||||
cur = cur[p]
|
||||
}
|
||||
cur[key] = node
|
||||
}
|
||||
|
||||
function buildJson (css) {
|
||||
const blocks = parseBlocks(css)
|
||||
const light = Object.assign({}, blocks[':root'] || {}, blocks[':root:not(.theme-dark)'] || {})
|
||||
const dark = blocks['.theme-dark'] || {}
|
||||
const root = {}
|
||||
const skipped = []
|
||||
for (const name of Object.keys(light)) {
|
||||
const value = light[name]
|
||||
const type = inferType(value, name)
|
||||
if (!type) { skipped.push(name); continue }
|
||||
let node
|
||||
if (type === 'duration' && /^--tr-/.test(name)) {
|
||||
const m = /^([\d.]+m?s)\s+(\S+)$/.exec(value)
|
||||
node = { $value: m[1], $type: 'duration', $description: '缓动 ' + m[2] }
|
||||
} else {
|
||||
node = { $value: value, $type: type }
|
||||
}
|
||||
if (dark[name]) node.$extensions = { 'com.image-workbench.dark': { $value: dark[name], $type: type } }
|
||||
put(root, groupOf(name), dtcgKey(name), node)
|
||||
}
|
||||
return { root, skipped }
|
||||
}
|
||||
|
||||
function build () {
|
||||
const css = buildCss()
|
||||
const { root, skipped } = buildJson(css)
|
||||
const json = {
|
||||
$description: 'Image Workbench 设计 token(由 src/theme-tokens.js 生成;暗色值在 $extensions.com.image-workbench.dark)',
|
||||
$version: '3.26.44',
|
||||
...root,
|
||||
}
|
||||
return { css, json: JSON.stringify(json, null, 2) + '\n', skipped }
|
||||
}
|
||||
|
||||
function main () {
|
||||
const write = process.argv.includes('--write')
|
||||
const { css, json, skipped } = build()
|
||||
|
||||
if (write) {
|
||||
fs.mkdirSync(path.dirname(JSON_OUT), { recursive: true })
|
||||
fs.writeFileSync(CSS_OUT, css)
|
||||
fs.writeFileSync(JSON_OUT, json)
|
||||
console.log('✓ src/design-tokens.css(' + css.split('\n').length + ' 行)')
|
||||
console.log('✓ dist/tokens.json(DTCG;跳过 ' + skipped.length + ' 个关系式:' + skipped.join(', ') + ')')
|
||||
return
|
||||
}
|
||||
|
||||
const problems = []
|
||||
const cur = fs.existsSync(CSS_OUT) ? fs.readFileSync(CSS_OUT, 'utf8') : ''
|
||||
if (cur !== css) {
|
||||
// 逐行指出第一处差异,别让人对着两千行找
|
||||
const a = cur.split('\n')
|
||||
const b = css.split('\n')
|
||||
let i = 0
|
||||
while (i < a.length && i < b.length && a[i] === b[i]) i++
|
||||
problems.push('src/design-tokens.css 与 derive() 不一致(第 ' + (i + 1) + ' 行)\n' +
|
||||
' 文件: ' + JSON.stringify(a[i] || '(缺)') + '\n' +
|
||||
' 应为: ' + JSON.stringify(b[i] || '(多)') + '\n' +
|
||||
' → 跑 node scripts/gen-tokens.js --write')
|
||||
}
|
||||
if (problems.length) {
|
||||
console.error('✗ ' + problems.join('\n'))
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('design-tokens: CSS 静态快照与 derive() 一致(' + css.split('\n').length + ' 行)')
|
||||
}
|
||||
|
||||
if (require.main === module) main()
|
||||
module.exports = { build, buildCss, buildJson }
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# 打包 dmg 的兜底实现(2026-11-23 新增)
|
||||
#
|
||||
# 为什么需要:`tauri build --bundles dmg` 在本机会失败在最后一步 bundle_dmg.sh:
|
||||
# grep: bad regex '/dev/disk1Xs': brackets ([ ]) not balanced
|
||||
# 根因是上游脚本第 431 行 `hdiutil attach | grep '^/dev/' | awk '{print $1}'`:
|
||||
# 新版 macOS 的 attach 输出会同时给出 Apple_partition_scheme 与 Apple_HFS 两行,
|
||||
# 两行被一起收进 DEV_NAME,拼出畸形模式后 grep 直接报错退出。
|
||||
# 此时 **app 本体已经构建成功**,只是封装失败 —— 没必要重跑几分钟的 release 编译。
|
||||
#
|
||||
# 本脚本只做打包:复制 .app → 建 Applications 快捷方式 → hdiutil create。
|
||||
# 产物名与 tauri 一致(image-workbench_<版本>_<arch>.dmg),release.sh 可直接接手。
|
||||
#
|
||||
# 用法:bash scripts/make-dmg.sh
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
VERSION=$(node -e "console.log(require('./src-tauri/tauri.conf.json').version)")
|
||||
case "$(uname -m)" in
|
||||
arm64) ARCH=aarch64 ;;
|
||||
x86_64) ARCH=x64 ;;
|
||||
*) ARCH=$(uname -m) ;;
|
||||
esac
|
||||
|
||||
BUNDLE_DIR="src-tauri/target/release/bundle"
|
||||
APP="$BUNDLE_DIR/macos/image-workbench.app"
|
||||
OUT="$BUNDLE_DIR/dmg/image-workbench_${VERSION}_${ARCH}.dmg"
|
||||
|
||||
if [ ! -d "$APP" ]; then
|
||||
echo "✗ 找不到 $APP —— 先跑一次构建(npx tauri build),本脚本只负责封装" >&2
|
||||
exit 1
|
||||
fi
|
||||
BIN="$APP/Contents/MacOS/image-workbench"
|
||||
if [ ! -x "$BIN" ]; then
|
||||
echo "✗ $APP 里没有可执行文件,产物不完整" >&2
|
||||
exit 1
|
||||
fi
|
||||
APP_VER=$(plutil -extract CFBundleShortVersionString raw "$APP/Contents/Info.plist" 2>/dev/null || echo "?")
|
||||
if [ "$APP_VER" != "$VERSION" ]; then
|
||||
echo "✗ 产物版本 $APP_VER ≠ 配置版本 $VERSION(app 是旧的,先重新构建)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 历史中断的打包会留下 rw.*.dmg 的挂载卷,它们会让下一次 hdiutil 复用设备号。
|
||||
# 只卸载 /Volumes 下的临时名(dmg.XXXXXX),不动用户自己的磁盘。
|
||||
for v in /Volumes/dmg.*; do
|
||||
# set -e 下必须显式吞掉失败:卷可能正被占用,卸载不了也不该让打包停下
|
||||
if [ -d "$v" ] && hdiutil detach "$v" -quiet 2>/dev/null; then
|
||||
echo " 已卸载残留卷 $v"
|
||||
fi
|
||||
done || true
|
||||
|
||||
mkdir -p "$BUNDLE_DIR/dmg"
|
||||
STAGE=$(mktemp -d "${TMPDIR:-/tmp}/iwb-dmg.XXXXXX")
|
||||
trap 'rm -rf "$STAGE"' EXIT
|
||||
|
||||
cp -R "$APP" "$STAGE/"
|
||||
ln -s /Applications "$STAGE/Applications"
|
||||
|
||||
hdiutil create -volname "image-workbench" -srcfolder "$STAGE" -ov -format UDZO -fs HFS+ "$OUT" >/dev/null
|
||||
hdiutil verify "$OUT" >/dev/null
|
||||
|
||||
SIZE=$(stat -f%z "$OUT")
|
||||
SHA=$(shasum -a 256 "$OUT" | awk '{print $1}')
|
||||
echo "✓ $OUT"
|
||||
echo " 版本 $VERSION / 大小 $((SIZE / 1048576))MB / sha256 $SHA"
|
||||
@@ -23,7 +23,13 @@ echo "版本:$VERSION"
|
||||
|
||||
if [ "$SKIP_BUILD" -eq 0 ]; then
|
||||
echo "→ 构建 dmg…"
|
||||
npx tauri build --bundles dmg
|
||||
# tauri 的 bundle_dmg.sh 在新版 macOS 上会因设备名解析 bug 失败
|
||||
# (grep: bad regex '/dev/disk1Xs': brackets ([ ]) not balanced,详见 scripts/make-dmg.sh 头注释)。
|
||||
# 那一刻 app 本体已经构建成功,只是封装失败 —— 降级到 hdiutil 兜底,不重跑几分钟的 release 编译。
|
||||
if ! npx tauri build --bundles dmg; then
|
||||
echo "⚠ tauri 封装 dmg 失败,改用 hdiutil 兜底(app 已构建成功)"
|
||||
bash scripts/make-dmg.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
DMG=$(ls -t src-tauri/target/release/bundle/dmg/*.dmg 2>/dev/null | head -1 || true)
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
#!/usr/bin/env node
|
||||
/* token-audit.js —— 设计 token 现状审计(只读)
|
||||
*
|
||||
* 用途:给 docs/standards/design-tokens.md 提供可复核的数字,将来也能当「棘轮」基线。
|
||||
* 不改任何文件;输出 Markdown 表格 + 关键告警。
|
||||
*
|
||||
* 用法:node scripts/token-audit.js [--json]
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
const read = (p) => { try { return fs.readFileSync(p, 'utf8') } catch (e) { return '' } }
|
||||
|
||||
const css = read(path.join(ROOT, 'style.css'))
|
||||
// M3 起 token 定义搬进生成的 src/design-tokens.css:变量清单要把两份合起来看,
|
||||
// 否则「定义的变量」会突然变成 0(脚本比代码先过时,是最容易误导人的失败模式)。
|
||||
const tokensCss = read(path.join(ROOT, 'src', 'design-tokens.css'))
|
||||
const allCss = css + '\n' + tokensCss
|
||||
const siteCss = read(path.join(ROOT, 'site', 'assets', 'style.css'))
|
||||
|
||||
function walk (dir, out) {
|
||||
let ents = []
|
||||
try { ents = fs.readdirSync(dir, { withFileTypes: true }) } catch (e) { return out }
|
||||
for (const e of ents) {
|
||||
const p = path.join(dir, e.name)
|
||||
if (e.isDirectory()) walk(p, out)
|
||||
else if (/\.(css|js)$/i.test(e.name)) out.push(p)
|
||||
}
|
||||
return out
|
||||
}
|
||||
const pluginFiles = walk(path.join(ROOT, 'plugins'), [])
|
||||
|
||||
const count = (re, src) => (src.match(re) || []).length
|
||||
const uniqSorted = (arr, numeric) => Array.from(new Set(arr)).sort(numeric ? (a, b) => a - b : undefined)
|
||||
|
||||
/* ---------- 1. 变量:定义 / 引用 / 未定义 / 死变量 ---------- */
|
||||
// 定义可以写在一行里的任意位置(--rd-sm: 6px; --rd: 8px; 这种),不能只认行首
|
||||
const defs = uniqSorted((allCss.match(/(?:^|[\s;{])--[a-z0-9-]+\s*:/gim) || []).map((s) => s.trim().replace(/^[;{]/, '').trim().replace(/\s*:$/, '')))
|
||||
const refs = uniqSorted((allCss.match(/var\(\s*--[a-z0-9-]+/gi) || []).map((s) => s.replace(/var\(\s*/, '')))
|
||||
// 运行时由 JS 写入的变量(app.js / canvas-*.js 里 setProperty),不算缺失
|
||||
const RUNTIME_SET = new Set(['--iwb-dock-l', '--iwb-dock-r', '--iwb-fb-k', '--iwb-node-color'])
|
||||
const undefinedRefs = refs.filter((r) => !defs.includes(r) && !RUNTIME_SET.has(r))
|
||||
|
||||
const usedCount = {}
|
||||
for (const r of refs) usedCount[r] = count(new RegExp('var\\(\\s*' + r + '(?=[,)])', 'g'), css)
|
||||
const deadTokens = defs.filter((d) => !usedCount[d] && !new RegExp('var\\(\\s*' + d + '\\s*[,)]').test(css))
|
||||
|
||||
/* ---------- 2. 命名空间:几套并存 ---------- */
|
||||
const ns = (re) => uniqSorted((allCss.match(re) || [])).length
|
||||
const namespaces = {
|
||||
'--iwb-*(旧宿主)': ns(/--iwb-[a-z0-9-]+/g),
|
||||
'--sp-*(间距)': ns(/--sp-[a-z0-9-]+/g),
|
||||
'--rd*(圆角)': ns(/--rd[a-z0-9-]*/g),
|
||||
'--fs-*(字号)': ns(/--fs-[a-z0-9-]+/g),
|
||||
'--sh-*(阴影)': ns(/--sh-[a-z0-9-]+/g),
|
||||
'--tr-*(过渡)': ns(/--tr-[a-z0-9-]+/g)
|
||||
}
|
||||
|
||||
/* ---------- 3. 硬编码 vs token 采用率 ---------- */
|
||||
const hard = {
|
||||
'十六进制色值': count(/#[0-9a-fA-F]{3,8}\b/g, css),
|
||||
'rgba()/rgb()': count(/rgba?\([^)]*\)/g, css),
|
||||
'font-size 写死': count(/font-size:\s*[0-9.]+px/g, css),
|
||||
'border-radius 写死': count(/border-radius:\s*[0-9.]+px/g, css),
|
||||
'padding/margin/gap 写死': count(/(?:padding|margin|gap)[a-z-]*:\s*[0-9.]+px/g, css),
|
||||
'box-shadow 声明': count(/box-shadow\s*:/g, css),
|
||||
'z-index 声明': count(/z-index\s*:/g, css)
|
||||
}
|
||||
|
||||
const scale = (re) => {
|
||||
const vals = (css.match(re) || []).map((s) => parseFloat(String(s).match(/[0-9.]+/)[0]))
|
||||
return vals
|
||||
}
|
||||
const fontSizes = scale(/font-size:\s*[0-9.]+px/g)
|
||||
const radii = scale(/border-radius:\s*[0-9.]+px/g)
|
||||
const spacings = scale(/(?:padding|margin|gap)[a-z-]*:\s*[0-9.]+px/g)
|
||||
const zindex = (css.match(/z-index:\s*-?[0-9]+/g) || []).map((s) => parseInt(String(s).match(/-?[0-9]+$/)[0], 10))
|
||||
const shadows = uniqSorted((css.match(/box-shadow:[^;}]*/g) || []).map((s) => s.replace(/\s+/g, ' ').trim()))
|
||||
|
||||
const tokenUse = {
|
||||
'var(--sp-*)': count(/var\(--sp-[0-9]/g, css),
|
||||
'var(--rd*)': count(/var\(--rd/g, css),
|
||||
'var(--fs-*)': count(/var\(--fs-[0-9a-z]/g, css),
|
||||
'var(--sh-*)': count(/var\(--sh-/g, css),
|
||||
'var(--tr-*)': count(/var\(--tr-/g, css)
|
||||
}
|
||||
|
||||
/* ---------- 4. 插件侧 ---------- */
|
||||
// 与 tests/plugin-theme-contract-test.js 同口径,分三类而不是只数 hex:
|
||||
// 私有皮肤(manifest 声明 skin:'private')—— 已声明的设计选择,不算欠债,但它不得引用宿主颜色 token
|
||||
// 强调色(chroma ≥ 24)—— 品牌/危险/成功色,亮暗两端都可读,允许写死
|
||||
// 中性色(chroma < 24)—— 表面/文字/边框,写死在暗色下必然白板或黑洞,这才是要修的
|
||||
const chromaOf = (hex) => {
|
||||
let h = hex.replace('#', '')
|
||||
if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2]
|
||||
if (h.length !== 6) return 0
|
||||
const n = parseInt(h, 16)
|
||||
const c = [(n >> 16) & 255, (n >> 8) & 255, n & 255]
|
||||
return Math.max(c[0], c[1], c[2]) - Math.min(c[0], c[1], c[2])
|
||||
}
|
||||
const pluginBad = []
|
||||
const pluginPrivate = []
|
||||
const pluginAccent = []
|
||||
for (const f of pluginFiles) {
|
||||
const src = read(f)
|
||||
const isPrivate = /skin:\s*'private'/.test(src.slice(0, 4096))
|
||||
const re = /(background(?:-color)?|color|border(?:-color)?)\s*:\s*([^;'"}]{0,80})/gi
|
||||
let m
|
||||
let neutral = 0
|
||||
let accent = 0
|
||||
while ((m = re.exec(src))) {
|
||||
const val = m[2]
|
||||
if (!/#[0-9a-f]{3,8}/i.test(val)) continue
|
||||
if (/\/\*iwb:content\*\//.test(val)) continue
|
||||
if (/var\(--[a-z0-9-]+\s*,\s*#[0-9a-f]{3,8}/i.test(val)) continue
|
||||
// 纯白文字压在图片/色块上:内容对比,不是主题表面色(契约测试同款例外)
|
||||
if (/^color$/i.test(m[1]) && /^#(?:fff|ffffff)$/i.test(val.trim().replace(/[}\s]+$/, ''))) continue
|
||||
for (const h of val.match(/#[0-9a-f]{3,8}/gi) || []) {
|
||||
if (chromaOf(h) >= 24) accent++
|
||||
else neutral++
|
||||
}
|
||||
}
|
||||
if (isPrivate) { pluginPrivate.push({ file: path.relative(ROOT, f), hex: neutral + accent }); continue }
|
||||
if (neutral) pluginBad.push({ file: path.relative(ROOT, f), hex: neutral })
|
||||
if (accent) pluginAccent.push({ file: path.relative(ROOT, f), hex: accent })
|
||||
}
|
||||
const pluginTokenUse = pluginFiles.reduce((a, f) => a + count(/var\(--iwb-/g, read(f)), 0)
|
||||
|
||||
/* ---------- 5. 官网 / 市场页 ---------- */
|
||||
const siteVars = uniqSorted((siteCss.match(/--[a-z0-9-]+:/gi) || []).map((s) => s.trim().replace(/:$/, '')))
|
||||
|
||||
const report = {
|
||||
cssLines: css.split('\n').length,
|
||||
tokenLines: tokensCss.split('\n').length,
|
||||
defs: defs.length,
|
||||
refs: refs.length,
|
||||
undefinedRefs,
|
||||
deadTokens,
|
||||
namespaces,
|
||||
hard,
|
||||
fontSizes: { distinct: uniqSorted(fontSizes, true), count: fontSizes.length },
|
||||
radii: { distinct: uniqSorted(radii, true), count: radii.length },
|
||||
spacings: { distinct: uniqSorted(spacings, true), count: spacings.length },
|
||||
zindex: { distinct: uniqSorted(zindex, true), count: zindex.length },
|
||||
shadows: { distinct: shadows.length },
|
||||
tokenUse,
|
||||
pluginBad,
|
||||
pluginTokenUse,
|
||||
siteVars
|
||||
}
|
||||
|
||||
if (process.argv.includes('--contrast')) {
|
||||
// 复现 docs/standards/design-tokens.md §1.5 的对比度实测(需要 theme-tokens.js 可独立运行)
|
||||
const sandbox = {}
|
||||
try {
|
||||
new Function('window', read(path.join(ROOT, 'src', 'theme-tokens.js')))(sandbox)
|
||||
} catch (e) {
|
||||
console.log('无法加载 theme-tokens.js:' + e.message)
|
||||
process.exit(1)
|
||||
}
|
||||
const T = sandbox.IWBThemeTokens
|
||||
const SURFACES = ['bg', 'panel', 'layer', 'layer2', 'nodeBg', 'field', 'canvasBg', 'pluginSurface', 'pluginCard']
|
||||
for (const dark of [false, true]) {
|
||||
const t = T.derive(T.DEFAULTS, dark)
|
||||
const MINS = { text: T.RATIO.text, text2: T.RATIO.text2, textDim: T.RATIO.dim }
|
||||
console.log('\n### ' + (dark ? '暗色' : '亮色') + ':文字对各表面(text≥' + MINS.text + ' / text2≥' + MINS.text2 + ' / textDim≥' + MINS.textDim + ')\n')
|
||||
console.log('| 表面 | text | text2 | textDim |\n|---|---|---|---|')
|
||||
for (const s of SURFACES) {
|
||||
const row = ['text', 'text2', 'textDim'].map((f) => {
|
||||
const v = T.contrast(t[f], t[s]).toFixed(2)
|
||||
return Number(v) < MINS[f] ? '**' + v + '**' : v
|
||||
})
|
||||
console.log('| ' + s + ' | ' + row.join(' | ') + ' |')
|
||||
}
|
||||
}
|
||||
/* 静态快照 vs derive():v3.26.44 起两者必须完全一致(D2)。
|
||||
* 之前这里硬编码着旧的「中灰底」值,脚本自己成了过时信息的来源 —— 现在从 .theme-dark 实时解析。 */
|
||||
console.log('\n### 静态快照 vs derive()(暗色)—— 必须一致\n')
|
||||
console.log('| token | `.theme-dark` 静态 | derive 默认 | 一致 |\n|---|---|---|---|')
|
||||
const darkBlock = (tokensCss.match(/\.theme-dark\s*\{([\s\S]*?)\n\}/) || [, ''])[1].replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const statDark = {}
|
||||
for (const m of darkBlock.matchAll(/--(?:iwb-)?([a-z0-9-]+)\s*:\s*(#[0-9a-fA-F]{6})\s*;/g)) statDark[m[1]] = m[2].toLowerCase()
|
||||
const d = T.derive(T.DEFAULTS, true)
|
||||
const KEYS = { bg: 'bg', panel: 'panel', layer: 'layer', layer2: 'layer2', 'node-bg': 'nodeBg', field: 'field', text: 'text', text2: 'text2', 'text-dim': 'textDim' }
|
||||
for (const [k, key] of Object.entries(KEYS)) {
|
||||
const sv = statDark[k] || '(表达式)'
|
||||
const ok = sv === d[key]
|
||||
console.log('| `--iwb-' + k + '` | `' + sv + '` | `' + d[key] + '` | ' + (ok ? '✓' : '**不一致**') + ' |')
|
||||
}
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
if (process.argv.includes('--json')) {
|
||||
console.log(JSON.stringify(report, null, 2))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const pad = (s, n) => String(s) + ' '.repeat(Math.max(0, n - String(s).replace(/[\u4e00-\u9fa5]/g, 'xx').length))
|
||||
|
||||
console.log('## 1. 变量规模\n')
|
||||
console.log(`| 指标 | 数值 |\n|---|---|`)
|
||||
console.log(`| style.css 行数 | ${report.cssLines} |`)
|
||||
console.log(`| design-tokens.css 行数(生成) | ${report.tokenLines} |`)
|
||||
console.log(`| 定义的 --* 变量 | ${defs.length} |`)
|
||||
console.log(`| 被 var() 引用的变量 | ${refs.length} |`)
|
||||
console.log(`| **引用了但从未定义** | **${undefinedRefs.length}** → ${undefinedRefs.join(' ')} |`)
|
||||
console.log(`| 定义了但从未引用 | ${deadTokens.length} |`)
|
||||
console.log('\n## 2. 命名空间并存\n')
|
||||
console.log('| 命名空间 | 变量个数 |\n|---|---|')
|
||||
for (const [k, v] of Object.entries(namespaces)) console.log(`| ${k} | ${v} |`)
|
||||
console.log('\n## 3. 硬编码 vs token\n')
|
||||
console.log('| 类别 | 写死数量 |\n|---|---|')
|
||||
for (const [k, v] of Object.entries(hard)) console.log(`| ${k} | ${v} |`)
|
||||
console.log('\n基础尺寸 token 实际采用:')
|
||||
for (const [k, v] of Object.entries(tokenUse)) console.log(`- ${k}: ${v} 次`)
|
||||
console.log('\n## 4. 尺度离散度\n')
|
||||
console.log('| 尺度 | 取值种类 | 实际分布 |\n|---|---|---|')
|
||||
console.log(`| 字号 | ${report.fontSizes.distinct.length} | ${report.fontSizes.distinct.join(' / ')} |`)
|
||||
console.log(`| 圆角 | ${report.radii.distinct.length} | ${report.radii.distinct.join(' / ')} |`)
|
||||
console.log(`| 间距 | ${report.spacings.distinct.length} | ${report.spacings.distinct.join(' / ')} |`)
|
||||
console.log(`| z-index | ${report.zindex.distinct.length} | ${report.zindex.distinct.join(' / ')} |`)
|
||||
console.log(`| box-shadow 写法 | ${report.shadows.distinct} | — |`)
|
||||
console.log('\n## 5. 插件侧\n')
|
||||
console.log(`- 插件文件数:${pluginFiles.length},引用 var(--iwb-*) 共 ${pluginTokenUse} 次`)
|
||||
console.log(`- 文件级豁免:0(B6 起按角色分类,不再整文件放行)`)
|
||||
console.log(`- 写死「中性色」的文件(暗色下会白板/黑洞,必须修):${pluginBad.length}`)
|
||||
for (const p of pluginBad.sort((a, b) => b.hex - a.hex)) console.log(` - ${p.file} → ${p.hex} 处`)
|
||||
console.log(`- 声明了私有皮肤的插件(已确认不跟随主题,代价是不得引用宿主颜色 token):${pluginPrivate.length}`)
|
||||
for (const p of pluginPrivate) console.log(` - ${p.file} → ${p.hex} 处(skin: 'private')`)
|
||||
console.log(`- 强调色写死(品牌/危险/成功,亮暗两端可读,允许):${pluginAccent.reduce((a, p) => a + p.hex, 0)} 处 / ${pluginAccent.length} 个文件`)
|
||||
console.log('\n## 6. 官网样式\n')
|
||||
console.log(`- site/assets/style.css 定义变量:${siteVars.join(' ') || '(无)'}`)
|
||||
@@ -0,0 +1,32 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>插件开发规范 · Image Workbench</title>
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
<style>
|
||||
.devdoc{max-width:860px;margin:0 auto;padding:40px 0 72px;color:var(--ink,#1b1f24);font-size:15px;line-height:1.75}
|
||||
.devdoc h1{font-size:38px;line-height:1.2;margin:8px 0 18px}
|
||||
.devdoc h2{font-size:24px;margin:38px 0 10px;padding-top:10px;border-top:1px solid var(--line,#e6e8ec)}
|
||||
.devdoc h3{font-size:18px;margin:26px 0 8px}
|
||||
.devdoc p{margin:10px 0}
|
||||
.devdoc ul,.devdoc ol{margin:10px 0 10px 22px}
|
||||
.devdoc li{margin:4px 0}
|
||||
.devdoc code{background:#f3f4f6;border-radius:5px;padding:1px 5px;font-size:13px}
|
||||
.devdoc pre{background:#111418;color:#e6e8ec;border-radius:10px;padding:14px 16px;overflow:auto;font-size:13px;line-height:1.6}
|
||||
.devdoc pre code{background:none;color:inherit;padding:0}
|
||||
.devdoc table{border-collapse:collapse;width:100%;margin:14px 0;font-size:14px}
|
||||
.devdoc th,.devdoc td{border:1px solid var(--line,#e6e8ec);padding:7px 10px;text-align:left;vertical-align:top}
|
||||
.devdoc th{background:#f7f8fa}
|
||||
.devdoc blockquote{border-left:3px solid #d6dae1;margin:12px 0;padding:2px 14px;color:#5b6472}
|
||||
.devdoc a{color:#2b6cff}
|
||||
</style>
|
||||
</head><body>
|
||||
<!--NAV-->
|
||||
<main>
|
||||
<div class="wrap"><article class="devdoc">
|
||||
<!--DEV_CONTENT-->
|
||||
</article></div>
|
||||
</main>
|
||||
<!--FOOTER-->
|
||||
</body></html>
|
||||
@@ -2,6 +2,8 @@
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Image Workbench · 本地优先的 AI 生图工作台</title>
|
||||
<meta name="description" content="本地优先的 AI 生图无限画布:节点式工作流、插件按需安装、数据全部留在本机。">
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
</head><body>
|
||||
<!--NAV-->
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>插件市场 · Image Workbench</title>
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css">
|
||||
</head><body>
|
||||
<!--NAV-->
|
||||
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 85 KiB |
@@ -139,3 +139,4 @@ pre.cmd code{font-size:12.5px}
|
||||
.hero-veil{background:
|
||||
radial-gradient(62% 58% at 50% 40%, rgba(255,255,255,.86) 0%, rgba(255,255,255,.70) 46%, rgba(255,255,255,.16) 100%),
|
||||
linear-gradient(180deg, rgba(255,255,255,.84) 0%, rgba(255,255,255,.52) 50%, rgba(255,255,255,.20) 76%, #fff 100%)}
|
||||
nav .brand .logo{width:26px;height:26px;border-radius:7px;object-fit:cover;display:block;flex:0 0 auto}
|
||||
@@ -0,0 +1,196 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>插件开发规范 · Image Workbench</title>
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.49-mwt2i899">
|
||||
<style>
|
||||
.devdoc{max-width:860px;margin:0 auto;padding:40px 0 72px;color:var(--ink,#1b1f24);font-size:15px;line-height:1.75}
|
||||
.devdoc h1{font-size:38px;line-height:1.2;margin:8px 0 18px}
|
||||
.devdoc h2{font-size:24px;margin:38px 0 10px;padding-top:10px;border-top:1px solid var(--line,#e6e8ec)}
|
||||
.devdoc h3{font-size:18px;margin:26px 0 8px}
|
||||
.devdoc p{margin:10px 0}
|
||||
.devdoc ul,.devdoc ol{margin:10px 0 10px 22px}
|
||||
.devdoc li{margin:4px 0}
|
||||
.devdoc code{background:#f3f4f6;border-radius:5px;padding:1px 5px;font-size:13px}
|
||||
.devdoc pre{background:#111418;color:#e6e8ec;border-radius:10px;padding:14px 16px;overflow:auto;font-size:13px;line-height:1.6}
|
||||
.devdoc pre code{background:none;color:inherit;padding:0}
|
||||
.devdoc table{border-collapse:collapse;width:100%;margin:14px 0;font-size:14px}
|
||||
.devdoc th,.devdoc td{border:1px solid var(--line,#e6e8ec);padding:7px 10px;text-align:left;vertical-align:top}
|
||||
.devdoc th{background:#f7f8fa}
|
||||
.devdoc blockquote{border-left:3px solid #d6dae1;margin:12px 0;padding:2px 14px;color:#5b6472}
|
||||
.devdoc a{color:#2b6cff}
|
||||
</style>
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
<div class="links">
|
||||
<a href="/">首页</a>
|
||||
<a href="/download/">下载</a>
|
||||
<a href="/plugins/">插件</a>
|
||||
<a href="/dev/" class="on">开发</a>
|
||||
<a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.49</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<div class="wrap"><article class="devdoc">
|
||||
<h1>Image Workbench 插件开发规范</h1>
|
||||
<p>> 版本:v1(2026-11-22)。面向官方与第三方插件;示例以 promptlib(提示词库)与 style-source(风格库)为准。</p>
|
||||
<p>> 相关文档:plugin-node-drag.md(节点拖入/指针交互踩坑)、plugin-node-outkind.md(下游连线声明)、plugin-theme.md(主题契约)。</p>
|
||||
<h2>1. 目录与基本结构</h2>
|
||||
<p>插件是「一个目录 + 一个 IIFE 入口」,由宿主在启用时动态加载并调用 register。</p>
|
||||
<pre><code>my-plugin/
|
||||
package.json # 版本 + ibwPlugin 元数据
|
||||
src/index.js # 入口(IIFE,末尾 IWBPluginHost.register)
|
||||
styles.css # 样式(必须自包含)
|
||||
README.md</code></pre>
|
||||
<p>package.json:</p>
|
||||
<pre><code>{
|
||||
"name": "@iwb-plugin/my-plugin",
|
||||
"version": "1.0.0",
|
||||
"ibwPlugin": { "id": "my-plugin", "entry": "src/index.js", "apiVersion": 1 }
|
||||
}</code></pre>
|
||||
<p>入口骨架:</p>
|
||||
<pre><code>;(function (global) {
|
||||
'use strict'
|
||||
if (!global.IWBPluginHost) return
|
||||
global.IWBPluginHost.register({
|
||||
id: 'my-plugin',
|
||||
name: '我的插件',
|
||||
version: '1.0.0',
|
||||
capabilities: ['panels', 'canvas', 'canvasWrite'],
|
||||
settings: { panel: { type: 'custom', label: '设置', render: renderSettings } },
|
||||
mount: mount,
|
||||
unmount: unmount,
|
||||
}, function (ctx) {
|
||||
// setup:注册面板/节点/命令
|
||||
return { dispose () {} }
|
||||
})
|
||||
})(typeof window !== 'undefined' ? window : globalThis)</code></pre>
|
||||
<h2>2. 能力(capabilities)与 ctx 映射</h2>
|
||||
<p>只申请用到的能力;能力名与 ctx 键不同:</p>
|
||||
<table><thead><tr><th>capability</th><th>ctx 键</th><th>用途</th></tr></thead><tbody>
|
||||
<tr><td>panels</td><td>ctx.ui</td><td>侧栏/独立面板注册</td></tr>
|
||||
<tr><td>promptlib</td><td>ctx.promptlib</td><td>提示词库数据 + 文件 + 备份</td></tr>
|
||||
<tr><td>nodeTypes</td><td>ctx.nodes</td><td>画布节点类型注册</td></tr>
|
||||
<tr><td>canvas</td><td>ctx.canvas</td><td>只读:getNodes / getSelectedNode / screenToWorld</td></tr>
|
||||
<tr><td>canvasWrite</td><td>ctx.canvasWrite</td><td>写入:createNode / createImageNode / setNodeImage</td></tr>
|
||||
<tr><td>nodeActions</td><td>ctx.nodeActions</td><td>节点右键/气泡动作</td></tr>
|
||||
<tr><td>commands</td><td>ctx.commands</td><td>命令面板</td></tr>
|
||||
<tr><td>settings</td><td>ctx.settings</td><td>KV 配置</td></tr>
|
||||
<tr><td>data</td><td>ctx.data</td><td>插件数据文件</td></tr>
|
||||
</tbody></table>
|
||||
<p><strong>注意</strong>:createNode 在 ctx.canvasWrite,不在 ctx.canvas。调错只会提示“宿主不支持”。</p>
|
||||
<h2>3. 面板</h2>
|
||||
<pre><code>ctx.ui.registerPanel({
|
||||
id: 'my-panel',
|
||||
title: '我的插件',
|
||||
mount (host) { /* 渲染到 host */ },
|
||||
unmount (host) { /* 清理定时器/监听 */ }
|
||||
})</code></pre>
|
||||
<ul>
|
||||
<li>mount 只调用一次,内部自己管理重渲染。</li>
|
||||
<li>面板宽度可变:使用栅格/瀑布流,不要写死 px 宽度。</li>
|
||||
<li>面板内所有 DOM 事件在 unmount 时移除。</li>
|
||||
</ul>
|
||||
<h2>4. 节点类型</h2>
|
||||
<pre><code>ctx.nodes.register({
|
||||
id: 'tpl',
|
||||
title: '模板节点',
|
||||
defaults: { outKind: 'prompt' },
|
||||
ports: { in: false, out: true },
|
||||
height: 360,
|
||||
render (node, props, host) { /* 首次建 DOM,之后 sync */ }
|
||||
})</code></pre>
|
||||
<p>宿主会生成类型 plugin:<插件id>:<变体id>。</p>
|
||||
<p><strong>必须遵守</strong>:</p>
|
||||
<ol>
|
||||
<li>输出文本/提示词 → data.outKind = 'prompt'(注册默认值、拖入数据、旧节点在 render 里自愈)。</li>
|
||||
<li>拖入画布用指针拖拽,不用原生 HTML5 DnD:</li>
|
||||
</ol>
|
||||
<pre><code>pointerdown → pointermove(>5px) 幽灵卡片
|
||||
→ pointerup → ctx.canvas.screenToWorld(x,y)
|
||||
→ ctx.canvasWrite.createNode('tpl', wx, wy, data)</code></pre>
|
||||
<ol>
|
||||
<li>输入框:未选中时 pointer-events: none,选中后才可编辑;只读 textarea 同样处理。</li>
|
||||
<li>单击 = 选中/拖动,双击 = 编辑;不要用单击打开详情。</li>
|
||||
<li>节点 render 必须可增量 sync,避免整块重建(输入框会丢焦点)。</li>
|
||||
</ol>
|
||||
<h2>5. 数据与文件</h2>
|
||||
<ul>
|
||||
<li>小数据:ctx.promptlib(或 ctx.data)JSON,单文件 < 1MB。</li>
|
||||
<li>大文件(封面/图片):ctx.promptlib.filePut/fileGet/fileList,落地在 plugin-data/<id>/files/。</li>
|
||||
<li>dataUrlToBytes() 返回 { mime, bytes },不是 Uint8Array。</li>
|
||||
<li>备份:提供导出/导入 JSON;导入按 id 合并,提供“覆盖同 id”选项。</li>
|
||||
<li>迁移:旧格式在 setup 里做一次性迁移,失败要提示而不是静默丢数据。</li>
|
||||
</ul>
|
||||
<h2>6. 设置页面</h2>
|
||||
<p>宿主设置页内嵌渲染,不弹独立页面:</p>
|
||||
<pre><code>settings: {
|
||||
panel: { type: 'custom', label: '分组与备份', render: renderSettings }
|
||||
}</code></pre>
|
||||
<p>render 返回 DOM;宿主负责挂载/卸载。设置页适合放:</p>
|
||||
<ul>
|
||||
<li>分组管理(新建/改名/排序/删除)</li>
|
||||
<li>数据备份(导出/导入)</li>
|
||||
<li>数据位置(打开数据目录)</li>
|
||||
<li>插件级开关/默认值</li>
|
||||
</ul>
|
||||
<h2>7. 样式规范</h2>
|
||||
<ol>
|
||||
<li><strong>自包含</strong>:宿主基础样式会变;用到的宿主类按作用域复制一份(.iwb-myplugin …)。</li>
|
||||
<li>统一前缀:面板/节点类名 my-plugin-*,避免与宿主 .iwb-* 冲突。</li>
|
||||
<li>颜色走 CSS 变量:var(--iwb-text)、--iwb-panel、--iwb-border、--iwb-plugin-accent。</li>
|
||||
<li>动画克制:只做 hover/press 反馈;不使用持续浮动动画。</li>
|
||||
<li>深色主题:不写死 #fff/#000;主题契约测试会扫描。</li>
|
||||
<li>悬停放大只缩放内层背景,不缩放卡片本体(避免命中区域漂移/闪烁)。</li>
|
||||
<li>图片/封面 pointer-events: none,点击永远落到卡片。</li>
|
||||
</ol>
|
||||
<h2>8. 错误处理与提示</h2>
|
||||
<ul>
|
||||
<li>所有用户可见错误用 ctx.promptlib.notify / ctx.ui.toast,文案给“下一步怎么办”。</li>
|
||||
<li>异步链必须有 catch;不要吞掉错误后静默。</li>
|
||||
<li>崩溃日志:window.onerror 由宿主统一采集,插件不要自己覆盖。</li>
|
||||
<li>定时器/监听在 unmount/dispose 清理,避免面板切换后重复执行。</li>
|
||||
</ul>
|
||||
<h2>9. 测试与门禁</h2>
|
||||
<p>提交前至少:</p>
|
||||
<pre><code>node scripts/validate-plugins.js # manifest/能力/入口校验
|
||||
node scripts/theme-contract-test.js # 主题变量
|
||||
node tests/plugin-<id>-render-test.js # jsdom 渲染/交互</code></pre>
|
||||
<p>jsdom 可覆盖:面板渲染、节点 render/sync、拖拽插入(stub screenToWorld/createNode)、双击详情、保存回详情、封面 img。</p>
|
||||
<h2>10. 发布与市场</h2>
|
||||
<ol>
|
||||
<li>改 package.json version 与入口 version(两处一致)。</li>
|
||||
<li>node scripts/sync-plugins-from-repo.js(同步到客户端 plugins/)</li>
|
||||
<li>node scripts/gen-market.js(生成 market/ 与 zip)</li>
|
||||
<li>上传 market 到 NAS(tar + scp + 解压)</li>
|
||||
<li>客户端发版:set-version → CHANGELOG → 锚点 → verify:ci → build → publish-update → releases/site → tag/push</li>
|
||||
</ol>
|
||||
<h2>11. 常见坑(务必先读)</h2>
|
||||
<ul>
|
||||
<li>原生 HTML5 拖放:WKWebView 吞 pointerup,节点落地后第一次点击异常 → 用指针拖拽。</li>
|
||||
<li>ctx.canvas 没有 createNode → 用 ctx.canvasWrite。</li>
|
||||
<li>输入框拦截拖动 → 未选中时 pointer-events:none。</li>
|
||||
<li>只读 textarea 仍可选中文本 → pointer-events:none。</li>
|
||||
<li>dataUrlToBytes 返回对象 → 取 .bytes。</li>
|
||||
<li>封面直接存 dataURL 会让 JSON 膨胀 → 迁移到文件,只存 { img }。</li>
|
||||
<li>插件节点不声明 outKind → 只能中继,无法直连生图。</li>
|
||||
</ul>
|
||||
</article></div>
|
||||
</main>
|
||||
<footer><div class="wrap">
|
||||
<div class="cols">
|
||||
<div><div style="color:#fff;font-weight:640;margin-bottom:8px">Image Workbench</div>
|
||||
<div style="font-size:13px;line-height:1.8">本地优先的 AI 生图无限画布。图片、提示词与模型配置全部留在你自己的电脑里。</div></div>
|
||||
<div><h4>产品</h4><a href="/">首页</a><a href="/download/">下载</a><a href="/plugins/">插件市场</a></div>
|
||||
<div><h4>资源</h4><a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码仓库</a><a href="https://git.maqiart.eu.org/malongan/iwb-plugins-desktop" target="_blank" rel="noopener">插件仓库</a><a href="/updates/latest.json" target="_blank" rel="noopener">更新源</a></div>
|
||||
<div><h4>说明</h4><a href="/download/">安装步骤</a><a href="/plugins/">插件安装</a></div>
|
||||
</div>
|
||||
<div class="copy"><span>© 2026 Image Workbench</span><span>数据保存在本地 · 不上传任何图片</span></div>
|
||||
</div></footer>
|
||||
</body></html>
|
||||
@@ -4,6 +4,8 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Image Workbench · 下载</title>
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=" + encodeURIComponent(latest.version + '-' + Date.now().toString(36)) + "">
|
||||
<style>
|
||||
*{box-sizing:border-box}
|
||||
@@ -34,11 +36,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
<div class="links">
|
||||
<a href="/">首页</a>
|
||||
<a href="/download/" class="on">下载</a>
|
||||
<a href="/plugins/">插件</a>
|
||||
<a href="/dev/">开发</a>
|
||||
<a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
@@ -54,13 +57,13 @@
|
||||
<h2>下载</h2>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Apple Silicon<div class="hint">M1 / M2 / M3 / M4</div></div>
|
||||
<div class="meta">版本 3.26.37 · 8.4 MB · .dmg<div class="hash">sha256 66abb4cfd7714ac3…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.37_aarch64.dmg?h=66abb4cfd771">下载</a>
|
||||
<div class="meta">版本 3.26.49 · 8.4 MB · .dmg<div class="hash">sha256 ce27a43c4b22505d…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.49_aarch64.dmg?h=ce27a43c4b22">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.26.37 · 8.8 MB · .dmg<div class="hash">sha256 c560d101175247d3…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.37_x64.dmg?h=c560d1011752">下载</a>
|
||||
<div class="meta">版本 3.26.49 · 8.8 MB · .dmg<div class="hash">sha256 cb01e10548431bfb…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.49_x64.dmg?h=cb01e1054843">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
@@ -94,6 +97,26 @@
|
||||
</ol>
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<div class="row">
|
||||
<div class="name">3.26.49<div class="hint">v3.26.49:设计 token 落地收尾(M4-B2~B6)——字号/间距/圆角/层级统一进闭集,暗色控件与画布端口对比度修正;插件主题契约文件级豁免清零,私有皮肤改为自声明。本版为 macOS 双架构,Windows 稍后跟进。</div></div>
|
||||
<div class="meta">2026-11-23<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.41<div class="hint">v3.26.41:修提示词接变量节点后组合节点读不到文案/不带参考图;连接节点同步修好;组合节点逻辑零改动。</div></div>
|
||||
<div class="meta">2026-11-23<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.40<div class="hint">Windows:修复 PowerShell 弹窗(改用 GetProcessMemoryInfo)</div></div>
|
||||
<div class="meta">2026-11-23<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.39<div class="hint">v3.26.39:修正插件插入落点与封面插入(拖拽落点按节点宽高居中到鼠标、插入落到画布可视中心、封面先解析为 dataURL 再插入)</div></div>
|
||||
<div class="meta">2026-11-22<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.38<div class="hint">Intel 版:同一版本</div></div>
|
||||
<div class="meta">2026-11-22<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.37<div class="hint">Intel 版:同一版本</div></div>
|
||||
<div class="meta">2026-11-22<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
@@ -476,7 +499,7 @@
|
||||
</div>
|
||||
|
||||
<div class="foot">
|
||||
本页由 <code>scripts/gen-release-page.js</code> 从 releases.json 生成 · 源码 <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop">git.maqiart.eu.org</a> · 更新于 2026-11-22
|
||||
本页由 <code>scripts/gen-release-page.js</code> 从 releases.json 生成 · 源码 <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop">git.maqiart.eu.org</a> · 更新于 2026-11-23
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
|
||||
@@ -2,31 +2,34 @@
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Image Workbench · 本地优先的 AI 生图工作台</title>
|
||||
<meta name="description" content="本地优先的 AI 生图无限画布:节点式工作流、插件按需安装、数据全部留在本机。">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.37-mwrsao55">
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.49-mwt2i899">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
<div class="links">
|
||||
<a href="/" class="on">首页</a>
|
||||
<a href="/download/">下载</a>
|
||||
<a href="/plugins/">插件</a>
|
||||
<a href="/dev/">开发</a>
|
||||
<a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.37</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.49</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.37-mwrsao55" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.49-mwt2i899" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.26.37 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.26.49 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.37</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.49</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 11 个插件</a>
|
||||
</div>
|
||||
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
|
||||
@@ -52,7 +55,7 @@
|
||||
<div class="grid c3">
|
||||
<div class="pcard" data-name="批量出图 batch-export 资源中心勾选节点,串行批量生成并打包 zip 下载 出图 批处理" data-tags="出图,批处理">
|
||||
<div class="head"><span class="av" style="background:#e8f0fe">🗂️</span>
|
||||
<div><div class="nm">批量出图</div><div class="ver">v1.2.0 · 官方</div></div></div>
|
||||
<div><div class="nm">批量出图</div><div class="ver">v1.2.1 · 官方</div></div></div>
|
||||
<div class="desc">资源中心勾选节点,串行批量生成并打包 ZIP 下载</div>
|
||||
<div class="tags"><span class="tag">出图</span><span class="tag">批处理</span></div>
|
||||
</div>
|
||||
@@ -64,7 +67,7 @@
|
||||
</div>
|
||||
<div class="pcard" data-name="应用内浏览器 browser 库面板内置真实浏览器:书签按分组管理、拖动排序;地址栏 ↗ 可把当前页放到画布节点 浏览器 效率" data-tags="浏览器,效率">
|
||||
<div class="head"><span class="av" style="background:#eaf1fb">🌐</span>
|
||||
<div><div class="nm">应用内浏览器</div><div class="ver">v1.7.0 · 官方</div></div></div>
|
||||
<div><div class="nm">应用内浏览器</div><div class="ver">v1.7.1 · 官方</div></div></div>
|
||||
<div class="desc">库面板内置真实浏览器:书签按分组管理、拖动排序;地址栏 ↗ 可把当前页放到画布节点</div>
|
||||
<div class="tags"><span class="tag">浏览器</span><span class="tag">效率</span></div>
|
||||
</div>
|
||||
@@ -82,7 +85,7 @@
|
||||
</div>
|
||||
<div class="pcard" data-name="提示词库 promptlib 右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供) 资源 提示词" data-tags="资源,提示词">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📖</span>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.6.6 · 官方</div></div></div>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.8.21 · 官方</div></div></div>
|
||||
<div class="desc">右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)</div>
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">提示词</span></div>
|
||||
</div>
|
||||
@@ -93,8 +96,8 @@
|
||||
<section class="section"><div class="wrap">
|
||||
<h2>下载 Image Workbench</h2>
|
||||
<p class="lead">选你的平台。装过一次之后,以后在应用内「设置 → 通用 → 版本与更新」就能一键升级。</p>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.37_aarch64.dmg?h=66abb4cfd771"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 8.4 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.26.37_x64.dmg?h=c560d1011752"><div class="n">macOS · Intel</div><div class="s">x86_64 · 8.8 MB · .dmg</div></a>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.49_aarch64.dmg?h=ce27a43c4b22"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 8.4 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.26.49_x64.dmg?h=cb01e1054843"><div class="n">macOS · Intel</div><div class="s">x86_64 · 8.8 MB · .dmg</div></a>
|
||||
<div class="none"><div class="n">Windows · x64</div><div class="s">暂未提供</div></div></div>
|
||||
<div style="margin-top:20px;color:#9ca3af;font-size:12.5px">安装包未做 Apple 公证 / Windows 代码签名,首次打开需手动放行一次,细节见 <a href="/download/" style="text-decoration:underline">下载页</a>。</div>
|
||||
</div></section>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"updatedAt": "2026-11-22T11:55:55.306Z",
|
||||
"updatedAt": "2026-11-23T09:29:26.654Z",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "batch-export",
|
||||
@@ -13,27 +13,27 @@
|
||||
"出图",
|
||||
"批处理"
|
||||
],
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/batch-export-1.2.0.zip",
|
||||
"bundleSize": 44936,
|
||||
"bundleSha256": "338cfbe8fe00e92771f60f996d6a4baeb3c3b4954dfe774cfe83879639234552",
|
||||
"bundle": "plugins/batch-export-1.2.1.zip",
|
||||
"bundleSize": 44966,
|
||||
"bundleSha256": "21225a0e49ab49d6502b8031897bfc41537b69caa93eafda03d0a8467472d367",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "163e5de559a6907982749cdf5fbf7372b492ab30096a5bb935315e002fb1c7a5",
|
||||
"sha256": "82baa12a06a37fea4ee1040212df13e13215a4f78eb75ca324efc632a360d560",
|
||||
"size": 393
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "b7d13ba66cf97ff65e94305328183a1a3b5a45b0393f3a63f77f6b7b46795389",
|
||||
"size": 44329
|
||||
"sha256": "4beb9bc20c263fee95d86357d6c5ac2ff429577931f7ea82a394989786b53450",
|
||||
"size": 44359
|
||||
}
|
||||
],
|
||||
"file": "plugins/plugin-batch-export.b7d13ba66cf9.js",
|
||||
"size": 44329,
|
||||
"sha256": "b7d13ba66cf97ff65e94305328183a1a3b5a45b0393f3a63f77f6b7b46795389",
|
||||
"integrity": "sha256-t9E7pmz5f/ZelDBTKBg6GjtaRbA5Pzpj939re0Z5U4k="
|
||||
"file": "plugins/plugin-batch-export.4beb9bc20c26.js",
|
||||
"size": 44359,
|
||||
"sha256": "4beb9bc20c263fee95d86357d6c5ac2ff429577931f7ea82a394989786b53450",
|
||||
"integrity": "sha256-S+ubwgwmP+6V2GNX1sWsL/QpV3kx9+qCo5SYl4a1NFA="
|
||||
},
|
||||
{
|
||||
"id": "blank-canvas",
|
||||
@@ -79,27 +79,27 @@
|
||||
"浏览器",
|
||||
"效率"
|
||||
],
|
||||
"version": "1.7.0",
|
||||
"version": "1.7.1",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/browser-1.7.0.zip",
|
||||
"bundleSize": 60839,
|
||||
"bundleSha256": "8a802986f075774c941a7309eeb0f36e870c318aa9535d263da523c12f37d975",
|
||||
"bundle": "plugins/browser-1.7.1.zip",
|
||||
"bundleSize": 60859,
|
||||
"bundleSha256": "a8e620b9f912e7215e82c0dcb6b3349ee40644b34262fec355fed8e52896c525",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "4dc8e8d883e900779932310c74947bcb2e505ac91167275becbf9f1685afdc48",
|
||||
"sha256": "42cbbfd6fef3ba1fe3d22128b45729ccede94aece36183cfabde4846eb59ea95",
|
||||
"size": 445
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "8161a82890d96724d90a2ae9c8949d37af92f94b944cd525adc07b65b5eab4f4",
|
||||
"size": 60180
|
||||
"sha256": "8f2a263e02ef088ced1ccf0c275feceb8ef637babeab9687b25d76f2f1f9d2b4",
|
||||
"size": 60200
|
||||
}
|
||||
],
|
||||
"file": "plugins/plugin-browser.8161a82890d9.js",
|
||||
"size": 60180,
|
||||
"sha256": "8161a82890d96724d90a2ae9c8949d37af92f94b944cd525adc07b65b5eab4f4",
|
||||
"integrity": "sha256-gWGoKJDZZyTZCirpyJSdN6+S+UuUTNUlrcB7ZbXqtPQ="
|
||||
"file": "plugins/plugin-browser.8f2a263e02ef.js",
|
||||
"size": 60200,
|
||||
"sha256": "8f2a263e02ef088ced1ccf0c275feceb8ef637babeab9687b25d76f2f1f9d2b4",
|
||||
"integrity": "sha256-jyomPgLvCIztHM8MJ1/s6472N7q+q5aHsl128vH50rQ="
|
||||
},
|
||||
{
|
||||
"id": "gallery",
|
||||
@@ -180,26 +180,26 @@
|
||||
"资源",
|
||||
"提示词"
|
||||
],
|
||||
"version": "1.6.6",
|
||||
"version": "1.8.21",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/promptlib-1.6.6.zip",
|
||||
"bundleSize": 114275,
|
||||
"bundleSha256": "ee3db5da55e1eeafc9795bb5cd8333063693e5d8a565e3c8eeb32bf01deea596",
|
||||
"bundle": "plugins/promptlib-1.8.21.zip",
|
||||
"bundleSize": 149157,
|
||||
"bundleSha256": "a9c11dff02e56ef3c95301e47c964d55d2b679fde1f7909a1603c62c1a4f930d",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "7e6d1c7258901b4b9b419480ca6490cd5ad22c2efb8e9c5482302b2f6ebbd480",
|
||||
"size": 540
|
||||
"sha256": "114e97a4abbf3270e27fcaff3952b5fdc60f8cccd58c66fb2965af90e76efac4",
|
||||
"size": 541
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "530b4bc021e0730f14505f666203c8c9c165bf9ea6bef9765ec7e9ebcda95c54",
|
||||
"size": 92685
|
||||
"sha256": "125e02a618e37505836f964dbe21a3637e3043ee355d9606c538a54eed4243ad",
|
||||
"size": 107029
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "872ceeded7eb67599dfa159c86be1b1e1724f7cd1e04cae1d79d939bb0e1ebdf",
|
||||
"size": 20740
|
||||
"sha256": "84ad2314d016c7d2351eb7cf2044ee8cc703992d40a76002ff644d34eb48838a",
|
||||
"size": 41277
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -214,27 +214,27 @@
|
||||
"修图",
|
||||
"标注"
|
||||
],
|
||||
"version": "1.20.6",
|
||||
"version": "1.20.7",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/image-annotate-1.20.6.zip",
|
||||
"bundleSize": 462110,
|
||||
"bundleSha256": "2653d2219d036342bc6768beb0936101e44a99d6635822d376cba3a6d663a28e",
|
||||
"bundle": "plugins/image-annotate-1.20.7.zip",
|
||||
"bundleSize": 462359,
|
||||
"bundleSha256": "987f46e73c4cf9cf9f0e5668a22695d4bf564951fa3f30596422a1c8ba56d11e",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "8bdba81a4d5c5aea085699679bb7f8be8fee81cbe07ac9a7b83cdb47fc05fff0",
|
||||
"sha256": "60c663639337434987382d1b992bd6943fc3e94af77870cbb1b744d681376293",
|
||||
"size": 373
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "7a865c7c353c3fbcaac551a8aeb5acd1bf624ca25f104db96fce493c3084b24f",
|
||||
"size": 461523
|
||||
"sha256": "fc04e57a7603bba4a0664486ec21263740dd718d5ba358dab0d3020237736634",
|
||||
"size": 461772
|
||||
}
|
||||
],
|
||||
"file": "plugins/plugin-image-annotate.7a865c7c353c.js",
|
||||
"size": 461523,
|
||||
"sha256": "7a865c7c353c3fbcaac551a8aeb5acd1bf624ca25f104db96fce493c3084b24f",
|
||||
"integrity": "sha256-eoZcfDU8P7yqxVGorrWs0b9iTKJfEE25b85JPDCEsk8="
|
||||
"file": "plugins/plugin-image-annotate.fc04e57a7603.js",
|
||||
"size": 461772,
|
||||
"sha256": "fc04e57a7603bba4a0664486ec21263740dd718d5ba358dab0d3020237736634",
|
||||
"integrity": "sha256-/ATlenYDu6SgZkSG7CEmN0DdcY1bo1jasNMCAjdzZjQ="
|
||||
},
|
||||
{
|
||||
"id": "image-vectorize",
|
||||
@@ -247,27 +247,27 @@
|
||||
"转换",
|
||||
"矢量"
|
||||
],
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/image-vectorize-0.6.0.zip",
|
||||
"bundleSize": 145682,
|
||||
"bundleSha256": "c6c36bbc56b36f19e4b91b2e8d9db62046804490a790a01b09a052adc6dec096",
|
||||
"bundle": "plugins/image-vectorize-0.6.1.zip",
|
||||
"bundleSize": 145910,
|
||||
"bundleSha256": "4be4c1a80a5602b14bce6296ca9766a9445ecf081147da85e1047a6debf3e242",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "4378b397d8954e3f4522c53bfff970b4d4d29ba8234501ac998bb552af03b30d",
|
||||
"sha256": "fd53c39302c403d27228fa0e368d8c299293d632d1c8e3b48bb96cefb1294a30",
|
||||
"size": 362
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "7014982f60e605e34909986ac0c372195e6130129e29a927d6d41a1405579e9f",
|
||||
"size": 145106
|
||||
"sha256": "0e5a7fa018b2e9de705f9112272ad02dcf187b5361696f7fc0a12a93c4f20d4e",
|
||||
"size": 145334
|
||||
}
|
||||
],
|
||||
"file": "plugins/plugin-image-vectorize.7014982f60e6.js",
|
||||
"size": 145106,
|
||||
"sha256": "7014982f60e605e34909986ac0c372195e6130129e29a927d6d41a1405579e9f",
|
||||
"integrity": "sha256-cBSYL2DmBeNJCZhqwMNyGV5hMBKeKakn1tQaFAVXnp8="
|
||||
"file": "plugins/plugin-image-vectorize.0e5a7fa018b2.js",
|
||||
"size": 145334,
|
||||
"sha256": "0e5a7fa018b2e9de705f9112272ad02dcf187b5361696f7fc0a12a93c4f20d4e",
|
||||
"integrity": "sha256-Dlp/oBiy6d5wX5ESJyrQLc8Ye1NhaW9/wKEqk8TyDU4="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>插件市场 · Image Workbench</title>
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.37-mwrsao55">
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.49-mwt2i899">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
<div class="links">
|
||||
<a href="/">首页</a>
|
||||
<a href="/download/">下载</a>
|
||||
<a href="/plugins/" class="on">插件</a>
|
||||
<a href="/dev/">开发</a>
|
||||
<a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.37</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.49</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
@@ -46,7 +49,7 @@
|
||||
<div class="grid c3" id="list">
|
||||
<div class="pcard" data-name="批量出图 batch-export 资源中心勾选节点,串行批量生成并打包 zip 下载 出图 批处理" data-tags="出图,批处理">
|
||||
<div class="head"><span class="av" style="background:#e8f0fe">🗂️</span>
|
||||
<div><div class="nm">批量出图</div><div class="ver">v1.2.0 · 官方</div></div></div>
|
||||
<div><div class="nm">批量出图</div><div class="ver">v1.2.1 · 官方</div></div></div>
|
||||
<div class="desc">资源中心勾选节点,串行批量生成并打包 ZIP 下载</div>
|
||||
<div class="tags"><span class="tag">出图</span><span class="tag">批处理</span></div>
|
||||
</div>
|
||||
@@ -58,7 +61,7 @@
|
||||
</div>
|
||||
<div class="pcard" data-name="应用内浏览器 browser 库面板内置真实浏览器:书签按分组管理、拖动排序;地址栏 ↗ 可把当前页放到画布节点 浏览器 效率" data-tags="浏览器,效率">
|
||||
<div class="head"><span class="av" style="background:#eaf1fb">🌐</span>
|
||||
<div><div class="nm">应用内浏览器</div><div class="ver">v1.7.0 · 官方</div></div></div>
|
||||
<div><div class="nm">应用内浏览器</div><div class="ver">v1.7.1 · 官方</div></div></div>
|
||||
<div class="desc">库面板内置真实浏览器:书签按分组管理、拖动排序;地址栏 ↗ 可把当前页放到画布节点</div>
|
||||
<div class="tags"><span class="tag">浏览器</span><span class="tag">效率</span></div>
|
||||
</div>
|
||||
@@ -76,19 +79,19 @@
|
||||
</div>
|
||||
<div class="pcard" data-name="提示词库 promptlib 右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供) 资源 提示词" data-tags="资源,提示词">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📖</span>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.6.6 · 官方</div></div></div>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.8.21 · 官方</div></div></div>
|
||||
<div class="desc">右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)</div>
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">提示词</span></div>
|
||||
</div>
|
||||
<div class="pcard" data-name="标注 / 修图 image-annotate 在画布内标注、涂抹、局部重绘 修图 标注" data-tags="修图,标注">
|
||||
<div class="head"><span class="av" style="background:#fdeaea">🖌️</span>
|
||||
<div><div class="nm">标注 / 修图</div><div class="ver">v1.20.6 · 官方</div></div></div>
|
||||
<div><div class="nm">标注 / 修图</div><div class="ver">v1.20.7 · 官方</div></div></div>
|
||||
<div class="desc">在画布内标注、涂抹、局部重绘</div>
|
||||
<div class="tags"><span class="tag">修图</span><span class="tag">标注</span></div>
|
||||
</div>
|
||||
<div class="pcard" data-name="位图转矢量 image-vectorize 把位图转成 svg 矢量路径 转换 矢量" data-tags="转换,矢量">
|
||||
<div class="head"><span class="av" style="background:#eaf3ea">✒️</span>
|
||||
<div><div class="nm">位图转矢量</div><div class="ver">v0.6.0 · 官方</div></div></div>
|
||||
<div><div class="nm">位图转矢量</div><div class="ver">v0.6.1 · 官方</div></div></div>
|
||||
<div class="desc">把位图转成 SVG 矢量路径</div>
|
||||
<div class="tags"><span class="tag">转换</span><span class="tag">矢量</span></div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,134 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-11-22T11:59:18.623Z",
|
||||
"updatedAt": "2026-11-23T09:32:53.647Z",
|
||||
"releases": [
|
||||
{
|
||||
"version": "3.26.49",
|
||||
"date": "2026-11-23",
|
||||
"notes": "v3.26.49:设计 token 落地收尾(M4-B2~B6)——字号/间距/圆角/层级统一进闭集,暗色控件与画布端口对比度修正;插件主题契约文件级豁免清零,私有皮肤改为自声明。本版为 macOS 双架构,Windows 稍后跟进。",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.49_aarch64.dmg",
|
||||
"size": 8798024,
|
||||
"sha256": "ce27a43c4b22505d18a3e5eea1b3a83f1634cdaf39606ae85437c66274d500ef",
|
||||
"h": "ce27a43c4b22",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.49_x64.dmg",
|
||||
"size": 9184548,
|
||||
"sha256": "cb01e10548431bfb0f6fa39b5979dc23e59405f361de9ef2dc3b2ec3f4a0c10e",
|
||||
"h": "cb01e1054843",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.41",
|
||||
"date": "2026-11-23",
|
||||
"notes": "v3.26.41:修提示词接变量节点后组合节点读不到文案/不带参考图;连接节点同步修好;组合节点逻辑零改动。",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.41_aarch64.dmg",
|
||||
"size": 8790656,
|
||||
"sha256": "e611247547043c00bef6a1afc1f1f85040853902474399e994360ebfc87f4889",
|
||||
"h": "e61124754704",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.41_x64.dmg",
|
||||
"size": 9189716,
|
||||
"sha256": "7a6068ff96d2112e4db2bc080a4ea1407260819f84f10e4929a2936a71b8f9d4",
|
||||
"h": "7a6068ff96d2",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.41_x64-setup.exe",
|
||||
"size": 4998852,
|
||||
"sha256": "3b41529e659546c9baaa77ec22018133b0670c48ad5133789bb4828eed7ed33f",
|
||||
"h": "3b41529e6595",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.40",
|
||||
"date": "2026-11-23",
|
||||
"notes": "Windows:修复 PowerShell 弹窗(改用 GetProcessMemoryInfo)",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.40_aarch64.dmg",
|
||||
"size": 8790542,
|
||||
"sha256": "165f48fa6c2d874f18020b6b2e99cd3a40e0496ca3714f4d895263553896ae2b",
|
||||
"h": "165f48fa6c2d",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.40_x64.dmg",
|
||||
"size": 9177668,
|
||||
"sha256": "6890b428aee6233c6093c091ea709468abeb0fa4b30abc3744bef45c28943a55",
|
||||
"h": "6890b428aee6",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.40_x64-setup.exe",
|
||||
"size": 5003204,
|
||||
"sha256": "c82010565b339520b72d56589bbbd287334119436adf86a5b43e3c4dfb363bf0",
|
||||
"h": "c82010565b33",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.39",
|
||||
"date": "2026-11-22",
|
||||
"notes": "v3.26.39:修正插件插入落点与封面插入(拖拽落点按节点宽高居中到鼠标、插入落到画布可视中心、封面先解析为 dataURL 再插入)",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.39_aarch64.dmg",
|
||||
"size": 8789132,
|
||||
"sha256": "15e9c10f31caea3a3d217db2d47e4cc07ed200153795cec462d02634cd35f31c",
|
||||
"h": "15e9c10f31ca",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.39_x64.dmg",
|
||||
"size": 9179272,
|
||||
"sha256": "1016831ad95f21be55b1410c16a8bb51f29fe0799c6bd8980fadf0369424f3ff",
|
||||
"h": "1016831ad95f",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.39_x64-setup.exe",
|
||||
"size": 5070508,
|
||||
"sha256": "b94166d04e5d53c3d805e6fc226a4725e1d27198d60b7947b90e4ace6a601ac1",
|
||||
"h": "b94166d04e5d",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.38",
|
||||
"date": "2026-11-22",
|
||||
"notes": "Intel 版:同一版本",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.38_aarch64.dmg",
|
||||
"size": 8795617,
|
||||
"sha256": "d7cce4643590125a77983264cfe895043675c66f125aa44ab7d0980ae9e43e52",
|
||||
"h": "d7cce4643590",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.38_x64.dmg",
|
||||
"size": 9179980,
|
||||
"sha256": "d2854862f7371306c0e78c54523928d08ff883cfc474939052f396f553c7ee90",
|
||||
"h": "d2854862f737",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.37",
|
||||
"date": "2026-11-22",
|
||||
|
||||
@@ -1983,7 +1983,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.37"
|
||||
version = "3.26.44"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
@@ -2002,6 +2002,7 @@ dependencies = [
|
||||
"tauri-plugin-single-instance",
|
||||
"tauri-plugin-updater",
|
||||
"url",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.37"
|
||||
version = "3.26.44"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
@@ -44,3 +44,7 @@ base64 = "0.22"
|
||||
# (Cargo.lock 里是同一个 0.6.x),这里显式依赖不会多编译一份。
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
objc2 = "0.6"
|
||||
|
||||
# Windows:直接读进程工作集(GetProcessMemoryInfo),不再启动 PowerShell 子进程
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { version = "0.52", features = ["Win32_Foundation", "Win32_System_ProcessStatus", "Win32_System_Threading"] }
|
||||
@@ -171,17 +171,13 @@ fn app_memory_mb() -> u64 {
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let script = format!("(Get-Process -Id {}).WorkingSet64", pid);
|
||||
let out = std::process::Command::new("powershell")
|
||||
.args(["-NoProfile", "-NonInteractive", "-Command", &script])
|
||||
.output();
|
||||
if let Ok(o) = out {
|
||||
if o.status.success() {
|
||||
let txt = String::from_utf8_lossy(&o.stdout);
|
||||
if let Ok(bytes) = txt.trim().parse::<u64>() {
|
||||
return bytes / (1024 * 1024);
|
||||
}
|
||||
}
|
||||
use windows_sys::Win32::System::ProcessStatus::{GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS};
|
||||
use windows_sys::Win32::System::Threading::GetCurrentProcess;
|
||||
let mut pmc: PROCESS_MEMORY_COUNTERS = unsafe { std::mem::zeroed() };
|
||||
pmc.cb = std::mem::size_of::<PROCESS_MEMORY_COUNTERS>() as u32;
|
||||
let ok = unsafe { GetProcessMemoryInfo(GetCurrentProcess(), &mut pmc, pmc.cb) };
|
||||
if ok != 0 {
|
||||
return (pmc.WorkingSetSize as u64) / (1024 * 1024);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.37",
|
||||
"version": "3.26.49",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
@@ -120,12 +120,12 @@
|
||||
let x1 = src.x + nodeWidth(src), y1 = src.y + hOf(src) / 2
|
||||
let x2 = dst.x, y2 = dst.y + inY
|
||||
if (src.type === 'batch' && ed.batchSrcId) {
|
||||
const bsrcs = ((graph && graph.incomingByNode.get(src.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n)).slice().sort(compareCanvasTextOrder)
|
||||
const bsrcs = ((graph && graph.incomingByNode.get(src.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n, graph && graph.edges, graph && graph.nodes)).slice().sort(compareCanvasTextOrder)
|
||||
const idx = bsrcs.findIndex((s) => s.id === ed.batchSrcId)
|
||||
if (idx >= 0) y1 = src.y + batchPortTop(idx, Math.max(1, bsrcs.length), hOf(src))
|
||||
}
|
||||
if (dst.type === 'batch') {
|
||||
const bsrcs = ((graph && graph.incomingByNode.get(dst.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n)).slice().sort(compareCanvasTextOrder)
|
||||
const bsrcs = ((graph && graph.incomingByNode.get(dst.id)) || []).map((e) => graph && graph.byId.get(e.from)).filter((n) => isBatchSrc(n, graph && graph.edges, graph && graph.nodes)).slice().sort(compareCanvasTextOrder)
|
||||
const idx = bsrcs.findIndex((s) => s.id === ed.from)
|
||||
if (idx >= 0) y2 = dst.y + batchPortTop(idx, Math.max(1, bsrcs.length), hOf(dst))
|
||||
}
|
||||
@@ -349,5 +349,15 @@
|
||||
return { x: Math.round(x), y: Math.round(y) }
|
||||
}
|
||||
|
||||
global.IWBCanvasGeometry = Object.freeze({ connectReasonOf, distToSeg, wantsDefaultSpot, parseWorldTransform, clientToWorld, snapToFreeSpot, placeBeside, pruneMeasured, seedFromTopLeft, clampIntoBounds, lodLowOf, lodModeOf, zoomStep, LOD_NODE_PX, LOD_PLAIN_SCALE, ZOOM_STEP, ZOOM_MIN, ZOOM_MAX, create })
|
||||
// 插件「插入画布」落到可视区域中心(findSpot 会把节点丢左上角,常被左侧面板遮住)。
|
||||
const promptCenterSpot = (bridge, w, h) => {
|
||||
try {
|
||||
const c = typeof document !== 'undefined' ? document.querySelector('.iwb-canvas') : null
|
||||
if (!c || !bridge || typeof bridge.screenToWorld !== 'function') return null
|
||||
const r = c.getBoundingClientRect()
|
||||
const p = bridge.screenToWorld(r.left + r.width / 2, r.top + r.height / 2)
|
||||
return p ? { x: p.x - (w || 0) / 2, y: p.y - (h || 0) / 2 } : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
global.IWBCanvasGeometry = Object.freeze({ connectReasonOf, distToSeg, wantsDefaultSpot, promptCenterSpot, parseWorldTransform, clientToWorld, snapToFreeSpot, placeBeside, pruneMeasured, seedFromTopLeft, clampIntoBounds, lodLowOf, lodModeOf, zoomStep, LOD_NODE_PX, LOD_PLAIN_SCALE, ZOOM_STEP, ZOOM_MIN, ZOOM_MAX, create })
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -11,18 +11,49 @@
|
||||
|
||||
function compareCanvasTextOrder(a, b) { return (Number(a.y) - Number(b.y)) || (Number(a.x) - Number(b.x)) || String(a.id).localeCompare(String(b.id)) }
|
||||
|
||||
function batchSrcText(n) {
|
||||
// 节点**自身**文案(不看上游):组合取 combined/extra,LLM 取 result.text,其余取 data.text
|
||||
function selfTextOf(n) {
|
||||
if (!n || !n.data) return ''
|
||||
if (n.type === 'combine') return ((n.data.combined || n.data.extra) || '').trim()
|
||||
if (n.type === 'relay') return ((n.data.text || '')).trim()
|
||||
if (n.type === 'llm') return ((n.data.result && n.data.result.text) || '').trim()
|
||||
return (n.data.text || '').trim()
|
||||
}
|
||||
function isBatchSrc(n) {
|
||||
// 继承态(2026-11-23):提示词 / 文本节点自己没写字时,它对外输出的就是「节点体显示的那一条上游文案」。
|
||||
// 产品规则:提示词节点本身不拼合多路文案(一个提示词只承接一条上游),所以这里只取第一条,
|
||||
// 排序与 inheritedTextOf / 节点体「继承 · 来自 上一级」逐字同源(文本按 Y→X,图片按 X→Y)。
|
||||
// 不传 edges/nodes 时保持旧行为(只看自身 data.text),未及改造的调用点不会变。
|
||||
function upstreamTextOf(n, edgesArr, nodesArr) {
|
||||
const seen = new Set([n.id])
|
||||
const walk = (x) => {
|
||||
const srcs = edgesArr.filter((e) => e.to === x.id).map((e) => nodesArr.find((y) => y.id === e.from))
|
||||
.filter((y) => y && y.type !== 'ref' && !(y.data && y.data.enabled === false)).sort(compareCanvasTextOrder)
|
||||
for (const src of srcs) {
|
||||
const t = selfTextOf(src)
|
||||
if (t) return t
|
||||
// 只穿透「本身无文案、职责是转接」的节点;组合 / LLM / 插件节点有自己的语义,不越过
|
||||
if (!seen.has(src.id) && (src.type === 'prompt' || src.type === 'textout' || src.type === 'relay' || src.type === 'batch')) {
|
||||
seen.add(src.id)
|
||||
const up = walk(src)
|
||||
if (up) return up
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
return walk(n)
|
||||
}
|
||||
function batchSrcText(n, edgesArr, nodesArr) {
|
||||
if (!n || !n.data) return ''
|
||||
const own = selfTextOf(n)
|
||||
if (own) return own
|
||||
// 继承态只有提示词 / 文本节点有(它们的节点体就显示「继承」);组合 / 连接 / LLM 不在此列
|
||||
return (n.type === 'prompt' || n.type === 'textout') && edgesArr && nodesArr ? upstreamTextOf(n, edgesArr, nodesArr) : ''
|
||||
}
|
||||
function isBatchSrc(n, edgesArr, nodesArr) {
|
||||
// outKind === 'prompt'(2026-11-14):插件节点声明「我输出的是提示词」后也算批量来源。
|
||||
// 加在这一处而不是三处:批量节点的候选来源、端口分布、组合来源行都走 isBatchSrc,
|
||||
// 认了它,「一条样式 × N 个商品图」的批量出图才成立。
|
||||
return !!n && (n.type === 'prompt' || n.type === 'textout' || n.type === 'combine' || n.type === 'llm' || n.type === 'relay' || (n.data && n.data.outKind === 'prompt')) && !!batchSrcText(n)
|
||||
return !!n && (n.type === 'prompt' || n.type === 'textout' || n.type === 'combine' || n.type === 'llm' || n.type === 'relay' || (n.data && n.data.outKind === 'prompt')) && !!batchSrcText(n, edgesArr, nodesArr)
|
||||
}
|
||||
function batchPortTop(idx, total, h) {
|
||||
const gap = Math.min(30, Math.max(20, (h - 90) / Math.max(1, total - 1)))
|
||||
@@ -48,10 +79,10 @@
|
||||
}
|
||||
if (n.data && n.data.enabled === false) return []
|
||||
if (n.type === 'batch') {
|
||||
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const s = inEdge.batchSrcId ? bsrcs.find((x) => x.id === inEdge.batchSrcId) : bsrcs[0]
|
||||
if (!s || (s.data && s.data.enabled === false)) return []
|
||||
const st = s ? batchJoinedText(n.data, batchSrcText(s)) : ''
|
||||
const st = s ? batchJoinedText(n.data, batchSrcText(s, edgesArr, nodesArr)) : ''
|
||||
return st ? [st] : []
|
||||
}
|
||||
return combineInputTexts(n, edgesArr, nodesArr)
|
||||
@@ -60,18 +91,18 @@
|
||||
if (!n || (n.data && n.data.enabled === false)) return []
|
||||
if (n.type === 'batch') {
|
||||
const bd = n.data || {}
|
||||
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
return bsrcs.map((src) => batchJoinedText(bd, batchSrcText(src))).filter(Boolean)
|
||||
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
return bsrcs.map((src) => batchJoinedText(bd, batchSrcText(src, edgesArr, nodesArr))).filter(Boolean)
|
||||
}
|
||||
if (n.type === 'relay') { const out = []; const relaySrcs = edgesArr.filter((x) => x.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter(Boolean).slice().sort(compareCanvasTextOrder); for (const src of relaySrcs) for (const t0 of combineInputTexts(src, edgesArr, nodesArr)) if (t0 && !out.includes(t0)) out.push(t0); return out }
|
||||
const t = batchSrcText(n)
|
||||
const t = batchSrcText(n, edgesArr, nodesArr)
|
||||
if (n.type === 'textout') {
|
||||
if (t) return [t]
|
||||
const bEdge = edgesArr.filter((e) => e.to === n.id).map((e) => ({ e, b: nodesArr.find((x) => x.id === e.from) })).find((o) => o.b && o.b.type === 'batch')
|
||||
if (bEdge) {
|
||||
const bsrcs = edgesArr.filter((e) => e.to === bEdge.b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
|
||||
const bsrcs = edgesArr.filter((e) => e.to === bEdge.b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
|
||||
const target = bEdge.e.batchSrcId ? bsrcs.find((s) => s.id === bEdge.e.batchSrcId) : bsrcs[0]
|
||||
const bt = target ? batchSrcText(target) : ''
|
||||
const bt = target ? batchSrcText(target, edgesArr, nodesArr) : ''
|
||||
return bt ? [bt] : []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/* 设计 token 静态快照 —— **生成文件,勿手改**
|
||||
*
|
||||
* 源:src/theme-tokens.js(derive() + 本文件生成器的 SCALE 表)
|
||||
* 生成:node scripts/gen-tokens.js --write (校验:--check,已进 verify:ci)
|
||||
*
|
||||
* 为什么要有这一层:JS 未执行的那一帧没有内联变量,用它顶住,避免首屏闪白/跳变。
|
||||
* 所以它必须逐值等于 derive() 的输出 —— 这条约束由 scripts/gen-tokens.js --check 强制。
|
||||
* 结构层(chrome/home/dock/edge/hr)刻意用 color-mix 表达关系式:换主题时 :root 的声明会在
|
||||
* html 元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值,天然跟随。
|
||||
*/
|
||||
:root {
|
||||
/* —— 表面阶(亮色往白里 mix) —— */
|
||||
--iwb-bg: #f7f7f7;
|
||||
--iwb-canvas-bg: #c6c6c6;
|
||||
--iwb-layer: #f5f5f5;
|
||||
--iwb-layer2: #ffffff;
|
||||
--iwb-panel: #fefefe;
|
||||
--iwb-node-bg: #efefef;
|
||||
--iwb-field: #ffffff;
|
||||
/* —— 结构层(公式与 derive 一致,见文件头) —— */
|
||||
--iwb-chrome: color-mix(in srgb, var(--iwb-bg) 60%, var(--iwb-canvas-bg) 40%); /* 顶部 chrome 色:页面底与画布之间的过渡层(标签条用) */
|
||||
--iwb-home-bg: color-mix(in srgb, var(--iwb-bg) 35%, var(--iwb-canvas-bg) 65%); /* 首页底色:画布色与顶栏色之间取 35/65 */
|
||||
--iwb-hr: color-mix(in srgb, var(--iwb-border) 50%, var(--iwb-border2) 50%); /* 首页上的细分隔线 */
|
||||
--iwb-dock-bg: color-mix(in srgb, var(--iwb-chrome) 55%, var(--iwb-canvas-bg) 45%); /* 左右停靠栏底色:排进 bg→chrome→home→canvas 灰阶 */
|
||||
--iwb-dock-head-bg: color-mix(in srgb, var(--iwb-panel) 55%, var(--iwb-dock-bg)); /* 顶栏底色比停靠栏更浅一档 */
|
||||
--iwb-plugin-bg: var(--iwb-bg); /* v3.25.85 插件主题契约:插件只能用这组别名 */
|
||||
--iwb-plugin-panel: var(--iwb-panel);
|
||||
--iwb-plugin-layer: var(--iwb-layer);
|
||||
--iwb-plugin-border: var(--iwb-border);
|
||||
--iwb-plugin-text: var(--iwb-text);
|
||||
--iwb-plugin-text2: var(--iwb-text2);
|
||||
--iwb-plugin-brand: var(--iwb-brand);
|
||||
--iwb-plugin-on-brand: var(--iwb-on-brand);
|
||||
--iwb-plugin-err: var(--iwb-err);
|
||||
--iwb-plugin-ok: var(--iwb-ok);
|
||||
--iwb-plugin-warn: var(--iwb-warn);
|
||||
--iwb-edge: var(--iwb-border2); /* 连线默认色:跟随边框灰(主题色只用于选中/悬停/上游高亮) */
|
||||
--iwb-edge-hot: var(--iwb-brand);
|
||||
--iwb-focus-ring: 2px solid color-mix(in srgb, var(--iwb-brand-text) 70%, transparent); /* 键盘焦点环(D8):颜色走 brand-text,暗色下 brand 画不出环 */
|
||||
--iwb-edge-w: 1.8px; /* 外观自定义:由 src/ui-appearance.js 按配置写入,这里只给兜底默认值 */
|
||||
--iwb-edge-dash: 4 3;
|
||||
--iwb-node-radius: 14px;
|
||||
--iwb-node-sel-w: 1px;
|
||||
--iwb-grid-size: 1.4px;
|
||||
--iwb-grid-gap: 22px;
|
||||
--iwb-grid-on: 1;
|
||||
--iwb-nav-w: 52px; /* 一级导航宽度:左停靠栏/工具栏让位都以它为基准 */
|
||||
/* —— 描边 / 文字三级(目标对比度见 IWBThemeTokens.RATIO) —— */
|
||||
--iwb-border: #c2c2c2;
|
||||
--iwb-border2: #ababab;
|
||||
--iwb-text: #404040;
|
||||
--iwb-text2: #5c5c5c;
|
||||
--iwb-text-dim: #767676;
|
||||
--iwb-color-text-on-canvas: #404040;
|
||||
--iwb-node-text: #404040;
|
||||
--iwb-node-text2: #6b6b6b;
|
||||
--iwb-tint: #404040;
|
||||
/* —— 品牌色:填充与文字是两个角色(D7) —— */
|
||||
--iwb-brand: #6b7280;
|
||||
--iwb-brand-text: #575d69;
|
||||
--iwb-on-brand: #ffffff;
|
||||
--iwb-grid-dot: #a6a6a6;
|
||||
/* —— 插件表面四层(只提供取值,不做变量重指) —— */
|
||||
--iwb-surface: #fefefe;
|
||||
--iwb-hover: #e9e9e9;
|
||||
--iwb-bg-menu: #fefefe;
|
||||
--iwb-plugin-surface: #f5f5f5;
|
||||
--iwb-plugin-card: #fefefe;
|
||||
--iwb-plugin-inset: #ebebeb;
|
||||
--iwb-plugin-hover: #e2e2e2;
|
||||
/* —— 语义色 —— */
|
||||
--iwb-err: #ef4444;
|
||||
--iwb-ok: #22c55e;
|
||||
--iwb-warn: #d97706;
|
||||
/* —— 尺度层(L1)—— */
|
||||
--sp-1: 4px; /* @deprecated 全部 5 个 → M3 的 --iwb-space-4/8/12/16/24 */
|
||||
--sp-2: 8px;
|
||||
--sp-3: 12px;
|
||||
--sp-4: 16px;
|
||||
--sp-5: 24px;
|
||||
--rd-sm: 6px; /* @deprecated rd-sm/rd-md/rd-lg → M3 的 --iwb-radius-chip/control/popover */
|
||||
--rd: 8px;
|
||||
--rd-md: 10px;
|
||||
--rd-lg: 12px;
|
||||
--fs-xs: 10px; /* @deprecated fs-xs/fs-md/fs-lg/fs-xl → M3 的 --iwb-font-*(fs-sm 仍被引用) */
|
||||
--fs-sm: 11px;
|
||||
--fs-md: 12px;
|
||||
--fs-lg: 13px;
|
||||
--fs-xl: 14px;
|
||||
--tr-fast: 0.1s ease-out;
|
||||
--tr-base: 0.2s ease-out; /* @deprecated tr-base/tr-slow → M3 的 --iwb-motion-*(tr-fast 仍被引用) */
|
||||
--tr-slow: 0.3s ease-out;
|
||||
--iwb-space-2: 2px;
|
||||
--iwb-space-4: 4px;
|
||||
--iwb-space-6: 6px;
|
||||
--iwb-space-8: 8px;
|
||||
--iwb-space-10: 10px;
|
||||
--iwb-space-12: 12px;
|
||||
--iwb-space-16: 16px;
|
||||
--iwb-space-20: 20px;
|
||||
--iwb-space-24: 24px;
|
||||
--iwb-space-32: 32px;
|
||||
--iwb-space-40: 40px;
|
||||
--iwb-space-48: 48px;
|
||||
--iwb-space-64: 64px;
|
||||
--iwb-radius-chip: 6px; /* M4 圆角:胶囊/标签 */
|
||||
--iwb-radius-control: 8px; /* 输入框/按钮 */
|
||||
--iwb-radius-card: 10px; /* 卡片/分组 */
|
||||
--iwb-radius-panel: 12px; /* 面板/工具栏 */
|
||||
--iwb-radius-popover: 14px; /* 浮层/菜单/右键 */
|
||||
--iwb-radius-full: 999px; /* 圆形/药丸 */
|
||||
--iwb-font-xs: 11px; /* M4 字号:状态栏/徽标 */
|
||||
--iwb-font-sm: 12px; /* 标签/次要正文 */
|
||||
--iwb-font-md: 13px; /* 正文/工具栏标题 */
|
||||
--iwb-font-lg: 15px; /* 小标题/节点标题 */
|
||||
--iwb-font-xl: 17px; /* 面板标题 */
|
||||
--iwb-font-2xl: 20px; /* 页面大标题 */
|
||||
--iwb-font-display: 24px; /* 展示级标题:页面/视图主标题(≤5 处) */
|
||||
--iwb-chrome-h: 36px; /* 顶部标签条高度:tabstrip / dockarea / home-panel 三处共用(原来各写一遍 36px) */
|
||||
--iwb-tab-h: 28px; /* 标签高度 */
|
||||
--iwb-tab-radius: 7px; /* 标签圆角 */
|
||||
--iwb-control-h: 30px; /* 表单控件高度:同一行里的输入框与默认按钮必须等高(设置页实测曾是 33 vs 24) */
|
||||
--iwb-z-ctx: 90; /* 右键遮罩 */
|
||||
--iwb-z-ctx-menu: 91; /* 右键菜单 */
|
||||
--iwb-z-curtain: 100; /* 应用遮罩 / 图片预览底 */
|
||||
--iwb-z-command: 120; /* 命令面板(⌘K) */
|
||||
--iwb-z-sheet: 260; /* 全窗口面板(资源中心) */
|
||||
--iwb-z-sheet-menu: 270; /* 面板内 portal 菜单:> sheet、< modal */
|
||||
--iwb-z-modal: 300; /* 弹窗 + 遮罩 */
|
||||
--iwb-z-modal-menu: 310; /* 侧栏/弹窗里挂 body 的菜单 */
|
||||
--iwb-z-splash: 400; /* 启动页 */
|
||||
--iwb-z-toast: 500; /* 提示条:必须高于弹窗 */
|
||||
--iwb-z-preview: 800; /* 图片预览(全屏) */
|
||||
--iwb-z-anchor: 3200; /* 锚定浮层:挂 body 的面板/首页菜单 */
|
||||
--iwb-z-palette: 3300; /* 背景色板 host(含锚定浮层) */
|
||||
--iwb-z-alert: 4000; /* 确认框 / 崩溃屏(最后一道) */
|
||||
/* —— 阴影 —— */
|
||||
--sh-sm: 0 2px 8px rgba(0, 0, 0, 0.12); /* @deprecated → M3 的 --iwb-elevation-1 */
|
||||
--sh-md: 0 6px 20px rgba(0, 0, 0, 0.16);
|
||||
--sh-lg: 0 12px 32px rgba(0, 0, 0, 0.24);
|
||||
--iwb-elevation-1: 0 2px 8px rgba(0, 0, 0, 0.12); /* 贴面浮层:浮动条 / 状态栏 */
|
||||
--iwb-elevation-2: 0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.10); /* 浮窗 / 菜单 / toast */
|
||||
--iwb-elevation-3: 0 18px 56px rgba(0, 0, 0, 0.26); /* 命令面板 / 锚定大浮层 */
|
||||
--iwb-elevation-4: 0 24px 64px rgba(0, 0, 0, 0.30); /* 弹窗 / 全窗口面板 */
|
||||
}
|
||||
|
||||
/* 暗色主题:html.theme-dark
|
||||
* 同一套语义名,值来自 derive(DEFAULTS, true)。结构层不在这里重复定义 ——
|
||||
* :root 的 color-mix 公式会在本元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值。 */
|
||||
.theme-dark {
|
||||
/* 生图动效在暗色下必须「发亮」:--iwb-brand 是中性灰,直接用会糊在深底里 */
|
||||
--iwb-anim: #ffffff;
|
||||
--iwb-anim-track: color-mix(in srgb, #ffffff 18%, transparent);
|
||||
--iwb-anim-glow: rgba(255, 255, 255, 0.72);
|
||||
--iwb-anim-tint: color-mix(in srgb, #ffffff 16%, transparent);
|
||||
--iwb-anim-flow-a: color-mix(in srgb, #ffffff 26%, var(--iwb-layer));
|
||||
--iwb-anim-flow-b: color-mix(in srgb, #ffffff 76%, var(--iwb-layer));
|
||||
/* —— 表面阶 —— */
|
||||
--iwb-bg: #121212;
|
||||
--iwb-canvas-bg: #313131;
|
||||
--iwb-layer: #161616;
|
||||
--iwb-layer2: #1c1c1c;
|
||||
--iwb-panel: #1c1c1c;
|
||||
--iwb-node-bg: #3d3d3d;
|
||||
--iwb-field: #494949;
|
||||
--iwb-border: #333333;
|
||||
--iwb-border2: #4d4d4d;
|
||||
/* —— 文字 / 品牌 —— */
|
||||
--iwb-text: #e3e3e3;
|
||||
--iwb-text2: #bababa;
|
||||
--iwb-text-dim: #989898;
|
||||
--iwb-color-text-on-canvas: #b2b2b2;
|
||||
--iwb-node-text: #e3e3e3;
|
||||
--iwb-node-text2: #aaaaaa;
|
||||
--iwb-tint: #e3e3e3;
|
||||
--iwb-brand: #6b7280;
|
||||
--iwb-brand-text: #b6bac0;
|
||||
--iwb-on-brand: #ffffff;
|
||||
--iwb-grid-dot: #525252;
|
||||
/* —— 插件表面 / 浮层 / 语义色 —— */
|
||||
--iwb-surface: #1c1c1c;
|
||||
--iwb-hover: #2a2a2a;
|
||||
--iwb-bg-menu: #3c3c3c;
|
||||
--iwb-plugin-surface: #232323;
|
||||
--iwb-plugin-card: #2c2c2c;
|
||||
--iwb-plugin-inset: #191919;
|
||||
--iwb-plugin-hover: #383838;
|
||||
--iwb-err: #f26666;
|
||||
--iwb-ok: #4acf7b;
|
||||
--iwb-warn: #e1953d;
|
||||
/* —— 阴影 —— */
|
||||
--sh-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
|
||||
--sh-md: 0 6px 20px rgba(0, 0, 0, 0.45);
|
||||
--sh-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
|
||||
--iwb-elevation-1: 0 2px 8px rgba(0, 0, 0, 0.40);
|
||||
--iwb-elevation-2: 0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.40);
|
||||
--iwb-elevation-3: 0 18px 56px rgba(0, 0, 0, 0.62);
|
||||
--iwb-elevation-4: 0 24px 64px rgba(0, 0, 0, 0.70);
|
||||
}
|
||||
|
||||
/* 亮色主题的生图动效 token:与暗色同结构,色取品牌色 */
|
||||
:root:not(.theme-dark) {
|
||||
--iwb-anim: var(--iwb-brand);
|
||||
--iwb-anim-track: color-mix(in srgb, var(--iwb-brand) 16%, transparent);
|
||||
--iwb-anim-glow: color-mix(in srgb, var(--iwb-brand) 75%, transparent);
|
||||
--iwb-anim-tint: color-mix(in srgb, var(--iwb-brand) 7%, transparent);
|
||||
--iwb-anim-flow-a: color-mix(in srgb, var(--iwb-brand) 16%, var(--iwb-layer));
|
||||
--iwb-anim-flow-b: color-mix(in srgb, var(--iwb-brand) 46%, var(--iwb-layer));
|
||||
}
|
||||
@@ -105,7 +105,7 @@
|
||||
return base.map((t) => ({ ...t, sourceNodeId: own ? n.id : (t.sourceNodeId || n.id), ownerNodeId: n.id, title: ownTitle || t.title || '', text: own || t.text, refNodes: dedupeTaskRefs((t.refNodes || []).concat(refs)) }))
|
||||
}
|
||||
if (n.type === 'combine') { const orderedC = children.slice().sort((a, b) => { const na = graph.byId.get(a.sourceNodeId), nb = graph.byId.get(b.sourceNodeId); return na && nb ? compareCanvasTextOrder(na, nb) : 0 }); return [{ sourceNodeId: n.id, ownerNodeId: n.id, title: String((n.data && n.data.title) || '').trim(), text: own || orderedC.map((t) => t.text).filter(Boolean).join(String((n.data && n.data.sep) || (global.IWBRuntimeConstants && global.IWBRuntimeConstants.combineSep) || ', ')), refNodes: dedupeTaskRefs(orderedC.flatMap((t) => t.refNodes)), diagnostics: { cycles: orderedC.flatMap((t) => (t.diagnostics && t.diagnostics.cycles) || []), disabledSources: [] } }] }
|
||||
if (n.type === 'batch') { const candidates = incoming.map((e) => graph.byId.get(e.from)).filter((x) => x && isBatchSrc(x) && !(x.data && x.data.enabled === false)); const selected = ctx.selectedBatchSourceId && candidates.find((x) => x.id === ctx.selectedBatchSourceId); const sources = selected ? [selected] : candidates; return sources.flatMap((src) => resolveNodeTaskValues(src.id, graph, { ...ctx, selectedBatchSourceId: null, stack: next }).map((t) => ({ ...t, text: batchJoinedText(n.data || {}, t.text) }))) }
|
||||
if (n.type === 'batch') { const candidates = incoming.map((e) => graph.byId.get(e.from)).filter((x) => x && isBatchSrc(x, graph.edges, graph.nodes) && !(x.data && x.data.enabled === false)); const selected = ctx.selectedBatchSourceId && candidates.find((x) => x.id === ctx.selectedBatchSourceId); const sources = selected ? [selected] : candidates; return sources.flatMap((src) => resolveNodeTaskValues(src.id, graph, { ...ctx, selectedBatchSourceId: null, stack: next }).map((t) => ({ ...t, text: batchJoinedText(n.data || {}, t.text) }))) }
|
||||
if (n.type === 'relay') {
|
||||
const sharedRefs = dedupeTaskRefs(children.filter((t) => !t.text).flatMap((t) => t.refNodes || []))
|
||||
const textTasks = [], seenTasks = new Set()
|
||||
@@ -248,13 +248,13 @@
|
||||
return out
|
||||
}
|
||||
if (n.type === 'batch') {
|
||||
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const bsrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr) && !(x.data && x.data.enabled === false)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const sel = inEdge && inEdge.batchSrcId ? bsrcs.find((s) => s.id === inEdge.batchSrcId) : bsrcs[0]
|
||||
if (!sel) return []
|
||||
const t = batchJoinedText((n.data || {}), (batchSrcText(sel) || ''))
|
||||
const t = batchJoinedText((n.data || {}), (batchSrcText(sel, edgesArr, nodesArr) || ''))
|
||||
return t ? [{ n: sel, text: t }] : []
|
||||
}
|
||||
const t = batchSrcText(n)
|
||||
const t = batchSrcText(n, edgesArr, nodesArr)
|
||||
return t ? [{ n, text: t }] : []
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
const bEdge = edgesArr.filter((e) => e.to === n.id).map((e) => ({ e, b: nodesArr.find((x) => x.id === e.from) })).find((o) => o.b && o.b.type === 'batch')
|
||||
if (bEdge) {
|
||||
const b = bEdge.b
|
||||
const bsrcs = edgesArr.filter((e) => e.to === b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
|
||||
const bsrcs = edgesArr.filter((e) => e.to === b.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
|
||||
const target = bEdge.e.batchSrcId ? bsrcs.find((s) => s.id === bEdge.e.batchSrcId) : bsrcs[0]
|
||||
if (target) {
|
||||
const seen = new Set()
|
||||
@@ -333,7 +333,7 @@
|
||||
}
|
||||
if (n.type === 'batch') {
|
||||
// 批量加文案:透传其所有输入源的参考图
|
||||
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x))
|
||||
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr))
|
||||
const seen = new Set()
|
||||
const out = []
|
||||
for (const st of textSrcs) for (const r of nodeRefsOf(st, edgesArr, nodesArr, visited)) if (!seen.has(r.id)) { seen.add(r.id); out.push(r) }
|
||||
@@ -344,7 +344,7 @@
|
||||
// 插件节点的入边通常为空(样式节点端口只出),所以 selfRefs 往往就是全部 ——
|
||||
// 少这一句,分层节点(走 layerInputsOf → nodeRefsOf)就看不到样式节点那张示例图。
|
||||
if (n.type !== 'combine') return dedupeTaskRefs(direct.concat(selfRefNodesOf(n)))
|
||||
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x) || (x && x.type === 'batch'))
|
||||
const textSrcs = edgesArr.filter((e) => e.to === n.id).map((e) => nodesArr.find((x) => x.id === e.from)).filter((x) => isBatchSrc(x, edgesArr, nodesArr) || (x && x.type === 'batch'))
|
||||
const seen = new Set()
|
||||
const out = []
|
||||
for (const st of textSrcs) for (const r of nodeRefsOf(st, edgesArr, nodesArr, visited)) if (!seen.has(r.id)) { seen.add(r.id); out.push(r) }
|
||||
|
||||
@@ -887,6 +887,14 @@
|
||||
commitCanvas(refs.nodes.concat(moved), refs.edges.concat(es), refs.groups.concat(gs))
|
||||
} else {
|
||||
setSel([])
|
||||
// 拖入后清掉宿主的临时手势状态:原生拖放期间鼠标事件被浏览器吞掉,
|
||||
// pointerup 可能没走到画布,refs.bodyDown/box 会残留 ⇒ 第一次点击节点被当成「收尾」。
|
||||
try {
|
||||
refs.bodyDown = null; refs.groupDown = null; refs.drag = null; refs.box = null; refs.pan = null
|
||||
const ae = /** @type {any} */ (document.activeElement)
|
||||
if (ae && typeof ae.blur === 'function') ae.blur()
|
||||
if (window.getSelection) window.getSelection().removeAllRanges()
|
||||
} catch (e) { /* ignore */ }
|
||||
setNotice({ type: 'ok', text: '✓ 已导入 ' + ns.length + ' 个节点 / ' + es.length + ' 条连线' })
|
||||
commitCanvas(ns, es, gs)
|
||||
}
|
||||
@@ -1097,13 +1105,35 @@
|
||||
data: {
|
||||
promptId: '', name: obj.name || '提示词模板', tpl: obj.text || '',
|
||||
vdefs: Array.isArray(obj.vdefs) ? obj.vdefs : [],
|
||||
vars: {}, cover: obj.cover || '', refOn: false, text: obj.text || '',
|
||||
vars: {}, cover: obj.cover || '', refOn: false, text: obj.text || '', outKind: 'prompt',
|
||||
},
|
||||
}
|
||||
: { id, type: 'prompt', x: Math.round(wx - 132), y: Math.round(wy - 20), data: { text: obj.text || '', title: obj.name || '' } }
|
||||
pushHistory() // 拖拽入画布新增节点:入撤销历史(鼠标落点保留)
|
||||
commitCanvas(refs.nodes.concat([node]), undefined, undefined)
|
||||
// 与风格库一致:新节点直接选中(未选中时第一次点击会被当成“先选中”而拖不动)
|
||||
setSel([id])
|
||||
// 拖放结束后浏览器可能还会给新节点补一次 focus/click(落在 readonly textarea 上会进入编辑态),
|
||||
// 导致「第一次点节点」变成选文本/输入框、拖不动。延时几次强制 blur + 取消选择,覆盖这段尾巴。
|
||||
const settleDrop = () => {
|
||||
try {
|
||||
const ae = /** @type {any} */ (document.activeElement)
|
||||
if (ae && ae !== document.body && typeof ae.blur === 'function') ae.blur()
|
||||
if (window.getSelection) window.getSelection().removeAllRanges()
|
||||
setSel([id])
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
setTimeout(settleDrop, 0)
|
||||
setTimeout(settleDrop, 80)
|
||||
setTimeout(settleDrop, 240)
|
||||
// 原生拖放期间浏览器的鼠标事件被吞掉,pointerup 不会走到画布:
|
||||
// refs.bodyDown/box 等临时手势会残留,导致「第一次点节点」被当成收尾(点不动/选中文本)。
|
||||
try {
|
||||
refs.bodyDown = null; refs.groupDown = null; refs.drag = null; refs.box = null; refs.pan = null
|
||||
const ae = /** @type {any} */ (document.activeElement)
|
||||
if (ae && typeof ae.blur === 'function') ae.blur()
|
||||
if (window.getSelection) window.getSelection().removeAllRanges()
|
||||
} catch (e) { /* ignore */ }
|
||||
setNotice({ type: 'ok', text: (hasVars ? '已插入提示词模板:' : '已插入提示词:') + (obj.name || '') })
|
||||
return
|
||||
} catch (err) { /* 非本应用拖入 */ }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* theme-tokens.js —— 配色自动适配(v3.25.81,P1)
|
||||
/* theme-tokens.js —— 配色自动适配(v3.26.44:色彩模型修正 D2–D6)
|
||||
*
|
||||
* 用户裁定:只定 4 个「种子」,其余颜色由函数派生:
|
||||
* ① 中性基调 seedNeutral(一个中灰)
|
||||
@@ -8,8 +8,10 @@
|
||||
*
|
||||
* 派生规则:
|
||||
* · 亮色:往白里 mix(越靠表面越白),画布往灰里 mix
|
||||
* · 暗色:往黑里 mix(同一套语义名,方向相反)
|
||||
* · 文本对表面做 4.5:1 对比度夹紧(不够就自动加深/提亮)
|
||||
* · 暗色:往黑里 mix(同一套语义名,方向同向 —— 见下方 layer 注释)
|
||||
* · 文字对**全部承载表面**做对比度夹紧(旧实现只对 bg,暗色正文在 layer 上只有 3.94:1)
|
||||
*
|
||||
* 对比度目标集中在 RATIO,不要在别处再写 4.5 / 3.2 这类魔数。
|
||||
* 产出沿用现有 --iwb-* 变量名,CSS 不需要重写。
|
||||
*/
|
||||
;(function (global) {
|
||||
@@ -46,14 +48,37 @@
|
||||
const l2 = Math.min(lum(a), lum(b))
|
||||
return (l1 + 0.05) / (l2 + 0.05)
|
||||
}
|
||||
// 文本对表面做对比度夹紧:不够就朝「远离表面」的方向继续 mix
|
||||
|
||||
/* 对比度目标(WCAG 2.1)
|
||||
* text 7.0 正文:AAA,界面里被读得最多的字
|
||||
* text2 4.5 次要文字 / 标签 / 说明:AA 正文
|
||||
* dim 3.0 占位符 / 禁用 / 装饰:AA 大字下限(不再往 2.1 掉)
|
||||
* canvas 6.0 画布上的节点标题:它还叠了 opacity .8,留 6.0 的余量保证合成后仍 ≥4.5
|
||||
* onBrand 4.5 品牌色上的文字 */
|
||||
const RATIO = { text: 7, text2: 4.5, dim: 3, canvas: 6, onBrand: 4.5 }
|
||||
|
||||
// 对单色表面夹紧:不够就朝「远离表面」的方向继续 mix
|
||||
function clampText (fg, bg, minRatio) {
|
||||
return clampAgainst(fg, [bg], minRatio)
|
||||
}
|
||||
|
||||
/* 对**一整套表面**夹紧:约束取「最差的那个表面」。
|
||||
* 旧实现只传 bg,于是暗色下 --iwb-text 在 layer(3.94) / nodeBg(4.38) / pluginCard(3.94)
|
||||
* 全都不达标 —— 而它在 style.css 里出现 200+ 次。 */
|
||||
function clampAgainst (fg, surfaces, minRatio) {
|
||||
const min = Number(minRatio) || 4.5
|
||||
const list = (Array.isArray(surfaces) ? surfaces : [surfaces]).filter(Boolean)
|
||||
if (!list.length) return fg
|
||||
let out = fg
|
||||
const away = lum(bg) > 0.5 ? '#000000' : '#ffffff'
|
||||
for (let i = 0; i < 12; i++) {
|
||||
if (contrast(out, bg) >= min) break
|
||||
out = mix(out, away, 0.12)
|
||||
const away = lum(list[0]) > 0.5 ? '#000000' : '#ffffff'
|
||||
for (let i = 0; i < 60; i++) {
|
||||
let worst = Infinity
|
||||
for (let j = 0; j < list.length; j++) {
|
||||
const r = contrast(out, list[j])
|
||||
if (r < worst) worst = r
|
||||
}
|
||||
if (worst >= min - 0.005) break
|
||||
out = mix(out, away, 0.05)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -68,21 +93,82 @@
|
||||
const d = !!dark
|
||||
const t = d ? '#000000' : '#ffffff'
|
||||
|
||||
// 表面阶:亮色往白、暗色往黑
|
||||
// —— 表面阶:亮色往白、暗色往黑 ——
|
||||
const surface0 = mix(N, t, d ? 0.86 : 0.94)
|
||||
const surface1 = mix(N, t, d ? 0.78 : 0.99)
|
||||
const surface2 = mix(N, t, d ? 0.70 : 0.90)
|
||||
const surface3 = mix(N, t, d ? 0.64 : 0.84)
|
||||
// 画布:亮色更深、暗色略亮(与 UI 拉开层次)
|
||||
const canvas = d ? mix(surface0, '#ffffff', depth / 100 * 0.6) : mix(surface0, '#000000', depth / 100 * 0.9)
|
||||
const border = mix(N, t, d ? 0.52 : 0.52)
|
||||
/* 暗色 0.52 会算出 #3d3d3d,与新的 nodeBg 撞成同色 → 节点边框消失。
|
||||
* 暗色压到 0.60(#333333)保证边框比卡片底暗一档;亮色不变。 */
|
||||
const border = mix(N, t, d ? 0.60 : 0.52)
|
||||
const border2 = mix(N, t, d ? 0.40 : 0.34)
|
||||
const layer = mix(N, t, d ? 0.66 : 0.92)
|
||||
const nodeBg = mix(N, t, d ? 0.72 : 0.88)
|
||||
const textBase = mix(N, t, d ? 0.06 : 0.06)
|
||||
const text = clampText(textBase, surface0, 4.5)
|
||||
const text2 = clampText(mix(N, t, d ? 0.30 : 0.34), surface0, 3.2)
|
||||
/* 内嵌层(--iwb-layer)。旧实现亮色 0.92、暗色 0.66:
|
||||
* 亮色 panel(.99) > layer(.92) → layer 更暗 = 内嵌 ✓
|
||||
* 暗色 panel(.78) < layer(.66) → layer 更亮 = 凸起 ✗
|
||||
* 同一个 token 在两套主题里表达相反的层次(D6)。改成暗色 .83,两个方向都「挖进去」。 */
|
||||
const inset = mix(N, t, d ? 0.83 : 0.92)
|
||||
/* 节点卡片必须始终「浮在画布上」。旧实现把 nodeBg 与 canvas 各自独立 mix,
|
||||
* 暗色下算出来 nodeBg(#242424) 比 canvas(#313131) 还暗 —— 卡片看着是凹进去的。
|
||||
* 改成相对画布派生、两套主题都往白走:亮色 72%、暗色 6%,
|
||||
* depth 拉到 0/60 两端也都保证 nodeBg 不低于 canvas。 */
|
||||
const nodeBg = mix(canvas, '#ffffff', d ? 0.06 : 0.72)
|
||||
/* 卡片内的控件面(输入框 / 下拉 / 任务卡 / 输出组):亮色=白,暗色=比节点**亮**一档。
|
||||
* 旧实现让这些控件吃 --iwb-panel(#1c1c1c) / --iwb-layer(#161616),而节点是画布派生的 #3d3d3d
|
||||
* —— 一张 #3d 的卡片里嵌着 #16 的方框,视觉上是「挖了个黑洞」(用户 2026-11-23 反馈)。
|
||||
* panel/layer 夹在应用底色附近,本身没问题;错的是「拿面板色的控件去铺在画布色的卡片上」。
|
||||
* 所以这里跟着 nodeBg 派生(与 nodeBg←canvas 同一套相对派生思路),暗色往白走一档。 */
|
||||
const field = d ? mix(nodeBg, '#ffffff', 0.06) : '#ffffff'
|
||||
|
||||
/* —— 结构层(先算表面,文字要用它们做夹紧) ——
|
||||
* 这里的四个公式必须与 style.css 的 :root color-mix 完全一致:
|
||||
* 同一批 token 此前有三套写法(CSS 用 chrome / derive 用 surface3 / apply 用 layer),
|
||||
* 于是「有没有动过配色」会让停靠栏颜色不一样(D1 三写入者的后果)。 */
|
||||
const chrome = mix(surface0, canvas, 0.4)
|
||||
/* 首页底:亮色要明显暗于页面底(形成「画布区」),暗色不能超过 panel ——
|
||||
* 旧公式暗色算出 #1d1d1d 比 panel(#1c1c1c) 还亮,卡片 52/48 混完等于背景,整个列表「隐身」。 */
|
||||
const homeBg = mix(surface0, canvas, d ? 0.12 : 0.35)
|
||||
const dockBg = mix(chrome, canvas, 0.45)
|
||||
const dockHeadBg = mix(surface1, dockBg, 0.45)
|
||||
const hover = d ? mix(surface0, '#ffffff', 0.10) : mix(surface0, '#000000', 0.055)
|
||||
// 插件历史变量补洞:此前未定义,插件只能吃硬编码兜底(暗色下会突然白底)
|
||||
const surface = surface1
|
||||
const pluginSurface = d ? mix(surface0, '#ffffff', 0.07) : mix(surface1, '#000000', 0.035)
|
||||
const pluginCard = d ? mix(surface0, '#ffffff', 0.11) : surface1
|
||||
/* 暗色内嵌块旧值 #101010:插件卡片是 #2c2c2c,差 28 级 —— 搜索框/列表底看着是「黑窟窿」。
|
||||
* 改成从面板色往下压 10%(#191919),与卡片差 10 级:仍是凹槽,但不再发黑。 */
|
||||
const pluginInset = d ? mix(surface1, '#000000', 0.10) : mix(surface1, '#000000', 0.075)
|
||||
const pluginHover = d ? mix(surface0, '#ffffff', 0.16) : mix(surface1, '#000000', 0.11)
|
||||
/* 浮层底(右键菜单 / 更多菜单 / 确认框)。浮层要「比它盖住的东西亮」:
|
||||
* 亮色直接用 panel(最白);暗色如果也用 panel(#1c1c1c),浮在画布(#313131)上反而更暗 ——
|
||||
* 看着像挖了个坑。暗色往白提 14% → #3c3c3c,稳定亮于画布且与节点同档。 */
|
||||
const menuBg = d ? mix(surface1, '#ffffff', 0.14) : surface1
|
||||
|
||||
/* 承载文字的整套表面。canvas 不在内 —— 画布上只有节点标题,另有专用色。
|
||||
* 顺序无关,clampAgainst 取最差者。 */
|
||||
const textSurfaces = [surface0, surface1, inset, surface2, surface3, nodeBg, field, hover, dockBg, chrome, pluginSurface, pluginCard, pluginInset, pluginHover]
|
||||
|
||||
const text = clampAgainst(mix(N, t, 0.06), textSurfaces, RATIO.text)
|
||||
const text2 = clampAgainst(mix(N, t, d ? 0.30 : 0.34), textSurfaces, RATIO.text2)
|
||||
// 三级文字:从二级往表面方向退一步,再夹到 dim 下限(保证「更淡但还看得见」)
|
||||
const textDim = clampAgainst(mix(text2, surface0, 0.34), textSurfaces, RATIO.dim)
|
||||
// 画布上的节点标题:对 canvas 夹紧,且预留 opacity .8 的余量
|
||||
const canvasText = clampAgainst(mix(N, t, d ? 0.30 : 0.34), [canvas], RATIO.canvas)
|
||||
|
||||
// v3.26.42:节点文字与界面文字分家(外观面板可分别微调)
|
||||
const nodeText = text
|
||||
const nodeText2 = clampAgainst(mix(N, t, d ? 0.30 : 0.34), [nodeBg, inset], RATIO.text2)
|
||||
/* tint:所有「以文字色做半透明底色/描边」的基色。刻意**不跟随**文字覆盖 ——
|
||||
* 用户把字调深/调浅时,悬停底、标签底、分隔线不应跟着一起变(否则调字等于重排整套灰阶)。 */
|
||||
const tint = text
|
||||
|
||||
const brand = A
|
||||
/* 品牌色的两个角色必须分开:
|
||||
* brand —— 填充(主按钮底、选中框、端口环),要够深以承白字
|
||||
* brandText —— 文字/图标,要够亮以在深底上读得清
|
||||
* 旧实现只有一个,暗色下作文字只有 3.9:1(D7 的延续) */
|
||||
const brandText = clampAgainst(A, textSurfaces, RATIO.text2)
|
||||
const brandHover = mix(A, d ? '#ffffff' : '#000000', 0.14)
|
||||
const edgeHot = d ? mix(A, '#ffffff', 0.25) : A
|
||||
const gridDot = mix(N, t, d ? 0.36 : 0.30)
|
||||
@@ -92,35 +178,45 @@
|
||||
const ok = d ? mix('#22c55e', '#ffffff', 0.18) : '#22c55e'
|
||||
const warn = d ? mix('#d97706', '#ffffff', 0.22) : '#d97706'
|
||||
// 品牌色上的文字:按对比度自动选黑/白
|
||||
const onBrand = contrast('#ffffff', brand) >= 4.5 ? '#ffffff' : '#1c2333'
|
||||
const onBrand = contrast('#ffffff', brand) >= RATIO.onBrand ? '#ffffff' : '#1c2333'
|
||||
|
||||
return {
|
||||
err, ok, warn, onBrand,
|
||||
bg: surface0,
|
||||
panel: surface1,
|
||||
layer,
|
||||
layer: inset,
|
||||
layer2: d ? surface1 : '#ffffff',
|
||||
nodeBg,
|
||||
field,
|
||||
canvasBg: canvas,
|
||||
chrome: mix(surface0, canvas, 0.4),
|
||||
homeBg: mix(surface0, canvas, 0.35),
|
||||
dockBg: mix(surface3, canvas, 0.45),
|
||||
chrome,
|
||||
homeBg,
|
||||
dockBg,
|
||||
// v3.26.19:顶栏比停靠栏更浅(向面板色靠 55%),不再压暗
|
||||
dockHeadBg: mix(mix(surface3, canvas, 0.45), surface0, 0.55),
|
||||
dockHeadBg,
|
||||
border,
|
||||
border2,
|
||||
text,
|
||||
text2,
|
||||
textDim,
|
||||
canvasText,
|
||||
nodeText,
|
||||
nodeText2,
|
||||
tint,
|
||||
surface,
|
||||
hover,
|
||||
menuBg,
|
||||
brand,
|
||||
brandText,
|
||||
brandHover,
|
||||
edge: border2,
|
||||
edgeHot,
|
||||
gridDot,
|
||||
// v3.26.20:插件通用灰(中性灰,不带蓝调;暗色模式跟随主题,不再固定浅色)
|
||||
pluginSurface: d ? mix(surface0, '#ffffff', 0.07) : mix(surface1, '#000000', 0.035),
|
||||
pluginCard: d ? mix(surface0, '#ffffff', 0.11) : surface1,
|
||||
pluginInset: d ? mix(surface0, '#000000', 0.12) : mix(surface1, '#000000', 0.075),
|
||||
pluginHover: d ? mix(surface0, '#ffffff', 0.16) : mix(surface1, '#000000', 0.11),
|
||||
// 亮色层
|
||||
pluginSurface,
|
||||
pluginCard,
|
||||
pluginInset,
|
||||
pluginHover,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +233,7 @@
|
||||
s('--iwb-layer', tokens.layer)
|
||||
s('--iwb-layer2', tokens.layer2)
|
||||
s('--iwb-node-bg', tokens.nodeBg)
|
||||
s('--iwb-field', tokens.field)
|
||||
s('--iwb-plugin-surface', tokens.pluginSurface)
|
||||
s('--iwb-plugin-card', tokens.pluginCard)
|
||||
s('--iwb-plugin-inset', tokens.pluginInset)
|
||||
@@ -145,7 +242,16 @@
|
||||
s('--iwb-border2', tokens.border2)
|
||||
s('--iwb-text', tokens.text)
|
||||
s('--iwb-text2', tokens.text2)
|
||||
s('--iwb-text-dim', tokens.textDim)
|
||||
s('--iwb-color-text-on-canvas', tokens.canvasText)
|
||||
s('--iwb-node-text', tokens.nodeText)
|
||||
s('--iwb-node-text2', tokens.nodeText2)
|
||||
s('--iwb-tint', tokens.tint)
|
||||
s('--iwb-surface', tokens.surface)
|
||||
s('--iwb-hover', tokens.hover)
|
||||
s('--iwb-bg-menu', tokens.menuBg)
|
||||
s('--iwb-brand', tokens.brand)
|
||||
s('--iwb-brand-text', tokens.brandText)
|
||||
s('--iwb-edge', tokens.edge)
|
||||
s('--iwb-edge-hot', tokens.edgeHot)
|
||||
s('--iwb-grid-dot', tokens.gridDot)
|
||||
@@ -155,5 +261,5 @@
|
||||
s('--iwb-on-brand', tokens.onBrand)
|
||||
}
|
||||
|
||||
global.IWBThemeTokens = { DEFAULTS, derive, applyTo, mix, contrast, clampText }
|
||||
global.IWBThemeTokens = { DEFAULTS, RATIO, derive, applyTo, mix, contrast, clampText, clampAgainst }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -1,10 +1,21 @@
|
||||
/* ui-appearance.js —— 外观(界面主题 / 画布 / 连线 / 节点 / 主题色)与取色器(v3.25.22)
|
||||
/* ui-appearance.js —— 外观(v2:种子 → 派生 → 覆盖,v3.26.42)
|
||||
*
|
||||
* 设计边界(与用户确认过):
|
||||
* · 开放:画布底色、网格、连线(颜色/粗细/线型/高亮)、节点(底色/边框/圆角/选中描边)、主题色
|
||||
* · 不开放:界面背景 / 面板底色 / 文字颜色 —— 它们被大量 color-mix 派生,开放后极易变成不可读
|
||||
* · 所有颜色项**亮/暗各存一套**;尺寸类(粗细、圆角、间距)共用一套
|
||||
* · 全部最终落到 CSS 变量上(改一个变量全局生效,不需要改渲染逻辑)
|
||||
* 用户裁定(2026-11-23):
|
||||
* · 不再有「自动配色」这个会把手动值整体作废的大开关;
|
||||
* 每项默认跟随派生,**改哪项就覆盖哪项**,点 ↺ 回到跟随(VS Code workbench.colorCustomizations 同款模型)
|
||||
* · 字体颜色开放:界面主/次、节点主/次 4 项,带对比度徽标与一键修正
|
||||
* · 两套系统合并成一条单向管线:derive(seeds, dark) → 叠加 overrides → **一次写完**
|
||||
* (旧实现先写手写 14 项再让派生覆盖 ⇒ 关掉自动配色后 19 个变量停在派生值,半新半旧)
|
||||
*
|
||||
* 数据模型:
|
||||
* { v:2, seeds:{neutral,accent,depth}, overrides:{亮色覆盖}, overridesDark:{暗色覆盖},
|
||||
* sizes:{网格/连线/节点尺寸}, presets:[{name,seeds,overrides,overridesDark,sizes}] }
|
||||
* v1 配置(auto/seedNeutral/xxxLight/xxxDark)由 normalize 自动迁移,不丢用户配色。
|
||||
*
|
||||
* 与插件的关系(重要):变量名**只增不改**。插件全部通过 CSS 变量取色,
|
||||
* 且都带硬编码兜底;这里只改「值」不改「名」,插件外观自动跟随、功能零影响。
|
||||
* 新增 --iwb-node-text / --iwb-node-text2 后,节点作用域内把 --iwb-text/-text2 重映射过去
|
||||
* (style.css),插件节点因此零改动跟随节点文字色。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
@@ -12,21 +23,6 @@
|
||||
const React = g.React || {}
|
||||
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
|
||||
|
||||
const DEFAULTS = Object.freeze({
|
||||
canvasBgLight: '#d9dbde', canvasBgDark: '#6f6f6f',
|
||||
gridDotLight: '#c9ccd6', gridDotDark: '#8f8f8f', gridSize: 1.4, gridGap: 22, gridOn: true, gridStyle: 'dots',
|
||||
// v3.25.81:自动配色(默认开)——只定 4 个种子,其余由 src/theme-tokens.js 派生
|
||||
auto: true, seedNeutral: '#808080', seedAccent: '#6b7280', depth: 22,
|
||||
edgeColorLight: '#b9bfca', edgeColorDark: '#7a7a7a',
|
||||
edgeWidth: 1.8, edgeDash: 'dashed',
|
||||
edgeHotLight: '#6b7280', edgeHotDark: '#ffffff',
|
||||
nodeBgLight: '#f1f3f6', nodeBgDark: '#b3b3b3',
|
||||
nodeBorderLight: '#d5d9e0', nodeBorderDark: '#4f4f4f',
|
||||
nodeRadius: 14, nodeSelWidth: 1,
|
||||
accent: '#6b7280',
|
||||
presets: [],
|
||||
})
|
||||
|
||||
const DASH = { solid: 'none', dashed: '4 3', dotted: '1 3' }
|
||||
const HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i
|
||||
const isHex = (v) => HEX_RE.test(String(v || ''))
|
||||
@@ -42,36 +38,129 @@
|
||||
return Math.min(hi, Math.max(lo, n))
|
||||
}
|
||||
|
||||
function normalize (cfg) {
|
||||
const c = (cfg && cfg.canvas && cfg.canvas.appearance) || {}
|
||||
const hex = (k) => normHex(c[k]) || DEFAULTS[k]
|
||||
const DEFAULT_SIZES = Object.freeze({
|
||||
gridSize: 1.4, gridGap: 22, gridOn: true, gridStyle: 'dots',
|
||||
edgeWidth: 1.8, edgeDash: 'dashed', nodeRadius: 14, nodeSelWidth: 1,
|
||||
})
|
||||
const DEFAULTS = Object.freeze({
|
||||
v: 2,
|
||||
seeds: Object.freeze({ neutral: '#808080', accent: '#6b7280', depth: 22 }),
|
||||
overrides: Object.freeze({}),
|
||||
overridesDark: Object.freeze({}),
|
||||
sizes: DEFAULT_SIZES,
|
||||
presets: Object.freeze([]),
|
||||
})
|
||||
|
||||
// 覆盖键 → derive() token 键。只收「颜色」,尺寸走 sizes。
|
||||
const OV_TOKEN = Object.freeze({
|
||||
bg: 'bg', panel: 'panel', layer: 'layer', border: 'border', border2: 'border2',
|
||||
text: 'text', text2: 'text2', nodeText: 'nodeText', nodeText2: 'nodeText2',
|
||||
nodeBg: 'nodeBg', canvasBg: 'canvasBg', gridDot: 'gridDot',
|
||||
edge: 'edge', edgeHot: 'edgeHot', brand: 'brand',
|
||||
})
|
||||
const OV_KEYS = Object.keys(OV_TOKEN)
|
||||
|
||||
function gridStyleOf (r) {
|
||||
const st = String(r.gridStyle || '')
|
||||
if (st === 'dots' || st === 'lines' || st === 'blank') return st
|
||||
return (r.gridOn === false) ? 'blank' : 'dots'
|
||||
}
|
||||
function cleanOv (o) {
|
||||
const out = {}
|
||||
if (!o || typeof o !== 'object') return out
|
||||
for (const k of OV_KEYS) { const v = normHex(o[k]); if (v) out[k] = v }
|
||||
return out
|
||||
}
|
||||
function cleanSizes (r) {
|
||||
const s = r || {}
|
||||
return {
|
||||
canvasBgLight: hex('canvasBgLight'), canvasBgDark: hex('canvasBgDark'),
|
||||
gridDotLight: hex('gridDotLight'), gridDotDark: hex('gridDotDark'),
|
||||
gridSize: clamp(c.gridSize, 0.8, 2.6, DEFAULTS.gridSize),
|
||||
gridGap: clamp(c.gridGap, 16, 40, DEFAULTS.gridGap),
|
||||
gridOn: c.gridOn !== false,
|
||||
gridStyle: (function () {
|
||||
const st = String(c.gridStyle || '')
|
||||
if (st === 'dots' || st === 'lines' || st === 'blank') return st
|
||||
return (c.gridOn === false) ? 'blank' : 'dots'
|
||||
})(),
|
||||
edgeColorLight: hex('edgeColorLight'), edgeColorDark: hex('edgeColorDark'),
|
||||
edgeWidth: clamp(c.edgeWidth, 1, 4, DEFAULTS.edgeWidth),
|
||||
edgeDash: DASH[c.edgeDash] ? c.edgeDash : DEFAULTS.edgeDash,
|
||||
edgeHotLight: hex('edgeHotLight'), edgeHotDark: hex('edgeHotDark'),
|
||||
auto: c.auto !== false,
|
||||
seedNeutral: normHex(c.seedNeutral) || DEFAULTS.seedNeutral,
|
||||
seedAccent: normHex(c.seedAccent) || DEFAULTS.seedAccent,
|
||||
depth: clamp(c.depth, 0, 60, DEFAULTS.depth),
|
||||
nodeBgLight: hex('nodeBgLight'), nodeBgDark: hex('nodeBgDark'),
|
||||
nodeBorderLight: hex('nodeBorderLight'), nodeBorderDark: hex('nodeBorderDark'),
|
||||
nodeRadius: clamp(c.nodeRadius, 6, 20, DEFAULTS.nodeRadius),
|
||||
nodeSelWidth: clamp(c.nodeSelWidth, 1, 4, DEFAULTS.nodeSelWidth),
|
||||
accent: hex('accent'),
|
||||
presets: Array.isArray(c.presets) ? c.presets.slice(0, 12) : [],
|
||||
gridSize: clamp(s.gridSize, 0.8, 2.6, DEFAULT_SIZES.gridSize),
|
||||
gridGap: clamp(s.gridGap, 16, 40, DEFAULT_SIZES.gridGap),
|
||||
gridOn: s.gridOn !== false,
|
||||
gridStyle: gridStyleOf(s),
|
||||
edgeWidth: clamp(s.edgeWidth, 1, 4, DEFAULT_SIZES.edgeWidth),
|
||||
edgeDash: DASH[s.edgeDash] ? s.edgeDash : DEFAULT_SIZES.edgeDash,
|
||||
nodeRadius: clamp(s.nodeRadius, 6, 20, DEFAULT_SIZES.nodeRadius),
|
||||
nodeSelWidth: clamp(s.nodeSelWidth, 1, 4, DEFAULT_SIZES.nodeSelWidth),
|
||||
}
|
||||
}
|
||||
function cleanSeeds (s) {
|
||||
const r = s || {}
|
||||
return {
|
||||
neutral: normHex(r.neutral) || DEFAULTS.seeds.neutral,
|
||||
accent: normHex(r.accent) || DEFAULTS.seeds.accent,
|
||||
depth: clamp(r.depth, 0, 60, DEFAULTS.seeds.depth),
|
||||
}
|
||||
}
|
||||
function cleanPreset (p) {
|
||||
const r = (p && typeof p === 'object') ? p : {}
|
||||
return {
|
||||
name: String(r.name || '预设').slice(0, 20),
|
||||
seeds: cleanSeeds(r.seeds),
|
||||
overrides: cleanOv(r.overrides),
|
||||
overridesDark: cleanOv(r.overridesDark),
|
||||
sizes: cleanSizes(r.sizes),
|
||||
}
|
||||
}
|
||||
|
||||
// v1 → v2:只有旧配置**明确关掉自动配色**时,那些手写颜色才是用户真实在用的,才固化成覆盖;
|
||||
// 其余情况一律回到「跟随派生」(旧版自动配色下改色本来就不生效,迁过来也不该突然生效)。
|
||||
function fromV1 (raw) {
|
||||
const r = raw || {}
|
||||
const sizes = cleanSizes({
|
||||
gridSize: r.gridSize, gridGap: r.gridGap, gridOn: r.gridOn, gridStyle: r.gridStyle,
|
||||
edgeWidth: r.edgeWidth, edgeDash: r.edgeDash, nodeRadius: r.nodeRadius, nodeSelWidth: r.nodeSelWidth,
|
||||
})
|
||||
const seeds = cleanSeeds({
|
||||
neutral: r.seedNeutral,
|
||||
accent: r.seedAccent || r.accent,
|
||||
depth: r.depth,
|
||||
})
|
||||
const overrides = {}
|
||||
const overridesDark = {}
|
||||
if (r.auto === false) {
|
||||
const pairs = [
|
||||
['canvasBg', 'canvasBgLight', 'canvasBgDark'],
|
||||
['nodeBg', 'nodeBgLight', 'nodeBgDark'],
|
||||
['border', 'nodeBorderLight', 'nodeBorderDark'],
|
||||
['edge', 'edgeColorLight', 'edgeColorDark'],
|
||||
['edgeHot', 'edgeHotLight', 'edgeHotDark'],
|
||||
['gridDot', 'gridDotLight', 'gridDotDark'],
|
||||
]
|
||||
for (const p of pairs) {
|
||||
const l = normHex(r[p[1]]); const d = normHex(r[p[2]])
|
||||
if (l) overrides[p[0]] = l
|
||||
if (d) overridesDark[p[0]] = d
|
||||
}
|
||||
}
|
||||
const presets = Array.isArray(r.presets)
|
||||
? r.presets.slice(0, 12).map((p) => cleanPreset(Object.assign({ name: p && p.name }, fromV1(p && p.values))))
|
||||
: []
|
||||
return { v: 2, seeds, overrides, overridesDark, sizes, presets }
|
||||
}
|
||||
|
||||
function normalize (cfg) {
|
||||
const raw = (cfg && cfg.canvas && cfg.canvas.appearance) || {}
|
||||
if (raw && (raw.v === 2 || (raw.seeds && typeof raw.seeds === 'object' && !raw.seedNeutral))) {
|
||||
const r = raw
|
||||
return {
|
||||
v: 2,
|
||||
seeds: cleanSeeds(r.seeds),
|
||||
overrides: cleanOv(r.overrides),
|
||||
overridesDark: cleanOv(r.overridesDark),
|
||||
sizes: cleanSizes(r.sizes),
|
||||
presets: Array.isArray(r.presets) ? r.presets.slice(0, 12).map(cleanPreset) : [],
|
||||
}
|
||||
}
|
||||
return fromV1(raw)
|
||||
}
|
||||
|
||||
// 当前模式下的「跟随值」:面板与 apply 共用,保证显示的就是实际生效的
|
||||
function followTokens (a, dark) {
|
||||
const T = g.IWBThemeTokens
|
||||
if (!T || typeof T.derive !== 'function') return null
|
||||
try { return T.derive(a.seeds, !!dark) } catch (e) { return null }
|
||||
}
|
||||
|
||||
function apply (cfg, dark) {
|
||||
try {
|
||||
@@ -79,34 +168,48 @@
|
||||
const root = g.document && g.document.documentElement
|
||||
if (!root || !root.style) return
|
||||
const set = (k, v) => root.style.setProperty(k, v)
|
||||
set('--iwb-canvas-bg', dark ? a.canvasBgDark : a.canvasBgLight)
|
||||
set('--iwb-brand', a.accent)
|
||||
set('--iwb-grid-dot', dark ? a.gridDotDark : a.gridDotLight)
|
||||
set('--iwb-grid-size', a.gridSize + 'px')
|
||||
set('--iwb-grid-gap', a.gridGap + 'px')
|
||||
const gs = a.gridStyle || 'dots'
|
||||
set('--iwb-grid-on', (gs !== 'blank' && a.gridOn !== false) ? '1' : '0')
|
||||
try { root.setAttribute('data-iwb-grid', gs) } catch (e) { /* ignore */ }
|
||||
set('--iwb-edge', dark ? a.edgeColorDark : a.edgeColorLight)
|
||||
set('--iwb-edge-w', a.edgeWidth + 'px')
|
||||
set('--iwb-edge-dash', DASH[a.edgeDash] || DASH.dashed)
|
||||
set('--iwb-edge-hot', dark ? a.edgeHotDark : a.edgeHotLight)
|
||||
set('--iwb-node-bg', dark ? a.nodeBgDark : a.nodeBgLight)
|
||||
set('--iwb-border', dark ? a.nodeBorderDark : a.nodeBorderLight)
|
||||
set('--iwb-node-radius', a.nodeRadius + 'px')
|
||||
set('--iwb-node-sel-w', a.nodeSelWidth + 'px')
|
||||
// v3.25.81:自动配色 —— 由 4 个种子派生整套语义色并覆盖上面的手写值
|
||||
if (a.auto) {
|
||||
const T = g.IWBThemeTokens
|
||||
if (T && typeof T.derive === 'function') {
|
||||
try { T.applyTo(root, T.derive(a, !!dark)) } catch (e) { /* 派生失败保留手写值 */ }
|
||||
}
|
||||
const s = a.sizes
|
||||
// 尺寸类与颜色无关,始终写(派生不可用时颜色交给 CSS 兜底)
|
||||
set('--iwb-grid-size', s.gridSize + 'px')
|
||||
set('--iwb-grid-gap', s.gridGap + 'px')
|
||||
set('--iwb-grid-on', (s.gridStyle !== 'blank' && s.gridOn !== false) ? '1' : '0')
|
||||
try { root.setAttribute('data-iwb-grid', s.gridStyle) } catch (e) { /* ignore */ }
|
||||
set('--iwb-edge-w', s.edgeWidth + 'px')
|
||||
set('--iwb-edge-dash', DASH[s.edgeDash] || DASH.dashed)
|
||||
set('--iwb-node-radius', s.nodeRadius + 'px')
|
||||
set('--iwb-node-sel-w', s.nodeSelWidth + 'px')
|
||||
|
||||
const tokens = followTokens(a, dark)
|
||||
const T = g.IWBThemeTokens
|
||||
if (!tokens || !T || typeof T.applyTo !== 'function') return
|
||||
const ov = dark ? a.overridesDark : a.overrides
|
||||
const final = Object.assign({}, tokens)
|
||||
for (const k of OV_KEYS) { if (ov[k]) final[OV_TOKEN[k]] = ov[k] }
|
||||
// 结构层与插件四层是从表面色 mix 出来的:覆盖了 bg/panel/canvasBg/layer 就跟着重算,
|
||||
// 否则会出现「暖色面板 + 冷灰顶栏」「暖色面板 + 冷灰插件卡片」的割裂
|
||||
const M = T.mix
|
||||
if (typeof M === 'function') {
|
||||
// 与 theme-tokens.derive() 及 style.css :root 的 color-mix 保持同一套公式,不许第三套
|
||||
final.chrome = M(final.bg, final.canvasBg, 0.4)
|
||||
final.homeBg = M(final.bg, final.canvasBg, 0.35)
|
||||
final.dockBg = M(final.chrome, final.canvasBg, 0.45)
|
||||
final.dockHeadBg = M(final.panel, final.dockBg, 0.45)
|
||||
final.surface = final.panel
|
||||
final.pluginCard = dark ? M(final.bg, '#ffffff', 0.11) : final.panel
|
||||
final.pluginSurface = dark ? M(final.bg, '#ffffff', 0.07) : M(final.panel, '#000000', 0.035)
|
||||
final.pluginInset = dark ? M(final.bg, '#000000', 0.12) : M(final.panel, '#000000', 0.075)
|
||||
final.pluginHover = dark ? M(final.bg, '#ffffff', 0.16) : M(final.panel, '#000000', 0.11)
|
||||
final.hover = dark ? M(final.bg, '#ffffff', 0.10) : M(final.bg, '#000000', 0.055)
|
||||
final.menuBg = dark ? M(final.panel, '#ffffff', 0.14) : final.panel
|
||||
}
|
||||
// tint 恒取派生文字色:调字不改悬停/标签底色(否则调一个字等于重排整套灰阶)
|
||||
final.tint = tokens.tint
|
||||
T.applyTo(root, final)
|
||||
} catch (e) { /* 样式写失败不影响功能 */ }
|
||||
}
|
||||
|
||||
function hexToRgb (hex) {
|
||||
const h = normHex(hex) || DEFAULTS.accent
|
||||
const h = normHex(hex) || DEFAULTS.seeds.accent
|
||||
return { r: parseInt(h.slice(1, 3), 16), g: parseInt(h.slice(3, 5), 16), b: parseInt(h.slice(5, 7), 16) }
|
||||
}
|
||||
function rgbToHex (r, gg, b) {
|
||||
@@ -147,7 +250,7 @@
|
||||
const readableOn = (bg) => (contrast(bg, '#1c2333') >= 3 ? '#1c2333' : '#ffffff')
|
||||
|
||||
function ColorPicker (props) {
|
||||
const value = normHex(props && props.value) || DEFAULTS.accent
|
||||
const value = normHex(props && props.value) || DEFAULTS.seeds.accent
|
||||
const onChange = (props && props.onChange) || function () {}
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const [hsv, setHsv] = React.useState(() => { const c = hexToRgb(value); return rgbToHsv(c.r, c.g, c.b) })
|
||||
@@ -228,26 +331,65 @@
|
||||
)
|
||||
}
|
||||
|
||||
function NumberRow (props) {
|
||||
const { label, value, min, max, step, unit, onChange, title } = props
|
||||
return el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-label', title: title || '' }, label),
|
||||
el('input', { type: 'range', min, max, step, value, className: 'iwb-appear-range', onChange: (e) => onChange(Number(e.target.value)) }),
|
||||
el('span', { className: 'iwb-appear-val' }, String(value) + (unit || '')),
|
||||
)
|
||||
}
|
||||
|
||||
// ── 内置预设 ────────────────────────────────────────────────────────────────
|
||||
// 「休息」= 低刺激暖灰:压蓝光、降对比刺激,但正文仍守在 4.5:1(长时间盯屏取向)。
|
||||
const PRESETS = [
|
||||
{ name: '默认', values: {} },
|
||||
{ name: '护眼深色', values: { canvasBgLight: '#cfd6cf', canvasBgDark: '#3c4a42', gridDotLight: '#b9c4b9', gridDotDark: '#6f7f73', edgeColorLight: '#9aa79c', edgeColorDark: '#8fa694', accent: '#3f8f6b', edgeHotLight: '#3f8f6b', edgeHotDark: '#7fe0b0', nodeBgLight: '#eef2ee', nodeBgDark: '#4a574e' } },
|
||||
{ name: '高对比', values: { canvasBgLight: '#ffffff', canvasBgDark: '#111111', gridDotLight: '#d0d0d0', gridDotDark: '#3a3a3a', edgeColorLight: '#111111', edgeColorDark: '#ffffff', edgeWidth: 2.4, edgeDash: 'solid', accent: '#0057d8', edgeHotLight: '#0057d8', edgeHotDark: '#59a4ff', nodeBgLight: '#ffffff', nodeBgDark: '#1e1e1e', nodeBorderLight: '#8a8a8a', nodeBorderDark: '#9a9a9a', nodeSelWidth: 2 } },
|
||||
{ name: '纸质', values: { canvasBgLight: '#efe7d7', canvasBgDark: '#3b3227', gridDotLight: '#d8cbb4', gridDotDark: '#5a4c3d', edgeColorLight: '#b9a88c', edgeColorDark: '#a2917a', edgeDash: 'solid', accent: '#8a6f4a', edgeHotLight: '#8a6f4a', edgeHotDark: '#e0c9a0', nodeBgLight: '#faf6ee', nodeBgDark: '#4a4034', nodeBorderLight: '#ddd0b8', nodeBorderDark: '#6b5c49' } },
|
||||
{ name: '默认', seeds: { neutral: '#808080', accent: '#6b7280', depth: 22 }, overrides: {}, overridesDark: {}, sizes: {} },
|
||||
{
|
||||
name: '休息',
|
||||
seeds: { neutral: '#8b8578', accent: '#7a6a52', depth: 30 },
|
||||
overrides: {
|
||||
bg: '#f2ede4', panel: '#faf6ee', layer: '#ece6db', layer2: '#fdfbf6',
|
||||
border: '#ddd5c6', border2: '#cfc5b2', canvasBg: '#e6dfd2', gridDot: '#d5cbb8',
|
||||
edge: '#c3b8a4', edgeHot: '#7a6a52',
|
||||
text: '#2c2823', text2: '#5a544c', nodeText: '#2c2823', nodeText2: '#5a544c',
|
||||
nodeBg: '#f4f0e8',
|
||||
},
|
||||
overridesDark: {
|
||||
bg: '#1c1a17', panel: '#24211d', layer: '#2a2622', layer2: '#302c27',
|
||||
border: '#57524a', border2: '#4a443b', canvasBg: '#302c26', gridDot: '#4a443b',
|
||||
edge: '#5f584e', edgeHot: '#b99c74',
|
||||
text: '#e8e2d6', text2: '#b3ac9e', nodeText: '#e8e2d6', nodeText2: '#b3ac9e',
|
||||
nodeBg: '#3a3630',
|
||||
},
|
||||
sizes: {},
|
||||
},
|
||||
{ name: '护眼深色', seeds: { neutral: '#7d8a80', accent: '#3f8f6b', depth: 26 }, overrides: {}, overridesDark: {}, sizes: {} },
|
||||
{
|
||||
name: '高对比',
|
||||
seeds: { neutral: '#9a9a9a', accent: '#0057d8', depth: 44 },
|
||||
overrides: {
|
||||
bg: '#ffffff', panel: '#ffffff', layer: '#f4f4f4', border: '#8a8a8a', border2: '#9a9a9a',
|
||||
text: '#0b0c0f', text2: '#3a3f4a', nodeBg: '#ffffff', nodeText: '#0b0c0f', nodeText2: '#3a3f4a', edge: '#111111',
|
||||
},
|
||||
overridesDark: {
|
||||
bg: '#0d0d0d', panel: '#171717', layer: '#222222', border: '#9a9a9a', border2: '#808080',
|
||||
text: '#ffffff', text2: '#c9ccd2', nodeBg: '#1e1e1e', nodeText: '#ffffff', nodeText2: '#c9ccd2', edge: '#ffffff',
|
||||
},
|
||||
sizes: { edgeWidth: 2.4, edgeDash: 'solid', nodeSelWidth: 2 },
|
||||
},
|
||||
{
|
||||
name: '纸质',
|
||||
seeds: { neutral: '#a99a86', accent: '#8a6f4a', depth: 30 },
|
||||
overrides: {
|
||||
bg: '#f6f0e4', panel: '#fdfaf3', layer: '#efe7d7', layer2: '#fffdf8',
|
||||
border: '#ddd0b8', border2: '#d3c4ab', canvasBg: '#efe7d7', gridDot: '#d8cbb4',
|
||||
edge: '#b9a88c', edgeHot: '#8a6f4a',
|
||||
text: '#2f2a22', text2: '#5f574a', nodeText: '#2f2a22', nodeText2: '#5f574a',
|
||||
nodeBg: '#faf6ee',
|
||||
},
|
||||
overridesDark: {
|
||||
bg: '#221f1a', panel: '#2b2721', layer: '#332e27', layer2: '#3a342c',
|
||||
border: '#6b5c49', border2: '#544a3d', canvasBg: '#3b3227', gridDot: '#5a4c3d',
|
||||
edge: '#a2917a', edgeHot: '#e0c9a0',
|
||||
text: '#efe6d8', text2: '#c0b4a1', nodeText: '#efe6d8', nodeText2: '#c0b4a1',
|
||||
nodeBg: '#4a4034',
|
||||
},
|
||||
sizes: { edgeDash: 'solid' },
|
||||
},
|
||||
]
|
||||
|
||||
// ── 外观面板(v3.25.75 重构)───────────────────────────────────────────────
|
||||
// 用户反馈:分组混乱、颜色字段看不出可点、网格三项无效、对比度警告刷屏。
|
||||
// 现在:4 个分组(主题 / 画布 / 连线 / 节点),统一两栏网格(标签 120px + 控件),
|
||||
// 每组组头右侧「恢复本组默认」;颜色统一为「色块 + hex + ▾」;警告收进行尾。
|
||||
// ── 外观面板 ────────────────────────────────────────────────────────────────
|
||||
function AppearanceTab (props) {
|
||||
const draft = (props && props.draft) || {}
|
||||
const setDraft = (props && props.setDraft) || function () {}
|
||||
@@ -255,23 +397,57 @@
|
||||
const setTheme = (props && props.setTheme) || function () {}
|
||||
const applyTheme = (props && props.applyTheme) || function () {}
|
||||
const value = normalize(draft)
|
||||
const set = (patch) => setDraft((d) => Object.assign({}, d, {
|
||||
canvas: Object.assign({}, d.canvas, { appearance: Object.assign({}, normalize(d), patch) }),
|
||||
}))
|
||||
const resetGroup = (keys) => { const p = {}; for (const k of keys) p[k] = DEFAULTS[k]; set(p) }
|
||||
const root = g.document && g.document.documentElement
|
||||
const isDark = !!(root && root.classList && root.classList.contains('theme-dark'))
|
||||
const follow = followTokens(value, isDark) || {}
|
||||
const ov = isDark ? value.overridesDark : value.overrides
|
||||
const modeKey = isDark ? 'overridesDark' : 'overrides'
|
||||
|
||||
// 所有改动都走 normalize 后的完整 v2 结构,避免半截字段写进配置
|
||||
const upd = (fn) => setDraft((d) => {
|
||||
const a = normalize(d)
|
||||
fn(a)
|
||||
return Object.assign({}, d, { canvas: Object.assign({}, d.canvas, { appearance: a }) })
|
||||
})
|
||||
const setSeed = (k, v) => upd((a) => { a.seeds[k] = v })
|
||||
const setSize = (k, v) => upd((a) => { a.sizes[k] = v })
|
||||
const setOv = (k, v) => upd((a) => { a[modeKey] = Object.assign({}, a[modeKey], { [k]: v }) })
|
||||
const clearOv = (k) => upd((a) => { const m = Object.assign({}, a[modeKey]); delete m[k]; a[modeKey] = m })
|
||||
const followVal = (k) => follow[OV_TOKEN[k]] || '#808080'
|
||||
|
||||
const importRef = React.useRef(null)
|
||||
|
||||
const Row = function (label, control, note) {
|
||||
return el('div', { className: 'iwb-appear-row' + (note ? ' iwb-appear-row-note' : '') },
|
||||
const ColorRow = function (label, key, extra) {
|
||||
const has = !!ov[key]
|
||||
return el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label', title: label }, label),
|
||||
el('div', { className: 'iwb-appear-ctrl' }, control),
|
||||
note ? el('span', { className: 'iwb-appear-note' }, note) : null)
|
||||
el('div', { className: 'iwb-appear-ctrl' },
|
||||
el(ColorPicker, { value: has ? ov[key] : followVal(key), onChange: (v) => setOv(key, v) })),
|
||||
el('span', { className: 'iwb-appear-note' },
|
||||
has
|
||||
? el('button', { type: 'button', className: 'iwb-appear-revert', title: '恢复跟随自动配色', onClick: () => clearOv(key) }, '自定义 ↺')
|
||||
: '跟随 ' + followVal(key).toUpperCase(),
|
||||
extra || null))
|
||||
}
|
||||
const Group = function (title, rows, keys) {
|
||||
const TextRow = function (label, key, bgKey) {
|
||||
const fg = ov[key] || followVal(key)
|
||||
const bg = ov[bgKey] || followVal(bgKey)
|
||||
const r = contrast(fg, bg)
|
||||
const cls = r >= 4.5 ? 'ok' : (r >= 3 ? 'warn' : 'bad')
|
||||
return ColorRow(label, key, el('span', { className: 'iwb-ratio ' + cls, title: '与底色的对比度(正文 AA 4.5:1)' }, r.toFixed(1) + ':1'))
|
||||
}
|
||||
const SizeRow = function (label, key, min, max, step, unit) {
|
||||
return el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label', title: label }, label),
|
||||
el('div', { className: 'iwb-appear-ctrl' },
|
||||
el('input', { type: 'range', min, max, step, value: value.sizes[key], className: 'iwb-appear-range', onChange: (e) => setSize(key, Number(e.target.value)) })),
|
||||
el('span', { className: 'iwb-appear-note' }, String(value.sizes[key]) + (unit || '')))
|
||||
}
|
||||
const Group = function (title, rows, note) {
|
||||
return el('section', { className: 'iwb-appear-group' },
|
||||
el('div', { className: 'iwb-appear-ghead' },
|
||||
el('span', { className: 'iwb-appear-gtitle' }, title),
|
||||
keys ? el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => resetGroup(keys) }, '恢复本组默认') : null),
|
||||
note ? el('span', { className: 'iwb-appear-gnote' }, note) : null),
|
||||
rows)
|
||||
}
|
||||
const Seg = function (val, onChange, items) {
|
||||
@@ -282,35 +458,44 @@
|
||||
onClick: () => onChange(item.value),
|
||||
}, item.label)))
|
||||
}
|
||||
const warnOf = function (edge, bg) {
|
||||
const r = contrast(edge, bg)
|
||||
return r < 1.5 ? ('⚠ 对比度 ' + r.toFixed(1) + ':1,可能看不清') : ''
|
||||
}
|
||||
|
||||
// 主题下拉:配色模式 + 全部预设合并(用户裁定:合并)
|
||||
const themeOptions = [{ value: 'theme:light', label: '亮色(节点灰底 + 内容白)' }, { value: 'theme:dark', label: '暗色' }, { value: 'theme:system', label: '跟随系统' }]
|
||||
const presetOptions = PRESETS.map((p) => ({ value: 'preset:' + p.name, label: '预设 · ' + p.name }))
|
||||
.concat(value.presets.map((p, i) => ({ value: 'preset-c:' + i, label: '预设 · ' + p.name })))
|
||||
const onThemePick = (raw) => {
|
||||
if (raw.indexOf('theme:') === 0) {
|
||||
const t = raw.slice(6)
|
||||
const v = (t === 'dark' || t === 'system') ? t : 'light'
|
||||
setTheme(v); applyTheme(v); return
|
||||
}
|
||||
if (raw.indexOf('preset-c:') === 0) {
|
||||
const p = value.presets[Number(raw.slice(9)) || 0]
|
||||
if (p && p.values) set(normalize({ canvas: { appearance: p.values } }))
|
||||
return
|
||||
}
|
||||
if (raw.indexOf('preset:') === 0) {
|
||||
const name = raw.slice(7)
|
||||
const p = PRESETS.find((x) => x.name === name)
|
||||
if (p) set(Object.assign({}, DEFAULTS, p.values))
|
||||
}
|
||||
// 一键把 4 个文字项夹到 4.5:1(用户显式点了才动,不自动改)
|
||||
const fixText = () => {
|
||||
const T = g.IWBThemeTokens
|
||||
if (!T || typeof T.clampText !== 'function') return
|
||||
const bg = ov.bg || followVal('bg')
|
||||
const nbg = ov.nodeBg || followVal('nodeBg')
|
||||
upd((a) => {
|
||||
const m = Object.assign({}, a[modeKey])
|
||||
m.text = T.clampText(m.text || followVal('text'), bg, 4.5)
|
||||
m.text2 = T.clampText(m.text2 || followVal('text2'), bg, 4.5)
|
||||
m.nodeText = T.clampText(m.nodeText || followVal('nodeText'), nbg, 4.5)
|
||||
m.nodeText2 = T.clampText(m.nodeText2 || followVal('nodeText2'), nbg, 4.5)
|
||||
a[modeKey] = m
|
||||
})
|
||||
}
|
||||
const usePreset = (p) => upd((a) => {
|
||||
a.seeds = Object.assign({}, a.seeds, p.seeds || {})
|
||||
a.overrides = Object.assign({}, p.overrides || {})
|
||||
a.overridesDark = Object.assign({}, p.overridesDark || {})
|
||||
a.sizes = Object.assign({}, a.sizes, p.sizes || {})
|
||||
})
|
||||
const savePreset = () => {
|
||||
const name = (g.prompt ? g.prompt('预设名称', '我的配色') : '') || ''
|
||||
if (!name) return
|
||||
upd((a) => {
|
||||
a.presets = a.presets.concat([{
|
||||
name: String(name).slice(0, 20),
|
||||
seeds: Object.assign({}, a.seeds),
|
||||
overrides: Object.assign({}, a.overrides),
|
||||
overridesDark: Object.assign({}, a.overridesDark),
|
||||
sizes: Object.assign({}, a.sizes),
|
||||
}]).slice(0, 12)
|
||||
})
|
||||
}
|
||||
const exportPresets = () => {
|
||||
try {
|
||||
const doc = { version: 1, appearance: Object.assign({}, value, { presets: undefined }) }
|
||||
const doc = { version: 2, appearance: Object.assign({}, value, { presets: undefined }) }
|
||||
const blob = new Blob([JSON.stringify(doc, null, 2)], { type: 'application/json' })
|
||||
const a = g.document.createElement('a')
|
||||
a.href = URL.createObjectURL(blob)
|
||||
@@ -327,82 +512,119 @@
|
||||
const doc = JSON.parse(String(rd.result || '{}'))
|
||||
const src = doc && (doc.appearance || doc)
|
||||
if (!src || typeof src !== 'object') return
|
||||
set(normalize({ canvas: { appearance: src } }))
|
||||
upd((a) => {
|
||||
const n = normalize({ canvas: { appearance: src } })
|
||||
a.seeds = n.seeds; a.overrides = n.overrides; a.overridesDark = n.overridesDark
|
||||
a.sizes = n.sizes
|
||||
})
|
||||
} catch (e) { /* 忽略坏文件 */ }
|
||||
}
|
||||
rd.readAsText(file)
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
const themeGroup = Group('主题', [
|
||||
Row('主题', el('select', {
|
||||
className: 'iwb-input iwb-appear-select', value: 'theme:' + theme,
|
||||
onChange: (e) => onThemePick(e.target.value),
|
||||
}, themeOptions.concat(presetOptions).map((o) => el('option', { key: o.value, value: o.value }, o.label))),
|
||||
'切换配色模式或直接套用预设'),
|
||||
Row('主题色', el(ColorPicker, { value: value.accent, onChange: (v) => set({ accent: v }) }), '按钮 / 端口 / 选中框'),
|
||||
Row('预设', el('div', { className: 'iwb-appear-btns' },
|
||||
el('button', {
|
||||
className: 'iwb-btn iwb-btn-sm',
|
||||
onClick: () => {
|
||||
const name = (g.prompt ? g.prompt('预设名称', '我的配色') : '') || ''
|
||||
if (!name) return
|
||||
const snap = Object.assign({}, value, { presets: undefined })
|
||||
set({ presets: value.presets.concat([{ name: String(name).slice(0, 20), values: snap }]).slice(0, 12) })
|
||||
},
|
||||
}, '保存当前为预设'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: exportPresets }, '导出'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => importRef.current && importRef.current.click() }, '导入'),
|
||||
el('input', { ref: importRef, type: 'file', accept: 'application/json', style: { display: 'none' }, onChange: (e) => { const f = e.target.files && e.target.files[0]; if (f) importFile(f) } }))),
|
||||
], null)
|
||||
|
||||
const canvasGroup = Group('画布', [
|
||||
Row('网格样式', Seg(value.gridStyle, (v) => set({ gridStyle: v, gridOn: v !== 'blank' }), [
|
||||
{ value: 'dots', label: '点' }, { value: 'lines', label: '线' }, { value: 'blank', label: '空白' },
|
||||
]), '空白 = 不显示背景网格'),
|
||||
Row('底色(亮)', el(ColorPicker, { value: value.canvasBgLight, onChange: (v) => set({ canvasBgLight: v }) })),
|
||||
Row('底色(暗)', el(ColorPicker, { value: value.canvasBgDark, onChange: (v) => set({ canvasBgDark: v }) })),
|
||||
Row(value.gridStyle === 'lines' ? '网格线色(亮)' : '网格点(亮)', el(ColorPicker, { value: value.gridDotLight, onChange: (v) => set({ gridDotLight: v }) })),
|
||||
Row(value.gridStyle === 'lines' ? '网格线色(暗)' : '网格点(暗)', el(ColorPicker, { value: value.gridDotDark, onChange: (v) => set({ gridDotDark: v }) })),
|
||||
Row(value.gridStyle === 'lines' ? '网格线粗细' : '网格点大小', el('input', { type: 'range', min: 0.8, max: 2.6, step: 0.1, value: value.gridSize, className: 'iwb-appear-range', onChange: (e) => set({ gridSize: Number(e.target.value) }) }),
|
||||
String(value.gridSize) + 'px'),
|
||||
Row('网格间距', el('input', { type: 'range', min: 16, max: 40, step: 1, value: value.gridGap, className: 'iwb-appear-range', onChange: (e) => set({ gridGap: Number(e.target.value) }) }),
|
||||
String(value.gridGap) + 'px'),
|
||||
], ['canvasBgLight', 'canvasBgDark', 'gridDotLight', 'gridDotDark', 'gridSize', 'gridGap', 'gridOn', 'gridStyle'])
|
||||
|
||||
const edgeGroup = Group('连线', [
|
||||
Row('默认色(亮)', el(ColorPicker, { value: value.edgeColorLight, onChange: (v) => set({ edgeColorLight: v }) }), warnOf(value.edgeColorLight, value.canvasBgLight)),
|
||||
Row('默认色(暗)', el(ColorPicker, { value: value.edgeColorDark, onChange: (v) => set({ edgeColorDark: v }) }), warnOf(value.edgeColorDark, value.canvasBgDark)),
|
||||
Row('粗细', el('input', { type: 'range', min: 1, max: 4, step: 0.1, value: value.edgeWidth, className: 'iwb-appear-range', onChange: (e) => set({ edgeWidth: Number(e.target.value) }) }), String(value.edgeWidth) + 'px'),
|
||||
Row('线型', el('select', { className: 'iwb-input iwb-appear-select', value: value.edgeDash, onChange: (e) => set({ edgeDash: e.target.value }) },
|
||||
el('option', { value: 'solid' }, '实线'), el('option', { value: 'dashed' }, '虚线'), el('option', { value: 'dotted' }, '点线'))),
|
||||
Row('高亮色(亮)', el(ColorPicker, { value: value.edgeHotLight, onChange: (v) => set({ edgeHotLight: v }) }), '仅选中/悬停/临时连线'),
|
||||
Row('高亮色(暗)', el(ColorPicker, { value: value.edgeHotDark, onChange: (v) => set({ edgeHotDark: v }) })),
|
||||
], ['edgeColorLight', 'edgeColorDark', 'edgeWidth', 'edgeDash', 'edgeHotLight', 'edgeHotDark'])
|
||||
|
||||
const nodeGroup = Group('节点', [
|
||||
Row('节点底色(亮)', el(ColorPicker, { value: value.nodeBgLight, onChange: (v) => set({ nodeBgLight: v }) })),
|
||||
Row('节点底色(暗)', el(ColorPicker, { value: value.nodeBgDark, onChange: (v) => set({ nodeBgDark: v }) })),
|
||||
Row('边框色(亮)', el(ColorPicker, { value: value.nodeBorderLight, onChange: (v) => set({ nodeBorderLight: v }) })),
|
||||
Row('边框色(暗)', el(ColorPicker, { value: value.nodeBorderDark, onChange: (v) => set({ nodeBorderDark: v }) })),
|
||||
Row('节点圆角', el('input', { type: 'range', min: 6, max: 20, step: 1, value: value.nodeRadius, className: 'iwb-appear-range', onChange: (e) => set({ nodeRadius: Number(e.target.value) }) }), String(value.nodeRadius) + 'px'),
|
||||
Row('选中描边', el('input', { type: 'range', min: 1, max: 4, step: 0.5, value: value.nodeSelWidth, className: 'iwb-appear-range', onChange: (e) => set({ nodeSelWidth: Number(e.target.value) }) }), String(value.nodeSelWidth) + 'px'),
|
||||
], ['nodeBgLight', 'nodeBgDark', 'nodeBorderLight', 'nodeBorderDark', 'nodeRadius', 'nodeSelWidth'])
|
||||
|
||||
const autoGroup = Group('自动配色', [
|
||||
Row('自动配色', el('label', { className: 'iwb-check' },
|
||||
el('input', { type: 'checkbox', checked: value.auto, onChange: (e) => set({ auto: e.target.checked }) }),
|
||||
'按 4 个种子自动派生整套配色'), '关闭后可逐项手动调节'),
|
||||
Row('中性基调', el(ColorPicker, { value: value.seedNeutral, onChange: (v) => set({ seedNeutral: v, auto: true }) }), '整机灰阶的基准'),
|
||||
Row('画布深浅', el('input', { type: 'range', min: 0, max: 60, step: 1, value: value.depth, className: 'iwb-appear-range', onChange: (e) => set({ depth: Number(e.target.value), auto: true }) }), String(value.depth)),
|
||||
Row('强调色', el(ColorPicker, { value: value.seedAccent, onChange: (v) => set({ seedAccent: v, auto: true }) }), '按钮 / 端口 / 选中框'),
|
||||
], ['auto', 'seedNeutral', 'seedAccent', 'depth'])
|
||||
const summary = [
|
||||
['底色', followVal('bg')], ['面板', followVal('panel')],
|
||||
['节点', followVal('nodeBg')], ['画布', followVal('canvasBg')],
|
||||
['文字', ov.text || followVal('text')], ['强调', ov.brand || followVal('brand')],
|
||||
]
|
||||
|
||||
return el('div', { className: 'iwb-appear' },
|
||||
autoGroup, themeGroup, value.auto ? el('div', { className: 'iwb-appear-note-only' }, '自动配色已开启;关闭后可逐项微调(画布 / 连线 / 节点)。') : canvasGroup, value.auto ? null : edgeGroup, value.auto ? null : nodeGroup,
|
||||
el('div', { className: 'iwb-row', style: { marginTop: 12 } },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => set(Object.assign({}, DEFAULTS, { presets: value.presets })) }, '全部恢复默认')))
|
||||
el('div', { className: 'iwb-appear-mode' },
|
||||
Seg(theme, (v) => { setTheme(v); applyTheme(v) }, [
|
||||
{ value: 'light', label: '亮色' }, { value: 'dark', label: '暗色' }, { value: 'system', label: '跟随系统' },
|
||||
]),
|
||||
el('span', { className: 'iwb-appear-modehint' }, '正在微调:' + (isDark ? '暗色' : '亮色'))),
|
||||
|
||||
Group('配色来源', [
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '中性基调'),
|
||||
el('div', { className: 'iwb-appear-ctrl' }, el(ColorPicker, { value: value.seeds.neutral, onChange: (v) => setSeed('neutral', v) })),
|
||||
el('span', { className: 'iwb-appear-note' }, '整机灰阶基准')),
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '强调色'),
|
||||
el('div', { className: 'iwb-appear-ctrl' }, el(ColorPicker, { value: value.seeds.accent, onChange: (v) => setSeed('accent', v) })),
|
||||
el('span', { className: 'iwb-appear-note' }, '按钮 / 端口 / 选中框')),
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '画布深浅'),
|
||||
el('div', { className: 'iwb-appear-ctrl' },
|
||||
el('input', { type: 'range', min: 0, max: 60, step: 1, value: value.seeds.depth, className: 'iwb-appear-range', onChange: (e) => setSeed('depth', Number(e.target.value)) })),
|
||||
el('span', { className: 'iwb-appear-note' }, String(value.seeds.depth))),
|
||||
el('div', { className: 'iwb-appear-swaches' }, summary.map(([n, c]) => el('span', { key: n, className: 'iwb-appear-sw' },
|
||||
el('i', { style: { background: c } }), n))),
|
||||
], '改这里,下面没动过的项会自动跟着变'),
|
||||
|
||||
Group('界面微调', [
|
||||
ColorRow('底色', 'bg'),
|
||||
ColorRow('面板 / 卡片', 'panel'),
|
||||
ColorRow('边框', 'border'),
|
||||
ColorRow('分隔线', 'border2'),
|
||||
], '只改你动过的项'),
|
||||
|
||||
Group('字体与对比度', [
|
||||
TextRow('界面主文字', 'text', 'bg'),
|
||||
TextRow('界面次文字', 'text2', 'bg'),
|
||||
TextRow('节点主文字', 'nodeText', 'nodeBg'),
|
||||
TextRow('节点次文字', 'nodeText2', 'nodeBg'),
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '对比度修正'),
|
||||
el('div', { className: 'iwb-appear-ctrl' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: fixText }, '把 4 项文字夹到 4.5:1')),
|
||||
el('span', { className: 'iwb-appear-note' }, '徽标 <4.5 时点这里')),
|
||||
], '正文 AA = 4.5:1,低于 3 会难读'),
|
||||
|
||||
Group('画布', [
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '网格样式'),
|
||||
el('div', { className: 'iwb-appear-ctrl' }, Seg(value.sizes.gridStyle, (v) => upd((a) => { a.sizes.gridStyle = v; a.sizes.gridOn = v !== 'blank' }), [
|
||||
{ value: 'dots', label: '点' }, { value: 'lines', label: '线' }, { value: 'blank', label: '空白' },
|
||||
]))),
|
||||
ColorRow('底色', 'canvasBg'),
|
||||
ColorRow('网格点 / 线', 'gridDot'),
|
||||
SizeRow('网格大小', 'gridSize', 0.8, 2.6, 0.1, 'px'),
|
||||
SizeRow('网格间距', 'gridGap', 16, 40, 1, 'px'),
|
||||
], null),
|
||||
|
||||
Group('连线', [
|
||||
ColorRow('默认色', 'edge'),
|
||||
ColorRow('高亮色', 'edgeHot'),
|
||||
SizeRow('粗细', 'edgeWidth', 1, 4, 0.1, 'px'),
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '线型'),
|
||||
el('div', { className: 'iwb-appear-ctrl' },
|
||||
el('select', { className: 'iwb-input iwb-appear-select', value: value.sizes.edgeDash, onChange: (e) => setSize('edgeDash', e.target.value) },
|
||||
el('option', { value: 'solid' }, '实线'), el('option', { value: 'dashed' }, '虚线'), el('option', { value: 'dotted' }, '点线')))),
|
||||
], null),
|
||||
|
||||
Group('节点', [
|
||||
ColorRow('节点底色', 'nodeBg'),
|
||||
SizeRow('圆角', 'nodeRadius', 6, 20, 1, 'px'),
|
||||
SizeRow('选中描边', 'nodeSelWidth', 1, 4, 0.5, 'px'),
|
||||
], '节点文字在上面「字体与对比度」里'),
|
||||
|
||||
Group('预设', [
|
||||
el('div', { className: 'iwb-appear-presets' },
|
||||
PRESETS.map((p) => el('button', { key: p.name, className: 'iwb-btn iwb-btn-sm', onClick: () => usePreset(p) }, p.name)),
|
||||
value.presets.map((p, i) => el('span', { key: 'c' + i, className: 'iwb-appear-preset' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => usePreset(p) }, p.name),
|
||||
el('button', {
|
||||
className: 'iwb-appear-del', title: '删除这个预设',
|
||||
onClick: () => upd((a) => { a.presets = a.presets.filter((_, j) => j !== i) }),
|
||||
}, '✕')))),
|
||||
el('div', { className: 'iwb-appear-btns' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: savePreset }, '保存当前为预设'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: exportPresets }, '导出'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => importRef.current && importRef.current.click() }, '导入'),
|
||||
el('input', { ref: importRef, type: 'file', accept: 'application/json', style: { display: 'none' }, onChange: (e) => { const f = e.target.files && e.target.files[0]; if (f) importFile(f) } }),
|
||||
el('button', {
|
||||
className: 'iwb-btn iwb-btn-sm',
|
||||
onClick: () => upd((a) => { a.seeds = cleanSeeds(null); a.overrides = {}; a.overridesDark = {}; a.sizes = cleanSizes(null) }),
|
||||
}, '全部恢复默认')),
|
||||
], '预设存的是「种子 + 覆盖 + 尺寸」整份快照'),
|
||||
)
|
||||
}
|
||||
|
||||
g.IWBUIApearance = Object.freeze({ DEFAULTS, PRESETS, DASH, normalize, apply, contrast, ColorPicker, AppearanceTab })
|
||||
g.IWBUIApearance = Object.freeze({
|
||||
DEFAULTS, PRESETS, DASH, OV_TOKEN, normalize, apply, followTokens, contrast, ColorPicker, AppearanceTab,
|
||||
})
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -468,9 +468,9 @@
|
||||
let batchSrcTxt = ''
|
||||
const bEdgeT = (props.edges || []).filter((e) => e.to === node.id).map((e) => ({ e, b: (props.nodes || []).find((n) => n.id === e.from) })).find((o) => o.b && o.b.type === 'batch')
|
||||
if (bEdgeT) {
|
||||
const bsrcsT = (props.edges || []).filter((e) => e.to === bEdgeT.b.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
|
||||
const bsrcsT = (props.edges || []).filter((e) => e.to === bEdgeT.b.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, props.edges || [], props.nodes || [])).slice().sort((a, b2) => (a.y - b2.y) || (a.x - b2.x))
|
||||
const tgtT = bEdgeT.e.batchSrcId ? bsrcsT.find((s) => s.id === bEdgeT.e.batchSrcId) : bsrcsT[0]
|
||||
if (tgtT) batchSrcTxt = batchSrcText(tgtT)
|
||||
if (tgtT) batchSrcTxt = batchSrcText(tgtT, props.edges || [], props.nodes || [])
|
||||
}
|
||||
// 透传参考图展示(按来源顺序,像提示词面板)
|
||||
const tRefs = nodePreviewRefsV2(node, props.nodes || [], props.edges || [])
|
||||
@@ -604,7 +604,7 @@
|
||||
const { onUpdate, stop } = ctx
|
||||
// 连接节点:多个来源各自追加统一文案,每个来源对应一对输入/输出端口
|
||||
const d = node.data || {}
|
||||
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, props.edges || [], props.nodes || [])).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const outCount = Object.keys(d.outs || {}).filter((k) => (props.nodes || []).some((n) => n.id === d.outs[k])).length // 兼容旧数据(手动模式下不再自动创建)
|
||||
return el('div', { className: 'iwb-node-body' },
|
||||
el('div', { className: 'iwb-row iwb-gen-head' },
|
||||
|
||||
@@ -241,7 +241,7 @@ function NodeCard(props) {
|
||||
if (hasOut) {
|
||||
if (node.type === 'batch') {
|
||||
// 连接节点:每个输入来源一个输出端口(按来源行均匀分布);无来源时默认 1 对占位端口
|
||||
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n)).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const bsrcs = (props.edges || []).filter((e) => e.to === node.id).map((e) => (props.nodes || []).find((n) => n.id === e.from)).filter((n) => isBatchSrc(n, props.edges || [], props.nodes || [])).slice().sort((a, b) => (a.y - b.y) || (a.x - b.x))
|
||||
const list = bsrcs.length ? bsrcs : [null]
|
||||
const n = list.length
|
||||
list.forEach((bs, bi) => {
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
// iwb-dev-probe: 设计 token 视觉基线(M0/T0.2),不入常规门禁(下划线前缀 + 此标记 = 被 scripts/list-e2e-specs.js 排除)
|
||||
//
|
||||
// 为什么不做成门禁 spec:
|
||||
// ① 截图像素受**字体渲染**(系统是否装同版本中文字体)、**DPR**、**GPU 合成**影响,
|
||||
// 跨机器必然漂移 → 挂门禁就是把机器差异变成 CI 红灯;
|
||||
// ② 它的用途是「我改完这一批,和上一批比 0 diff」,属于本地验收工具,不是代码正确性断言。
|
||||
//
|
||||
// 用法:
|
||||
// npm run build && node scripts/serve-test.js & # 端口 8787
|
||||
// npx playwright test _visual-tokens --update-snapshots # 首次生成/确认变更
|
||||
// npx playwright test _visual-tokens # 比对(0 diff 才算过)
|
||||
//
|
||||
// 6 个场景 × 亮/暗 = 12 张,覆盖「壳层 / 画布 / 浮层 / 抽屉 / 插件面板 / 右键菜单」六类界面。
|
||||
// 稳定化:固定 1280×800 + deviceScaleFactor 1、animations disabled、caret hide、等字体与两帧。
|
||||
|
||||
const { test, expect } = require('./_pw-coverage')
|
||||
|
||||
const baseURL = process.env.IWB_BASE_URL || 'http://127.0.0.1:8787'
|
||||
test.use({ baseURL, viewport: { width: 1280, height: 800 }, deviceScaleFactor: 1 })
|
||||
|
||||
// 预置一张「有东西可看」且**在视口内**的画布:提示词 → 文本 / 组合,组合 → 配置。
|
||||
// 不放 out 节点:它的节点体是一张大卡片,会把画布基线变成「一张图 vs 一堆节点」的对比。
|
||||
const WS = {
|
||||
workspaces: [{
|
||||
id: 'ws_visual', name: '视觉基线', groups: [],
|
||||
nodes: [
|
||||
{ id: 'p1', type: 'prompt', x: 240, y: 180, data: { text: '一只橘猫坐在窗台上,午后阳光,胶片质感' } },
|
||||
{ id: 't1', type: 'textout', x: 600, y: 180, data: {} },
|
||||
{ id: 'c1', type: 'combine', x: 240, y: 400, data: {} },
|
||||
{ id: 'g1', type: 'gen', x: 600, y: 400, data: { size: '1024x1024', n: 1 } },
|
||||
],
|
||||
edges: [
|
||||
{ id: 'e1', from: 'p1', to: 't1' },
|
||||
{ id: 'e2', from: 'p1', to: 'c1' },
|
||||
{ id: 'e3', from: 'c1', to: 'g1' },
|
||||
],
|
||||
}],
|
||||
activeId: 'ws_visual', rev: 1, schemaVersion: 1,
|
||||
}
|
||||
|
||||
const CFG = { providers: [], canvas: {} }
|
||||
|
||||
// 停靠栏状态:左栏停在「节点组」(默认「浏览器」面板在网页环境下只有一句客户端提示,
|
||||
// 「风格库」首帧是异步加载态,两者都不适合做像素基线);右栏默认关,④⑤ 用例自己点开。
|
||||
const DOCK = {
|
||||
left: { open: true, w: 318, list: ['groups', 'browser', 'styles'], removed: [], active: 'groups' },
|
||||
right: { open: false, w: 330, list: ['prompts', 'gallery'], removed: [], active: 'gallery' },
|
||||
}
|
||||
|
||||
// 主题走 iwb_theme(app.js initTheme 的读取键);清掉外观覆盖,保证基线是「出厂派生色」
|
||||
async function seed(page, theme) {
|
||||
await page.addInitScript(({ cfg, ws, dock, theme }) => {
|
||||
localStorage.clear()
|
||||
localStorage.setItem('iwb_web_cfg', JSON.stringify(cfg))
|
||||
localStorage.setItem('iwb_web_workspaces', JSON.stringify(ws))
|
||||
localStorage.setItem('iwb_ws_active', ws.activeId)
|
||||
localStorage.setItem('iwb_theme', theme)
|
||||
localStorage.setItem('iwb.dock.v1', JSON.stringify(dock))
|
||||
}, { cfg: CFG, ws: WS, dock: DOCK, theme })
|
||||
}
|
||||
|
||||
// 等「真的画完了」:字体就绪 + 连续两帧 + 没有正在跑的动画帧(rAF 计数稳定)
|
||||
async function settle(page) {
|
||||
await page.evaluate(() => document.fonts && document.fonts.ready)
|
||||
await page.evaluate(() => new Promise((resolve) => {
|
||||
let left = 3
|
||||
const step = () => { left -= 1; if (left <= 0) resolve(); else requestAnimationFrame(step) }
|
||||
requestAnimationFrame(step)
|
||||
}))
|
||||
await page.waitForTimeout(250) // 少量固定等待:等 CSS 过渡(120ms)收尾;本文件不进门禁,不影响固定等待棘轮
|
||||
}
|
||||
|
||||
async function shot(page, name) {
|
||||
await settle(page)
|
||||
await expect(page).toHaveScreenshot(name + '.png', {
|
||||
animations: 'disabled',
|
||||
caret: 'hide',
|
||||
maxDiffPixels: 0,
|
||||
// threshold 默认 0.2(每像素 YCbCr 距离),`maxDiffPixels: 0` 只是「超阈值的像素数为 0」——
|
||||
// 两者叠加并不等于逐像素精确。B5 踩到:端口描边色改了约 19 级,全被 0.2 吃掉,
|
||||
// 基线没更新、比对还显示 12/12 通过(假绿灯)。这里显式压到 0,让「0 diff」名副其实。
|
||||
threshold: 0,
|
||||
})
|
||||
}
|
||||
|
||||
async function bootHome(page, theme) {
|
||||
await seed(page, theme)
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' })
|
||||
await page.waitForSelector('.iwb-home-card:not(.iwb-home-new)', { timeout: 20000 })
|
||||
await settle(page)
|
||||
}
|
||||
|
||||
async function bootCanvas(page, theme) {
|
||||
await bootHome(page, theme)
|
||||
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
|
||||
await page.waitForSelector('.iwb-canvas:not(.iwb-canvas-hidden)', { timeout: 20000 })
|
||||
await expect(page.locator('.iwb-node')).toHaveCount(4, { timeout: 15000 })
|
||||
// 画布基线关掉左栏:打开时它浮在画布之上 318px,而首次进入的自动取景只按窗口宽度居中
|
||||
// (不避让停靠栏),节点必然被压一半。停靠栏本身由 ④⑤ 两张右栏截图覆盖。
|
||||
const toggle = page.locator('.iwb-top-nav-icon[title="显示 / 隐藏左栏"]').first()
|
||||
await toggle.click()
|
||||
await expect(page.locator('.iwb-dock[data-side="left"]')).toHaveCount(0)
|
||||
await page.waitForTimeout(300)
|
||||
}
|
||||
|
||||
// 右栏默认是关的(dock 状态 right.open=false),必须点顶栏开关;开完等面板挂载
|
||||
async function openRightDock(page) {
|
||||
await page.locator('.iwb-top-nav-icon[title="显示 / 隐藏右栏"]').first().click()
|
||||
await expect(page.locator('.iwb-dock[data-side="right"]')).toBeVisible({ timeout: 15000 })
|
||||
await page.waitForTimeout(400) // 插件面板挂载是异步的(pluginMount effect)
|
||||
}
|
||||
|
||||
for (const theme of ['light', 'dark']) {
|
||||
test.describe('视觉基线 · ' + theme, () => {
|
||||
test('① 首页', async ({ page }) => {
|
||||
await bootHome(page, theme)
|
||||
await shot(page, '01-home-' + theme)
|
||||
})
|
||||
|
||||
test('② 画布(节点 + 连线)', async ({ page }) => {
|
||||
await bootCanvas(page, theme)
|
||||
await shot(page, '02-canvas-' + theme)
|
||||
})
|
||||
|
||||
test('③ 设置弹窗', async ({ page }) => {
|
||||
await bootCanvas(page, theme)
|
||||
await page.locator('button[title="设置"]').first().click()
|
||||
await expect(page.locator('.iwb-settings-modal')).toBeVisible()
|
||||
await shot(page, '03-settings-' + theme)
|
||||
})
|
||||
|
||||
test('④ 库面板(右抽屉 · 图库)', async ({ page }) => {
|
||||
await bootCanvas(page, theme)
|
||||
await openRightDock(page)
|
||||
await shot(page, '04-drawer-gallery-' + theme)
|
||||
})
|
||||
|
||||
test('⑤ 插件面板(右抽屉 · 提示词库)', async ({ page }) => {
|
||||
await bootCanvas(page, theme)
|
||||
await openRightDock(page)
|
||||
await page.locator('.iwb-dock-btn[data-panel="prompts"]').first().click()
|
||||
await expect(page.locator('.iwb-dock[data-side="right"] .iwb-dock-body')).toBeVisible()
|
||||
await shot(page, '05-panel-promptlib-' + theme)
|
||||
})
|
||||
|
||||
test('⑥ 右键菜单', async ({ page }) => {
|
||||
await bootCanvas(page, theme)
|
||||
// 用合成 contextmenu 而不是 mouse.click(button:'right'):后者在 Chromium/macOS 上
|
||||
// 会被节点/顶栏的命中判定吃掉,坐标依赖视口高度 → 基线不可复现。
|
||||
await page.locator('.iwb-canvas').first().dispatchEvent('contextmenu', { clientX: 320, clientY: 520 })
|
||||
await expect(page.locator('.iwb-ctxmenu').first()).toBeVisible()
|
||||
await shot(page, '06-ctxmenu-' + theme)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 70 KiB |
@@ -0,0 +1,143 @@
|
||||
'use strict'
|
||||
// 外观 v2 管线(v3.26.42):种子 → 派生 → 覆盖,一次写完;旧配置可迁移;插件变量名不变。
|
||||
//
|
||||
// 用户报障(2026-11-23):「用了自动配色后再点下面的选项就会破坏自动颜色」「字体颜色不能调」。
|
||||
// 根因是两套系统(手写 14 项 / 派生 26 项)同一批变量、后写覆盖先写:
|
||||
// · 自动配色开着时画布/连线/节点三组被整体隐藏,没有微调入口;
|
||||
// · 「主题色」在自动配色下被 seedAccent 覆盖,等于无效;
|
||||
// · 关掉自动配色后 19 个变量停在派生值 ⇒ 半新半旧、冷启动与热切换不一致。
|
||||
// 现在改成「每项默认跟随派生,改哪项覆盖哪项」,本测试把这几条钉死。
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
|
||||
function loadSandbox () {
|
||||
const g = { React: {} }
|
||||
g.window = g
|
||||
g.globalThis = g
|
||||
new Function('window', fs.readFileSync(path.join(ROOT, 'src', 'theme-tokens.js'), 'utf8'))(g)
|
||||
new Function('window', fs.readFileSync(path.join(ROOT, 'src', 'ui-appearance.js'), 'utf8'))(g)
|
||||
return g
|
||||
}
|
||||
function fakeRoot () {
|
||||
const props = {}
|
||||
return {
|
||||
props,
|
||||
style: { setProperty: (k, v) => { props[k] = v } },
|
||||
setAttribute: function () {},
|
||||
classList: { contains: () => false },
|
||||
}
|
||||
}
|
||||
const wrap = (appearance) => ({ canvas: { appearance } })
|
||||
|
||||
const g = loadSandbox()
|
||||
const A = g.IWBUIApearance
|
||||
const T = g.IWBThemeTokens
|
||||
assert.ok(A && typeof A.apply === 'function', 'ui-appearance 应导出 apply')
|
||||
assert.ok(T && typeof T.derive === 'function', 'theme-tokens 应导出 derive')
|
||||
|
||||
// ① v1 默认(自动配色开着、没动过颜色)→ 迁移成「全部跟随派生」,不得凭空生成覆盖
|
||||
const migrated = A.normalize(wrap({ auto: true, seedNeutral: '#808080', seedAccent: '#6b7280', depth: 22 }))
|
||||
assert.strictEqual(migrated.v, 2)
|
||||
assert.deepStrictEqual(migrated.overrides, {}, 'v1 自动配色下的手写字段不得变成覆盖')
|
||||
assert.deepStrictEqual(migrated.overridesDark, {}, 'v1 自动配色下的手写字段不得变成覆盖(暗)')
|
||||
assert.deepStrictEqual(migrated.seeds, { neutral: '#808080', accent: '#6b7280', depth: 22 })
|
||||
|
||||
// ② v1 明确关掉自动配色 → 那些手写颜色才是用户真实在用的,必须保留成覆盖
|
||||
const legacyOff = A.normalize(wrap({
|
||||
auto: false, canvasBgLight: '#eeeeee', canvasBgDark: '#222222',
|
||||
nodeBgLight: '#ffffff', nodeBorderLight: '#cccccc', accent: '#3366ff',
|
||||
}))
|
||||
assert.strictEqual(legacyOff.overrides.canvasBg, '#eeeeee', 'v1 手写画布底色应迁成亮色覆盖')
|
||||
assert.strictEqual(legacyOff.overridesDark.canvasBg, '#222222', 'v1 手写画布底色应迁成暗色覆盖')
|
||||
assert.strictEqual(legacyOff.overrides.nodeBg, '#ffffff')
|
||||
assert.strictEqual(legacyOff.overrides.border, '#cccccc')
|
||||
assert.strictEqual(legacyOff.seeds.accent, '#3366ff', 'v1 主题色应迁到 seeds.accent(这正是从前在自动配色下失效的那项)')
|
||||
|
||||
// ③ v2 只收已知覆盖键(防止把脏字段写进配置)
|
||||
const cleaned = A.normalize(wrap({ v: 2, seeds: { neutral: '#777777' }, overrides: { text: '#ff0000', evil: '#00ff00' } }))
|
||||
assert.deepStrictEqual(cleaned.overrides, { text: '#ff0000' }, '未知覆盖键应被丢弃')
|
||||
assert.strictEqual(cleaned.seeds.accent, A.DEFAULTS.seeds.accent, '缺省种子应回填默认')
|
||||
|
||||
// ④ 覆盖生效,且 tint 不跟着文字走(否则调一个字等于重排整套灰阶)
|
||||
const base = T.derive(T.DEFAULTS, false)
|
||||
const root = fakeRoot()
|
||||
g.document = { documentElement: root }
|
||||
A.apply(wrap({ v: 2, overrides: { text: '#ff0000' } }), false)
|
||||
assert.strictEqual(root.props['--iwb-text'], '#ff0000', '文字覆盖应生效(字体颜色可调)')
|
||||
assert.strictEqual(root.props['--iwb-tint'], base.tint, 'tint 必须保持派生文字色')
|
||||
assert.notStrictEqual(root.props['--iwb-tint'], '#ff0000', 'tint 不得跟随文字覆盖')
|
||||
|
||||
// ⑤ 节点文字与界面文字互不影响
|
||||
A.apply(wrap({ v: 2, overrides: { nodeText: '#00ff00' } }), false)
|
||||
assert.strictEqual(root.props['--iwb-node-text'], '#00ff00', '节点主文字覆盖应生效')
|
||||
assert.strictEqual(root.props['--iwb-text'], base.text, '改节点文字不得动界面文字')
|
||||
A.apply(wrap({ v: 2, overrides: { text2: '#123456' } }), false)
|
||||
assert.strictEqual(root.props['--iwb-node-text2'], base.nodeText2, '改界面次文字不得动节点次文字')
|
||||
|
||||
// ⑥ 亮/暗覆盖互不串味
|
||||
A.apply(wrap({ v: 2, overrides: { text: '#ff0000' }, overridesDark: { text: '#00ff00' } }), true)
|
||||
assert.strictEqual(root.props['--iwb-text'], '#00ff00', '暗色应使用 overridesDark')
|
||||
const darkBase = T.derive(T.DEFAULTS, true)
|
||||
A.apply(wrap({ v: 2, overrides: { text: '#ff0000' } }), true)
|
||||
assert.strictEqual(root.props['--iwb-text'], darkBase.text, '只有亮色覆盖时,暗色应回到派生值(不得复用亮色值导致不可读)')
|
||||
|
||||
// ⑦ 一次写完:关键变量一个都不能停在「上一次的值」(旧实现关掉自动配色后 19 个变量没重写)
|
||||
A.apply(wrap({ v: 2, seeds: { neutral: '#8b8578', accent: '#7a6a52', depth: 30 } }), true)
|
||||
const required = [
|
||||
'--iwb-bg', '--iwb-canvas-bg', '--iwb-chrome', '--iwb-home-bg', '--iwb-dock-bg', '--iwb-dock-head-bg',
|
||||
'--iwb-panel', '--iwb-layer', '--iwb-layer2', '--iwb-node-bg', '--iwb-border', '--iwb-border2',
|
||||
'--iwb-text', '--iwb-text2', '--iwb-text-dim', '--iwb-node-text', '--iwb-node-text2', '--iwb-tint',
|
||||
'--iwb-surface', '--iwb-hover', '--iwb-brand', '--iwb-on-brand', '--iwb-edge', '--iwb-edge-hot',
|
||||
'--iwb-grid-dot', '--iwb-err', '--iwb-ok', '--iwb-warn',
|
||||
'--iwb-plugin-surface', '--iwb-plugin-card', '--iwb-plugin-inset', '--iwb-plugin-hover',
|
||||
'--iwb-node-radius', '--iwb-node-sel-w', '--iwb-edge-w', '--iwb-edge-dash', '--iwb-grid-size', '--iwb-grid-gap', '--iwb-grid-on',
|
||||
]
|
||||
for (const k of required) assert.ok(Object.prototype.hasOwnProperty.call(root.props, k), '一次写完应包含 ' + k)
|
||||
|
||||
// ⑧ 内置「休息」预设:亮/暗两套都要落在 4.5:1 以上(低刺激但不能读不清)
|
||||
const rest = A.PRESETS.filter((p) => p.name === '休息')[0]
|
||||
assert.ok(rest, '应有「休息」预设')
|
||||
for (const dark of [false, true]) {
|
||||
const t = T.derive(rest.seeds, dark)
|
||||
const ov = dark ? rest.overridesDark : rest.overrides
|
||||
assert.ok(Object.keys(ov).length > 0, '休息预设应给亮/暗都写覆盖')
|
||||
const fg = ov.text || t.text
|
||||
const bg = ov.bg || t.bg
|
||||
const r = T.contrast(fg, bg)
|
||||
assert.ok(r >= 4.5, '休息预设' + (dark ? '暗色' : '亮色') + '正文对比度应 >= 4.5,实际 ' + r.toFixed(2) + ':1')
|
||||
const nfg = ov.nodeText || t.nodeText
|
||||
const nbg = ov.nodeBg || t.nodeBg
|
||||
const nr = T.contrast(nfg, nbg)
|
||||
assert.ok(nr >= 4.5, '休息预设' + (dark ? '暗色' : '亮色') + '节点文字对比度应 >= 4.5,实际 ' + nr.toFixed(2) + ':1')
|
||||
}
|
||||
|
||||
// ⑨ 插件兼容:变量名只增不改(改名 = 插件落到硬编码兜底,暗色下会白底白字)
|
||||
// M3 起 token 定义搬进生成的 src/design-tokens.css(build 时内联在 style.css 之前):
|
||||
// 契约检查要连起来看,否则「插件能引用的变量」会误判为缺失
|
||||
const css = fs.readFileSync(path.join(ROOT, 'style.css'), 'utf8') + '\n' +
|
||||
fs.readFileSync(path.join(ROOT, 'src', 'design-tokens.css'), 'utf8')
|
||||
for (const v of [
|
||||
'--iwb-bg', '--iwb-panel', '--iwb-layer', '--iwb-layer2', '--iwb-border', '--iwb-border2',
|
||||
'--iwb-text', '--iwb-text2', '--iwb-text-dim', '--iwb-brand', '--iwb-on-brand', '--iwb-warn',
|
||||
'--iwb-node-bg', '--iwb-node-radius', '--iwb-canvas-bg', '--iwb-grid-dot',
|
||||
'--iwb-node-text', '--iwb-node-text2', '--iwb-tint', '--iwb-surface', '--iwb-hover',
|
||||
]) {
|
||||
assert.ok(css.indexOf(v + ':') >= 0, 'style.css 必须定义 ' + v + '(插件可能引用)')
|
||||
}
|
||||
assert.ok(/--iwb-plugin-text:\s*var\(--iwb-text\)/.test(css), '插件文字别名仍应指向 --iwb-text')
|
||||
assert.ok(/--iwb-plugin-bg:\s*var\(--iwb-bg\)/.test(css), '插件底色别名仍应指向 --iwb-bg')
|
||||
assert.ok(/--iwb-plugin-surface:/.test(css), '插件面板四层变量应保留')
|
||||
// 节点作用域重映射:插件节点零改动跟随节点文字色
|
||||
assert.ok(/\.iwb-node\s*\{[^}]*--iwb-text:\s*var\(--iwb-node-text\)/.test(css), '.iwb-node 应把 --iwb-text 重映射到 --iwb-node-text')
|
||||
assert.ok(/\.iwb-node\s*\{[^}]*--iwb-text2:\s*var\(--iwb-node-text2\)/.test(css), '.iwb-node 应把 --iwb-text2 重映射到 --iwb-node-text2')
|
||||
|
||||
// ⑩ 自引用声明是无效声明(此前 --iwb-canvas-bg/--iwb-border/--iwb-warn 都是 var(自己))
|
||||
for (const v of ['--iwb-canvas-bg', '--iwb-border', '--iwb-warn']) {
|
||||
const bad = new RegExp(v.replace(/--/, '--') + ':\\s*var\\(' + v + '\\)')
|
||||
assert.ok(!bad.test(css), v + ' 不得自引用')
|
||||
}
|
||||
|
||||
console.log('appearance v2 checks passed(迁移 / 覆盖 / 一次写完 / 休息预设 4.5:1 / 插件变量名不变)')
|
||||
@@ -55,4 +55,28 @@ const s2 = n('s2', 'prompt', { text: 'B' }); s2.y = 10
|
||||
const edges = [{ from: 's1', to: 'b' }, { from: 's2', to: 'b' }]
|
||||
assert.strictEqual(T.combineInputTexts(bs, edges, [bs, s1, s2]).join('|'), 'A-!|B-!')
|
||||
|
||||
// ── 继承态(2026-11-23):提示词承接上游文案后,对外输出就是那条文案 ────────────
|
||||
// 场景:风格库变量节点 → 提示词(自己没写字,节点体显示「继承 · 来自 上一级」)→ 组合节点。
|
||||
// 出图侧一直能拿到文案(resolveNodeTaskValues 的 own || 上游),但组合侧读的是 batchSrcText,
|
||||
// 原来只看 data.text ⇒ 组合里一行都没有。修复后两侧同口径;组合的拼接逻辑本身不动。
|
||||
const up = n('s1', 'plugin:style-source:style', { text: '上游文案', outKind: 'prompt' }); up.x = 0; up.y = 100
|
||||
const inh = n('p1', 'prompt', {}); inh.x = 300; inh.y = 100
|
||||
const inhEdges = [{ from: 's1', to: 'p1' }]
|
||||
assert.strictEqual(T.batchSrcText(inh, inhEdges, [up, inh]), '上游文案')
|
||||
assert.strictEqual(T.isBatchSrc(inh, inhEdges, [up, inh]), true)
|
||||
assert.strictEqual(T.isBatchSrc(inh), false, '不传图时保持旧行为(只看 data.text)')
|
||||
assert.strictEqual(T.combineInputTexts(inh, inhEdges, [up, inh]).join('|'), '上游文案')
|
||||
// 接管态:自己写了字就用自己的,不再透传
|
||||
inh.data.text = '自己的文案'
|
||||
assert.strictEqual(T.batchSrcText(inh, inhEdges, [up, inh]), '自己的文案')
|
||||
inh.data.text = ''
|
||||
// 多路上游:提示词节点不拼合,只取画布顺序第一条(与节点体「继承 · 来自 上一级」一致)
|
||||
const up2 = n('s2', 'plugin:style-source:style', { text: '第二路', outKind: 'prompt' }); up2.x = 0; up2.y = 600
|
||||
assert.strictEqual(T.batchSrcText(inh, [{ from: 's1', to: 'p1' }, { from: 's2', to: 'p1' }], [up, up2, inh]), '上游文案')
|
||||
// 上游停用:不参与
|
||||
const upOff = n('s3', 'plugin:style-source:style', { text: '停用', outKind: 'prompt', enabled: false })
|
||||
assert.strictEqual(T.batchSrcText(n('p2', 'prompt', {}), [{ from: 's3', to: 'p2' }], [upOff]), '')
|
||||
// 环:提示词 ↔ 中继 不死循环
|
||||
assert.strictEqual(T.batchSrcText(n('p3', 'prompt', {}), [{ from: 'r3', to: 'p3' }, { from: 'p3', to: 'r3' }], [n('r3', 'relay', {})]), '')
|
||||
|
||||
console.log('canvas text checks passed')
|
||||
@@ -9,6 +9,8 @@ assert.ok(!source.includes("className: 'iwb-home-card-check'"))
|
||||
assert.ok(source.includes('const [homeSelectedWs, setHomeSelectedWs] = useState([])'))
|
||||
assert.ok(source.includes('homeSelectedWs.includes(w.id)'))
|
||||
assert.ok(source.includes("homeSelectedWs.forEach((id) => (homeView === 'trash' ? purgeWs(id) : trashWs(id)))"))
|
||||
assert.ok(css.includes('.iwb-home-head'))
|
||||
// v3.26.46(M4-B3):首页头部是「左侧栏 + 主区」两栏,旧的 .iwb-home-head 已无生产者(DOM 里 0 次),
|
||||
// 断言改为钉真正在用的布局类。
|
||||
assert.ok(css.includes('.iwb-home-side {') && css.includes('.iwb-home-main {'))
|
||||
assert.ok(css.includes('.iwb-home-card-actions'))
|
||||
console.log('home canvas library checks passed')
|
||||
@@ -16,7 +16,8 @@ const css = fs.readFileSync(path.join(__dirname, '..', 'style.css'), 'utf8')
|
||||
assert.ok(source.includes("shellView === 'home' ? el('div', { className: 'iwb-home-panel' }"))
|
||||
assert.ok(css.includes('.iwb-top-nav { height: 64px;'))
|
||||
assert.ok(!css.includes('.iwb-leftrail'))
|
||||
assert.ok(css.includes('.iwb-fullmask { position: fixed; z-index: 260;'))
|
||||
// M4-B2:全窗口面板的层级改由 token 表达(原裸值 260),顺序约束见 tests/overlay-layer-test.js
|
||||
assert.ok(css.includes('.iwb-fullmask { position: fixed; z-index: var(--iwb-z-sheet);'))
|
||||
// v5 起画布在页面容器内,偏移由容器负责:这里钉住**最终生效**的 0 偏移(旧的 52/64 早已被 !important 覆盖)
|
||||
assert.ok(css.includes('.iwb-canvas, .ws-expanded .iwb-canvas { left: 0 !important; }'))
|
||||
assert.ok(css.includes('.iwb-canvas, .ws-expanded .iwb-canvas { top: 0 !important; }'))
|
||||
|
||||
@@ -594,6 +594,36 @@ test('⑫ 暗色主题下自定义背景色仍能看清深色文字(对比度
|
||||
}
|
||||
})
|
||||
|
||||
test('⑫-b 跟随系统:系统切暗后内联 token 必须一起变(D1)', async ({ page }) => {
|
||||
// 2026-11-23 修 D1(token 三写入者):mq 回调原来只 toggle(theme-dark),不重算 <html> 上的内联 token,
|
||||
// 于是「跟随系统 + 日落自动转暗」会得到壳层暗、画布与节点还是亮色的混色半成品。
|
||||
// 守三件事:class 变了 + --iwb-bg 跟着变 + 变暗(不是换成另一个亮色)。
|
||||
await page.emulateMedia({ colorScheme: 'light' })
|
||||
const WS = { workspaces: [{ id: 'ws_sys', name: '跟随系统', groups: [], nodes: [], edges: [] }], activeId: 'ws_sys', rev: 1, schemaVersion: 1 }
|
||||
await page.addInitScript((d) => {
|
||||
localStorage.clear()
|
||||
localStorage.setItem('iwb_web_cfg', JSON.stringify({ providers: [], canvas: {} }))
|
||||
localStorage.setItem('iwb_web_workspaces', JSON.stringify(d.ws))
|
||||
localStorage.setItem('iwb_ws_active', 'ws_sys')
|
||||
localStorage.setItem('iwb_theme', 'system')
|
||||
}, { ws: WS })
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' })
|
||||
await W.waitHomeReady(page)
|
||||
|
||||
const bgVar = () => page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--iwb-bg').trim())
|
||||
const lumOf = (v) => {
|
||||
const s0 = String(v).trim()
|
||||
const c = s0.charAt(0) === '#' ? [1, 3, 5].map((i) => parseInt(s0.slice(i, i + 2), 16)) : String(s0).match(/[\d.]+/g).slice(0, 3).map(Number)
|
||||
const lin = c.map((x) => { const s = x / 255; return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4) })
|
||||
return 0.2126 * lin[0] + 0.7152 * lin[1] + 0.0722 * lin[2]
|
||||
}
|
||||
const before = await bgVar()
|
||||
await page.emulateMedia({ colorScheme: 'dark' })
|
||||
await expect(page.locator('html')).toHaveClass(/theme-dark/, { timeout: 5000 })
|
||||
await expect.poll(bgVar, { timeout: 5000 }).not.toBe(before)
|
||||
expect(lumOf(await bgVar()), '暗色的 --iwb-bg 必须比亮色更暗(否则就是没重算)').toBeLessThan(lumOf(before))
|
||||
})
|
||||
|
||||
test('⑬ 连接节点来源行与组合节点一致;中继节点改色只染圆环、中间透明', async ({ page }) => {
|
||||
// 2026-11-01 用户要求:
|
||||
// ① 连接(batch)节点的来源行样式与组合(combine)节点**靠齐**(原来 batch 用品牌色淡染,视觉上不一样)
|
||||
|
||||
@@ -99,3 +99,59 @@ test('提示词与文本节点显示上游继承文本,改字即接管、可
|
||||
|
||||
expect(errors, '全程不应有页面 JS 异常').toEqual([])
|
||||
})
|
||||
|
||||
// 2026-11-23 用户报障:提示词接了变量节点后,文案没进组合节点(出图却有)。
|
||||
// 根因是组合侧读 batchSrcText(只看 data.text),继承态提示词 data.text 为空 ⇒ 整路被丢。
|
||||
// 这里钉 DOM:组合节点要出现这一行,且上游改动要跟着变(组合功能本身不变,只是拿到来源)。
|
||||
const SRC2 = '组合里应该出现这段文案'
|
||||
const WS2 = {
|
||||
workspaces: [{
|
||||
id: 'ws_c', name: '继承进组合', groups: [],
|
||||
nodes: [
|
||||
{ id: 'p1', type: 'prompt', x: 140, y: 160, w: 300, h: 200, data: { text: SRC2 } },
|
||||
{ id: 'r1', type: 'relay', x: 520, y: 210, data: {} },
|
||||
{ id: 'p2', type: 'prompt', x: 700, y: 160, w: 300, h: 200, data: {} },
|
||||
{ id: 'cb', type: 'combine', x: 1040, y: 160, w: 300, h: 200, data: {} },
|
||||
],
|
||||
edges: [
|
||||
{ id: 'c1', from: 'p1', to: 'r1' },
|
||||
{ id: 'c2', from: 'r1', to: 'p2' },
|
||||
{ id: 'c3', from: 'p2', to: 'cb' },
|
||||
],
|
||||
}],
|
||||
activeId: 'ws_c', rev: 1,
|
||||
}
|
||||
|
||||
test('提示词(继承态)的文案会进入组合节点,并跟随上游变化', async ({ page }) => {
|
||||
const errors = []
|
||||
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)))
|
||||
await page.addInitScript((d) => {
|
||||
if (localStorage.getItem('iwb_combine_inherit_init') === '1') return
|
||||
localStorage.clear()
|
||||
localStorage.setItem('iwb_combine_inherit_init', '1')
|
||||
localStorage.setItem('iwb_web_workspaces', JSON.stringify(d.ws))
|
||||
localStorage.setItem('iwb_ws_active', 'ws_c')
|
||||
localStorage.setItem('iwb_web_cfg', JSON.stringify(d.cfg))
|
||||
}, { ws: WS2, cfg: CFG })
|
||||
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' })
|
||||
await page.waitForTimeout(700)
|
||||
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
|
||||
await page.waitForTimeout(900)
|
||||
|
||||
// ① 组合节点里应出现继承来的那一行(不是空 + 红字提示)
|
||||
await expect(box(page, 'cb').locator('.iwb-combine-src'), '继承态提示词的文案必须进组合').toHaveCount(1)
|
||||
await expect(box(page, 'cb').locator('.iwb-combine-src')).toContainText(SRC2)
|
||||
await expect(box(page, 'cb').locator('.iwb-err'), '有来源时不应再报「请连接有文本的节点」').toHaveCount(0)
|
||||
|
||||
// ② 跟随上游:改最上游,组合行同步(提示词未接管)
|
||||
await typeInto(page, 'p1', '上游改过之后的文案')
|
||||
await expect(box(page, 'cb').locator('.iwb-combine-src')).toContainText('上游改过之后的文案')
|
||||
|
||||
// ③ 提示词接管后,组合用提示词自己的文案
|
||||
await typeInto(page, 'p2', '提示词自己写的文案')
|
||||
await expect(box(page, 'cb').locator('.iwb-combine-src')).toContainText('提示词自己写的文案')
|
||||
await expect(box(page, 'cb').locator('.iwb-combine-src')).not.toContainText('上游改过之后的文案')
|
||||
|
||||
expect(errors, '全程不应有页面 JS 异常').toEqual([])
|
||||
})
|
||||
@@ -30,7 +30,9 @@ assert.ok(source.includes("inst[id].version"), '应比较 inst[id].version')
|
||||
// v3.25.57:宿主提示词界面下线(改由 promptlib 插件提供),资源中心浮层的 resourceTab 钉点随组件删除
|
||||
assert.ok(!source.includes("resourceTab === 'prompts'"), '宿主不应再保留资源中心提示词 tab 实现')
|
||||
assert.ok(!css.includes('.iwb-leftrail'))
|
||||
assert.ok(css.includes('.iwb-res-tabs {'))
|
||||
assert.ok(css.includes('.iwb-res-tab-active {'))
|
||||
// v3.27.1(M4-B1):这两条与上一行注释矛盾 —— 注释说「随组件删除」,断言却还要求存在。
|
||||
// 现在反过来钉「不得复活」:标签统一到 .iwb-tab / .iwb-tab-active 一套。
|
||||
assert.ok(!css.includes('.iwb-res-tabs {'))
|
||||
assert.ok(!css.includes('.iwb-res-tab-active {'))
|
||||
assert.ok(css.includes('.iwb-overlay.drawer-open .iwb-canvas { left: 0 !important;'))
|
||||
console.log('left resource layout checks passed')
|
||||
@@ -35,7 +35,8 @@ assert.deepStrictEqual(specsBase, expectedSpecs, '门禁 spec 必须等于全部
|
||||
assert.strictEqual(result.specs.length, 52, '当前门禁应自动发现 52 个 spec')
|
||||
// 排除集合 = 全部人工 dev 探针,且都必须已声明标记
|
||||
// 4 = 3 + _probe-tab-switch(切画布标签耗时归因:四轮对照实验,只读诊断)
|
||||
assert.deepStrictEqual(excludedBase, ['_perf-baseline.spec.js', '_plugin-host-probe.spec.js', '_probe-drag.spec.js', '_probe-tab-switch.spec.js'], '被排除的应是全部带 iwb-dev-probe 标记的 dev 探针')
|
||||
// 5 = 4 + _visual-tokens(设计 token 视觉基线:像素受字体/DPR 影响,不入 CI,本地 0 diff 验收用)
|
||||
assert.deepStrictEqual(excludedBase, ['_perf-baseline.spec.js', '_plugin-host-probe.spec.js', '_probe-drag.spec.js', '_probe-tab-switch.spec.js', '_visual-tokens.spec.js'], '被排除的应是全部带 iwb-dev-probe 标记的 dev 探针')
|
||||
|
||||
// 结构不变量:两集合无交集 + 并集 == 磁盘上全部 spec
|
||||
assert.strictEqual(result.specs.length + result.excluded.length, all.length, 'specs + excluded 必须等于磁盘全部')
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// B5 节点:三条不变量
|
||||
//
|
||||
// 这一批的病灶和 B3/B4 同源,但表现更狠:节点卡内部的控件沿用了「面板」的表面色
|
||||
// (--iwb-layer / --iwb-layer2)。深色下这两个值是 #161616 / #1c1c1c,而节点卡是 #3d3d3d ——
|
||||
// 端口就成了一颗嵌在卡片上的纯黑洞(差 39 级),任务卡里的等待按钮同理。
|
||||
// 按 D10 的相对派生原则:**控件明暗由贴着的那张卡片决定**,节点卡内一律用 --iwb-field。
|
||||
//
|
||||
// 另一类:浮条底是 --iwb-panel,子项 hover 也用 --iwb-layer2,深色下两者都是 #1c1c1c,
|
||||
// hover 完全没有反馈 —— 这类「改数字不生效」只能靠断言兜。
|
||||
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const root = path.join(__dirname, '..')
|
||||
const css = fs.readFileSync(path.join(root, 'style.css'), 'utf8')
|
||||
|
||||
// 按 } 切块,取每块选择器的最后一行(多选择器组只影响可读性,不影响 body)
|
||||
const blocks = []
|
||||
for (const chunk of css.split('}')) {
|
||||
const i = chunk.lastIndexOf('{')
|
||||
if (i < 0) continue
|
||||
const sel = chunk.slice(0, i).split('\n').filter((l) => l.trim()).pop() || ''
|
||||
blocks.push({ sel: sel.trim(), body: chunk.slice(i + 1) })
|
||||
}
|
||||
|
||||
const NODE_SCOPE = /^\.iwb-(node|gen|port|relay|conn|lod|ref|resize|task|size)/
|
||||
const nodeBlocks = blocks.filter((b) => NODE_SCOPE.test(b.sel))
|
||||
|
||||
// ── 1. 节点卡内部不许用「面板表面色」 ──
|
||||
// 浮条例外:它是浮层(底就是 --iwb-panel),不贴在卡片上。
|
||||
const PANEL_SURFACE = /background(?:-color)?:\s*var\(--iwb-(?:layer|layer2|panel)\)/
|
||||
const offenders = nodeBlocks
|
||||
.filter((b) => !/floatbar/.test(b.sel))
|
||||
.filter((b) => PANEL_SURFACE.test(b.body))
|
||||
.map((b) => b.sel)
|
||||
assert.deepStrictEqual(
|
||||
offenders,
|
||||
[],
|
||||
'节点卡内部的控件必须用 --iwb-field(深色下 layer/layer2 #161616/#1c1c1c 打在节点卡 #3d3d3d 上等于黑洞)'
|
||||
)
|
||||
|
||||
// 端口是本批的「样板」:它的底色必须是 field,三个态都不能退回 layer/panel
|
||||
const port = blocks.find((b) => b.sel === '.iwb-port')
|
||||
assert.ok(port, '找不到 .iwb-port 规则')
|
||||
assert.ok(port.body.includes('background: var(--iwb-field)'), '.iwb-port 底色必须是 --iwb-field')
|
||||
// 描边必须由文字色派生:深色下 --iwb-border2 是 #4d4d4d,与填充 --iwb-field(#494949) 同色,
|
||||
// 描边等于没有,12px 的小圆点会糊成一团。这条断言守的是「边缘锐度」而不只是「颜色对」。
|
||||
assert.ok(
|
||||
/border:\s*1\.5px solid color-mix\(in srgb, var\(--iwb-text\)/.test(port.body),
|
||||
'.iwb-port 描边必须由 --iwb-text 派生(--iwb-border2 在深色下与填充同色,端口边缘会糊)'
|
||||
)
|
||||
for (const sel of ['.iwb-node:hover .iwb-port', '.iwb-port:hover', '.iwb-node-selected .iwb-port:not(.iwb-port-linked)']) {
|
||||
const b = blocks.find((x) => x.sel === sel)
|
||||
assert.ok(b, '找不到规则:' + sel)
|
||||
assert.ok(
|
||||
!/var\(--iwb-(?:layer|layer2|panel)\)/.test(b.body),
|
||||
sel + ' 不能用面板表面色 —— 端口贴在节点卡上,深色下会变成黑洞'
|
||||
)
|
||||
}
|
||||
|
||||
// ── 2. 节点区字号必须走档位,不写死 ──
|
||||
// 例外:8px / 10px 是微缩徽标(序号角标、图片计数),闭集最低档 11px 会把它们撑出圆点;
|
||||
// 14px 是尺寸自定义输入(属于图像设置浮层,不在节点卡内)。
|
||||
const MICRO = new Set(['8px', '10px', '14px'])
|
||||
const bareFont = []
|
||||
for (const b of nodeBlocks) {
|
||||
for (const m of b.body.matchAll(/font-size:\s*([\d.]+px)/g)) {
|
||||
if (!MICRO.has(m[1])) bareFont.push(b.sel + ' → ' + m[1])
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(bareFont, [], '节点区字号必须用 --iwb-font-*,不写死 px(微缩徽标 8/10px 除外)')
|
||||
|
||||
// ── 3. 节点区间距与圆角同样走档位 ──
|
||||
// 例外:端口热区 inset 是负数(扩大点击区,不是节奏值);圆角只允许 token 或 50%/2px(圆形与占位条)
|
||||
const bareSpace = []
|
||||
for (const b of nodeBlocks) {
|
||||
for (const m of b.body.matchAll(/(?:padding|margin|gap)(?:-(?:top|right|bottom|left))?:\s*([^;}]+)/g)) {
|
||||
if (/(^|[\s(])\d+px/.test(m[1])) bareSpace.push(b.sel + ' → ' + m[0].trim())
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(bareSpace, [], '节点区间距必须用 --iwb-space-*,不写死 px')
|
||||
|
||||
const bareRadius = []
|
||||
for (const b of nodeBlocks) {
|
||||
for (const m of b.body.matchAll(/border-radius:\s*([\d.]+px)/g)) {
|
||||
if (m[1] !== '2px') bareRadius.push(b.sel + ' → ' + m[1])
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(bareRadius, [], '节点区圆角必须用 --iwb-radius-*,不写死 px(2px 占位条除外)')
|
||||
|
||||
// ── 4. 已删除的死规则不许回来 ──
|
||||
// 判据:dist/app.js 与 plugins/** 里都是 0 次(尺寸/质量行已并入图像设置浮层)。
|
||||
const DEAD = [
|
||||
'.iwb-gen-sizerow', '.iwb-gen-qualityrow', '.iwb-gen-tag',
|
||||
'.iwb-size-x', '.iwb-size-align', '.iwb-size-badge',
|
||||
]
|
||||
for (const cls of DEAD) {
|
||||
const re = new RegExp('\\' + cls + '(?![-A-Za-z0-9_])')
|
||||
assert.ok(!re.test(css), cls + ' 已确认无生产者(DOM 与插件都不再产出),不该重新出现')
|
||||
}
|
||||
|
||||
console.log('node scope checks passed(端口用 field / ' + nodeBlocks.length + ' 条节点规则字号·间距·圆角全走档位 / ' + DEAD.length + ' 个死类名不复现)')
|
||||
@@ -0,0 +1,75 @@
|
||||
// 浮层层级守卫(M4-B2)
|
||||
//
|
||||
// 为什么要有这个测试:z-index 是「没有类型、没有报错、错了只在特定操作顺序下露馅」的那类东西。
|
||||
// 迁移前 42 种裸值散在 2400 行 CSS 里,靠人肉比大小,出过两次真 bug:
|
||||
// ① toast(200) < 弹窗(300) → 在弹窗/确认框里点「保存」,成功提示被盖住,用户以为没生效;
|
||||
// ② 资源中心右键菜单(91) 被全窗口面板(260) 盖住 → 当时靠给这一个选择器打 270 补丁。
|
||||
// 现在层级只在 src/design-tokens.css(生成产物)里定义一次,组件引名字。本测试钉三件事:
|
||||
// 1. 浮层族**不许再写裸数字**(防止回潮,M5 的 token-lint 会扩到全仓);
|
||||
// 2. 引用的 --iwb-z-* 必须真的定义过(拼错名字时 z-index 变成无效声明,静默退化为 auto);
|
||||
// 3. 四条顺序关系成立(见下面 INVARIANTS)。
|
||||
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const css = fs.readFileSync(path.join(ROOT, 'style.css'), 'utf8')
|
||||
const tokens = fs.readFileSync(path.join(ROOT, 'src/design-tokens.css'), 'utf8')
|
||||
|
||||
// 层级表(生成产物里的 --iwb-z-*)
|
||||
const z = {}
|
||||
for (const m of tokens.matchAll(/(--iwb-z-[a-z-]+)\s*:\s*(\d+)\s*;/g)) z[m[1]] = Number(m[2])
|
||||
assert.ok(Object.keys(z).length >= 10, '--iwb-z-* 层级表缺失或过短:' + Object.keys(z).join(', '))
|
||||
|
||||
// 1. 顺序关系。改数值前先想清楚这三条,测试只负责在你改错时喊停。
|
||||
const INVARIANTS = [
|
||||
['toast 必须高于弹窗(弹窗里点保存要能看到提示)', '--iwb-z-toast', '--iwb-z-modal'],
|
||||
['弹窗必须高于全窗口面板', '--iwb-z-modal', '--iwb-z-sheet'],
|
||||
['面板内 portal 菜单要高于面板本身(否则被自己的容器盖住)', '--iwb-z-sheet-menu', '--iwb-z-sheet'],
|
||||
['面板内 portal 菜单不许越过弹窗(它是子菜单,不是新一层)', '--iwb-z-modal', '--iwb-z-sheet-menu'],
|
||||
['右键菜单高于右键遮罩(同一次点击里成对出现)', '--iwb-z-ctx-menu', '--iwb-z-ctx'],
|
||||
['右键菜单低于全窗口面板(面板开在菜单之上是正确方向)', '--iwb-z-sheet', '--iwb-z-ctx-menu'],
|
||||
['确认框/崩溃屏在最上层', '--iwb-z-alert', '--iwb-z-anchor'],
|
||||
['锚定浮层高于弹窗(外观面板挂在设置弹窗里)', '--iwb-z-anchor', '--iwb-z-modal'],
|
||||
['启动页高于弹窗(启动阶段不该被任何浮层穿透)', '--iwb-z-splash', '--iwb-z-modal'],
|
||||
]
|
||||
for (const [why, higher, lower] of INVARIANTS) {
|
||||
assert.ok(z[higher] != null, '未定义:' + higher)
|
||||
assert.ok(z[lower] != null, '未定义:' + lower)
|
||||
assert.ok(z[higher] > z[lower], `${why}:${higher}(${z[higher]}) 必须 > ${lower}(${z[lower]})`)
|
||||
}
|
||||
|
||||
// 2. 浮层族的声明里不许出现裸数字 z-index。
|
||||
// 只查这 16 个选择器(它们构成「谁盖谁」的全部边界);画布内的端口/手柄是局部堆叠,不在此列。
|
||||
const OVERLAYS = [
|
||||
'.iwb-modal-mask', '.iwb-fullmask', '.iwb-command-mask', '.iwb-command',
|
||||
'.iwb-ctxmask', '.iwb-ctxmenu', '.iwb-toast', '.iwb-pop-anchor',
|
||||
'.iwb-ws-more', '.iwb-splash', '.iwb-imgpreview', '.iwb-crash-screen',
|
||||
'.iwb-confirm-overlay', '.iwb-bg-palette-host',
|
||||
]
|
||||
const lines = css.split('\n')
|
||||
for (const sel of OVERLAYS) {
|
||||
for (const line of lines) {
|
||||
if (!line.startsWith(sel + ' ') && !line.startsWith(sel + '{')) continue
|
||||
const m = line.match(/z-index:\s*(-?\d+)/)
|
||||
assert.ok(!m, `${sel} 还在写裸 z-index: ${m && m[1]},请改用 --iwb-z-*(层级表在 design-tokens.css)`)
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 引用的 z token 必须存在(拼错 → 声明无效 → 静默退化成 auto,最难查的一类)
|
||||
for (const m of css.matchAll(/z-index:\s*var\((--iwb-z-[a-z-]+)\)/g)) {
|
||||
assert.ok(z[m[1]] != null, '引用了不存在的层级 token:' + m[1])
|
||||
}
|
||||
|
||||
// 4. toast 必须 portal 到 body —— 只改 CSS 数字治不好这条。
|
||||
// `.iwb-overlay` 自己带 z-index(100),是一个**堆叠上下文**:挂它里面的 toast 无论写多高,
|
||||
// 整个子树都被封在 100 这一层里,压不过 portal 到 body 的弹窗(300)。这正是历史 bug
|
||||
// 「弹窗里点保存看不到成功提示」的真正成因(2026-11-23 实测:改数字无效,portal 才有效)。
|
||||
const appSrc = fs.readFileSync(path.join(ROOT, 'app.js'), 'utf8')
|
||||
assert.ok(
|
||||
/ReactDOM\.createPortal\(el\('div', \{ className: 'iwb-toast/.test(appSrc),
|
||||
'toast 必须 ReactDOM.createPortal 到 document.body:.iwb-overlay 是堆叠上下文,内联渲染的 toast 永远压不过弹窗'
|
||||
)
|
||||
|
||||
console.log('overlay layer checks passed(层级表 ' + Object.keys(z).length + ' 档,' + INVARIANTS.length + ' 条顺序约束,toast portal 已钉)')
|
||||
@@ -13,7 +13,9 @@ const source = uiAllSrc()
|
||||
// 「不该出现的视图里不出现」(如首页不应有 .iwb-canvas-topbar / .iwb-fullmask)。
|
||||
// 被替换的 class:iwb-home-side / iwb-home-panel / iwb-canvas-topbar / iwb-fullmask /
|
||||
// iwb-res-tab / iwb-home-card-title / iwb-home-card-foot / iwb-canvas-meta
|
||||
const css = fs.readFileSync(path.join(__dirname, '..', 'style.css'), 'utf8')
|
||||
// M3 起 token(:root / .theme-dark)在生成的 src/design-tokens.css 里,组件规则仍在 style.css
|
||||
const css = fs.readFileSync(path.join(__dirname, '..', 'style.css'), 'utf8') + '\n' +
|
||||
fs.readFileSync(path.join(__dirname, '..', 'src', 'design-tokens.css'), 'utf8')
|
||||
assert.ok(source.includes("lsRawGet('iwb_shell_view'")) // 2026-11-06 存储收敛:改为统一 helper 入口
|
||||
assert.ok(source.includes("panel: '<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"/><path d=\"M9 3v18\"/>'"))
|
||||
assert.ok(source.includes("const [enteringWs, setEnteringWs] = useState(false)"))
|
||||
@@ -40,11 +42,17 @@ assert.ok(source.includes('if (!homeManage) openCanvasEditor(w.id)'))
|
||||
assert.ok(source.includes("iwb-rename-input"))
|
||||
assert.ok(source.includes("'确定彻底删除画布「' + (w.name || '未命名画布') + '」?此操作不可恢复。'"))
|
||||
assert.ok(!source.includes('Codex 未连接'))
|
||||
assert.ok(css.includes('.iwb-res-tabs'))
|
||||
assert.ok(css.includes('.iwb-home-card-title strong { font-size: 15px;'))
|
||||
// v3.27.1(M4-B1):标签收敛为唯一一套。资源中心的三段式页签已随新 UI 下线(dist 里
|
||||
// iwb-res-tab 出现 0 次,只剩 e2e 里的过时 locator),这里反过来断言它不得复活。
|
||||
assert.ok(!css.includes('.iwb-res-tabs'), 'v3.27.1:资源中心旧页签已删除,统一到 .iwb-tab')
|
||||
assert.ok(!css.includes('.iwb-drawer-tab'), 'v3.27.1:抽屉页签已删除(已被停靠栏取代)')
|
||||
assert.ok(!css.includes('.iwb-rail-tab'), 'v3.27.1:右竖栏页签已删除(无生产者)')
|
||||
// v3.26.46(M4-B3):字号改钉「档位」而不是像素值 —— 之前钉 `font-size: 15px`,
|
||||
// 迁到 token 后这种断言会红,但它真正要保护的是「卡片标题用 lg 档」这个层级关系。
|
||||
assert.ok(/\.iwb-home-card-title strong \{[^}]*font-size: var\(--iwb-font-lg\)/.test(css), 'v3.26.46:卡片标题应为 font-lg 档')
|
||||
// v3.1.0 首页灰色系:蓝 accent 清零(激活项/胶囊/chip/星标全走墨色或灰阶)
|
||||
assert.ok(/\.iwb-tab-home\.iwb-tab-active \{[^}]*background: transparent/.test(css)) // 首页按钮无选中底色
|
||||
assert.ok(/\.iwb-home-card \{[^}]*color-mix\(in srgb, var\(--iwb-panel\) 52%, var\(--iwb-home-bg\) 48%\)/.test(css)) // v3.1.0-pre.26:卡片随底色提亮,仍亮于首页底
|
||||
assert.ok(/\.iwb-home-card \{[^}]*background: var\(--iwb-bg-menu\)/.test(css)) // v3.26.44:卡片改用浮起层(亮=面板色,暗=比面板亮一档)
|
||||
assert.ok(!source.includes('iwb-home-card-active')) // 无「默认必有一个选中卡」的伪选中态
|
||||
assert.ok(!/\.iwb-home-card-cat \{[^}]*iwb-brand/.test(css))
|
||||
assert.ok(!/\.iwb-home-side-item\.active \{[^}]*iwb-brand/.test(css))
|
||||
@@ -57,8 +65,16 @@ assert.ok(/\.iwb-home-main-head \.iwb-btn \{[^}]*color-mix/.test(css))
|
||||
assert.ok(/\.iwb-home-main-head \.iwb-btn-primary \{[^}]*var\(--iwb-text2\)/.test(css))
|
||||
assert.ok(/\.iwb-home-search \.iwb-input \{[^}]*color-mix/.test(css))
|
||||
// v3.1.0 全灰阶收口:品牌 token=同亮度灰;画布选中标签=亮灰;app 内无蓝色 hex(节点色/连线)
|
||||
assert.ok(css.includes('--iwb-brand: var(--iwb-text2)'), '品牌色默认跟随文字二级色(v3.25.83);自动配色会改写这个变量')
|
||||
assert.ok(/\.iwb-tab-active \{ background: color-mix\(in srgb, var\(--iwb-text\) 9%, transparent\)/.test(css))
|
||||
// v3.26.44 修正(D7):品牌色曾退化为 `var(--iwb-text2)` —— 主按钮与次要文字同值,没有强调语义。
|
||||
// 现在恢复成真正的强调色种子;「文字版」另拆 --iwb-brand-text(按对比度夹紧,暗色会明显更亮)。
|
||||
assert.ok(css.includes('--iwb-brand: #6b7280'), 'v3.26.44:品牌色恢复为独立强调色(D7),不再等于 --iwb-text2')
|
||||
assert.ok(css.includes('--iwb-brand-text:'), '品牌色的文字版必须独立存在(暗色下填充色当文字只有 3.9:1)')
|
||||
// v3.26.42:半透明底色的基色由 --iwb-text 换成 --iwb-tint(tint 默认 = 派生文字色,视觉不变;
|
||||
// 分离的目的:外观面板调字体颜色时,悬停/标签/分隔底色不被连带改掉)
|
||||
// v3.27.1(M4-B1):激活态收敛为唯一一条 —— 品牌淡底 + 品牌字 + 600。
|
||||
// 此前是 tint 9% 中性底,与「选中=品牌高亮」的设计语言不一致;5 套变体各写一份也已删除。
|
||||
assert.ok(/\.iwb-tab-active \{ background: color-mix\(in srgb, var\(--iwb-brand\) 14%, transparent\); color: var\(--iwb-text\)/.test(css), 'v3.27.1:标签激活态应为品牌淡底 + 主文字色')
|
||||
assert.ok(/\.iwb-tab \{[^}]*height: var\(--iwb-tab-h\)[^}]*border-radius: var\(--iwb-tab-radius\)/.test(css), 'v3.27.1:标签高度/圆角必须走 token')
|
||||
assert.ok(!/(#4f6ef7|#6366f1|#3b82f6|#0ea5e9|#8b5cf6)/i.test(css))
|
||||
assert.ok(!/(#4f6ef7|#6366f1|#3b82f6|#0ea5e9|#8b5cf6|#f59e0b|#10b981)/i.test(source))
|
||||
// v3.1.0 资源中心面板灰阶化:选中分类胶囊=浅白灰、标签/星标/页签/高亮全去蓝;首页改名按钮去底色
|
||||
@@ -80,8 +96,10 @@ assert.ok(source.includes("title: '显示 / 隐藏左栏'") && source.includes("
|
||||
assert.ok(css.includes('.iwb-landing-actions .iwb-btn { min-height: 42px;'))
|
||||
// 合并后规则变紧凑,用正则匹配(属性顺序/空白不敏感)
|
||||
assert.ok(/\.iwb-home-card-actions\s*\{[^}]*opacity:\s*0/.test(css))
|
||||
assert.ok(css.includes('.iwb-home-card.iwb-manage .iwb-home-card-check { display: inline-block; }'))
|
||||
// v3.26.46(M4-B3):批量管理早已改为「点卡片=选中」,复选框元素不再渲染,
|
||||
// 对应两条 .iwb-home-card-check 规则一并删除 —— 这里反向断言它不得复活。
|
||||
assert.ok(!css.includes('.iwb-home-card-check'), 'v3.26.46:复选框样式已删除(管理模式下点卡片即选中)')
|
||||
// 合并后规则变紧凑;且最终生效列宽是 230px(300px 的旧定义早已被覆盖)
|
||||
assert.ok(/\.iwb-home-grid\s*\{[^}]*repeat\(auto-fill,\s*minmax\(230px/.test(css))
|
||||
assert.ok(css.includes('.iwb-home-card-foot small { color: var(--iwb-text2); font-size: 12px; line-height: 1.4; white-space: nowrap;'))
|
||||
assert.ok(/\.iwb-home-card-foot small \{[^}]*color: var\(--iwb-text2\)[^}]*font-size: var\(--iwb-font-sm\)[^}]*line-height: 1\.4[^}]*white-space: nowrap/.test(css), 'v3.26.46:卡片脚注应走 font-sm 档 + 单行省略')
|
||||
console.log('page chrome regression checks passed')
|
||||
@@ -33,7 +33,7 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
{ id: 'q3', name: '未分组的一条', text: '没有分组的', tags: [], group: '' },
|
||||
]
|
||||
let groups = [{ id: '小红书', name: '小红书' }, { id: '收藏', name: '收藏' }]
|
||||
const calls = { save: 0, insert: [], copy: [], notify: [] }
|
||||
const calls = { save: 0, insert: [], copy: [], notify: [], create: [] }
|
||||
let panel = null
|
||||
|
||||
const ctx = {
|
||||
@@ -46,11 +46,23 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
notify: (t, ty) => { calls.notify.push([t, ty]) },
|
||||
onChanged: () => () => {},
|
||||
},
|
||||
canvasWrite: {
|
||||
createImageNode: (payload) => { calls.create.push({ type: 'img', payload }); return 'n-img' },
|
||||
createNode: (type, x, y, data) => { calls.create.push({ type, x, y, data }); return 'n1' },
|
||||
},
|
||||
canvas: {
|
||||
screenToWorld: (x, y) => ({ x, y }),
|
||||
|
||||
},
|
||||
}
|
||||
registered.f(ctx)
|
||||
assert.ok(panel && typeof panel.mount === 'function', '应注册面板')
|
||||
|
||||
const host = window.document.getElementById('host')
|
||||
const plCanvas = window.document.createElement('div')
|
||||
plCanvas.className = 'iwb-canvas'
|
||||
window.document.body.appendChild(plCanvas)
|
||||
plCanvas.getBoundingClientRect = () => ({ left: 0, top: 0, right: 800, bottom: 600, width: 800, height: 600 })
|
||||
panel.mount(host) // 宿主只传一个参数
|
||||
await wait(60)
|
||||
|
||||
@@ -84,26 +96,33 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
const back = host.querySelector('.iwb-chip-active')
|
||||
assert.ok(back && back.textContent.indexOf('小红书') === 0, '「×」清空后应回到「小红书」,实际 ' + (back && back.textContent))
|
||||
|
||||
// 拖拽 payload
|
||||
// v1.6.15:改为指针拖拽插入(与风格库一致),不再走 HTML5 dataTransfer
|
||||
const canvasEl = window.document.createElement('div')
|
||||
canvasEl.className = 'iwb-canvas'
|
||||
window.document.body.appendChild(canvasEl)
|
||||
canvasEl.getBoundingClientRect = () => ({ left: 0, top: 0, right: 800, bottom: 600, width: 800, height: 600 })
|
||||
const card = cards()[0]
|
||||
const store = {}
|
||||
const dragEvt = new window.Event('dragstart', { bubbles: true })
|
||||
dragEvt.dataTransfer = { setData: (k, v) => { store[k] = v }, effectAllowed: '' }
|
||||
card.dispatchEvent(dragEvt)
|
||||
assert.ok(store['application/x-iwb-promptid'], '拖拽应带提示词 id')
|
||||
assert.strictEqual(JSON.parse(store['application/x-iwb-prompt']).text, '生成小红书封面图', '拖拽应带正文 payload')
|
||||
card.dispatchEvent(new window.MouseEvent('pointerdown', { bubbles: true, clientX: 40, clientY: 40, button: 0 }))
|
||||
window.dispatchEvent(new window.MouseEvent('pointermove', { bubbles: true, clientX: 70, clientY: 70 }))
|
||||
window.dispatchEvent(new window.MouseEvent('pointermove', { bubbles: true, clientX: 300, clientY: 200 }))
|
||||
assert.ok(window.document.querySelector('.iwb-plp-dragghost'), '拖动时应出现幽灵卡片')
|
||||
window.dispatchEvent(new window.MouseEvent('pointerup', { bubbles: true, clientX: 300, clientY: 200 }))
|
||||
await wait(20)
|
||||
assert.strictEqual(calls.create.length, 1, '拖入画布应调用 createNode')
|
||||
assert.strictEqual(calls.create[0].type, 'prompt', '无变量应插入普通提示词节点')
|
||||
assert.strictEqual(calls.create[0].data.text, '生成小红书封面图', '插入应带正文')
|
||||
|
||||
// v1.1.0:单击卡片 → 详情(只读),再点「编辑」→ 浮层
|
||||
card.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
// v1.6.12:双击卡片 → 详情(只读),再点「编辑」→ 浮层
|
||||
card.dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
|
||||
await wait(40)
|
||||
const dlg = window.document.querySelector('.iwb-plp-dialog')
|
||||
assert.ok(dlg && dlg.querySelector('.iwb-plp-dtext'), '单击卡片应打开详情弹窗(长文区)')
|
||||
assert.ok(dlg && dlg.querySelector('.iwb-plp-dtext'), '双击卡片应打开详情弹窗(长文区)')
|
||||
const editBtn = Array.from(dlg.querySelectorAll('.iwb-plp-dhead button')).find((b) => b.textContent === '编辑')
|
||||
assert.ok(editBtn, '详情页应有「编辑」按钮')
|
||||
editBtn.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
await wait(40)
|
||||
const editor = window.document.querySelector('.iwb-plp-dialog-edit')
|
||||
assert.ok(editor, '单击卡片应打开编辑浮层')
|
||||
assert.ok(editor, '详情里点编辑应打开编辑浮层')
|
||||
const nameIn = editor.querySelector('input.iwb-input')
|
||||
nameIn.value = '小红书封面(改)'
|
||||
const saveBtn = Array.from(editor.querySelectorAll('button')).find((b) => b.textContent === '保存')
|
||||
@@ -114,16 +133,26 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
assert.strictEqual(prompts.find((p) => p.id === 'q3' || p.id === 'q1').name.length > 0, true)
|
||||
assert.strictEqual(window.document.querySelector('.iwb-plp-dialog-edit'), null, '保存后编辑弹窗应关闭')
|
||||
|
||||
// v1.6.12:保存后自动回到详情(新行为)—— 关掉它,避免影响后续断言
|
||||
window.document.querySelectorAll('.iwb-modal-mask').forEach((m) => m.remove())
|
||||
|
||||
// 插入画布按钮(+ 图标,title 含「插入到画布」)
|
||||
// 再点一次卡片 → 详情弹窗 → 底部「插入画布」
|
||||
cards()[0].dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
const allChip = Array.from(host.querySelectorAll('.iwb-chip')).find((c) => c.textContent.indexOf('全部') === 0)
|
||||
if (allChip) allChip.click()
|
||||
await wait(30)
|
||||
assert.ok(cards().length > 0, '应有卡片可点')
|
||||
cards()[0].dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
|
||||
await wait(40)
|
||||
const dlg2 = window.document.querySelector('.iwb-plp-dialog')
|
||||
const insBtn = dlg2 ? Array.from(dlg2.querySelectorAll('.iwb-plp-dfooter button')).find((b) => b.textContent === '插入画布') : null
|
||||
assert.ok(insBtn, '卡片应有「插入到画布」按钮')
|
||||
insBtn.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
await wait(50)
|
||||
assert.strictEqual(calls.insert.length, 1, '插入应调用 ctx.promptlib.insert')
|
||||
await wait(40)
|
||||
assert.ok(window.document.querySelector('.iwb-plp-placebox'), '插入画布应进入两步放置(出现放置框)')
|
||||
window.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Escape' }))
|
||||
await wait(20)
|
||||
assert.strictEqual(window.document.querySelector('.iwb-plp-placebox'), null, 'Esc 应取消放置')
|
||||
|
||||
// ---- v1.4.0 新增覆盖:封面渲染 / 插入封面图片 / 弹窗拖动缩放 ----
|
||||
// 1) 封面:mock coverUrl 返回一张 dataURL,卡片应出现 <img class=iwb-plp-cover>
|
||||
@@ -140,18 +169,21 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
// 2) 插入封面图片:详情底部出现「插入图片」,点击后调用 insertImage 并关闭弹窗
|
||||
const inserted = []
|
||||
ctx.promptlib.insertImage = async (cover, name) => { inserted.push([cover, name]); return { ok: true } }
|
||||
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
|
||||
await wait(40)
|
||||
const dlgA = window.document.querySelector('.iwb-plp-dialog')
|
||||
const imgBtn = dlgA && Array.from(dlgA.querySelectorAll('.iwb-plp-dfooter button')).find((b) => b.textContent === '插入图片')
|
||||
assert.ok(imgBtn, '有封面时详情应有「插入图片」按钮')
|
||||
imgBtn.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
await wait(60)
|
||||
assert.strictEqual(inserted.length, 1, '应调用 promptlib.insertImage')
|
||||
await wait(40)
|
||||
assert.strictEqual(window.document.querySelector('.iwb-plp-dialog'), null, '插入图片后弹窗应关闭')
|
||||
assert.ok(window.document.querySelector('.iwb-plp-placebox'), '插入图片应进入两步放置')
|
||||
plCanvas.dispatchEvent(new window.MouseEvent('pointerdown', { bubbles: true, clientX: 300, clientY: 200 }))
|
||||
await wait(30)
|
||||
assert.ok(calls.create.some((c) => c.type === 'img'), '点击画布应调用 createImageNode')
|
||||
|
||||
// 3) 弹窗拖动 + 缩放:标题栏拖动改变 left,右下角拖拽改变 width(且不小于 640)
|
||||
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
|
||||
window.document.querySelector('#host .iwb-plp-card').dispatchEvent(new window.MouseEvent('dblclick', { bubbles: true }))
|
||||
await wait(40)
|
||||
const dlgB = window.document.querySelector('.iwb-plp-dialog')
|
||||
assert.ok(dlgB, '应打开详情弹窗')
|
||||
|
||||
@@ -191,4 +191,25 @@ ok('两张参考图按 X 轴排序:样式节点的图跟节点位置走', () =
|
||||
assert.strictEqual(tasks[0].refs[1].value, 'https://cdn.example.com/right.png')
|
||||
})
|
||||
|
||||
// ── ⑤ 组合节点:继承态提示词的文案与图都要到位(2026-11-23)──────────────
|
||||
ok('样式 → 提示词(继承) → 组合:组合行有文案、下游拿得到参考图', () => {
|
||||
const s1 = styleNode('s1', 0, 0)
|
||||
const p1 = plainPrompt('p1', 300, 0, '')
|
||||
const c1 = { id: 'c1', type: 'combine', x: 700, y: 0, data: { sep: ', ' } }
|
||||
const nodes = [s1, p1, c1, genNode]
|
||||
const edges = [edge('s1', 'p1'), edge('p1', 'c1'), edge('c1', 'g1')]
|
||||
// 组合行:来自 p1(提示词节点本身),文案是它继承的那条(组合的拼接逻辑不改)
|
||||
const pairs = []
|
||||
for (const e of edges) if (e.to === 'c1') { const src = nodes.find((n) => n.id === e.from); pairs.push.apply(pairs, TG.combineSourcePairs(src, e, edges, nodes)) }
|
||||
assert.strictEqual(pairs.length, 1)
|
||||
assert.strictEqual(pairs[0].text, 'a 银发少女 in the rain')
|
||||
// 组合 → 下游(文本节点 / 分层节点走 nodeRefsOf)不能丢图
|
||||
assert.strictEqual(TG.nodeRefsOf(c1, edges, nodes).map((r) => r.id).join(','), 's1:ref')
|
||||
// 生成任务不变:仍是 1 个任务,文案与图都在
|
||||
const tasks = TG.buildGenerationTasksV2(genNode, nodes, edges)
|
||||
assert.strictEqual(tasks.length, 1)
|
||||
assert.strictEqual(tasks[0].text, 'a 银发少女 in the rain')
|
||||
assert.strictEqual(tasks[0].refs.length, 1)
|
||||
})
|
||||
|
||||
console.log('\nplugin-style-node: ' + passed + ' passed')
|
||||
@@ -1,26 +1,59 @@
|
||||
'use strict'
|
||||
// 插件主题契约守门(v3.25.85,P4)
|
||||
// 插件主题契约守门(v3.25.85 P4 起;v3.26.49 / M4-B6 重写)
|
||||
//
|
||||
// 规则:插件给**面板/弹层**写的样式必须用宿主主题变量(--iwb-* / --iwb-plugin-*),
|
||||
// 不允许把颜色写死 —— 否则自动配色/暗色主题下插件永远是白底黑字。
|
||||
// 目标只有一个:**宿主换主题时,插件不能变成白板或黑块**。
|
||||
//
|
||||
// 允许的例外(写进 ALLOW 列表并在注释里说明为什么):
|
||||
// · var(--x, #hex) 形式里的 fallback(浏览器不支持变量时的兜底)
|
||||
// · 画布内容自身的颜色(画笔色、填充色),属于数据不属于主题
|
||||
// 旧做法是「文件级豁免」—— 把整个插件文件放进 ALLOW_FILES,等于对它放弃全部检查。
|
||||
// 结果是豁免越攒越多(B6 时 6 个),而其中一半早已过期:style-source / blank-canvas 的
|
||||
// hex 全在 var() fallback 里,规则本来就会放行,白名单只是没人回来删。
|
||||
// 剩下 4 个也不是同一种情况,硬塞一张名单里就再也看不出区别了。
|
||||
//
|
||||
// 现在按「这段颜色在 UI 里是什么角色」分三类(判据写死在下面对应的函数里):
|
||||
//
|
||||
// ① 表面色 / 文字色 / 边框色 —— 随主题翻转的东西。必须用 var(--iwb-*)。
|
||||
// 这类颜色接近中性(chroma 小),写死在暗色下必然是一块白板或一个黑洞。
|
||||
// ② 强调色 / 状态色 —— 品牌绿、危险红、成功态。饱和度足够,亮暗两端都可读,
|
||||
// 属插件自己的设计语言,允许写死。判据用 chroma 而不是「查表」:
|
||||
// 表会过期、会被人往里加,chroma 是颜色自身的属性。
|
||||
// ③ 私有皮肤 —— 自带整套调色板(标注 / 矢量化这类深色专业工具 UI),
|
||||
// 在 manifest 里声明 skin: 'private'。颜色全部放行。
|
||||
// 代价必须付:**不得引用宿主颜色 token**。混用才是「一半跟主题走、一半写死」
|
||||
// 导致暗色下花屏的真正根源 —— 这才是 old ALLOW_FILES 掩盖掉的问题。
|
||||
//
|
||||
// 内容色(画布填充、看片台白底)用行内 `/*iwb:content*/` 标记放行:
|
||||
// 它是**声明级**的,写明「这一条是内容不是主题」,比文件级豁免精确得多。
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
const PLUG_DIR = path.join(ROOT, 'plugins')
|
||||
const ALLOW_FILES = new Set([
|
||||
'plugin-image-annotate.7a865c7c353c.js', // 画笔/文字颜色是用户内容色
|
||||
'plugin-blank-canvas.67763893fa99.js', // 画布填充色(白底画布内容)+ 变量 fallback
|
||||
'plugin-image-vectorize.7014982f60e6.js', // 位图转矢量的浮层是深色自绘 UI(#1b1b22 等),待插件源码改用 --iwb-*
|
||||
'plugin-style-source.ee7168565a44.js', // 风格库角标:白字(品牌底)+ 琥珀色提示,属内容色
|
||||
'plugin-browser.8161a82890d9.js', // 浏览器面板的刷新/危险按钮用自家色(#e05252/#1d9e75/#888780)
|
||||
'plugin-batch-export.b7d13ba66cf9.js', // 导出面板按钮用自家品牌色(#1d9e75/#d85a30/#2f6fed),待插件源码仓库改用 --iwb-*
|
||||
])
|
||||
|
||||
// 私有皮肤可用的宿主变量(布局尺寸,不属于主题色)。新增需在此登记并说明用途。
|
||||
const PRIVATE_ALLOWED_VARS = new Set(['--iwb-side-w'])
|
||||
|
||||
// chroma 阈值:max(r,g,b) - min(r,g,b) 的差。
|
||||
// 24/255 ≈ 0.094 —— 低于它的颜色看起来就是「灰」,靠它承载面板/文字必然要跟主题走;
|
||||
// 高于它的有明确色相,作为强调色在亮暗两端都能读。
|
||||
const CHROMA_MIN = 24
|
||||
|
||||
// 内容色的行内标记:`background:#fff/*iwb:content*/`(看片台、画布填充等)。
|
||||
// 用标记而不是值来判断,是因为同一个 #fff 在面板上是 bug、在画布上是内容 —— 值分不出来,上下文才分得出来。
|
||||
const CONTENT_MARK = /\/\*iwb:content\*\//
|
||||
|
||||
function toRgb (hex) {
|
||||
let h = hex.replace('#', '')
|
||||
if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2]
|
||||
if (h.length !== 6) return null
|
||||
const n = parseInt(h, 16)
|
||||
return [(n >> 16) & 255, (n >> 8) & 255, n & 255]
|
||||
}
|
||||
|
||||
function chromaOf (hex) {
|
||||
const c = toRgb(hex)
|
||||
if (!c) return 0
|
||||
return Math.max(c[0], c[1], c[2]) - Math.min(c[0], c[1], c[2])
|
||||
}
|
||||
|
||||
function walk (dir, out) {
|
||||
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
@@ -37,25 +70,63 @@ if (!fs.existsSync(PLUG_DIR)) {
|
||||
}
|
||||
|
||||
const files = walk(PLUG_DIR, [])
|
||||
let checked = 0
|
||||
const bad = []
|
||||
const accents = new Map()
|
||||
let checked = 0
|
||||
let privateCount = 0
|
||||
|
||||
for (const f of files) {
|
||||
const base = path.basename(f)
|
||||
if (ALLOW_FILES.has(base)) continue
|
||||
// 已知 plugin-batch-export 的导出按钮色写死(#1d9e75 等),留给插件源码仓库修。
|
||||
const src = fs.readFileSync(f, 'utf8')
|
||||
checked++
|
||||
// 找 background/color/border 声明里直接写 hex(排除 var(--x,#hex) 的 fallback)
|
||||
const re = /(background(?:-color)?|color|border(?:-color)?)\s*:\s*([^;'"]{0,80})/gi
|
||||
|
||||
// 私有皮肤:声明在产物 manifest 里(build-plugin.mjs 把 banner 原样放在文件最前面)
|
||||
const isPrivate = /skin:\s*'private'/.test(src.slice(0, 4096))
|
||||
if (isPrivate) {
|
||||
privateCount++
|
||||
// 自洽性:不跟随主题,就不能借宿主的颜色
|
||||
const used = new Set([...src.matchAll(/var\(\s*(--iwb-[a-z0-9-]+)/gi)].map((m) => m[1]))
|
||||
const borrowed = [...used].filter((v) => !PRIVATE_ALLOWED_VARS.has(v))
|
||||
assert.deepStrictEqual(
|
||||
borrowed, [],
|
||||
base + ' 声明了 skin: \'private\',却又引用宿主变量 ' + borrowed.join(', ') +
|
||||
' —— 私有皮肤必须自洽(要么全跟主题、要么全自己来,混用会在暗色下花屏)'
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
// 普通插件:逐条检查 CSS 颜色声明(`}` 也算值结束 —— 否则 `color:#fff}` 的尾巴会混进值里)
|
||||
const re = /(background(?:-color)?|color|border(?:-color)?)\s*:\s*([^;'"}]{0,120})/gi
|
||||
let m
|
||||
while ((m = re.exec(src))) {
|
||||
const prop = m[1].toLowerCase()
|
||||
const val = m[2]
|
||||
if (!/#[0-9a-f]{3,8}/i.test(val)) continue
|
||||
if (/var\(--[a-z0-9-]+\s*,\s*#[0-9a-f]{3,8}/i.test(val)) continue // fallback
|
||||
// 白字(压在图片/渐变上的标题)属于内容对比,不算主题表面色
|
||||
if (/^color$/i.test(m[1]) && /^#(?:fff|ffffff)$/i.test(val)) continue
|
||||
bad.push(base + ' → ' + m[1] + ': ' + val.trim().slice(0, 60))
|
||||
if (CONTENT_MARK.test(val)) continue // 显式标记的内容色
|
||||
if (/var\(--[a-z0-9-]+\s*,\s*#[0-9a-f]{3,8}/i.test(val)) continue // 变量 fallback
|
||||
// 纯白文字压在图片/色块上:属于内容对比,不是主题表面色
|
||||
if (prop === 'color' && /^#(?:fff|ffffff)$/i.test(val.trim())) continue
|
||||
|
||||
for (const h of val.match(/#[0-9a-f]{3,8}/gi) || []) {
|
||||
const c = chromaOf(h)
|
||||
if (c >= CHROMA_MIN) {
|
||||
// 强调色:允许,但要能被看见(打印出来供 review)
|
||||
accents.set(base + ' ' + h.toLowerCase(), (prop + ': ' + val.trim()).slice(0, 60))
|
||||
continue
|
||||
}
|
||||
bad.push(base + ' → ' + prop + ': ' + val.trim().slice(0, 60))
|
||||
}
|
||||
}
|
||||
}
|
||||
assert.strictEqual(bad.length, 0, '插件样式不得写死颜色(改用 --iwb-plugin-*):\n' + bad.slice(0, 10).join('\n'))
|
||||
console.log('plugin theme contract checks passed(检查 ' + checked + ' 个插件文件)')
|
||||
|
||||
assert.strictEqual(
|
||||
bad.length, 0,
|
||||
'插件把「中性色」(表面/文字/边框)写死了 —— 暗色下会变白板或黑块,改用 var(--iwb-*):\n' +
|
||||
bad.slice(0, 10).join('\n')
|
||||
)
|
||||
|
||||
console.log('plugin theme contract checks passed(' + checked + ' 个文件 / ' + privateCount +
|
||||
' 个私有皮肤插件 / ' + accents.size + ' 个强调色 / 0 个文件级豁免)')
|
||||
if (accents.size) {
|
||||
for (const [k, v] of accents) console.log(' · 强调色 ' + k + ' ' + v)
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// B4 设置/外观:三条不变量
|
||||
//
|
||||
// 这一批踩到的两类坑都不是「写错值」,而是「写了但不生效」「写了但没人用」:
|
||||
// ① `.iwb-set-nav-item` 声明了 padding: 7px 9px,被 `.iwb-settings-modal .iwb-tab`(两个类)
|
||||
// 按 specificity 盖掉,实测一直是 8/16 —— 改它毫无反应,只能靠采样计算样式发现;
|
||||
// ② `.iwb-setcell` / `.iwb-set-row` 这类类名在样式表里躺着,DOM 早已不渲染(v3.22 与插件设置页改版)。
|
||||
// 所以这里的断言不看「值对不对」,只看「这条声明还有没有意义」。
|
||||
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const root = path.join(__dirname, '..')
|
||||
const css = fs.readFileSync(path.join(root, 'style.css'), 'utf8')
|
||||
const tokens = fs.readFileSync(path.join(root, 'src/design-tokens.css'), 'utf8')
|
||||
|
||||
// ── 1. 控件高度:同一行里的输入框与默认按钮必须共用同一个 token ──
|
||||
const m = tokens.match(/--iwb-control-h:\s*(\d+px)/)
|
||||
assert.ok(m, '缺少 --iwb-control-h(表单控件高度)')
|
||||
assert.strictEqual(m[1], '30px', '--iwb-control-h 应为 30px')
|
||||
|
||||
for (const sel of ['.iwb-settings-modal .iwb-input {', '.iwb-settings-modal .iwb-btn {']) {
|
||||
const i = css.indexOf(sel)
|
||||
assert.ok(i >= 0, '找不到规则:' + sel)
|
||||
const body = css.slice(i, css.indexOf('}', i))
|
||||
assert.ok(
|
||||
body.includes('height: var(--iwb-control-h)'),
|
||||
sel + ' 必须用 height: var(--iwb-control-h) —— 否则它旁边的控件会高低不齐(曾是 33 vs 24)'
|
||||
)
|
||||
}
|
||||
|
||||
// 渠道卡片是「卡片里的卡片」,允许按自身内边距算高,但必须显式 height: auto 而不是继承 30
|
||||
const llm = css.indexOf('.iwb-settings-modal .iwb-llm-card .iwb-input {')
|
||||
assert.ok(llm > 0, '找不到渠道卡片输入框规则')
|
||||
assert.ok(css.slice(llm, css.indexOf('}', llm)).includes('height: auto'), '渠道卡片输入框应显式 height: auto')
|
||||
|
||||
// ── 1b. 全局 .iwb-input 保持「内容撑高」,不得写死 height ──
|
||||
// B6 裁定 control-h 不扩到全局:画布/节点/停靠栏里的输入框是紧凑控件,强制 30px 会连带
|
||||
// 拉高节点与面板行距。判据是「有没有并排的另一半」——并排的表单用 control-h,成组的紧凑控件靠内容撑高。
|
||||
const gInput = css.indexOf('.iwb-input, .iwb-textarea {')
|
||||
assert.ok(gInput > 0, '找不到全局 .iwb-input 规则')
|
||||
assert.ok(
|
||||
!/\bheight\s*:/.test(css.slice(gInput, css.indexOf('}', gInput))),
|
||||
'全局 .iwb-input 不该写死 height —— 它服务的是画布里的紧凑控件,写死就会把节点撑高(并排场景请就地用 control-h)'
|
||||
)
|
||||
|
||||
// ── 2. 半像素字号必须清零(B6 后是全文件) ──
|
||||
// 13.5px / 12.5px 这类值来自「凭手感调半像素」,闭集里没有它们。
|
||||
// B4 清了设置/外观范围内的 12 处;B6 把备份页、右键菜单、操作日志、确认框、插件市场卡
|
||||
// 剩下的 16 处一并清完,所以断言从「范围内」收紧成「全文件」—— 以后新增的一律拦下。
|
||||
const halfPixel = []
|
||||
css.split('\n').forEach((line, i) => {
|
||||
if (/font-size:\s*[\d]+\.5px/.test(line)) halfPixel.push((i + 1) + ':' + line.trim().slice(0, 70))
|
||||
})
|
||||
assert.deepStrictEqual(halfPixel, [], 'style.css 里还有半像素字号(闭集只有 11/12/13/15/17/20/24)')
|
||||
|
||||
// ── 3. 已删除的死规则不许回来 ──
|
||||
// 判据:DOM 不渲染 + 插件不复用。删除前查过 dist/app.js 与 plugins/**(B3 的教训:只查产物会把插件契约误删)。
|
||||
const DEAD = [
|
||||
'.iwb-setcell', '.iwb-setgrid', '.iwb-setopen', '.iwb-ratio-mini', '.iwb-ratio-box',
|
||||
'.iwb-set-row', '.iwb-set-page-head', '.iwb-appear-val', '.iwb-appear-note-only',
|
||||
]
|
||||
for (const cls of DEAD) {
|
||||
const re = new RegExp('\\' + cls + '(?![-A-Za-z0-9_])')
|
||||
assert.ok(!re.test(css), cls + ' 已确认无生产者(DOM 与插件都不再产出),不该重新出现')
|
||||
}
|
||||
|
||||
// ── 4. 引用的 token 必须存在 ──
|
||||
// `border-radius: var(--iwb-radius-pill)` 这种拼错不会报错、不会警告,声明整条失效,圆角静默变 0。
|
||||
// 本批真踩到了:999px 的药丸圆角 token 叫 `--iwb-radius-full`,我写成了 `--iwb-radius-pill`,
|
||||
// 亮色基线照样「看起来正常」(那几个胶囊不在基线视野里)。所以这条必须是断言,不能只靠审计脚本打印。
|
||||
const defs = new Set([...tokens.matchAll(/(?:^|[\s;{])--[a-z0-9-]+\s*:/gim)]
|
||||
.map((s) => s[0].trim().replace(/^[;{]/, '').trim().replace(/\s*:$/, '')))
|
||||
for (const m2 of css.matchAll(/(?:^|[\s;{])--[a-z0-9-]+\s*:/gim)) {
|
||||
defs.add(m2[0].trim().replace(/^[;{]/, '').trim().replace(/\s*:$/, ''))
|
||||
}
|
||||
// 运行时由 JS 写进 style 的变量(见 scripts/token-audit.js 的 RUNTIME_SET)
|
||||
const RUNTIME = new Set(['--iwb-dock-l', '--iwb-dock-r', '--iwb-fb-k', '--iwb-node-color'])
|
||||
const missing = [...new Set([...css.matchAll(/var\(\s*(--[a-z0-9-]+)/gi)].map((r) => r[1]))]
|
||||
.filter((r) => !defs.has(r) && !RUNTIME.has(r))
|
||||
assert.deepStrictEqual(missing, [], '引用了不存在的 token(声明会整条失效且没有报错)')
|
||||
|
||||
console.log('settings scope checks passed(控件等高 / 半像素清零 / ' + DEAD.length + ' 个死类名不复现 / ' + defs.size + ' 个 token 引用全部有定义)')
|
||||
@@ -31,7 +31,9 @@ assert.ok(fs.readFileSync(path.join(__dirname, '..', 'src', 'ui-dock-panels.js')
|
||||
assert.ok((source + dockPanelsSrc).includes("pluginId: 'gallery'"))
|
||||
assert.ok((source + dockPanelsSrc).includes("图库插件未安装"))
|
||||
assert.ok(!source.includes("dockGalleryEl"))
|
||||
assert.ok(css.includes('.iwb-res-tabs {'))
|
||||
// v3.27.1(M4-B1):这条断言原先自相矛盾 —— 注释从 v3.25.57 起就说「已下线、钉点移除」,
|
||||
// 但断言一直要求 .iwb-res-tabs 存在,于是这组死 CSS 谁也不敢删。现在反过来钉「不得复活」。
|
||||
assert.ok(!css.includes('.iwb-res-tabs {'), '资源中心旧页签已删除(统一到 .iwb-tab)')
|
||||
assert.ok(source.includes("'无限画布'"))
|
||||
assert.ok(source.includes("className: 'iwb-canvas' + (shellView !== 'canvas' ? ' iwb-canvas-hidden'"))
|
||||
assert.ok(css.includes('.iwb-canvas-hidden { visibility: hidden; pointer-events: none; }'))
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
// CSS 静态 token 必须等于 IWBThemeTokens.derive() 的输出(v3.26.44,M2/D2 守卫)
|
||||
//
|
||||
// 背景:design-tokens.css 的 :root / .theme-dark 是设计 token 的「静态快照」,用途是顶住 JS 执行前
|
||||
// 那一帧。历史上这两段是**另一套独立设计**(暗色是中灰底 #757575 + 深字 #111),与 derive
|
||||
// 的「近黑底 + 浅字」同名不同值 —— 结果切主题像换了个产品,而且首屏会闪一下再跳变。
|
||||
//
|
||||
// 这个测试把「快照 == 派生」钉成硬约束:改派生公式忘了同步 CSS,这里就红。
|
||||
// 结构层(chrome/home/dock/edge/hr/plugin 别名)刻意用 color-mix 表达关系式,跳过。
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
// M3 起 token 从 style.css 搬到生成的 src/design-tokens.css(构建时内联到 style.css 前面)
|
||||
const css = fs.readFileSync(path.join(ROOT, 'src/design-tokens.css'), 'utf8')
|
||||
|
||||
// 载入 theme-tokens(它是 UMD,挂到传入的对象上)
|
||||
const sandbox = {}
|
||||
new Function('window', fs.readFileSync(path.join(ROOT, 'src/theme-tokens.js'), 'utf8'))(sandbox)
|
||||
const T = sandbox.IWBThemeTokens
|
||||
assert(T && typeof T.derive === 'function', 'theme-tokens 未正确导出 derive')
|
||||
|
||||
function assert (cond, msg) {
|
||||
if (!cond) { console.error('✗ ' + msg); process.exit(1) }
|
||||
}
|
||||
|
||||
// 取出某个选择器块里的 `--var: value;` 声明
|
||||
function block (selector) {
|
||||
const i = css.indexOf(selector + ' {')
|
||||
assert(i >= 0, '找不到选择器块: ' + selector)
|
||||
const start = css.indexOf('{', i)
|
||||
let depth = 0
|
||||
for (let j = start; j < css.length; j++) {
|
||||
if (css[j] === '{') depth++
|
||||
else if (css[j] === '}') {
|
||||
depth--
|
||||
if (depth === 0) return css.slice(start + 1, j)
|
||||
}
|
||||
}
|
||||
assert(false, '选择器块未闭合: ' + selector)
|
||||
}
|
||||
|
||||
function decls (body) {
|
||||
const out = {}
|
||||
// 去掉注释,避免注释里的示例声明被当成真声明
|
||||
const clean = body.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
const re = /--(?:iwb-)?([a-z0-9-]+)\s*:\s*([^;]+);/g
|
||||
let m
|
||||
while ((m = re.exec(clean))) out[m[1]] = m[2].trim()
|
||||
return out
|
||||
}
|
||||
|
||||
const rootVars = decls(block(':root'))
|
||||
const darkVars = decls(block('.theme-dark'))
|
||||
|
||||
// token 键(derive 返回的驼峰)→ CSS 变量名(kebab)
|
||||
const KEYS = [
|
||||
'bg', 'canvasBg', 'panel', 'layer', 'layer2', 'nodeBg', 'field', 'border', 'border2',
|
||||
'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint',
|
||||
'surface', 'hover', 'menuBg', 'brand', 'brandText', 'gridDot',
|
||||
'pluginSurface', 'pluginCard', 'pluginInset', 'pluginHover',
|
||||
'err', 'ok', 'warn', 'onBrand',
|
||||
]
|
||||
// derive 键 → CSS 变量名(去掉 --iwb- 前缀)。canvasText 的变量名是特例(--iwb-color-text-on-canvas)
|
||||
const VAR_ALIAS = { canvasText: 'color-text-on-canvas', menuBg: 'bg-menu' }
|
||||
const varOf = (k) => VAR_ALIAS[k] || k.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())
|
||||
|
||||
let checked = 0
|
||||
const bad = []
|
||||
|
||||
function checkOne (mode, dark, vars, table) {
|
||||
const tokens = T.derive(T.DEFAULTS, dark)
|
||||
for (const k of KEYS) {
|
||||
const name = '--iwb-' + varOf(k)
|
||||
const want = tokens[k]
|
||||
const got = vars[varOf(k)]
|
||||
if (!want) { bad.push(`${mode}: derive 未返回 ${k}`); continue }
|
||||
if (!got) { bad.push(`${mode}: CSS 缺少 ${name}(期望 ${want})`); continue }
|
||||
// 只比对字面量色值;color-mix/var() 表达式归结构层,跳过
|
||||
if (!/^#[0-9a-f]{6}$/i.test(got)) continue
|
||||
checked++
|
||||
if (got.toLowerCase() !== String(want).toLowerCase()) {
|
||||
bad.push(`${mode}: ${name} = ${got},derive 给 ${want}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkOne(':root', false, rootVars)
|
||||
checkOne('.theme-dark', true, darkVars)
|
||||
|
||||
// 结构层:CSS 用 color-mix 表达,必须与 derive 用同一组系数
|
||||
assert(/^color-mix\(in srgb, var\(--iwb-bg\) 60%, var\(--iwb-canvas-bg\) 40%\)$/.test(rootVars.chrome || ''),
|
||||
'chrome 公式应为 bg 60% + canvas 40%(derive 用 mix(bg, canvas, 0.4))')
|
||||
assert(/^color-mix\(in srgb, var\(--iwb-chrome\) 55%, var\(--iwb-canvas-bg\) 45%\)$/.test(rootVars['dock-bg'] || ''),
|
||||
'dockBg 公式应为 chrome 55% + canvas 45%(derive 用 mix(chrome, canvas, 0.45);曾有三套写法)')
|
||||
assert(/^color-mix\(in srgb, var\(--iwb-panel\) 55%, var\(--iwb-dock-bg\)\)$/.test(rootVars['dock-head-bg'] || ''),
|
||||
'dockHeadBg 公式应为 panel 55% + dockBg 45%')
|
||||
|
||||
// 暗色块不应再重复定义结构层(否则又会分叉出第二套公式)
|
||||
for (const k of ['chrome', 'home-bg', 'dock-bg', 'dock-head-bg']) {
|
||||
assert(!darkVars[k], `暗色块不应重新定义 --iwb-${k}(应让 :root 的 color-mix 在 html 上重新求值)`)
|
||||
}
|
||||
|
||||
if (bad.length) {
|
||||
console.error('✗ CSS 静态快照与 derive() 不一致:\n ' + bad.join('\n '))
|
||||
console.error('\n修法:改 style.css 里对应的字面量,或(若刚改了派生公式)用')
|
||||
console.error(' node -e "const s={};new Function(\'window\',require(\'fs\').readFileSync(\'src/theme-tokens.js\',\'utf8\'))(s);console.log(s.IWBThemeTokens.derive(s.IWBThemeTokens.DEFAULTS,true))"')
|
||||
console.error('重新生成快照。')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`theme static snapshot checks passed(${checked} 个色值与 derive 一致,亮/暗各一套)`)
|
||||
@@ -19,6 +19,6 @@ assert.ok(!source.includes("railBtn('groups'"))
|
||||
assert.ok(!source.includes("railBtn('history'"))
|
||||
assert.ok(css.includes('.iwb-product-nav'))
|
||||
assert.ok(css.includes('.iwb-landing-panel'))
|
||||
assert.ok(css.includes('.iwb-res-tabs'))
|
||||
assert.ok(!css.includes('.iwb-res-tabs'), 'v3.27.1:资源中心旧页签已删除(统一到 .iwb-tab)')
|
||||
assert.ok(!css.includes('.iwb-left-drawer'))
|
||||
console.log('three page layout checks passed')
|
||||