Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d504a2cfb5 | ||
|
|
47013fb6b8 | ||
|
|
573f245460 | ||
|
|
f271ed014b | ||
|
|
f910f1c1bd | ||
|
|
bda83d5d4f | ||
|
|
4f93dee3ef | ||
|
|
b6152e0ac7 | ||
|
|
9a94563bc4 | ||
|
|
8ba7811ac9 | ||
|
|
c426880c8d | ||
|
|
4dddb09304 | ||
|
|
058090d60f | ||
|
|
74790ffdef | ||
|
|
7d1fe90c7e | ||
|
|
6767f04df6 | ||
|
|
e6bca55983 | ||
|
|
80366e1c70 | ||
|
|
39cbe79ada | ||
|
|
c0aa9c63b7 | ||
|
|
b0881bce59 | ||
|
|
2c2a4313f9 | ||
|
|
ee68c8566a | ||
|
|
f88038143e | ||
|
|
7d5ec3f5ee | ||
|
|
e5ff776c5d | ||
|
|
28ba14ae68 | ||
|
|
54f9acc93b | ||
|
|
474e27f7c4 | ||
|
|
e058b21b6e | ||
|
|
7f42860fc8 | ||
|
|
8ef453b3b4 | ||
|
|
12ed8e6cbf | ||
|
|
56961d6d8a | ||
|
|
293c500dca | ||
|
|
b99af53c49 | ||
|
|
120c85ff04 | ||
|
|
3f1cab0d67 | ||
|
|
ded94390ae | ||
|
|
d38a359e19 | ||
|
|
bf7856344b | ||
|
|
af9b10d1e2 | ||
|
|
4921fb984a | ||
|
|
21554b05ae | ||
|
|
46008b4d8b | ||
|
|
746598800b | ||
|
|
cab473c3cd | ||
|
|
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 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
* text=auto
|
||||
*.css text eol=lf
|
||||
*.js text eol=lf
|
||||
*.json text eol=lf
|
||||
*.md text eol=lf
|
||||
src/design-tokens.css text eol=lf
|
||||
@@ -14,6 +14,403 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.26.55(2026-11-24)Windows 构建解锁:token 校验容忍 CRLF
|
||||
|
||||
> 状态:正式发布(macOS arm64 / x86_64;Windows 同版本)
|
||||
|
||||
- 3.26.54 在 Windows 上 `app:build` 失败:`build.js` 的 token 快照比较对 CRLF 严格不等
|
||||
- `scripts/build.js` 与 `scripts/gen-tokens.js` 均先归一 `\r\n`,再比较 token 快照
|
||||
- 新增 `.gitattributes`(`*.css/*.js/*.json/*.md eol=lf`),降低跨平台检出差异
|
||||
- 无 UI / 功能变化,纯构建修复
|
||||
|
||||
## v3.26.54(2026-11-24)设置页全量统一 + 图库稳定性修复
|
||||
|
||||
> 状态:正式发布(macOS arm64 / x86_64)
|
||||
|
||||
- 设置页全部页面统一为 Obsidian 式分组:通用 / 外观 / 生图服务 / LLM 服务 / 图片传输 / 尺寸预设 / 快捷键 / 备份与还原 / 诊断
|
||||
- 分组底色取设计值 `#F9F9F9`(暗色等价混色),新增 `--iwb-set-group-pad-y`、`--iwb-set-check-size`、`--iwb-set-btn-gap` 等控件 token
|
||||
- 分组标题不再附带说明文案;分组块间距统一 32px
|
||||
- 备份与还原:内嵌组件融入分组、去掉内层滚动;还原时只写回与所选项目相关的图片,避免孤儿图库字节
|
||||
- 插件管理新增「全部更新」:检查后一键更新全部可更新插件,完成后提示重启
|
||||
- 图库插件 1.6.11:修复面板显隐/宽度变化后不刷新(重排实时量宽 + 缩略图 eager + 超时放宽)
|
||||
|
||||
## v3.26.53(2026-11-23)设置页重构:可缩放 + Obsidian 式分组 + 统一 token
|
||||
|
||||
> 状态:正式发布(macOS arm64 / x86_64)
|
||||
|
||||
设置窗口与主要页面按 Obsidian 的设置页重排,并沉淀为设置面板 token 规范(§3.11)。
|
||||
|
||||
- 设置窗口支持右下角拖拽缩放(自定义手柄,兼容 WKWebView),最小 760×480
|
||||
- 通用页:卡片改为「二级标题在页面底 + 内容浅灰圆角容器」,版本与更新置顶
|
||||
- 外观页:全部设置项按同一分组重排,去掉顶部重复的「外观」标题
|
||||
- 生图服务:多服务商 chips 保留;详情拆为 服务 / 服务器地址 / 接口路径 / API Key / 请求分类 / 模型 / 分层模型
|
||||
- 分组标题下不再放说明文案;解释只保留行内提示或「更多说明」折叠
|
||||
- 分组块间距统一为 `--iwb-set-group-gap` = 32px,禁止各页自写 gap/padding
|
||||
- 输入框描边新增 `--iwb-set-input-border`(40% 边框 + 面板色),比常规更淡
|
||||
- 模型行删除收进「⋯」更多菜单,避免误触;内置模型提示不可删除
|
||||
- 新增视觉基线 ⑪ 生图服务、⑫ 通用(亮/暗)
|
||||
|
||||
## v3.26.52(2026-11-23)节点正文不再套白卡片:M6 后第一个真实观感回归
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿;视觉基线 8 张重录、16/16 复跑全绿;本批只出 macOS 本地安装包供安装验证,未上线)
|
||||
|
||||
用户截图反馈:提示词 / 文本节点卡片是灰色,正文却是一块白色矩形;进入编辑态还多一圈方框。
|
||||
根因不是配色数值,是**三层 CSS 覆盖**叠出来的:
|
||||
|
||||
| # | 谁盖了谁 | 现象 |
|
||||
|---|---|---|
|
||||
| ① | `.iwb-node .iwb-textarea { background: var(--iwb-field) }`(0,2,0) 压过 `.iwb-textarea-plain`(0,1,0) 的 `transparent` | 亮色 `--iwb-field = #ffffff`,灰色卡片(`#efefef`)里套出一张白卡片;设了 `data-bg` 自定义底色的节点另有规则才恰好正常,所以现象时有时无 |
|
||||
| ② | `.iwb-textarea-plain:focus` 写在 `.iwb-textarea:focus` **之前**且同权重 | 编辑时 `box-shadow: 0 0 0 2px` 光晕复活,成了「方框」 |
|
||||
| ③ | 文件末尾 D8 `:focus-visible` 全局焦点环 | 真聚焦实测 `outlineStyle` 仍是 `solid`,去掉 border / shadow 后仍剩一圈 2px 矩形环 |
|
||||
|
||||
**修法**:控件面规则收窄为 `.iwb-textarea:not(.iwb-textarea-plain)`(只给节点内**可交互控件**);
|
||||
新增 `.iwb-node .iwb-textarea-plain` —— `background: transparent` / `border: 0` / `padding: 0` /
|
||||
`box-shadow: none` / `outline: none`,聚焦态再压一次且写在基础 focus 规则**之后**。
|
||||
保留 `.iwb-node-selected` 节点选中框作为编辑状态的唯一反馈;其余控件的 D8 键盘焦点环不动。
|
||||
|
||||
**规范结论**(`docs/standards/design-tokens.md` §1.9 / §1.13 / §3.1):`--iwb-field` 是
|
||||
「节点内可交互控件面」,不是「节点内一切面」。表面角色三分法=面板控件 `layer` / 节点控件 `field` /
|
||||
节点正文 `transparent`(**刻意不建 token**,因为值随 `data-bg` 自定义底色变化,固定色会穿帮)。
|
||||
判据分两步:先问是不是可交互控件,再问贴在哪张卡片上。
|
||||
|
||||
**守卫**:`tests/node-scope-test.js` 第 5 条 —— 正文必须 `transparent`、禁 `field / layer / panel`、
|
||||
禁 border / box-shadow / outline、聚焦规则须在基本 focus 之后、`:not()` 必须存在;每条都做过反向验证。
|
||||
|
||||
**验证**:差异图红色像素只落在两个节点正文矩形内(纯颜色替换,无布局位移、无文字重排);
|
||||
像素采样亮色 `(255,255,255) → (239,239,239)`、暗色 `(73,73,73) → (61,61,61)`;
|
||||
编辑态计算样式 `background=transparent / borderWidth=0px / boxShadow=none / outlineStyle=none`。
|
||||
视觉基线 **8 张重录**(② 画布 / ④ 图库抽屉 / ⑤ 提示词库面板 / ⑥ 右键菜单 × 亮暗,背景是同一张画布),
|
||||
其余 8 张 0 diff;更新后 16/16 连跑全绿,`verify:ci` / `lint:tokens` / `tokens:check` 全绿。
|
||||
|
||||
## v3.26.51(2026-11-23)M6 延展验证:照着规范写一遍,撞出来的才是真问题
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿;亮色状态色调深使 **7 张亮色基线更新**(每张 200–400 像素的局部状态色,无布局变化),复核 **16/16** 连跑两次全绿;本批只出本地安装包与源码提交,未上线)
|
||||
|
||||
M5 装完闸门,M6 的任务不是再迁移一批数字,而是**证明这套东西真的能照着写**。
|
||||
选了插件管理面板(设置行 / 列表 / 开关 / 工具条 / 筛选胶囊 / 卡片墙,覆盖面够)和
|
||||
`batch-export` 插件各写一遍。顺的地方不用记,**卡住的三处才是需要修的地方**——
|
||||
都回去改了 token 和守卫,没有在文档里糊过去。
|
||||
|
||||
**① 面板合并重写(133 行新增,0 处裸值)**
|
||||
|
||||
这段样式原本是 v3.26.24 → v3.26.27 六次叠加:`.iwb-mk-list` 的 `gap` 写过 3 次、
|
||||
`.iwb-mk-grid` 3 次、主按钮背景 4 次、`.iwb-set-page` 的 `max-width` 一改一撤,
|
||||
最终值散在 `style.css` 两处相隔 300 行的位置。按当前生效值**重写成一份**,
|
||||
删掉 3 个零引用类和 1 条永不生效的 `var(--iwb-ok, #1d9e75)` 死兜底。
|
||||
`style.css` 净减 34 行,`lint:tokens` 对全部新增行放行。
|
||||
|
||||
> **亮色 7 张基线变了,不是噪声**:`--iwb-ok/err/warn` 调深后,画布状态标签、
|
||||
> 插件「未加载」标签、市场「已安装」徽标等局部色块变化(每张 200–400 像素,占比 0.01),
|
||||
> 暗色一张没动(暗色状态色本来就没改)。逐张看过 diff,无位移、无裁切。
|
||||
|
||||
**② 撞出来的三个缺口**
|
||||
|
||||
- **闭集缺 14px**:表单行标题、命令输入、帮助正文全站 10 处,13→15 跨 2px 无处安放。
|
||||
补 `--iwb-font-base: 14px`(7→8 档),走 `gen-tokens.js` 单一源同步 CSS / DTCG / 快照。
|
||||
- **状态色不能当文字色**:`--iwb-ok` 亮色 `#22c55e` 对浅页面对比只有 **2.13**,
|
||||
而 `.iwb-status-ok` / `.iwb-ratio.ok` 一直直接拿它当文字色 —— M5 的 114 对守卫只查
|
||||
text/text2/dim/brandText,把这类漏了。`derive()` 亮色状态色调深
|
||||
(ok `#15803d` / err `#b91c1c` / warn `#b45309`,暗色不变),守卫补 24 对 → **138 对**。
|
||||
- **最乱的面板没有截图保护**:`DesktopPluginsTab` 只在 `isDesk()` 时渲染,网页 e2e 走另一条分支。
|
||||
新增 ⑦⑧ 组件夹具基线(同类名 + 真实 `dist/style.css` + 构造 DOM),亮暗共 **16 张**。
|
||||
夹具里必须 `transition:none` —— 开关 `.15s` 收尾会让两次截图差 7 个像素 × 1 级灰度,
|
||||
`threshold: 0` 就会随机红。
|
||||
|
||||
**③ `batch-export` 1.2.2(插件仓)**
|
||||
|
||||
文件级豁免那一半在 B6 已清零,本批做另一半:状态色改走宿主语义 token(保留私有值兜底,
|
||||
脱离宿主不退化);去掉与「全灰阶、无蓝」冲突的纯蓝主按钮,改成 `text`/`layer` 成对反相;
|
||||
热按钮从「实心绿 + 白字」改成绿描边 + 绿字 + 14% 绿底。实测亮色主按钮对比 **9.51**、暗色 **14.10**;
|
||||
状态色对页面亮 5.38/6.95、暗 10.01/7.03。
|
||||
|
||||
**④ 存量真的降了(棘轮装好后第一次)**
|
||||
|
||||
字号写死 170→159、圆角 103→95、间距 415→377、hex 84→79、圆角种数 18→17、阴影 45→44,
|
||||
已写回 `tests/fixtures/token-baseline.json`。闸门管增量、真实改版清存量,分工成立。
|
||||
|
||||
**文档**:规范新增 §5.7 接入案例(两份实现的决策表 + 三个缺口 + 照抄清单);
|
||||
顺手修掉 §5.2 里「动效用 `--iwb-dur-*`」这条会让人踩空的说明 —— 该 token 根本不存在,
|
||||
现改为明确标注「动效尚未 token 化」这个已知缺口。
|
||||
|
||||
**M1–M6 全部完成**。本批未上线:插件 `[email protected]` 与客户端 v3.26.51 的发布动作留待确认。
|
||||
|
||||
## v3.26.50(2026-11-23)M5 闸门:让「下次又散掉」变得不可能
|
||||
|
||||
> **状态:待发布**(`verify:ci` 全绿含新闸门;零观感,视觉基线应 12/12 不变)
|
||||
|
||||
M4 把 token 铺完了,但那时**没有任何东西阻止下一个人再写 `padding: 13px`**。
|
||||
这一批只做一件事:把「token 化」从**约定**变成**构建会红**。
|
||||
|
||||
**三道闸门,各自打过红一次才算数**
|
||||
|
||||
| 闸门 | 做什么 | 反向验证(注入 → 结果) |
|
||||
|---|---|---|
|
||||
| `npm run lint:tokens` | 只看 diff **新增行**:裸 `#hex`/`rgba()`、裸 `px`(字号/圆角/内距/间距/外边距)、裸 `z-index` | 8 行探针文件 → 6 处全部点名,含「例外已过期 raw-until=3.26.10」 |
|
||||
| `tests/design-token-ratchet-test.js` | 13 项计数**只降不升**(基线 `tests/fixtures/token-baseline.json`) | `style.css` 追加一条 `font-size: 13px` → `170 → 171(+1)` 立刻红 |
|
||||
| `tests/theme-contrast-test.js` | 亮/暗 × 文字 × 表面 **114 对**,阈值取 `RATIO` | 把 `clampAgainst` 短路成 `return fg` → 100+ 对跌破阈值 |
|
||||
|
||||
**为什么只查新增行**:存量还有 170 处写死字号、415 处写死间距。要求一次清零只会逼人加白名单,
|
||||
而白名单比债务更难发现 —— B6 刚把 `ALLOW_FILES` 拆掉,不能隔一批又造一张。
|
||||
分工是:闸门管增量(立刻生效),棘轮管存量(只降不升),视觉基线管观感(改了必须看得见)。
|
||||
|
||||
**四条白名单**(缺一条都会逼人绕路)
|
||||
- 内容色 `/*iwb:content*/`:画布内容不是主题表面色,同一个 `#fff` 在按钮上是 bug、在图片上是内容
|
||||
- 变量兜底 `var(--x, 8px)`:兜底值不生效时 var 本身就会红
|
||||
- 布局尺寸:`width/height/top/left` 没有闭集,强行 token 化只会发明只用一次的名字
|
||||
- 临时例外 `/*iwb:raw-until=3.28.0*/`:**必须带到期版本**,到期后闸门直接失败
|
||||
|
||||
**一个被证伪的直觉**:本想用「调坏 mix 权重」验证对比度守卫,改完仍全绿 —— 因为 `clampAgainst`
|
||||
会重新夹回阈值。这反过来证明夹紧有效,也说明守卫真正防的是「有人删掉夹紧 / 把 token 写死成常数」,
|
||||
于是按这个失效模式重做了注入。
|
||||
|
||||
**口径不重复实现**:棘轮不自己写正则,直接跑 `token-audit.js --json`。两套口径一旦漂移,
|
||||
就会出现「守卫绿、审计红」这种最难查的分歧。
|
||||
|
||||
**④ 顺带堵住最后一个口子:JS 内联样式**
|
||||
|
||||
写完闸门回头验证时发现,B6 说的「`style.css` 里半像素一个不剩」是**真的**,但 `src/*.js` 里
|
||||
还留着一处 `font-size:12.5px` —— 就在**首次启动「选择资料目录」弹窗**里。那个弹窗是纯手写
|
||||
`cssText` + `innerHTML`,白底 `#fff`/字色 `#111`/主按钮 `#2563eb`,**亮暗主题都不跟**,
|
||||
深色模式下会跳出一个刺眼的白盒子。
|
||||
|
||||
于是闸门扩到 JS,判据分两种(否则会误伤布局参数):
|
||||
- **CSS 文本**(`cssText` / `innerHTML` 里的 `style="…"`):必须带 `px` 单位或 `#`/`rgb` 才判,
|
||||
所以 `CanvasGeometry.snapToFreeSpot({ gap: 20 })` 这种**画布布局参数**不会被误报;
|
||||
- **React 内联对象**:只认无歧义的 camelCase(`fontSize` / `marginLeft` / `zIndex`…),
|
||||
`gap`、`padding` 在 JS 对象里可能是任何东西,不查。
|
||||
|
||||
弹窗本身也 token 化了:表面/文字/圆角/间距/主按钮全部走 token,每个 `var()` 都带字面兜底
|
||||
(这个弹窗在主题 CSS 生效前就要显示,token 缺席时必须退化成旧样子,而不是透明盒子)。
|
||||
**遮罩色是唯一没法 token 化的**——全仓 3 处 rgba 遮罩(`.iwb-modal-mask` / `.iwb-command-mask` /
|
||||
这里),既不是 `bg` 也不是 `panel`,硬凑会让亮色主题出现「浅色遮罩」。留给 RFC 决定
|
||||
`--iwb-scrim` 的取值,在此之前用 `/*iwb:raw-until=3.28.0*/` 登记——这条也是例外机制的真实样本。
|
||||
|
||||
**存量一个没动**:`style.css` 的字号 170 / 圆角 103 / 间距 415 / z-index 31 与 B6 完全一致。
|
||||
本批唯一可见变化是那个首启动弹窗:深色下不再是白盒子,主按钮从蓝色 `#2563eb` 变成品牌灰
|
||||
`--iwb-brand`(与全站主按钮一致)。
|
||||
|
||||
## 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)继承态提示词把文案与参考图交给组合/连接节点
|
||||
|
||||
- 修「提示词接风格库变量节点后,组合节点读不到文案、也不往下带参考图」(出图一直正常,所以表现为「能出图、组合是空的」)。
|
||||
|
||||
@@ -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 124 个单测文件(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
|
||||
}
|
||||
@@ -6140,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(释放空间,治撑爆)
|
||||
@@ -8676,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,483 @@
|
||||
# 设计 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)—— ✅ 已完成 2026-11-23(v3.26.50)
|
||||
|
||||
| ID | 任务 | 文件 | 规则 |
|
||||
|---|---|---|---|
|
||||
| T5.1 | `scripts/token-lint.js` | 新增 | 新增行出现裸 `#hex` / 裸 `px`(font-size、border-radius、padding、gap、margin)→ 失败;四条白名单(内容色、布局尺寸、变量兜底、临时例外带到期版本) |
|
||||
| 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-anchor`(3200) |
|
||||
| T5.6 | 接入 `verify:ci` | `package.json` | 三条命令失败即 CI 失败 |
|
||||
| T5.7 | 流程文档落章 | `design-tokens.md` §5 | RFC 模板、9 步、弃用窗口、PR 三问 |
|
||||
|
||||
**执行结果(2026-11-23,零观感)**:
|
||||
|
||||
| ID | 计划 | 实际 | 偏差与理由 |
|
||||
|---|---|---|---|
|
||||
| T5.1 | 新增行禁裸值 | ✅ `scripts/token-lint.js`,默认 diff HEAD、`--base` 查已提交批次、`--file` 整文件 | 加 `--file` 是因为迁移时要看整份文件;默认只看未提交改动,才符合「写的时候就知道」。**验证时发现 CSS 闸门看不见 JS 内联样式**(首启动弹窗里还留着 12.5px),遂扩到 `cssText` 与 React 内联对象两套判据 |
|
||||
| T5.2 | 基线 JSON | ✅ 13 项计数(原计划只提了硬编码项,实际把「取值种数」也纳入) | 种数下降比处数下降更能反映「收敛」,且不会被「同一行写两个裸值」这种记账差异干扰 |
|
||||
| T5.3 | 完整性 | ✅ 并入棘轮测试 | 同一份审计数据能同时判三件事,不必再开一个进程 |
|
||||
| T5.4 | 5 表面 ≥4.5 | ✅ 实际断言 **114 对**,阈值直接取 `theme-tokens.js` 的 `RATIO`(text 7 / text2 4.5 / dim 3 / canvas 6) | 计划写的 4.5 是下限;实现里正文本来就夹到 7,按 7 断言更严且只有一个数字来源 |
|
||||
| T5.5 | 插件不超 popover | ⚠️ **没有 `--iwb-z-popover` 这个 token** → 改用 `--iwb-z-anchor`(3200) | B2 的层级表里最接近的是 anchor;palette/alert 是宿主专属层,插件不该碰到 |
|
||||
| T5.6 | 接 verify:ci | ✅ `tokens:check` 之后插 `lint:tokens`;两个新测试进 `test:unit` | 放进 `test:unit` 而不是单开一段,是为了让「孤儿测试」守卫自动覆盖到 |
|
||||
| T5.7 | 文档 | ✅ §5.2/5.4/5.5/5.6 重写 + §1.12 执行记录 + S3 闸门表按实际命令改写 | 旧 §5 还写着 `--iwb-color-*` / `--iwb-gap-*` 这些**不存在的名字**,照着写会直接踩空 |
|
||||
|
||||
**反向验证**(三道闸门各自打红一次,确认不是「绿得不明不白」):
|
||||
|
||||
| 闸门 | 注入 | 结果 |
|
||||
|---|---|---|
|
||||
| token-lint | 8 行探针文件,含裸色/裸字号/裸 z-index/过期例外 | 6 处全部点名,含「例外已过期:raw-until=3.26.10」 |
|
||||
| 棘轮 | `style.css` 追加 `font-size: 13px` | `font-size 写死 170 → 171(+1)` 立刻红,还原后绿 |
|
||||
| 对比度 | 把 `clampAgainst` 短路成 `return fg` | 100+ 对跌破阈值(亮色 text × inset 2.97 vs 下限 7) |
|
||||
|
||||
**一个被证伪的直觉**:本想用「调坏某个 mix 权重」验证对比度守卫,改完却仍全绿 —— 因为 `clampAgainst` 会重新夹回阈值。这反过来证明夹紧机制有效,也说明守卫该防的是「有人删掉夹紧 / 把 token 写死成常数」,于是按这个失效模式重做了注入。
|
||||
|
||||
**计划外但必须现在做**:验证闸门时发现 CSS 闸门**看不见 JS 内联样式**,而 `src/storage-file.js` 的首启动「选择资料目录」弹窗是全仓唯一完全未 token 化的界面(`font-size:12.5px` / 白底 `#fff` / 主按钮 `#2563eb`,深色下是白盒子)。已一并处理:闸门扩到 JS(CSS 文本按 `px` 单位判、React 对象按 camelCase 判,避免误伤 `{ gap: 20 }` 这类布局参数),弹窗本身 token 化并给每个 `var()` 加字面兜底。
|
||||
|
||||
**留给 RFC 的一件事**:遮罩色 `rgba(18,20,26,.72)` 没有对应 token(全仓 3 处遮罩各写一份),硬凑 `bg`/`panel` 会让亮色主题出现浅色遮罩 —— 登记 `/*iwb:raw-until=3.28.0*/`,待 `--iwb-scrim` 的取值与消费者定案。
|
||||
|
||||
### M6 延展验证(0.5d)—— ✅ 已完成 2026-11-23(v3.26.51)
|
||||
|
||||
| ID | 任务 | 验收 |
|
||||
|---|---|---|
|
||||
| T6.1 | 用 token 重做一个真实面板(建议「插件管理」分区:表格 + 卡片 + 开关,覆盖面够) | 新代码零裸值;token-lint 通过 |
|
||||
| T6.2 | 选 `plugin-batch-export`(15 处硬编码)改版并发一个 patch | 契约测试白名单移除该项;插件暗色正常 |
|
||||
| T6.3 | 把这次的两份实现写成「接入案例」附在规范 §5.2 下 | 后来者照抄即可 |
|
||||
|
||||
**执行结果**:
|
||||
|
||||
| ID | 做了什么 | 验收实测 |
|
||||
|---|---|---|
|
||||
| T6.1 ✅ | 把 `style.css` 里 v3.26.24→27 六次叠加的两段(1819–1885 / 2194–2295)**合并重写成一份**;删 3 个零引用类与 1 条死兜底;新增 `--iwb-font-base` 承接 14px 正文 | 133 行新增 → `lint:tokens` **0 处裸值**;`style.css` 净减 34 行;新增 ⑦⑧ 两张组件夹具基线,16 张连跑两次全绿 |
|
||||
| T6.2 ✅ | 文件级豁免那一半在 **B6 已提前完成**(`ALLOW_FILES` 6→0);本批改的是另一半:`batch-export` 状态色改走宿主语义 token + 保留私有值兜底,去掉与「全灰阶」冲突的纯蓝主按钮,发 **1.2.2** | 亮色主按钮对比 **9.51**、暗色 **14.10**;状态色对页面亮 5.38/6.95、暗 10.01/7.03;插件仓 `validate` 13/13、契约测试 0 文件豁免 |
|
||||
| T6.3 ✅ | 规范新增 **§5.7 接入案例**(两份实现的决策表 + 三个缺口 + 照抄清单);顺手修掉 §5.2 里「引用并不存在的 `--iwb-dur-*`」这条会让人踩空的说明 | 文档与代码同批复核 |
|
||||
|
||||
**三个被撞出来的缺口**(这才是 M6 的产出 —— 都回去改了 token/守卫,没有改文档糊过去):
|
||||
|
||||
1. **闭集缺 14px**:表单行标题、命令输入、帮助正文全站 10 处,13→15 跨 2px 无处安放 → 新增 `--iwb-font-base: 14px`(7→8 档)。
|
||||
2. **状态色不能当文字色**:`--iwb-ok` 亮色 `#22c55e` 对浅页面只有 **2.13**,而 `.iwb-status-ok` / `.iwb-ratio.ok` 一直这么用 → `derive()` 亮色状态色调深(暗色不变),`theme-contrast-test` 补 3 色 × 4 表面 × 2 主题,**114 → 138 对**。M5 的守卫只查 text/text2/dim/brandText,把这类漏了。
|
||||
3. **面板在网页 e2e 里不可达**:`DesktopPluginsTab` 只在 `isDesk()` 时渲染,最乱的样式反而没有截图保护 → 加组件夹具基线(同类名 + 真实 `dist/style.css` + 构造 DOM),并必须在夹具里关掉 `transition`,否则开关 `.15s` 收尾会让两次截图差 7 个像素 × 1 级灰度,`threshold: 0` 随机红。
|
||||
|
||||
**存量计数下调并写回棘轮基线**:字号 170→159、圆角 103→95、间距 415→377、hex 84→79、圆角种数 18→17、阴影 45→44。
|
||||
这是 M5 装上棘轮以来**第一次真正下降** —— 闸门管增量、真实改版清存量,分工成立。
|
||||
|
||||
## 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.26.50 | M5 ✅ | 零 | 闸门上线:`lint:tokens`(只查新增行)+ 13 项棘轮 + 114 对对比度;三道闸门各打红一次 |
|
||||
| 3.26.51 | M6 ✅ | 亮色状态色调深(见下) | 案例沉淀:合并重写插件面板 + batch-export 1.2.2 + 补 font-base 档 + 对比度守卫 114→138 |
|
||||
|
||||
> 前置: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**;闭集 7 档已建) | **8**(M6 补 `--iwb-font-base`:14px,散值仍 13) |
|
||||
| 圆角档数 | 18 | 5 | 5 |
|
||||
| 间距档数 | 30 | ≤16 | ≤16 |
|
||||
| 字号写死处 | 268 | ≤60(B6 后 **170**) | ≤20(**M6 后 159**) |
|
||||
| 圆角写死处 | 164 | ≤40(B6 后 **103**) | ≤10(**M6 后 95**) |
|
||||
| 间距写死处 | 629 | ≤200(B6 后 **415**) | ≤80(**M6 后 377**) |
|
||||
| 阴影写法种类 | 52 | ≤8 | 5(**M6 后 44**,存量待清) |
|
||||
| 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 | **16 张**(M6 新增 ⑦⑧ 组件夹具;亮色状态色调深使 7 张亮色更新,复核 16/16) |
|
||||
| **新增裸值(增量)** | 无闸门 | **0/PR**(M5:`lint:tokens` 只查新增行) | 0 |
|
||||
| **对比度达标对** | 未度量 | **114/114**(M5:亮/暗 × 文字 × 表面) | **138/138**(M6 补状态色 24 对) |
|
||||
|
||||
**M6 后(v3.26.51)**:**第一次真正下降** —— 字号 159 / 圆角 95 / 间距 377 / hex 79 / 圆角种数 17 / 阴影 44,
|
||||
已写回棘轮基线。同时补齐两处「规范自称有、实际没有」的地方:`--iwb-font-base`(14px) 与状态色对比度守卫(138 对)。
|
||||
M1–M6 全部完成,设计 token 从「铺完」走到「能照着写、有闸门、有回归」。
|
||||
|
||||
**M6 后修订(v3.26.52,用户截图反馈)**:收官后的第一个真实观感回归 —— 提示词 / 文本节点正文被 `--iwb-field`(亮色=纯白)铺成白矩形、编辑态冒出控件聚焦框。根因是 §1.9 的 D10 使用规则被读成「节点内**一切**表单控件」,漏了「正文文本区不是控件」这一层分类;两条 CSS 覆盖链见规范 §1.13。修法与表面角色三分法写进规范 §1.9 / §1.13 / §3.1,守卫进 `tests/node-scope-test.js` 第 5 条,受影响的 8 张画布相关基线(②④⑤⑥ × 亮/暗)重录并复核差异图(红色像素只在节点正文矩形内,无布局位移)。
|
||||
|
||||
> 教训:**相对派生解决的是「控件该多亮」,不解决「这里该不该有控件面」**。分类判据必须写进规范,
|
||||
> 不能只靠颜色公式;否则每一批「统一节点内表面」都会把正文顺手刷成控件。
|
||||
|
||||
## 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 = 2b8e337`(线上 `v3.26.41+2b8e337` —— 2026-11-23 发**正式线**:继承态提示词把上游文案与参考图交给组合/连接节点(来源判定加 `(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()` 注入 ⇒ 从存档直接进画布时节点无样式、缩略图按原图铺满)。上一条 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 = 573f245`(线上 `v3.26.55+573f245` —— 2026-11-23 **节点正文文本区修复**:提示词/文本节点正文透明继承卡片底色(白卡片消失)、编辑态三层框(控件 border / 聚焦光晕 / D8 焦点环)全去掉,规范补表面角色三分法与 `node-scope-test` 第 5 条守卫,8 张基线重录;上一条 `v3.26.51+21554b0` —— **M6 延展验证**:插件面板两段六次叠加样式合并重写、133 行新增零裸值;补 `--iwb-font-base`(14px) 第 8 档与亮色状态色调深(对浅页面 2.13 → ≥4.6),对比度守卫 114→138 对;新增 ⑦⑧ 组件夹具基线共 16 张;`batch-export` 1.2.2 状态色走宿主 token、去掉纯蓝主按钮;棘轮基线首次下调。M1–M6 全部完成;上一条 `v3.26.50+cab473c` —— **M5 闸门**:新增 `scripts/token-lint.js`(只查 diff 新增行,CSS 与 JS 内联样式两套判据、四类白名单)+ `tests/design-token-ratchet-test.js`(13 项计数只降不升)+ `tests/theme-contrast-test.js`(亮/暗 × 文字 × 表面 114 对),三条各做一次打红验证后接进 `verify:ci`;顺手把首启动「选择资料目录」弹窗 token 化(全仓最后一个完全未 token 化的界面);上一条 `v3.26.49+1743453` —— **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` 通过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 迁出)
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
1. **只用变量**:`--iwb-plugin-*` 或 `--iwb-*`,禁止写死 `#hex` / `rgba()`。
|
||||
(守门测试 `tests/plugin-theme-contract-test.js` 会卡)
|
||||
1.5. **尺寸只许闭集**:字号 11/12/13/14/15/17/20/24、圆角 6/8/10/12/14/999、间距 0/2/4/6/8/10/12/16/20/24/32/40/48/64;散值由 `tests/plugin-scale-contract-test.js` 棘轮拦截(只降不升)。
|
||||
|
||||
2. **面板根不画底色**:宿主已给 `--iwb-plugin-surface`;插件根容器只写 `background: var(--iwb-plugin-surface)`。
|
||||
3. **卡片才用 card**:列表项/卡片用 `--iwb-plugin-card`,这样「浅灰底 + 白卡片」的层次才成立。
|
||||
4. **文字层级**:主文字 `--iwb-plugin-text`,次要 `--iwb-plugin-text2`,品牌 `--iwb-plugin-brand`(底色上的字用 `--iwb-plugin-on-brand`,宿主按对比度自动黑/白)。
|
||||
|
||||
@@ -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,73 @@
|
||||
# UI 改动约束清单(Design Token 落地版)
|
||||
|
||||
> 适用范围:所有界面调整(宿主 `style.css` / `src/ui-*.js`、`plugins/**`、`site/**`)。
|
||||
> 唯一数值来源:[design-tokens.md](./design-tokens.md);插件契约:[plugin-theme.md](./plugin-theme.md)。
|
||||
|
||||
## 1. 写前:先查表,不许临场编值
|
||||
|
||||
| 要改什么 | 必须用 | 禁止 |
|
||||
| --- | --- | --- |
|
||||
| 灰/表面/文字/边框色 | `--iwb-plugin-*`(插件面板)或 `--iwb-color-*`(宿主) | `#hex`、`rgba()`(`var(--x,#hex)` 兜底除外) |
|
||||
| 间距 | `--iwb-space-2/4/6/8/10/12/16/20/24/32/40/48/64` | 13/14/18/22 等非档位值 |
|
||||
| 字号 | `--iwb-font-xs…display`(11/12/13/14/15/17/20/24) | 半像素字号(10.5/11.5/12.5/13.5) |
|
||||
| 圆角 | `--iwb-radius-chip/control/card/panel/popover/full`(6/8/10/12/14/999) | 7/9/11/13 等散值 |
|
||||
| 阴影 | `--iwb-elevation-1..4` | 自定义 `0 4px 16px rgba(...)` |
|
||||
| 层级 | `--iwb-z-*` | 9999/4000 等裸数字 |
|
||||
| 动效 | `--iwb-dur-*` / `--iwb-ease-*` | 200ms/0.3s 混用 |
|
||||
|
||||
插件额外规则:
|
||||
|
||||
- 面板根 `--iwb-plugin-surface`、卡片 `--iwb-plugin-card`、输入框/内嵌 `--iwb-plugin-inset`、hover `--iwb-plugin-hover`
|
||||
- 高饱和强调色允许写死(chroma ≥ 24);灰色必须 token
|
||||
- 只有 `manifest.skin = "private"` 才可整套私有配色,且不得引用宿主颜色 token
|
||||
- 内容色(画布白底、画笔色)必须行内 `/*iwb:content*/`
|
||||
|
||||
## 2. 写中:三条机械规则
|
||||
|
||||
1. **不改 token 定义**:要新值,先按 `design-tokens.md §5.1` 提 RFC(用途 / 消费者 ≥2 / 亮暗值 / 替代方案 / 弃用计划),先改规范再改代码。
|
||||
2. **只引用 L2**:组件/插件只消费 L2;需要 L1 说明层选错了。
|
||||
3. **例外登记,不做文件豁免**:只能行内 `/*iwb:raw-until=<版本>*/`(必须带到期版本)或 `/*iwb:content*/`,禁止整文件白名单。
|
||||
|
||||
## 3. 写后:四道闸门(缺一不可合并/发版)
|
||||
|
||||
| 闸门 | 命令 | 拦什么 |
|
||||
| --- | --- | --- |
|
||||
| Token 快照 | `npm run tokens:check` | `design-tokens.css` 与 `derive()` 漂移 |
|
||||
| 新增行 lint | `npm run lint:tokens` | 新增行写死字号/圆角/间距/颜色/z-index |
|
||||
| 插件契约 | `node tests/plugin-theme-contract-test.js` | 插件写死灰色、私有皮肤违规 |
|
||||
| 插件尺度棘轮 | `node tests/plugin-scale-contract-test.js` | 插件字号/圆角/间距散值只降不升 |
|
||||
| 视觉回归 | `npm run test:visual` | 亮/暗截图与基线像素 diff |
|
||||
|
||||
> `npm run verify:ci` 已串起前四道(构建、快照、lint、单测);`test:visual` 在改动浮层/面板时必跑。
|
||||
|
||||
## 4. 视觉验证流程(防止“测试过但变丑”)
|
||||
|
||||
1. 静态 HTML + Playwright 截图(亮/暗两套,固定视口)
|
||||
2. 与上一版基线叠图对比,确认只有预期区域变化
|
||||
3. 真机截图复核
|
||||
4. 再 bump 版本 / 上市场
|
||||
|
||||
## 5. 违规处理
|
||||
|
||||
- CI 红 → 不合并、不发版
|
||||
- **禁止“为了过测试改语义”**:不得把 `color` 换成 `border` token 糊弄测试(历史事故,见 `promptlib-style-baseline.md`)
|
||||
- 测试与视觉冲突时:改测试规则或补 token,不改视觉语义
|
||||
- 每版发布前跑 `node scripts/token-audit.js --json`,散值数量只能降不能升
|
||||
|
||||
## 6. 复核命令
|
||||
|
||||
```bash
|
||||
node scripts/token-audit.js # 宿主 token 现状
|
||||
node scripts/token-audit.js --plugins # 插件写死色/散值清单(按文件)
|
||||
node scripts/token-audit.js --contrast # 对比度矩阵
|
||||
node scripts/token-lint.js --file style.css
|
||||
npm run test:visual
|
||||
```
|
||||
|
||||
## 7. 视觉基线(已接入 promptlib)
|
||||
|
||||
- 基线文件:`tests/_visual-tokens.spec.js` 的 ⑨ 编辑弹窗 / ⑩ 详情弹窗(亮/暗各 2 张,共 4 张)
|
||||
- 运行:`npm run test:visual`(比对本机基线,0 diff 才算过)
|
||||
- 有意改动:`npm run test:visual:update` 后**人工确认截图**,再提交快照
|
||||
- 纯重构(token 迁移、去重):必须 0 diff;若 diff 非 0,先解释变化区域再更新基线
|
||||
- 该套件不挂 CI(字体/DPR/GPU 跨机器会漂移),属于发版前本地验收
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.41",
|
||||
"version": "3.26.55",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
@@ -10,22 +10,30 @@
|
||||
"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 && node tests/plugin-scale-contract-test.js && node tests/design-token-ratchet-test.js && node tests/theme-contrast-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:tokens && 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",
|
||||
"sync:facts": "node scripts/sync-facts.js",
|
||||
"sync:facts:write": "node scripts/sync-facts.js --write",
|
||||
"typecheck": "tsc -p tsconfig.json",
|
||||
"release:desktop": "bash scripts/release.sh"
|
||||
"release:desktop": "bash scripts/release.sh",
|
||||
"lint:tokens": "node scripts/token-lint.js",
|
||||
"test:tokens": "node tests/design-token-ratchet-test.js && node tests/theme-contrast-test.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.64.1",
|
||||
|
||||
@@ -300,6 +300,11 @@
|
||||
function renderGrid () {
|
||||
clear(grid)
|
||||
var gap = 6
|
||||
// 每次重排都重新量一次宽度:面板显隐/停靠栏展开时 gridW 可能是旧值,
|
||||
// 只靠 ResizeObserver 会在「变成 0 再回来」期间漏掉,导致必须拖宽度才出图。
|
||||
var liveW = availableW()
|
||||
if (liveW > 0 && Math.abs(liveW - gridW) > 1) gridW = liveW
|
||||
if (!gridW) gridW = 320
|
||||
var tileW = Math.max(40, Number(cfg.tile) || 110)
|
||||
var n = Math.max(1, Math.floor((gridW + gap) / (tileW + gap)))
|
||||
// v1.6.6:列宽 = 均分宽度(铺满面板),图幅只决定「列数」——
|
||||
@@ -368,7 +373,7 @@
|
||||
function paint (url) {
|
||||
if (!url || typeof url !== 'string') { fail('图片已丢失'); return }
|
||||
if (!box.isConnected) return
|
||||
var img = el('img', { src: url, alt: '', loading: 'lazy', draggable: 'true' })
|
||||
var img = el('img', { src: url, alt: '', loading: 'eager', draggable: 'true' })
|
||||
if (it.w && it.h) img.setAttribute('style', 'aspect-ratio:' + it.w + ' / ' + it.h)
|
||||
img.addEventListener('load', function () {
|
||||
// naturalWidth=0 说明拿到的是坏图(空 data URL / 截断文件):按失败处理,别留白块
|
||||
@@ -407,7 +412,7 @@
|
||||
if (img.parentNode === box) box.replaceChild(holder, img)
|
||||
fail('缩略图加载失败(点击重试)')
|
||||
} catch (e) { /* ignore */ }
|
||||
}, 700)
|
||||
}, 2000)
|
||||
// 加载成功后再替换占位(避免破图标 + 长 title 占满格子)
|
||||
if (img.complete && img.naturalWidth > 0) { img.style.display = ''; if (holder.parentNode === box) box.replaceChild(img, holder) }
|
||||
else if (img.complete && !img.naturalWidth) { /* 立即失败(坏图)*/ tries++; if (tries <= 2) setTimeout(boot, 400 * tries); else { if (img.parentNode === box) box.replaceChild(holder, img); fail('缩略图加载失败(点击重试)') } }
|
||||
@@ -447,7 +452,7 @@
|
||||
render()
|
||||
}
|
||||
|
||||
function render () { renderHead(); renderGrid() }
|
||||
function render () { renderHead(); renderGrid(); global.requestAnimationFrame(function () { try { measure() } catch (e) {} }); setTimeout(function () { try { measure() } catch (e) {} }, 150) }
|
||||
|
||||
function load (force) {
|
||||
if (force) setStatus('刷新中…')
|
||||
@@ -538,7 +543,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.6.9',
|
||||
version: '1.6.11',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "gallery",
|
||||
"name": "图库",
|
||||
"version": "1.6.9",
|
||||
"version": "1.6.11",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"图库"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "26c7e64b3a0021c6b9514dfb84d4d2580276698222b4791cfa99f22ead66ff52",
|
||||
"styles.css": "9d5b4ab1343761e51ef0c479cab96a94d3d6eaa27f0fdb500bff789ec81d70e0"
|
||||
"main.js": "cf456629b21f9001d7cc8016a6af0d2b065aae110ef822b7946e6279ec822f11",
|
||||
"styles.css": "35ae17de8b0f3bddab9cbef6270cd8bbf5153c9ecf6ed2b4f06216f6fef45b8b"
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
/* ---- 顶栏 ---- */
|
||||
.iwb-gal-head { display: flex; align-items: center; gap: 6px; min-height: 0; }
|
||||
.iwb-gal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
||||
.iwb-gal-actions .iwb-btn-sm { padding: 2px 7px; }
|
||||
.iwb-gal-actions .iwb-btn-sm { padding: 2px 6px; }
|
||||
|
||||
/* ---- 底栏:左信息 / 右工具组 ---- */
|
||||
.iwb-gal-foot {
|
||||
@@ -32,7 +32,7 @@
|
||||
.iwb-gal-foot .iwb-gal-icobtn:active {
|
||||
width: 20px; height: 20px; min-width: 20px; padding: 0; box-sizing: border-box;
|
||||
display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
|
||||
border: 0; box-shadow: none; background: transparent; border-radius: 4px;
|
||||
border: 0; box-shadow: none; background: transparent; border-radius: 6px;
|
||||
color: var(--iwb-text2); line-height: 1; transform: none;
|
||||
}
|
||||
.iwb-gal-foot .iwb-gal-icobtn svg { display: block; pointer-events: none; }
|
||||
@@ -43,7 +43,7 @@
|
||||
/* ---- 设置浮层(三个下拉不占前台) ---- */
|
||||
.iwb-gal-settings {
|
||||
position: absolute; right: 8px; bottom: 34px; z-index: 30; width: 176px; max-width: calc(100% - 16px);
|
||||
display: flex; flex-direction: column; gap: 8px; padding: 9px 10px;
|
||||
display: flex; flex-direction: column; gap: 8px; padding: 8px 10px;
|
||||
background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 8px;
|
||||
box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
|
||||
}
|
||||
@@ -65,7 +65,7 @@
|
||||
font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all;
|
||||
}
|
||||
.iwb-history-actions { display: flex; gap: 4px; padding: 4px 2px 0; }
|
||||
.iwb-history-actions .iwb-btn-sm { padding: 1px 6px; font-size: 10px; }
|
||||
.iwb-history-actions .iwb-btn-sm { padding: 2px 6px; font-size: 11px; }
|
||||
.iwb-history-more { display: flex; justify-content: center; padding: 4px 0 2px; }
|
||||
/* 只作用于图库自己的空态提示:不加前缀会泄漏到设置页等使用 .iwb-hint 的地方(文字被居中) */
|
||||
.iwb-history-embedded .iwb-hint { font-size: 11px; color: var(--iwb-text2); text-align: center; padding: 12px 6px; }
|
||||
|
||||
@@ -439,7 +439,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'grouplib',
|
||||
name: '节点组',
|
||||
version: '1.0.4',
|
||||
version: '1.0.5',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'grouplib'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "grouplib",
|
||||
"name": "节点组",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"节点组"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "8cb2e39f9880d49c9b9c15a1f7d62d9772170c8d0eac0faaa237bb7056af34ff",
|
||||
"styles.css": "ee6e292ffebdcc1351651bf7937399128ae06e0b364624792f34111866f9355b"
|
||||
"main.js": "f59e06065392d01c2e87808382d546d91bf8d57451ef81922b3204f36e6490c9",
|
||||
"styles.css": "909e49d15a183ab9f36c298241fcab4506ed29e22b5a5daa47f086cbc7a65376"
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
.iwb-glp-dragging { opacity: .55; }
|
||||
/* 空态:虚线框 */
|
||||
.iwb-glp-empty {
|
||||
margin: 4px 0; padding: 14px 12px; border-radius: 10px; text-align: center;
|
||||
margin: 4px 0; padding: 12px 12px; border-radius: 10px; text-align: center;
|
||||
border: 1px dashed var(--iwb-border2, #b9bfca); color: var(--iwb-text2, #4d5668);
|
||||
font-size: 12px; line-height: 1.7;
|
||||
}
|
||||
@@ -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.44c13ac8e6d9.js",
|
||||
"version": "1.2.2",
|
||||
"integrity": "sha256-RME6yObZW4tKMZmfwtaIX4iODMFlo57baLn/y0GZbfU="
|
||||
},
|
||||
{
|
||||
"id": "blank-canvas",
|
||||
@@ -13,19 +13,19 @@
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"dir": "gallery",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.6.9",
|
||||
"version": "1.6.11",
|
||||
"files": {
|
||||
"main.js": "26c7e64b3a0021c6b9514dfb84d4d2580276698222b4791cfa99f22ead66ff52",
|
||||
"styles.css": "9d5b4ab1343761e51ef0c479cab96a94d3d6eaa27f0fdb500bff789ec81d70e0"
|
||||
"main.js": "cf456629b21f9001d7cc8016a6af0d2b065aae110ef822b7946e6279ec822f11",
|
||||
"styles.css": "35ae17de8b0f3bddab9cbef6270cd8bbf5153c9ecf6ed2b4f06216f6fef45b8b"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -33,10 +33,10 @@
|
||||
"dir": "grouplib",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"files": {
|
||||
"main.js": "8cb2e39f9880d49c9b9c15a1f7d62d9772170c8d0eac0faaa237bb7056af34ff",
|
||||
"styles.css": "ee6e292ffebdcc1351651bf7937399128ae06e0b364624792f34111866f9355b"
|
||||
"main.js": "f59e06065392d01c2e87808382d546d91bf8d57451ef81922b3204f36e6490c9",
|
||||
"styles.css": "909e49d15a183ab9f36c298241fcab4506ed29e22b5a5daa47f086cbc7a65376"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -44,23 +44,23 @@
|
||||
"dir": "promptlib",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.8.21",
|
||||
"version": "1.8.24",
|
||||
"files": {
|
||||
"main.js": "125e02a618e37505836f964dbe21a3637e3043ee355d9606c538a54eed4243ad",
|
||||
"styles.css": "84ad2314d016c7d2351eb7cf2044ee8cc703992d40a76002ff644d34eb48838a"
|
||||
"main.js": "0bab5f57c173d0bf45a16881042d9b3b1973a2afe2e6c3745a27fd5181b793b0",
|
||||
"styles.css": "e14fee1fd446188ef44913cc2d549e02480b10d95a67371078ec4fa623786d60"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -1763,7 +1763,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'promptlib',
|
||||
name: '提示词库',
|
||||
version: '1.8.21',
|
||||
version: '1.8.24',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
|
||||
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "promptlib",
|
||||
"name": "提示词库",
|
||||
"version": "1.8.21",
|
||||
"version": "1.8.24",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"提示词"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "125e02a618e37505836f964dbe21a3637e3043ee355d9606c538a54eed4243ad",
|
||||
"styles.css": "84ad2314d016c7d2351eb7cf2044ee8cc703992d40a76002ff644d34eb48838a"
|
||||
"main.js": "0bab5f57c173d0bf45a16881042d9b3b1973a2afe2e6c3745a27fd5181b793b0",
|
||||
"styles.css": "e14fee1fd446188ef44913cc2d549e02480b10d95a67371078ec4fa623786d60"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
.iwb-promptlib, .iwb-plp-dialog, .iwb-plp-mask, .iwb-plp-dragghost, .iwb-plp-placebox{--iwb-plp-accent:#6b4dff;--iwb-plp-accent-soft:#f1ecff;--iwb-plp-accent-border:#d9d3ff}
|
||||
/* promptlib(提示词库)自带样式
|
||||
作用域全部带 .iwb-plp-*,不影响宿主与其他插件;样式随插件发布,不必等客户端发版。 */
|
||||
|
||||
@@ -34,9 +35,9 @@
|
||||
.iwb-plp-card:hover { border-color: var(--iwb-border2, #b9bfca); }
|
||||
.iwb-plp-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||
.iwb-plp-t {
|
||||
position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 7px 6px;
|
||||
position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 6px 6px;
|
||||
background: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,.66));
|
||||
color: var(--plp-c1, #fff); font-size: 10.5px; line-height: 1.35; max-height: 48%;
|
||||
color: var(--plp-c1, #fff); font-size: 11px; 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);
|
||||
}
|
||||
@@ -54,26 +55,26 @@
|
||||
/* 编辑弹窗:760 宽 + 大文本框 */
|
||||
.iwb-promptlib-editor { width: 760px; max-width: 94vw; }
|
||||
.iwb-promptlib-editor .iwb-modal-body { max-height: 78vh; }
|
||||
.iwb-promptlib-text { min-height: 360px; height: 44vh; font-size: 12.5px; line-height: 1.9; resize: vertical; }
|
||||
.iwb-promptlib-text { min-height: 360px; height: 44vh; font-size: 13px; line-height: 1.9; resize: vertical; }
|
||||
.iwb-plp-editor-cover { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
|
||||
.iwb-plp-editor-thumb { flex: 0 0 96px; width: 96px; height: 128px; border-radius: 8px; overflow: hidden; border: 1px solid var(--iwb-border, #d5d9e0); }
|
||||
.iwb-plp-editor-coverops { display: flex; flex-direction: column; gap: 8px; }
|
||||
|
||||
/* v1.2.0:可拖动 / 可缩放的详情与编辑弹窗(同宽 880×640,最小 640×420) */
|
||||
.iwb-plp-mask { background: transparent; display: block; }
|
||||
.iwb-plp-dialog { display: flex; flex-direction: column; overflow: hidden; border-radius: 16px;
|
||||
.iwb-plp-dialog { display: flex; flex-direction: column; overflow: hidden; border-radius: 14px;
|
||||
box-shadow: 0 24px 60px rgba(0,0,0,.28); }
|
||||
.iwb-plp-dhead { display: flex; align-items: center; gap: 6px; padding: 10px 14px;
|
||||
.iwb-plp-dhead { display: flex; align-items: center; gap: 6px; padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--iwb-border, #d5d9e0); cursor: move; user-select: none; }
|
||||
.iwb-plp-grip { display: grid; grid-template-columns: repeat(3, 3px); gap: 2px; margin-right: 6px; }
|
||||
.iwb-plp-grip i { width: 3px; height: 3px; border-radius: 50%; background: var(--iwb-border2, #b9bfca); display: block; }
|
||||
.iwb-plp-dbody { flex: 1 1 auto; min-height: 0; display: flex; gap: 14px; padding: 14px; }
|
||||
.iwb-plp-dbody { flex: 1 1 auto; min-height: 0; display: flex; gap: 12px; padding: 12px; }
|
||||
.iwb-plp-dcov { flex: 0 0 210px; width: 210px; height: 280px; border-radius: 10px; overflow: hidden;
|
||||
border: 1px solid var(--iwb-border, #d5d9e0); background: var(--iwb-plugin-inset, #f5f6f7); }
|
||||
.iwb-plp-dright { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
|
||||
.iwb-plp-dtext { flex: 1 1 auto; min-height: 0; overflow: auto; white-space: pre-wrap; word-break: break-word;
|
||||
font-size: 12px; line-height: 1.9; color: var(--iwb-text2, #4d5668); }
|
||||
.iwb-plp-dfooter { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 14px;
|
||||
.iwb-plp-dfooter { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px;
|
||||
border-top: 1px solid var(--iwb-border, #d5d9e0); }
|
||||
.iwb-plp-resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize;
|
||||
background: linear-gradient(135deg, transparent 0 45%, var(--iwb-border2, #b9bfca) 45% 50%, transparent 50% 62%, var(--iwb-border2, #b9bfca) 62% 67%, transparent 67%); }
|
||||
@@ -81,7 +82,7 @@
|
||||
.iwb-plp-eleft { flex: 0 0 240px; width: 240px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
|
||||
.iwb-plp-ecov { width: 240px; height: 300px; border-radius: 10px; overflow: hidden;
|
||||
border: 1px solid var(--iwb-border, #d5d9e0); background: var(--iwb-plugin-inset, #f5f6f7); }
|
||||
.iwb-plp-lrow { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--iwb-text2, #4d5668); }
|
||||
.iwb-plp-lrow { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--iwb-text2, #4d5668); }
|
||||
.iwb-plp-etext { flex: 1 1 auto; min-height: 0; height: auto; resize: none; font-size: 12px; line-height: 1.9; }
|
||||
/* 输入框边框柔化(用户反馈现在的边框太深) */
|
||||
.iwb-plp-dialog .iwb-input { border-color: color-mix(in srgb, var(--iwb-border, #d5d9e0) 72%, transparent); }
|
||||
@@ -143,48 +144,48 @@
|
||||
.iwb-plp-node{display:flex;flex-direction:column;gap:6px;padding:8px 10px;font-size:12px;color:var(--iwb-text,#1c2333)}
|
||||
.iwb-plp-nhead{display:flex;align-items:center;gap:8px}
|
||||
.iwb-plp-nthumb{width:44px;height:44px;border-radius:8px;object-fit:cover;flex:0 0 auto}
|
||||
.iwb-plp-ntitle{font-weight:600;font-size:12.5px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
||||
.iwb-plp-ntitle{font-weight:600;font-size: 13px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
||||
.iwb-plp-nvars{display:flex;flex-direction:column;gap:4px}
|
||||
.iwb-plp-nrow{display:flex;align-items:center;gap:6px;height:26px}
|
||||
.iwb-plp-nk{width:64px;flex:0 0 64px;color:var(--iwb-text2,#5b6472);font-size:11.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.iwb-plp-nin{flex:1;height:24px;font-size:11.5px}
|
||||
.iwb-plp-nref{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--iwb-text2,#5b6472);border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px}
|
||||
.iwb-plp-nk{width:64px;flex:0 0 64px;color:var(--iwb-text2,#5b6472);font-size: 12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.iwb-plp-nin{flex:1;height:24px;font-size: 12px}
|
||||
.iwb-plp-nref{display:flex;align-items:center;gap:6px;font-size: 12px;color:var(--iwb-text2,#5b6472);border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px}
|
||||
.iwb-plp-nref em{font-style:normal;color:var(--iwb-text2,#8b929c)}
|
||||
.iwb-plp-nprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;color:var(--iwb-text2,#5b6472);font-size:11.5px;line-height:1.6;max-height:88px;overflow:hidden}
|
||||
.iwb-plp-nprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;color:var(--iwb-text2,#5b6472);font-size: 12px;line-height:1.6;max-height:88px;overflow:hidden}
|
||||
|
||||
/* v1.5.0:变量编辑器 / 详情变量 */
|
||||
.iwb-plp-emid{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px}
|
||||
.iwb-plp-vars{border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px;display:flex;flex-direction:column;gap:6px;background:var(--iwb-plugin-surface,#fff)}
|
||||
.iwb-plp-vhead{display:flex;align-items:center;gap:8px;font-size:11.5px;color:var(--iwb-text2,#5b6472)}
|
||||
.iwb-plp-vhead{display:flex;align-items:center;gap:8px;font-size: 12px;color:var(--iwb-text2,#5b6472)}
|
||||
.iwb-plp-vhint{color:var(--iwb-text2,#8b929c);font-size:11px}
|
||||
.iwb-plp-vchips{display:flex;flex-wrap:wrap;gap:6px}
|
||||
.iwb-plp-vchip{display:inline-flex;align-items:center;gap:4px;padding:1px 7px;border-radius:6px;background:color-mix(in srgb, var(--iwb-plp-accent, #7c4dff) 10%, transparent);color:var(--iwb-plp-accent, #5a4bd0);font-size:11.5px}
|
||||
.iwb-plp-vchip{display:inline-flex;align-items:center;gap:4px;padding: 2px 6px;border-radius:6px;background:color-mix(in srgb, var(--iwb-plp-accent, #7c4dff) 10%, transparent);color:var(--iwb-plp-accent, #5a4bd0);font-size: 12px}
|
||||
.iwb-plp-vx{font-style:normal;cursor:pointer;color:var(--iwb-plp-accent, #8b7ff0);font-weight:700}
|
||||
.iwb-plp-vrows{display:flex;flex-direction:column;gap:5px}
|
||||
.iwb-plp-vrows{display:flex;flex-direction:column;gap: 6px}
|
||||
.iwb-plp-vrow{display:flex;align-items:center;gap:8px}
|
||||
.iwb-plp-vk{width:92px;flex:0 0 92px;font-size:11.5px;color:var(--iwb-text2,#5b6472);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.iwb-plp-vin{flex:1;height:26px;font-size:11.5px}
|
||||
.iwb-plp-vprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;font-size:11.5px;line-height:1.6;color:var(--iwb-text2,#5b6472);max-height:72px;overflow:auto;white-space:pre-wrap}
|
||||
.iwb-plp-dvars{display:flex;flex-direction:column;gap:5px;border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px}
|
||||
.iwb-plp-vk{width:92px;flex:0 0 92px;font-size: 12px;color:var(--iwb-text2,#5b6472);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.iwb-plp-vin{flex:1;height:26px;font-size: 12px}
|
||||
.iwb-plp-vprev{margin-top:2px;border-top:1px dashed var(--iwb-border,#e3e5e9);padding-top:6px;font-size: 12px;line-height:1.6;color:var(--iwb-text2,#5b6472);max-height:72px;overflow:auto;white-space:pre-wrap}
|
||||
.iwb-plp-dvars{display:flex;flex-direction:column;gap: 6px;border:1px solid var(--iwb-border,#e3e5e9);border-radius:10px;padding:8px 10px}
|
||||
|
||||
/* v1.5.6:模板节点参照风格节点 —— 封面 + 名称 + 变量,正文不再铺开 */
|
||||
.iwb-plp-nthumb{width:56px;height:56px;border-radius:8px;object-fit:cover;flex:0 0 auto}
|
||||
.iwb-plp-ntitlebox{min-width:0;display:flex;flex-direction:column;gap:2px}
|
||||
.iwb-plp-ntitle{font-weight:600;font-size:12.5px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
||||
.iwb-plp-nmeta{font-size:10.5px;color:var(--iwb-text2,#8b929c)}
|
||||
.iwb-plp-ntitle{font-weight:600;font-size: 13px;line-height:1.3;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
|
||||
.iwb-plp-nmeta{font-size: 11px;color:var(--iwb-text2,#8b929c)}
|
||||
.iwb-plp-nempty{font-size:11px;color:var(--iwb-text2,#8b929c);padding:2px 0}
|
||||
.iwb-plp-nwarn{font-size:11px;line-height:1.5;color:var(--iwb-warn,#d97706)}
|
||||
|
||||
/* v1.5.10:设置页 */
|
||||
.iwb-plp-settings{display:flex;flex-direction:column;gap:18px}
|
||||
.iwb-plp-ssec{border:1px solid var(--iwb-border,#e3e5e9);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:8px}
|
||||
.iwb-plp-stitle{font-weight:600;font-size:12.5px}
|
||||
.iwb-plp-settings{display:flex;flex-direction:column;gap: 16px}
|
||||
.iwb-plp-ssec{border:1px solid var(--iwb-border,#e3e5e9);border-radius:12px;padding: 12px 12px;display:flex;flex-direction:column;gap:8px}
|
||||
.iwb-plp-stitle{font-weight:600;font-size: 13px}
|
||||
.iwb-plp-sgroups{display:flex;flex-direction:column;border:1px solid var(--iwb-border,#eef0f2);border-radius:10px;overflow:hidden}
|
||||
.iwb-plp-sgrow{display:flex;align-items:center;gap:8px;padding:7px 10px;border-top:1px solid var(--iwb-border,#f1f3f5)}
|
||||
.iwb-plp-sgrow{display:flex;align-items:center;gap:8px;padding: 6px 10px;border-top:1px solid var(--iwb-border,#f1f3f5)}
|
||||
.iwb-plp-sgrow:first-child{border-top:0}
|
||||
.iwb-plp-sgrip{width:12px;height:12px;background:radial-gradient(var(--iwb-text2,#c2c7cf) 1px,transparent 1px);background-size:4px 4px;border-radius:3px;flex:0 0 auto}
|
||||
.iwb-plp-sgrip{width:12px;height:12px;background:radial-gradient(var(--iwb-text2,#c2c7cf) 1px,transparent 1px);background-size:4px 4px;border-radius: 6px;flex:0 0 auto}
|
||||
.iwb-plp-sgname{width:170px;height:26px;font-size:12px}
|
||||
.iwb-plp-sgcount{font-size:11.5px;color:var(--iwb-text2,#8b929c);width:56px}
|
||||
.iwb-plp-sgcount{font-size: 12px;color:var(--iwb-text2,#8b929c);width:56px}
|
||||
.iwb-plp-sadd{display:flex;gap:8px;align-items:center}
|
||||
.iwb-plp-sbtns{display:flex;gap:8px;align-items:center}
|
||||
.iwb-plp-sopt{display:flex;gap:8px;align-items:center;font-size:12px;color:var(--iwb-text2,#4d5668)}
|
||||
@@ -202,7 +203,7 @@ flex: 1;
|
||||
display: flex; gap: 6px; align-items: center;
|
||||
}
|
||||
.iwb-promptlib .iwb-hint {
|
||||
font-size: 10px; color: var(--iwb-text2); margin-top: 4px;
|
||||
font-size: 11px; color: var(--iwb-text2); margin-top: 4px;
|
||||
}
|
||||
.iwb-promptlib .iwb-toolbar-title {
|
||||
font-weight: 700; font-size: 13px; margin-right: 2px;
|
||||
@@ -217,10 +218,10 @@ width: 680px; max-width: calc(100vw - 60px); max-height: 82vh; background: var(-
|
||||
display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--iwb-border);
|
||||
}
|
||||
.iwb-plp-dialog-body {
|
||||
padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; max-height: 62vh;
|
||||
padding: 12px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; max-height: 62vh;
|
||||
}
|
||||
.iwb-promptlib .iwb-lib-body {
|
||||
flex: 1; overflow: hidden; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
|
||||
flex: 1; overflow: hidden; padding: 12px 12px; display: flex; flex-direction: column; gap: 8px;
|
||||
}
|
||||
.iwb-promptlib .iwb-lib-fixed {
|
||||
flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px;
|
||||
@@ -232,7 +233,7 @@ flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction:
|
||||
display: none;
|
||||
}
|
||||
.iwb-promptlib .iwb-lib-chips-scroll > .iwb-chip:last-child {
|
||||
margin-right: 18px;
|
||||
margin-right: 16px;
|
||||
}
|
||||
.iwb-promptlib .iwb-lib-searchscope-back {
|
||||
display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--iwb-text2); font-size: 13px; line-height: 1; cursor: pointer;
|
||||
@@ -241,7 +242,7 @@ display: inline-flex; align-items: center; justify-content: center; width: 15px;
|
||||
background: color-mix(in srgb, var(--iwb-text) 12%, transparent); color: var(--iwb-text);
|
||||
}
|
||||
.iwb-promptlib .iwb-chip {
|
||||
flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--iwb-text2); cursor: pointer; white-space: nowrap; transition: all 0.15s;
|
||||
flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--iwb-text2); cursor: pointer; white-space: nowrap; transition: all 0.15s;
|
||||
}
|
||||
.iwb-promptlib .iwb-chip:hover {
|
||||
color: var(--iwb-text); border-color: var(--iwb-border2);
|
||||
@@ -253,7 +254,7 @@ background: var(--iwb-panel); border-color: var(--iwb-border2); color: var(--iwb
|
||||
color: var(--iwb-text);
|
||||
}
|
||||
.iwb-promptlib .iwb-chip-count {
|
||||
font-size: 10px; opacity: 0.8;
|
||||
font-size: 11px; opacity: 0.8;
|
||||
}
|
||||
.iwb-promptlib .iwb-chip-add {
|
||||
font-weight: 700;
|
||||
@@ -268,7 +269,7 @@ color: var(--iwb-text); opacity: 1;
|
||||
border: 1px solid var(--iwb-border); border-radius: 8px; padding: 8px 10px; background: var(--iwb-panel);
|
||||
}
|
||||
.iwb-promptlib .iwb-tag {
|
||||
display: inline-block; background: color-mix(in srgb, var(--iwb-text) 7%, transparent); color: var(--iwb-text2); border-radius: 4px; font-size: 10px; padding: 1px 6px; margin: 3px 4px 0 0;
|
||||
display: inline-block; background: color-mix(in srgb, var(--iwb-text) 7%, transparent); color: var(--iwb-text2); border-radius: 6px; font-size: 11px; padding: 2px 6px; margin: 4px 4px 0 0;
|
||||
}
|
||||
.iwb-plp-dialog-sm {
|
||||
width: 460px;
|
||||
@@ -301,7 +302,7 @@ background: var(--iwb-brand); border-color: var(--iwb-brand); color: var(--iwb-o
|
||||
background: color-mix(in srgb, var(--iwb-brand) 85%, var(--iwb-text)); border-color: var(--iwb-brand); color: var(--iwb-on-brand);
|
||||
}
|
||||
.iwb-promptlib .iwb-btn-sm {
|
||||
padding: 3px 7px; font-size: 11px;
|
||||
padding: 4px 6px; font-size: 11px;
|
||||
}
|
||||
.iwb-promptlib .iwb-btn-danger {
|
||||
color: var(--iwb-err);
|
||||
@@ -313,10 +314,10 @@ border-color: var(--iwb-err); color: var(--iwb-err);
|
||||
position: fixed; min-width: 196px; max-width: 240px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 6px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); z-index: 91; display: flex; flex-direction: column; gap: 2px;
|
||||
}
|
||||
.iwb-promptlib .iwb-ctx-title {
|
||||
font-size: 10px; font-weight: 700; color: var(--iwb-text2); letter-spacing: 1px; padding: 6px 10px 2px; text-transform: uppercase;
|
||||
font-size: 11px; font-weight: 700; color: var(--iwb-text2); letter-spacing: 1px; padding: 6px 10px 2px; text-transform: uppercase;
|
||||
}
|
||||
.iwb-promptlib .iwb-ctx-item {
|
||||
display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: none; border-radius: 8px; background: transparent; color: var(--iwb-text); font-size: 12.5px; cursor: pointer; text-align: left;
|
||||
display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: none; border-radius: 8px; background: transparent; color: var(--iwb-text); font-size: 13px; cursor: pointer; text-align: left;
|
||||
}
|
||||
.iwb-promptlib .iwb-ctx-item .iwb-ic {
|
||||
width: 14px; height: 14px; flex: 0 0 auto; color: var(--iwb-text2);
|
||||
@@ -364,11 +365,11 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
|
||||
.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-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: 10px;box-shadow:0 12px 28px rgba(0,0,0,.22);font-size:12px;pointer-events:none;z-index: var(--iwb-z-anchor, 3200)}
|
||||
.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)}
|
||||
.iwb-plp-ghosthint{font-size: 11px;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}
|
||||
@@ -390,11 +391,11 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
|
||||
.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}
|
||||
.iwb-plp-placehint{font-size: 11px;color:var(--iwb-plp-accent,#5a4bd0);margin-top:2px}
|
||||
.iwb-plp-placebox{position:fixed;left:-9999px;top:0;z-index: var(--iwb-z-anchor, 3200);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: 4px 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{border: 2px dashed var(--iwb-border2, #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}
|
||||
@@ -408,51 +409,51 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
|
||||
.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-vi{flex:0 0 auto;width:24px;height:24px;padding:0;border-radius:50%;border:1px solid var(--iwb-border,#dfe3e9);background: var(--iwb-plugin-card, #fff);color: var(--iwb-text-dim, #9aa1ac);font-size:11px;line-height:22px;text-align:center}
|
||||
.iwb-plp-vi.is-open{background: var(--iwb-plp-accent-soft, #f1ecff);border-color: var(--iwb-plp-accent-border, #d8cbff);color: var(--iwb-plp-accent, #5a3fd0)}
|
||||
.iwb-plp-vdesc{width:100%;height:28px;margin-top: 6px;border-style:dashed;background: var(--iwb-field, #fbfcfd);font-size: 12px;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}
|
||||
.iwb-plp-dvar{background: var(--iwb-plp-accent-soft, #f1ecff);color: var(--iwb-plp-accent, #5a3fd0);border-radius: 6px;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-dbody{gap:10px;padding:12px;background: var(--iwb-plugin-inset, #f4f5f7)}
|
||||
.iwb-plp-dialog .iwb-plp-eleft{flex:0 0 236px;width:236px;background: var(--iwb-plugin-card, #fff);border: 1px solid var(--iwb-plugin-border, #e6e8ec);border-radius:12px;padding:12px}
|
||||
.iwb-plp-dialog .iwb-plp-emid{background: var(--iwb-plugin-card, #fff);border: 1px solid var(--iwb-plugin-border, #e6e8ec);border-radius:12px;padding:10px 12px 12px}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext{border: 1px solid var(--iwb-plugin-border, #eef0f3);background: var(--iwb-field, #fbfcfd);border-radius: 8px;padding:10px 12px}
|
||||
.iwb-plp-dialog .iwb-plp-emid .iwb-plp-etext:focus{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #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: 6px}
|
||||
.iwb-plp-dialog .iwb-plp-esplit:hover{background: var(--iwb-plugin-hover, #e7e9ee)}
|
||||
.iwb-plp-dialog .iwb-plp-esplit::before{content:'';display:block;width:2px;height:30px;border-radius: 6px;background: var(--iwb-plugin-hover, #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)}
|
||||
.iwb-plp-dialog .iwb-plp-vname{background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eceef2);border-radius:8px;height:32px;padding:0 10px;font-size: 13px;color: var(--iwb-text, #33383f)}
|
||||
.iwb-plp-dialog .iwb-plp-vname:focus{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #cfc3ff);box-shadow:0 0 0 3px rgba(107,77,255,.08)}
|
||||
.iwb-plp-dialog .iwb-plp-vi{background:transparent;border:0;color: var(--iwb-text-dim, #aab0ba);width:22px;height:22px;line-height:20px}
|
||||
.iwb-plp-dialog .iwb-plp-vi:hover{background: var(--iwb-plugin-inset, #eef0f4);color: var(--plp-c3, #6b7280)}
|
||||
.iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--iwb-plp-accent-soft, #f1ecff);color: var(--iwb-plp-accent, #5a3fd0)}
|
||||
.iwb-plp-dialog .iwb-plp-vdesc{background: var(--iwb-field, #fbfcfd);border: 1px dashed var(--iwb-plugin-border, #e2e6ec);border-radius: 8px;height:28px;margin-top:4px}
|
||||
.iwb-plp-dialog .iwb-plp-lrow span{color: var(--iwb-text2, #8a919c);font-size: 12px}
|
||||
.iwb-plp-dialog .iwb-plp-lrow .iwb-input{background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eceef2);border-radius:8px;height:32px}
|
||||
.iwb-plp-dialog .iwb-plp-lrow .iwb-input:focus{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #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{position:relative;flex:1 1 auto;min-height:0;display:flex;border-radius: 8px;background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eef0f3)}
|
||||
.iwb-plp-ewrap:focus-within{background: var(--iwb-plugin-card, #fff);border-color: var(--iwb-plp-accent-border, #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)}
|
||||
.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(--iwb-text2, #5b6472);pointer-events:none;z-index:0}
|
||||
.iwb-plp-hlvar{color: var(--iwb-text, #1d2129);font-weight:600}
|
||||
.iwb-plp-dialog .iwb-plp-vi.is-open{background: var(--iwb-plugin-hover, #eef0f3);color: var(--iwb-text2, #5b6472)}
|
||||
.iwb-plp-dialog .iwb-plp-vdesc{background:transparent;border: 1px dashed var(--iwb-plugin-border, #dfe3e9)}
|
||||
.iwb-plp-dvar{background:transparent;color: var(--iwb-text, #1d2129);font-weight:600;padding:0}
|
||||
.iwb-plp-hres{height:6px;margin: -4px 0 0;cursor:ns-resize;flex:0 0 auto;border-radius: 6px}
|
||||
.iwb-plp-hres:hover{background: var(--iwb-plugin-hover, #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{flex:1 1 auto;min-height:0;position:relative;display:flex;background: var(--iwb-field, #fbfcfd);border: 1px solid var(--iwb-plugin-border, #eef0f3);border-radius: 8px}
|
||||
.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}
|
||||
.iwb-plp-namebox{min-height:34px;height:34px;line-height:1.45;padding: 6px 10px;resize:vertical;overflow:auto;font-size: 13px}
|
||||
.iwb-plp-insvar{color: var(--iwb-text, #1d2129)!important;background: var(--iwb-plugin-card, #fff)!important;border-color: var(--iwb-plugin-border, #e2e6ec)!important}
|
||||
.iwb-plp-insvar:hover{background: var(--iwb-plugin-inset, #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}
|
||||
@@ -489,48 +490,48 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
|
||||
/* 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-dtitle{font-size: 17px;font-weight:650;line-height:1.35;margin-top: 12px;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-dgroup{font-size: 12px;background: var(--iwb-plugin-inset, #eef0f4);color: var(--iwb-text2, #5b6472);border-radius:999px;padding: 2px 8px}
|
||||
.iwb-plp-dtag{font-size: 12px;background: var(--iwb-plp-accent-soft, #f4f0ff);color: var(--iwb-plp-accent, #5a3fd0);border-radius:999px;padding: 2px 8px}
|
||||
.iwb-plp-dlen{font-size: 12px;color: var(--iwb-text-dim, #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-tagchips{display:flex;flex-wrap:wrap;gap: 6px}
|
||||
.iwb-plp-tagchip{display:inline-flex;align-items:center;gap:4px;font-size: 12px;background: var(--iwb-plugin-inset, #eef0f4);border-radius:999px;padding:2px 8px;color: var(--iwb-text, #3f4450)}
|
||||
.iwb-plp-tagx{cursor:pointer;color: var(--iwb-text-dim, #9aa1ac);font-style:normal}
|
||||
.iwb-plp-tagx:hover{color: var(--iwb-err, #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-dmeta{display:flex;flex-direction:column;gap: 6px;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-dmk{flex:0 0 30px;width:30px;font-size: 12px;color: var(--iwb-text-dim, #9aa1ac)}
|
||||
.iwb-plp-dmv{display:flex;flex-wrap:wrap;align-items:center;gap: 6px;min-width:0}
|
||||
.iwb-plp-dgroup{font-size:12px;color: var(--iwb-text, #3f4450);background: var(--iwb-plugin-inset, #f2f4f7);border-radius:6px;padding: 2px 8px}
|
||||
.iwb-plp-dtag{font-size: 12px;color: var(--iwb-plp-accent, #5a3fd0);background: var(--iwb-plp-accent-soft, #f4f0ff);border-radius:6px;padding: 2px 8px}
|
||||
.iwb-plp-dempty{font-size:12px;color: var(--iwb-text-dim, #b3b9c2)}
|
||||
.iwb-plp-dlen{font-size:12px;color: var(--iwb-text2, #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)}
|
||||
.iwb-plp-tagadd{flex:0 0 auto;width:30px;height:30px;padding:0;border-radius:8px;background: var(--iwb-plugin-inset, #f2f4f7);border: 1px solid var(--iwb-plugin-border, #e2e6ec);color: var(--iwb-text2, #5b6472);font-size: 15px;line-height:1;display:inline-flex;align-items:center;justify-content:center}
|
||||
.iwb-plp-tagadd:hover{background: var(--iwb-plugin-hover, #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-dbody{gap: 12px;padding:16px;background: var(--iwb-plugin-inset, #f4f5f7)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dleftcol{flex:0 0 300px;width:300px;padding:12px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #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)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtitle{font-size:20px;font-weight:650;line-height:1.35;margin-top: 12px;color:var(--iwb-text,#1d2129)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmeta{margin-top:12px;padding-top:12px;border-top: 1px solid var(--iwb-plugin-border, #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: 12px 16px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #fff);overflow:hidden}
|
||||
.iwb-plp-dsec{font-size: 12px;font-weight:600;color: var(--iwb-text2, #8a919c);letter-spacing:.04em;padding-bottom:8px;margin-bottom:8px;border-bottom: 1px solid var(--iwb-plugin-border, #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: 14px;line-height:2;color: var(--iwb-text, #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-dbody{display:flex;flex:1 1 auto;min-height:0;overflow:hidden;gap: 12px;padding:16px;background: var(--iwb-plugin-inset, #f4f5f7)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dleftcol{align-self:stretch;display:flex;flex-direction:column;overflow:auto;padding:12px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #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: 12px 16px;border: 1px solid var(--iwb-plugin-border, #e8eaee);border-radius:14px;background: var(--iwb-plugin-card, #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:右卡片纵向拉伸填满,正文出现滚动条 */
|
||||
@@ -539,18 +540,18 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
|
||||
.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-dmeta{margin-top:12px;padding-top: 12px;border-top: 1px solid var(--iwb-plugin-border, #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)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dmk{flex:0 0 auto;width:auto;font-size:12px;line-height:1.6;color: var(--iwb-text-dim, #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: 13px;line-height:1.6;color: var(--iwb-text, #2f3540)}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dtag{color: var(--iwb-plp-accent, #5a3fd0);}
|
||||
.iwb-plp-dialog-detail .iwb-plp-dlen{font-size: 13px;line-height:1.6;color: var(--iwb-text, #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{padding: 6px 0;border-bottom: 1px solid var(--iwb-plugin-border, #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-dialog .iwb-plp-ecov{background: var(--iwb-field, #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}
|
||||
|
||||
@@ -454,37 +454,47 @@
|
||||
'.iwb-bx-name{flex:1;min-width:70px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
||||
'.iwb-bx-tag{font-size:11px;white-space:nowrap;color:var(--iwb-text2,#4d5668);',
|
||||
'max-width:46%;min-width:0;overflow:hidden;text-overflow:ellipsis}',
|
||||
'.iwb-bx-tag-ok{color:#1d9e75}',
|
||||
'.iwb-bx-tag-err{color:#d85a30}',
|
||||
// 状态色不能直接当文字色:宿主 --iwb-ok 亮色是 #22c55e,压在浅页面上对比只有 2.13。
|
||||
// 照 design-tokens.md §3 的 iwb-mk-badge 范例,用 color-mix 往 --iwb-text 压 18%,亮暗两端都读得清。
|
||||
'.iwb-bx-tag-ok{color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333))}',
|
||||
'.iwb-bx-tag-err{color:color-mix(in srgb,var(--iwb-err,#d85a30) 82%,var(--iwb-text,#1c2333))}',
|
||||
// 行内单张下载:常驻不悬浮(要一眼看出「这行能下什么」),无产物时灰掉但保留占位,
|
||||
// 避免产物出现时行宽突然变化导致列表跳动。
|
||||
'.iwb-bx-dl{flex:0 0 auto;padding:2px 6px;border-radius:5px;font-size:11px;line-height:1.5;',
|
||||
'font-family:ui-monospace,SFMono-Regular,Menlo,monospace;border:1px solid var(--iwb-border,#d5d9e0);',
|
||||
'background:transparent;color:var(--iwb-text2,#4d5668);cursor:pointer}',
|
||||
'.iwb-bx-dl-on{background:var(--iwb-layer,#f0f1f4);color:var(--iwb-text,#1c2333);border-color:var(--iwb-text2,#4d5668)}',
|
||||
'.iwb-bx-dl-on:hover{border-color:#2f6fed;color:#2f6fed}',
|
||||
'.iwb-bx-dl-on:hover{border-color:var(--iwb-brand,#2f6fed);color:var(--iwb-brand-text,#2f6fed)}',
|
||||
'.iwb-bx-dl[disabled]{opacity:.45;cursor:not-allowed;border-color:var(--iwb-border,#d5d9e0)}',
|
||||
'.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}',
|
||||
'.iwb-bx-thumb-out{border-color:#1d9e75;cursor:zoom-in}',
|
||||
'border:1px solid var(--iwb-border,#d5d9e0);background:#fff/*iwb:content*/;cursor:zoom-in;padding:1px}',
|
||||
'.iwb-bx-thumb-out{border-color:var(--iwb-ok,#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)}',
|
||||
'color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333));',
|
||||
'background:color-mix(in srgb,var(--iwb-ok,#1d9e75) 8%,transparent);',
|
||||
'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-btn-hot 会被后定义的 .iwb-bx-btn 背景覆盖(同特异性,后者胜)
|
||||
'.iwb-bx-btn.iwb-bx-btn-hot{background:#1d9e75;border-color:#1d9e75;color:#fff}',
|
||||
'.iwb-bx-zoom img{max-width:86vw;max-height:86vh;border-radius:8px;background:#fff/*iwb:content*/}',
|
||||
// 主/热按钮此前是纯蓝 #2f6fed 实心 + 白字:与项目「全灰阶、无蓝」的配色约束冲突,
|
||||
// 且暗色下亮绿底压白字对比度不足。改成宿主语义色成对反相 + 状态色描边,
|
||||
// var() 兜底保留私有值,脱离宿主独立运行时不退化。
|
||||
'.iwb-bx-btn.iwb-bx-btn-hot{',
|
||||
'background:color-mix(in srgb,var(--iwb-ok,#1d9e75) 14%,transparent);',
|
||||
'border-color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333));',
|
||||
'color:color-mix(in srgb,var(--iwb-ok,#1d9e75) 82%,var(--iwb-text,#1c2333))}',
|
||||
'.iwb-bx-foot{display:flex;align-items:center;gap:8px;padding:10px 12px;',
|
||||
'border-top:1px solid var(--iwb-border,#d5d9e0)}',
|
||||
'.iwb-bx-prog{flex:1;height:4px;border-radius:2px;background:var(--iwb-border,#d5d9e0);overflow:hidden}',
|
||||
'.iwb-bx-prog i{display:block;height:100%;width:0;background:#2f6fed;transition:width .15s}',
|
||||
'.iwb-bx-prog i{display:block;height:100%;width:0;background:var(--iwb-brand-text,#2f6fed);transition:width .15s}',
|
||||
'.iwb-bx-btn{padding:5px 10px;border-radius:6px;border:1px solid var(--iwb-border,#d5d9e0);',
|
||||
'background:var(--iwb-layer,#f0f1f4);color:inherit;font:inherit;cursor:pointer;white-space:nowrap}',
|
||||
'.iwb-bx-btn[disabled]{opacity:.45;cursor:not-allowed}',
|
||||
'.iwb-bx-btn-primary{background:#2f6fed;border-color:#2f6fed;color:#fff}',
|
||||
'.iwb-bx-btn-primary{background:var(--iwb-text,#2f6fed);border-color:var(--iwb-text,#2f6fed);',
|
||||
'color:var(--iwb-layer,#fff)}',
|
||||
].join('')
|
||||
|
||||
function ensureStyle() {
|
||||
@@ -500,7 +510,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'batch-export',
|
||||
name: '批量出图',
|
||||
version: '1.2.0',
|
||||
version: '1.2.2',
|
||||
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,25 @@ 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')
|
||||
// Windows 检出可能是 CRLF(core.autocrlf=true):内容一致时不应让构建失败
|
||||
const tokensCss = fs.readFileSync(tokensCssPath, 'utf8').replace(/\r\n/g, '\n')
|
||||
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'],
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
#!/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', '紧凑正文/工具栏标题'],
|
||||
// 14px 是浏览器默认正文字号,也是全站第四高频(M6 实测 10 处:表单行标题、命令输入、
|
||||
// 帮助正文、尺寸数字)。闭集原本 13 → 15 跨 2px,中间有洞,凡是「标准正文」都无处安放,
|
||||
// 只能就近塞进 13(偏小)或 15(偏大)。补这一档而不是继续塞,是因为它不是一处特例。
|
||||
['--iwb-font-base', '14px', '标准正文:表单行标题/命令输入/帮助正文'],
|
||||
['--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 = []
|
||||
// Windows 默认 core.autocrlf=true 会把 CSS 检出成 CRLF;内容一致但字符串不等,
|
||||
// 会误报「快照与 derive() 不一致」。比较前统一换行符(写入始终 LF,见 .gitattributes)。
|
||||
const cur = (fs.existsSync(CSS_OUT) ? fs.readFileSync(CSS_OUT, 'utf8') : '').replace(/\r\n/g, '\n')
|
||||
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,282 @@
|
||||
#!/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'), [])
|
||||
|
||||
/* ---------- 插件专项(--plugins):写死灰 / 半像素 / 散值 ---------- */
|
||||
if (process.argv.includes('--plugins')) {
|
||||
const FONT = new Set([11, 12, 13, 14, 15, 17, 20, 24])
|
||||
const RADIUS = new Set([6, 8, 10, 12, 14, 999])
|
||||
const SPACE = new Set([0, 2, 4, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 64])
|
||||
const hexToRgb = (h) => {
|
||||
let v = h.replace('#', '')
|
||||
if (v.length === 3) v = v.split('').map((c) => c + c).join('')
|
||||
if (v.length !== 6) return null
|
||||
return [parseInt(v.slice(0, 2), 16), parseInt(v.slice(2, 4), 16), parseInt(v.slice(4, 6), 16)]
|
||||
}
|
||||
const chroma = (h) => { const c = hexToRgb(h); return c ? Math.max(...c) - Math.min(...c) : 0 }
|
||||
const rows = []
|
||||
for (const f of pluginFiles.filter((x) => /\.css$/i.test(x))) {
|
||||
const src = read(f)
|
||||
const rel = path.relative(ROOT, f).split(path.sep).join('/')
|
||||
const r = { file: rel, font: 0, radius: 0, space: 0, color: 0, gray: 0 }
|
||||
for (const m of src.matchAll(/([a-z-]+)\s*:\s*([^;{}]+)/g)) {
|
||||
const prop = m[1].toLowerCase()
|
||||
const val = m[2].trim()
|
||||
if (val.includes('var(')) continue
|
||||
if (prop === 'font-size') {
|
||||
const px = /([0-9.]+)px/.exec(val); if (px && !FONT.has(Number(px[1]))) r.font++
|
||||
} else if (prop === 'border-radius') {
|
||||
for (const px of val.matchAll(/([0-9.]+)px/g)) if (!RADIUS.has(Number(px[1]))) r.radius++
|
||||
} else if (/^(gap|row-gap|column-gap)$/.test(prop) || /^(padding|margin)/.test(prop)) {
|
||||
for (const px of val.matchAll(/([0-9.]+)px/g)) if (!SPACE.has(Number(px[1]))) r.space++
|
||||
} else if (/^(color|background(-color)?|border(-color)?)$/.test(prop)) {
|
||||
for (const hx of val.matchAll(/#[0-9a-f]{3,8}/gi)) {
|
||||
r.color++
|
||||
if (chroma(hx[0]) < 24) r.gray++
|
||||
}
|
||||
}
|
||||
}
|
||||
if (r.font || r.radius || r.space || r.color) rows.push(r)
|
||||
}
|
||||
rows.sort((a, b) => (b.gray + b.font + b.radius + b.space) - (a.gray + a.font + a.radius + a.space))
|
||||
const sum = (k) => rows.reduce((n, r) => n + r[k], 0)
|
||||
console.log('## 插件样式审计(--plugins)' + '\n')
|
||||
console.log('| 文件 | 中性色写死 | 半/散字号 | 散圆角 | 散间距 |' + '\n' + '|---|---|---|---|---|')
|
||||
for (const r of rows.slice(0, 20)) console.log('| ' + r.file + ' | ' + r.gray + ' | ' + r.font + ' | ' + r.radius + ' | ' + r.space + ' |')
|
||||
console.log('\n' + '- 合计:中性色写死 **' + sum('gray') + '** 处(另有强调色写死 ' + (sum('color') - sum('gray')) + ' 处,允许)')
|
||||
console.log('- 散字号 **' + sum('font') + '** / 散圆角 **' + sum('radius') + '** / 散间距 **' + sum('space') + '**', '(棘轮:只降不升,见 tests/plugin-scale-contract-test.js)')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
|
||||
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,234 @@
|
||||
#!/usr/bin/env node
|
||||
/* token-lint.js —— 设计 token 的「新增行」闸门(M5-T5.1 / T5.5)
|
||||
*
|
||||
* 只查**新增行**,不查存量:M4 结束时 style.css 里还有 170 处写死字号、55 处裸 z-index,
|
||||
* 一次性要求全清零只会逼人加白名单。闸门的作用是**不让数字再涨**(存量交给棘轮测试慢慢降)。
|
||||
*
|
||||
* 四条白名单(缺一条都会逼人绕路,绕路比违规更难发现):
|
||||
* ① 内容色:行内 `/*iwb:content*/` —— 画布内容(图片上的纯白文字、截图底色)不是主题表面色,
|
||||
* 同一个 #fff 在按钮上是 bug、在图片上是内容,值分不出来,只能靠标记。
|
||||
* ② 变量兜底:`var(--x, 8px)` 里的 8px 不查 —— 兜底值不生效时才是问题,而那时 var 本身就会红。
|
||||
* ③ 布局尺寸:只查排版属性(字号/圆角/内距/间距/外边距)。width/height/left/top 没有闭集,
|
||||
* 强行 token 化只会发明一堆只用一次的名字。
|
||||
* ④ 临时例外:行内 `/*iwb:raw-until=3.27.0*/` —— **必须带到期版本**,到期后本脚本把它当失败,
|
||||
* 不会像普通白名单那样悄悄变成永久免死金牌。
|
||||
*
|
||||
* 用法:
|
||||
* node scripts/token-lint.js # 查工作区未提交的改动(diff vs HEAD)
|
||||
* node scripts/token-lint.js --base origin/main # 查 base..HEAD 的改动(CI / 发版前)
|
||||
* node scripts/token-lint.js --file style.css # 查整个文件(迁移时看全局)
|
||||
* node scripts/token-lint.js --json
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execFileSync } = require('child_process')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
const VERSION = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version
|
||||
|
||||
// 排版属性:这些值必须来自闭集。其余属性(width/height/top/left/flex/…)没有闭集,不查。
|
||||
const SIZE_PROPS = new Set([
|
||||
'font-size', 'border-radius', 'gap', 'row-gap', 'column-gap'
|
||||
])
|
||||
const SIZE_PREFIX = /^(padding|margin)(-(top|right|bottom|left|block|inline)(-(start|end))?)?$/
|
||||
|
||||
// 颜色属性:表面色/文字色必须来自语义 token。
|
||||
// box-shadow 不在其中 —— 它已由 --iwb-elevation-* 四档收口,阴影里的 rgba 是笔画而不是表面。
|
||||
const COLOR_PROPS = new Set([
|
||||
'color', 'background', 'background-color',
|
||||
'border-color', 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color',
|
||||
'fill', 'stroke', 'outline-color'
|
||||
])
|
||||
|
||||
// 生成物与第三方:token 定义本身当然满地是值;站点是另一套系统(自己的 --*-变量)
|
||||
const SKIP_FILE = /^(src\/design-tokens\.css|dist\/|node_modules\/|site\/|docs\/)/
|
||||
// 插件产物由 tests/plugin-theme-contract-test.js 按「私有皮肤 / 强调色 / 中性色」分类治理,
|
||||
// 这里只对插件查层级(插件内部若写死 9999,会盖住宿主的弹窗与确认框)。
|
||||
const PLUGIN_FILE = /^plugins\//
|
||||
|
||||
const CONTENT_MARK = /\/\*iwb:content\*\//
|
||||
const EXCEPTION_MARK = /\/\*iwb:raw-until=(\d+\.\d+\.\d+)\*\//
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
const argOf = (name) => {
|
||||
const i = argv.indexOf(name)
|
||||
return i >= 0 ? argv[i + 1] : null
|
||||
}
|
||||
const jsonOut = argv.includes('--json')
|
||||
const base = argOf('--base')
|
||||
const onlyFile = argOf('--file')
|
||||
|
||||
/* ── 1. 取「要检查的行」:{file, line, text} ───────────────────────────── */
|
||||
function linesFromDiff () {
|
||||
const args = ['-C', ROOT, 'diff', '--no-color', '--unified=0', '--no-ext-diff']
|
||||
// 默认 diff HEAD 会把已暂存与未暂存都算进来(工作区真实状态);--base 则是「已提交的这批」
|
||||
args.push(base ? base + '...HEAD' : 'HEAD')
|
||||
args.push('--', '*.css', 'app.js', 'src', 'plugins')
|
||||
|
||||
let out = ''
|
||||
try {
|
||||
out = execFileSync('git', args, { encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 })
|
||||
} catch (e) {
|
||||
// 不是 git 仓库(或浅克隆取不到 base)时不要假装通过:直接报错,让人显式用 --file
|
||||
console.error('token-lint: 无法取到 git diff(' + (e.message || e) + ')')
|
||||
console.error(' 不在 git 仓库里时用 --file <path> 指定要查的文件')
|
||||
process.exit(2)
|
||||
}
|
||||
|
||||
const rows = []
|
||||
let file = null
|
||||
let next = 0
|
||||
for (const raw of out.split('\n')) {
|
||||
if (raw.startsWith('+++ b/')) { file = raw.slice(6); continue }
|
||||
if (raw.startsWith('+++ /dev/null')) { file = null; continue }
|
||||
const h = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(raw)
|
||||
if (h) { next = Number(h[1]); continue }
|
||||
if (!file) continue
|
||||
if (raw.startsWith('+')) { rows.push({ file, line: next, text: raw.slice(1) }); next++ }
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
function linesFromFile (p) {
|
||||
const abs = path.isAbsolute(p) ? p : path.join(ROOT, p)
|
||||
const rel = path.relative(ROOT, abs).split(path.sep).join('/')
|
||||
return fs.readFileSync(abs, 'utf8').split('\n').map((text, i) => ({ file: rel, line: i + 1, text }))
|
||||
}
|
||||
|
||||
/* ── 2. 判定 ──────────────────────────────────────────────────────────── */
|
||||
const cmpVer = (a, b) => {
|
||||
const pa = a.split('.').map(Number)
|
||||
const pb = b.split('.').map(Number)
|
||||
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] - pb[i]
|
||||
return 0
|
||||
}
|
||||
|
||||
// 把 var(...) 整段抠掉:兜底值不查(见白名单 ②),剩下的才是「裸值」
|
||||
const stripVar = (v) => v.replace(/var\([^()]*\)/g, 'var')
|
||||
|
||||
const problems = []
|
||||
const warn = []
|
||||
|
||||
// JS 里的样式有两种写法,判据必须分开(否则会误伤布局参数):
|
||||
// ① CSS 文本:`cssText = 'padding:16px;font-size:12px'`、`innerHTML = '<div style="color:#333">'`
|
||||
// —— 只有**带 px 单位**或带 #/rgb 颜色才算样式;`{ gap: 20 }` 这种是画布布局参数,不能管
|
||||
// ② React 内联对象:`style={{ fontSize: 13 }}` —— 数字即 px,但键名要用**无歧义**的
|
||||
// camelCase(fontSize / marginLeft / zIndex…);`gap` / `padding` 在 JS 对象里可能是
|
||||
// 任何东西(CanvasGeometry 的 snapToFreeSpot 就吃 `{ gap: 20 }`),所以不查
|
||||
const JS_PX = /(font-size|border-radius|padding[a-z-]*|gap|row-gap|column-gap|margin[a-z-]*)\s*:\s*(-?\d*\.?\d+)px/g
|
||||
const JS_COLOR = /(color|background|border-color)\s*:\s*(#[0-9a-f]{3,8}|rgba?\([^)]*\))/gi
|
||||
const JS_Z = /z-index\s*:\s*(-?\d+)/g
|
||||
const JS_CAMEL = /(fontSize|borderRadius|paddingTop|paddingBottom|paddingLeft|paddingRight|marginTop|marginBottom|marginLeft|marginRight|rowGap|columnGap|zIndex)\s*:\s*(\d+)/g
|
||||
|
||||
function check (row) {
|
||||
const { file, line, text } = row
|
||||
if (!text || !text.includes(':')) return
|
||||
if (SKIP_FILE.test(file)) return
|
||||
|
||||
const isPlugin = PLUGIN_FILE.test(file)
|
||||
const isJs = /\.js$/.test(file)
|
||||
const contentOk = CONTENT_MARK.test(text)
|
||||
const ex = EXCEPTION_MARK.exec(text)
|
||||
const expired = ex ? cmpVer(VERSION, ex[1]) >= 0 : false
|
||||
const bucket = (msg, hard) => {
|
||||
if (ex && !expired) {
|
||||
warn.push({ file, line, msg, until: ex[1] })
|
||||
return
|
||||
}
|
||||
if (expired) msg += '(例外已过期:raw-until=' + ex[1] + ',当前 ' + VERSION + ')'
|
||||
if (hard) problems.push({ file, line, msg })
|
||||
else warn.push({ file, line, msg })
|
||||
}
|
||||
|
||||
if (isJs) {
|
||||
// 纯注释行跳过:注释里写「z-index:2 是局部层级」这种说明不该被判违规
|
||||
if (/^\s*(\/\/|\/\*|\*)/.test(text)) return
|
||||
// 插件产物里的颜色/字号交给插件契约测试;层级照样管(见下)
|
||||
const scanPx = !isPlugin
|
||||
if (scanPx) {
|
||||
for (const m of text.matchAll(JS_PX)) {
|
||||
if (Number(m[2]) === 0) continue
|
||||
bucket(m[1] + ': ' + m[2] + 'px → 用 --iwb-(font|radius|space)-* 闭集', true)
|
||||
}
|
||||
for (const m of text.matchAll(JS_CAMEL)) {
|
||||
if (m[1] === 'zIndex') continue // 层级单独报,避免同一条重复计数
|
||||
if (Number(m[2]) === 0) continue
|
||||
bucket(m[1] + ': ' + m[2] + ' → 用 --iwb-(font|radius|space)-* 闭集(数字即 px)', true)
|
||||
}
|
||||
for (const m of text.matchAll(JS_COLOR)) {
|
||||
const white = m[1].toLowerCase() === 'color' && /^#(fff|ffffff)$/i.test(m[2])
|
||||
if (contentOk || white) continue
|
||||
bucket(m[1] + ': ' + m[2] + ' → 用语义色 token(内容色加 /*iwb:content*/ 标记)', true)
|
||||
}
|
||||
}
|
||||
for (const m of text.matchAll(JS_Z)) {
|
||||
bucket('z-index: ' + m[1] + ' → 用 --iwb-z-*(插件不得高于 --iwb-z-anchor / 3200)', true)
|
||||
}
|
||||
for (const m of text.matchAll(JS_CAMEL)) {
|
||||
if (m[1] !== 'zIndex') continue
|
||||
bucket('zIndex: ' + m[2] + ' → 用 --iwb-z-*', true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
for (const m of text.matchAll(/([a-z-]+)\s*:\s*([^;{}]+)/g)) {
|
||||
const prop = m[1].toLowerCase()
|
||||
const value = m[2].trim()
|
||||
const bare = stripVar(value)
|
||||
|
||||
// z-index:任何裸数字都不行(层级表见 docs/standards/design-tokens.md §3.4)
|
||||
if (prop === 'z-index') {
|
||||
if (/^-?\d+$/.test(bare)) {
|
||||
bucket('z-index: ' + bare + ' → 用 --iwb-z-*(插件不得高于 --iwb-z-anchor / 3200)', true)
|
||||
}
|
||||
continue
|
||||
}
|
||||
// 插件内部除了层级,其余交给插件契约测试(私有皮肤是允许整套调色板的)
|
||||
if (isPlugin) continue
|
||||
|
||||
if (SIZE_PROPS.has(prop) || SIZE_PREFIX.test(prop)) {
|
||||
const hit = /(-?\d*\.?\d+)px/.exec(bare)
|
||||
if (hit && Number(hit[1]) !== 0) {
|
||||
bucket(prop + ': ' + value + ' → 用 --iwb-(font|radius|space)-* 闭集', true)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if (COLOR_PROPS.has(prop)) {
|
||||
const hex = /#[0-9a-f]{3,8}\b/i.test(bare)
|
||||
const rgb = /rgba?\(/i.test(bare)
|
||||
if (!hex && !rgb) continue
|
||||
// 纯白文字压在图片/色块上:内容对比,不是主题表面色(与插件契约同款例外)
|
||||
const whiteText = prop === 'color' && /^#(fff|ffffff)$/i.test(bare)
|
||||
if (contentOk || whiteText) continue
|
||||
bucket(prop + ': ' + value + ' → 用语义色 token(内容色加 /*iwb:content*/ 标记)', true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 3. 跑 ────────────────────────────────────────────────────────────── */
|
||||
const rows = onlyFile ? linesFromFile(onlyFile) : linesFromDiff()
|
||||
for (const r of rows) check(r)
|
||||
|
||||
const anchor = (() => {
|
||||
const css = fs.readFileSync(path.join(ROOT, 'src', 'design-tokens.css'), 'utf8')
|
||||
const m = /--iwb-z-anchor:\s*(\d+)/.exec(css)
|
||||
return m ? Number(m[1]) : null
|
||||
})()
|
||||
|
||||
if (jsonOut) {
|
||||
console.log(JSON.stringify({ version: VERSION, mode: onlyFile ? 'file' : (base || 'HEAD'), checked: rows.length, problems, warn, pluginZCeiling: anchor }, null, 2))
|
||||
process.exit(problems.length ? 1 : 0)
|
||||
}
|
||||
|
||||
const mode = onlyFile ? '整个文件 ' + onlyFile : (base ? base + '...HEAD' : '工作区未提交改动')
|
||||
console.log('token-lint: ' + mode + ',检查 ' + rows.length + ' 行新增' + (anchor ? '(插件层级上限 ' + anchor + ')' : ''))
|
||||
for (const w of warn) console.log(' · ' + w.file + ':' + w.line + ' ' + w.msg + (w.until ? ' [例外至 ' + w.until + ']' : ''))
|
||||
if (problems.length) {
|
||||
for (const p of problems) console.log(' ✗ ' + p.file + ':' + p.line + ' ' + p.msg)
|
||||
console.log('\ntoken-lint: ' + problems.length + ' 处新增裸值 —— 失败。理由与白名单见 docs/standards/design-tokens.md §5')
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('token-lint: 通过(0 处新增裸值' + (warn.length ? ',' + warn.length + ' 条已登记的例外' : '') + ')')
|
||||
@@ -3,7 +3,7 @@
|
||||
<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.40-mwsgavpk">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.55-mwtywasp">
|
||||
<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}
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.40</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.55</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
|
||||
@@ -57,18 +57,18 @@
|
||||
<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.40 · 8.4 MB · .dmg<div class="hash">sha256 165f48fa6c2d874f…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.40_aarch64.dmg?h=165f48fa6c2d">下载</a>
|
||||
<div class="meta">版本 3.26.55 · 8.4 MB · .dmg<div class="hash">sha256 b76eee462d181129…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.55_aarch64.dmg?h=b76eee462d18">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.26.40 · 8.8 MB · .dmg<div class="hash">sha256 6890b428aee6233c…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.40_x64.dmg?h=6890b428aee6">下载</a>
|
||||
<div class="meta">版本 3.26.55 · 8.8 MB · .dmg<div class="hash">sha256 c121f0855a2a56d0…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.55_x64.dmg?h=c121f0855a2a">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
<div class="meta">版本 3.26.40 · 4.8 MB · .exe<div class="hash">sha256 c82010565b339520…</div></div>
|
||||
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.40_x64-setup.exe?h=c82010565b33">下载</a>
|
||||
<div class="meta"></div>
|
||||
<span class="muted">暂未提供</span>
|
||||
</div>
|
||||
|
||||
<h2>系统要求</h2>
|
||||
@@ -97,6 +97,26 @@
|
||||
</ol>
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<div class="row">
|
||||
<div class="name">3.26.55</div>
|
||||
<div class="meta">2026-11-24<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.54</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.53</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.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>
|
||||
@@ -491,7 +511,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-24
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<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?v=3.26.40-mwsgavpk">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.55-mwtywasp">
|
||||
</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>
|
||||
@@ -17,19 +17,19 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.40</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.55</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.40-mwsgavpk" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.55-mwtywasp" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.26.40 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.26.55 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.40</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.55</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 11 个插件</a>
|
||||
</div>
|
||||
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
|
||||
@@ -55,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.2 · 官方</div></div></div>
|
||||
<div class="desc">资源中心勾选节点,串行批量生成并打包 ZIP 下载</div>
|
||||
<div class="tags"><span class="tag">出图</span><span class="tag">批处理</span></div>
|
||||
</div>
|
||||
@@ -67,25 +67,25 @@
|
||||
</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>
|
||||
<div class="pcard" data-name="图库 gallery 右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供) 资源 图库" data-tags="资源,图库">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
|
||||
<div><div class="nm">图库</div><div class="ver">v1.6.9 · 官方</div></div></div>
|
||||
<div><div class="nm">图库</div><div class="ver">v1.6.11 · 官方</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="节点组 grouplib 左栏收藏的节点组:分组/改名/删除,拖到画布实例化(数据由客户端提供) 资源 节点组" data-tags="资源,节点组">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📦</span>
|
||||
<div><div class="nm">节点组</div><div class="ver">v1.0.4 · 官方</div></div></div>
|
||||
<div><div class="nm">节点组</div><div class="ver">v1.0.5 · 官方</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="提示词库 promptlib 右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供) 资源 提示词" data-tags="资源,提示词">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📖</span>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.8.8 · 官方</div></div></div>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.8.24 · 官方</div></div></div>
|
||||
<div class="desc">右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)</div>
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">提示词</span></div>
|
||||
</div>
|
||||
@@ -96,9 +96,9 @@
|
||||
<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.40_aarch64.dmg?h=165f48fa6c2d"><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.40_x64.dmg?h=6890b428aee6"><div class="n">macOS · Intel</div><div class="s">x86_64 · 8.8 MB · .dmg</div></a>
|
||||
<a href="/updates/windows-x86_64/image-workbench_3.26.40_x64-setup.exe?h=c82010565b33"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 4.8 MB · .exe</div></a></div>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.55_aarch64.dmg?h=b76eee462d18"><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.55_x64.dmg?h=c121f0855a2a"><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>
|
||||
</main>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"updatedAt": "2026-11-22T15:51:05.074Z",
|
||||
"updatedAt": "2026-11-23T23:09:26.902Z",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "batch-export",
|
||||
@@ -13,27 +13,27 @@
|
||||
"出图",
|
||||
"批处理"
|
||||
],
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.2",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/batch-export-1.2.0.zip",
|
||||
"bundleSize": 44936,
|
||||
"bundleSha256": "338cfbe8fe00e92771f60f996d6a4baeb3c3b4954dfe774cfe83879639234552",
|
||||
"bundle": "plugins/batch-export-1.2.2.zip",
|
||||
"bundleSize": 45959,
|
||||
"bundleSha256": "9e987bc94726ae75d1a1ad258a27cf0656b4f3253a533b36a56f5b2a61db5a56",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "163e5de559a6907982749cdf5fbf7372b492ab30096a5bb935315e002fb1c7a5",
|
||||
"sha256": "59e80e8dc3d72aa1b8970f900b4d8b4c7958210e608d3ad55d3c116a5142704f",
|
||||
"size": 393
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "b7d13ba66cf97ff65e94305328183a1a3b5a45b0393f3a63f77f6b7b46795389",
|
||||
"size": 44329
|
||||
"sha256": "44c13ac8e6d95b8b4a31999fc2d6885f888e0cc165a39edb68b9ffcb41996df5",
|
||||
"size": 45352
|
||||
}
|
||||
],
|
||||
"file": "plugins/plugin-batch-export.b7d13ba66cf9.js",
|
||||
"size": 44329,
|
||||
"sha256": "b7d13ba66cf97ff65e94305328183a1a3b5a45b0393f3a63f77f6b7b46795389",
|
||||
"integrity": "sha256-t9E7pmz5f/ZelDBTKBg6GjtaRbA5Pzpj939re0Z5U4k="
|
||||
"file": "plugins/plugin-batch-export.44c13ac8e6d9.js",
|
||||
"size": 45352,
|
||||
"sha256": "44c13ac8e6d95b8b4a31999fc2d6885f888e0cc165a39edb68b9ffcb41996df5",
|
||||
"integrity": "sha256-RME6yObZW4tKMZmfwtaIX4iODMFlo57baLn/y0GZbfU="
|
||||
},
|
||||
{
|
||||
"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",
|
||||
@@ -112,25 +112,25 @@
|
||||
"资源",
|
||||
"图库"
|
||||
],
|
||||
"version": "1.6.9",
|
||||
"version": "1.6.11",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/gallery-1.6.9.zip",
|
||||
"bundleSize": 34272,
|
||||
"bundleSha256": "9588b28fd2b2b3cc0f38ecd06fee05873474ca98867ce5b2dc5d6cc5948cf383",
|
||||
"bundle": "plugins/gallery-1.6.11.zip",
|
||||
"bundleSize": 34761,
|
||||
"bundleSha256": "6068b2a86f8be90d009e89db93bb847a7ecfd0e5ec8c84f682671f75497eeba0",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "0523a370d28132dcca912894929e402e9e7bac4a611be146ee075d073f26276c",
|
||||
"size": 526
|
||||
"sha256": "645c704f257f434473e76be4e5cfe13d28a336d628533f8f1e4e214c3854b906",
|
||||
"size": 527
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "26c7e64b3a0021c6b9514dfb84d4d2580276698222b4791cfa99f22ead66ff52",
|
||||
"size": 28241
|
||||
"sha256": "cf456629b21f9001d7cc8016a6af0d2b065aae110ef822b7946e6279ec822f11",
|
||||
"size": 28729
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "9d5b4ab1343761e51ef0c479cab96a94d3d6eaa27f0fdb500bff789ec81d70e0",
|
||||
"sha256": "35ae17de8b0f3bddab9cbef6270cd8bbf5153c9ecf6ed2b4f06216f6fef45b8b",
|
||||
"size": 5195
|
||||
}
|
||||
]
|
||||
@@ -146,25 +146,25 @@
|
||||
"资源",
|
||||
"节点组"
|
||||
],
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/grouplib-1.0.4.zip",
|
||||
"bundle": "plugins/grouplib-1.0.5.zip",
|
||||
"bundleSize": 24479,
|
||||
"bundleSha256": "842fd7d519bf8378b205c1c35894b8b2925e40595792fed99b1d456a2563404d",
|
||||
"bundleSha256": "d11ab6b0ce4672b90d3b117d1bcd6fe7e2000b3ce5ef52b4099b4668e12d080d",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "b35b748d9e76380f8c02d04ca10e93e280d1b6386c6e0a3b55f5be2448a3c65f",
|
||||
"sha256": "570365cad7b2971a6eb0d5827c4a4f988daa945ace296aab4536e9de592cb795",
|
||||
"size": 530
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "8cb2e39f9880d49c9b9c15a1f7d62d9772170c8d0eac0faaa237bb7056af34ff",
|
||||
"sha256": "f59e06065392d01c2e87808382d546d91bf8d57451ef81922b3204f36e6490c9",
|
||||
"size": 21601
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "ee6e292ffebdcc1351651bf7937399128ae06e0b364624792f34111866f9355b",
|
||||
"sha256": "909e49d15a183ab9f36c298241fcab4506ed29e22b5a5daa47f086cbc7a65376",
|
||||
"size": 2038
|
||||
}
|
||||
]
|
||||
@@ -180,26 +180,26 @@
|
||||
"资源",
|
||||
"提示词"
|
||||
],
|
||||
"version": "1.8.8",
|
||||
"version": "1.8.24",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/promptlib-1.8.8.zip",
|
||||
"bundleSize": 146066,
|
||||
"bundleSha256": "af91d59add3df05c390c6ead566663545acaf1200461185668750422360a2f6f",
|
||||
"bundle": "plugins/promptlib-1.8.24.zip",
|
||||
"bundleSize": 150074,
|
||||
"bundleSha256": "5f42119783e20fc667cf5f2e2014e4a517bc6436d7060fb2acf185297a5ef032",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "667ddf6ddedab0ce3abbccbe3dfaa34c56bfa90179369c1c013e736ee5eb15e7",
|
||||
"size": 540
|
||||
"sha256": "18c0c76e8830ec9f1ee306c7e1d0fb40f430410409d1990384ce72c94169e94d",
|
||||
"size": 541
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "91fde4bcfa888b04ee2b0e79a05d951a56247bc76ecd11b5d9500131df11d542",
|
||||
"size": 106422
|
||||
"sha256": "0bab5f57c173d0bf45a16881042d9b3b1973a2afe2e6c3745a27fd5181b793b0",
|
||||
"size": 107029
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "82bdae857b0c6e66c0e1c9fa0ea47b269dcbde51cdfacd552e4b919cfa4576c7",
|
||||
"size": 38794
|
||||
"sha256": "e14fee1fd446188ef44913cc2d549e02480b10d95a67371078ec4fa623786d60",
|
||||
"size": 42194
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -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",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<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.40-mwsgavpk">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.55-mwtywasp">
|
||||
</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>
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.40</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.55</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
@@ -49,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.2 · 官方</div></div></div>
|
||||
<div class="desc">资源中心勾选节点,串行批量生成并打包 ZIP 下载</div>
|
||||
<div class="tags"><span class="tag">出图</span><span class="tag">批处理</span></div>
|
||||
</div>
|
||||
@@ -61,37 +61,37 @@
|
||||
</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>
|
||||
<div class="pcard" data-name="图库 gallery 右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供) 资源 图库" data-tags="资源,图库">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
|
||||
<div><div class="nm">图库</div><div class="ver">v1.6.9 · 官方</div></div></div>
|
||||
<div><div class="nm">图库</div><div class="ver">v1.6.11 · 官方</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="节点组 grouplib 左栏收藏的节点组:分组/改名/删除,拖到画布实例化(数据由客户端提供) 资源 节点组" data-tags="资源,节点组">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📦</span>
|
||||
<div><div class="nm">节点组</div><div class="ver">v1.0.4 · 官方</div></div></div>
|
||||
<div><div class="nm">节点组</div><div class="ver">v1.0.5 · 官方</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="提示词库 promptlib 右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供) 资源 提示词" data-tags="资源,提示词">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📖</span>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.8.8 · 官方</div></div></div>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.8.24 · 官方</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,120 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-11-22T17:16:21.567Z",
|
||||
"updatedAt": "2026-11-24T00:39:37.806Z",
|
||||
"releases": [
|
||||
{
|
||||
"version": "3.26.55",
|
||||
"date": "2026-11-24",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.55_aarch64.dmg",
|
||||
"size": 8797296,
|
||||
"sha256": "b76eee462d1811299cef938449669ebf873c0448b2ce293427ae683533f461c9",
|
||||
"h": "b76eee462d18",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.55_x64.dmg",
|
||||
"size": 9186452,
|
||||
"sha256": "c121f0855a2a56d00684ab1f1c83428832e8738a2ef5c3186d33ab27a867b087",
|
||||
"h": "c121f0855a2a",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.54",
|
||||
"date": "2026-11-23",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.54_aarch64.dmg",
|
||||
"size": 8797148,
|
||||
"sha256": "05f3f0b858fd6fcc70481865f2226b94dd13d1b5c076eaf0f4206376bbf1aaf7",
|
||||
"h": "05f3f0b858fd",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.54_x64.dmg",
|
||||
"size": 9182228,
|
||||
"sha256": "4241a9151b764ff010d646e97c4dc27e2f13d91105dca9e159cb70542dcb2055",
|
||||
"h": "4241a9151b76",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.53",
|
||||
"date": "2026-11-23",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.53_aarch64.dmg",
|
||||
"size": 8795507,
|
||||
"sha256": "db04dfa286719226249379ff2d8a7a6a4f313bcb39561be698d02c112c467fcf",
|
||||
"h": "db04dfa28671",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.53_x64.dmg",
|
||||
"size": 9189961,
|
||||
"sha256": "d37f2aeca05c9b1340d66210c588c6dac2d9f3f9850680d551868198dea0f468",
|
||||
"h": "d37f2aeca05c",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -1983,7 +1983,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.40"
|
||||
version = "3.26.55"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.41"
|
||||
version = "3.26.55"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.41",
|
||||
"version": "3.26.55",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
@@ -261,8 +261,10 @@
|
||||
var d = document.createElement('div')
|
||||
d.setAttribute('data-iwb-cwv-hint', '')
|
||||
d.style.cssText = 'position:absolute;inset:0;display:flex;align-items:center;justify-content:center;'
|
||||
+ 'padding:16px;text-align:center;font-size:12px;line-height:1.7;white-space:pre-line;'
|
||||
+ 'background:rgba(128,128,128,.08);pointer-events:none;z-index:2'
|
||||
+ 'padding:var(--iwb-space-16,16px);text-align:center;font-size:var(--iwb-font-sm,12px);line-height:1.7;white-space:pre-line;'
|
||||
// z-index:2 是**组件内部**的局部层级(与宿主层级表无关,只在本容器内压住画布),
|
||||
// 不是 body 级浮层,所以不走 --iwb-z-*;登记为例外,到期复核是否还需要它
|
||||
+ 'background:color-mix(in srgb,var(--iwb-text) 8%,transparent);pointer-events:none;z-index:2 /*iwb:raw-until=3.28.0*/'
|
||||
st.hintEl = d
|
||||
el.appendChild(d)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
/* 设计 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: #b91c1c;
|
||||
--iwb-ok: #15803d;
|
||||
--iwb-warn: #b45309;
|
||||
/* —— 尺度层(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-base: 14px; /* 标准正文:表单行标题/命令输入/帮助正文 */
|
||||
--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));
|
||||
}
|
||||
@@ -767,22 +767,36 @@
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
const mask = document.createElement('div')
|
||||
mask.style.cssText = 'position:fixed;inset:0;z-index:2147483647;background:rgba(18,20,26,.72);display:flex;align-items:center;justify-content:center;font:14px/1.6 -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif'
|
||||
// 这个弹窗在首启动、主题 CSS 可能尚未生效时就要显示,所以每个 var() 都带字面兜底:
|
||||
// token 缺席时退化成本版改动前的样子(白底深字),而不是透明盒子。
|
||||
mask.style.cssText = 'position:fixed;inset:0;z-index:var(--iwb-z-alert,4000);'
|
||||
// 遮罩色是全仓唯一没有 token 的表面色(.iwb-modal-mask / .iwb-command-mask 也各写了一份 rgba)。
|
||||
// 它既不是 bg 也不是 panel,硬凑会让亮色主题出现「浅色遮罩」。留给 RFC 决定 --iwb-scrim
|
||||
// 的取值与消费者(现有 3 处),在此之前登记为例外,不让它悄悄变成永久的裸值。
|
||||
+ 'background:rgba(18,20,26,.72) /*iwb:raw-until=3.28.0*/;'
|
||||
+ 'display:flex;align-items:center;justify-content:center;'
|
||||
+ 'font-family:-apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif;'
|
||||
+ 'font-size:var(--iwb-font-md,14px);line-height:1.6'
|
||||
const box = document.createElement('div')
|
||||
box.style.cssText = 'background:#fff;color:#111;border-radius:14px;padding:24px 26px;max-width:580px;box-shadow:0 24px 60px rgba(0,0,0,.35)'
|
||||
box.style.cssText = 'background:var(--iwb-panel,#fff);color:var(--iwb-text,#111);'
|
||||
+ 'border-radius:var(--iwb-radius-popover,14px);padding:var(--iwb-space-24,24px);'
|
||||
+ 'max-width:580px;box-shadow:var(--iwb-elevation-4,0 24px 60px rgba(0,0,0,.35))'
|
||||
const btn = (t, primary) => {
|
||||
const b = document.createElement('button')
|
||||
b.textContent = t
|
||||
b.style.cssText = 'padding:8px 16px;border-radius:8px;font-size:13px;cursor:pointer;border:1px solid ' +
|
||||
(primary ? '#2563eb' : '#d0d4dc') + ';background:' + (primary ? '#2563eb' : '#fff') + ';color:' + (primary ? '#fff' : '#111')
|
||||
b.style.cssText = 'padding:var(--iwb-space-8,8px) var(--iwb-space-16,16px);'
|
||||
+ 'border-radius:var(--iwb-radius-control,8px);font-size:var(--iwb-font-md,13px);cursor:pointer;'
|
||||
+ 'border:1px solid ' + (primary ? 'var(--iwb-brand,#2563eb)' : 'var(--iwb-border,#d0d4dc)') + ';'
|
||||
+ 'background:' + (primary ? 'var(--iwb-brand,#2563eb)' : 'var(--iwb-panel,#fff)') + ';'
|
||||
+ 'color:' + (primary ? 'var(--iwb-on-brand,#fff)' : 'var(--iwb-text,#111)')
|
||||
return b
|
||||
}
|
||||
box.innerHTML = '<div style="font-size:17px;font-weight:600;margin-bottom:10px">首次启动:选择资料目录</div>' +
|
||||
'<div style="color:#333;margin-bottom:6px">设置、提示词、画布和所有图片都会存在这个目录里。</div>' +
|
||||
'<div style="color:#333;margin-bottom:14px">换机器/重装时,把目录指到<b>旧的资料目录</b>就能直接继续用。</div>' +
|
||||
'<div style="color:#666;font-size:12.5px;margin-bottom:18px">默认位置:' + defaultDir + '</div>'
|
||||
box.innerHTML = '<div style="font-size:var(--iwb-font-xl,17px);font-weight:600;margin-bottom:var(--iwb-space-10,10px)">首次启动:选择资料目录</div>' +
|
||||
'<div style="color:var(--iwb-text2,#333);margin-bottom:var(--iwb-space-6,6px)">设置、提示词、画布和所有图片都会存在这个目录里。</div>' +
|
||||
'<div style="color:var(--iwb-text2,#333);margin-bottom:var(--iwb-space-12,14px)">换机器/重装时,把目录指到<b>旧的资料目录</b>就能直接继续用。</div>' +
|
||||
'<div style="color:var(--iwb-text2,#666);font-size:var(--iwb-font-sm,12px);margin-bottom:var(--iwb-space-16,18px)">默认位置:' + defaultDir + '</div>'
|
||||
const row = document.createElement('div')
|
||||
row.style.cssText = 'display:flex;gap:10px;justify-content:flex-end'
|
||||
row.style.cssText = 'display:flex;gap:var(--iwb-space-10,10px);justify-content:flex-end'
|
||||
const bDefault = btn('用默认目录', true)
|
||||
const bPick = btn('选择已有目录…', false)
|
||||
const done = (v) => { try { mask.remove() } catch (e) { /* ignore */ } resolve(v) }
|
||||
|
||||
@@ -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,59 +93,133 @@
|
||||
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)
|
||||
|
||||
// 语义色:色相固定,明度随主题调整(暗色提亮一档,避免发闷)
|
||||
const err = d ? mix('#ef4444', '#ffffff', 0.18) : '#ef4444'
|
||||
const ok = d ? mix('#22c55e', '#ffffff', 0.18) : '#22c55e'
|
||||
const warn = d ? mix('#d97706', '#ffffff', 0.22) : '#d97706'
|
||||
// 亮色状态色必须能**直接当文字色**(.iwb-status-ok / .iwb-ratio.ok / 插件状态标签都这么用)。
|
||||
// 原先 #22c55e / #ef4444 / #d97706 对浅页面只有 2.1 / 3.5 / 3.0,M6 给 batch-export
|
||||
// 接 token 时实测撞到;暗色仍用原来的亮色版本(对深页面本来就够)。
|
||||
const err = d ? mix('#ef4444', '#ffffff', 0.18) : '#b91c1c'
|
||||
const ok = d ? mix('#22c55e', '#ffffff', 0.18) : '#15803d'
|
||||
const warn = d ? mix('#d97706', '#ffffff', 0.22) : '#b45309'
|
||||
// 品牌色上的文字:按对比度自动选黑/白
|
||||
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 +236,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 +245,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 +264,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,24 +397,56 @@
|
||||
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) {
|
||||
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),
|
||||
rows)
|
||||
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-gset-group' },
|
||||
el('div', { className: 'iwb-gset-group-h' }, title),
|
||||
el('div', { className: 'iwb-gset-group-body' }, rows))
|
||||
}
|
||||
const Seg = function (val, onChange, items) {
|
||||
return el('div', { className: 'iwb-seg' }, (items || []).map((item) => el('button', {
|
||||
@@ -282,35 +456,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 +510,123 @@
|
||||
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 })) }, '全部恢复默认')))
|
||||
Group('主题', [
|
||||
el('div', { className: 'iwb-appear-row' },
|
||||
el('span', { className: 'iwb-appear-label' }, '外观模式'),
|
||||
el('div', { className: 'iwb-appear-ctrl' },
|
||||
Seg(theme, (v) => { setTheme(v); applyTheme(v) }, [
|
||||
{ value: 'light', label: '亮色' }, { value: 'dark', label: '暗色' }, { value: 'system', label: '跟随系统' },
|
||||
])),
|
||||
el('span', { className: 'iwb-appear-note' }, '正在微调:' + (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)
|
||||
@@ -394,8 +394,14 @@ function BackupModal(props) {
|
||||
const imgs = (restoreData.images || []).concat(Array.isArray(restoreData.imagesData) ? restoreData.imagesData.map((x) => ({ key: x.key, data: x.data })) : [])
|
||||
let imgOk = 0
|
||||
const imgBad = []
|
||||
const restoreGallery = !!restoreSel.outputs
|
||||
const restoreRefs = !!(restoreSel.nodeGroups || restoreSel.workspaces)
|
||||
for (const im of imgs) {
|
||||
if (!im.key || !im.data) continue
|
||||
// 只恢复与所选项目相关的图片:未选图库时跳过 gallery_*(避免写回孤儿字节),
|
||||
// 只恢复设置/提示词时也不写任何图片。
|
||||
if (!restoreGallery && String(im.name || '').indexOf('gallery_') === 0) continue
|
||||
if (!restoreGallery && !restoreRefs) continue
|
||||
try {
|
||||
// C3:Blob 仓库的键必须写 Blob(备份里是 dataURL/字节)——否则 image-blob-store 读出来不是 Blob
|
||||
let val = im.data
|
||||
@@ -454,7 +460,7 @@ function BackupModal(props) {
|
||||
el('div', { className: 'iwb-backup-sec-title' }, '① 备份(导出所选数据)'),
|
||||
el('label', { className: 'iwb-backup-item iwb-backup-all' },
|
||||
el('input', { type: 'checkbox', checked: bkAll, onChange: (e) => setBkAll(e.target.checked) }, null),
|
||||
el('span', { className: 'iwb-backup-item-name' }, '全部数据'),
|
||||
el('span', { className: 'iwb-backup-item-name' }, '全部基础数据'),
|
||||
el('span', { className: 'iwb-backup-item-count' }, bkAll ? '已全选' : '全选'),
|
||||
),
|
||||
bkCheck('prompts', '提示词库(含分组)', counts.prompts + ' 条'),
|
||||
|
||||
@@ -72,6 +72,71 @@
|
||||
return true
|
||||
}
|
||||
|
||||
// 生图服务:多服务商单栏切换的选中态与新增/设默认逻辑(抽到组件外,避免 SettingsModal 行数棘轮)
|
||||
function useProviderSelection (setDraft, uid) {
|
||||
const [provSel, setProvSel] = React.useState('')
|
||||
const addProvider = () => {
|
||||
const id = uid('p')
|
||||
setDraft((d) => ({ ...d, providers: (d.providers || []).concat([{
|
||||
id, name: '新服务', baseUrl: '', fallbacks: [], genPath: '/images/generations', editPath: '/images/edits',
|
||||
keys: [{ id: uid('k'), name: 'Key 分组', source: 'literal', value: '' }], models: [], layerModels: [],
|
||||
}]) }))
|
||||
setProvSel(id)
|
||||
}
|
||||
// 默认项由数组顺序决定:设为默认 = 移到第一位(与地址「设默认」同一语义)
|
||||
const makeProviderDefault = (pi) => setDraft((d) => {
|
||||
const list = (d.providers || []).slice()
|
||||
if (pi <= 0 || pi >= list.length) return d
|
||||
const item = list.splice(pi, 1)[0]
|
||||
return { ...d, providers: [item].concat(list) }
|
||||
})
|
||||
return { provSel, setProvSel, addProvider, makeProviderDefault }
|
||||
}
|
||||
|
||||
// 设置窗口右下角缩放手柄(WKWebView 对 CSS resize 手柄支持不一致,用 pointer 事件兜底)
|
||||
function attachSettingsResize (e) {
|
||||
e.preventDefault(); e.stopPropagation()
|
||||
const modal = e.currentTarget.closest('.iwb-settings-modal')
|
||||
if (!modal) return
|
||||
const r = modal.getBoundingClientRect()
|
||||
const sx = e.clientX; const sy = e.clientY; const sw = r.width; const sh = r.height
|
||||
const move = (ev) => {
|
||||
modal.style.width = Math.max(760, Math.min(sw + ev.clientX - sx, window.innerWidth - 40)) + 'px'
|
||||
modal.style.height = Math.max(480, Math.min(sh + ev.clientY - sy, window.innerHeight - 40)) + 'px'
|
||||
}
|
||||
const up = () => { window.removeEventListener('pointermove', move); window.removeEventListener('pointerup', up) }
|
||||
window.addEventListener('pointermove', move); window.addEventListener('pointerup', up)
|
||||
}
|
||||
|
||||
// 图片与图库分组(从 SettingsModal 抽出,避免组件行数棘轮)
|
||||
function makeImageLibSection (draft, setDraft, backfillOutputOriginals) {
|
||||
return el('div', null,
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('div', { className: 'iwb-gset-row-label' }, '原图'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('label', { className: 'iwb-check' },
|
||||
el('input', { type: 'checkbox', checked: draft.canvas.backupOriginals === true, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, backupOriginals: e.target.checked } })) }, null),
|
||||
' 入库时同时保留原图',
|
||||
),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-hint' }, '不保留则只存缩略图,导出时可能只剩远程链接;桌面端取原图走原生 HTTP,不受图床跨域限制。'),
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('div', { className: 'iwb-gset-row-label' }, '补存'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: backfillOutputOriginals }, '补存缺失的原图'),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// 设置分组(与 sections 里的 GSetGroup 同一套类名)
|
||||
function SetGroup (props) {
|
||||
return el('div', { className: 'iwb-gset-group' },
|
||||
el('div', { className: 'iwb-gset-group-h' }, props.title),
|
||||
el('div', { className: 'iwb-gset-group-body' }, props.children))
|
||||
}
|
||||
|
||||
function SettingsModal(props) {
|
||||
const [tab, setTab] = useState(props.initialTab || 'gen')
|
||||
// 诊断页「刷新」:重读崩溃记录后需要一个自增值触发重渲染。
|
||||
@@ -102,6 +167,7 @@ function SettingsModal(props) {
|
||||
const [msg, setMsg] = useState(null)
|
||||
const [folderMsg, setFolderMsg] = useState('未选择文件夹(生成图片仍保存到浏览器图库)')
|
||||
const [speed, setSpeed] = useState(null)
|
||||
const { provSel, setProvSel, addProvider, makeProviderDefault } = useProviderSelection(setDraft, uid)
|
||||
const [modelInput, setModelInput] = useState({})
|
||||
const [layerModelInput, setLayerModelInput] = useState({})
|
||||
const [llmWarn, setLlmWarn] = useState('')
|
||||
@@ -147,12 +213,6 @@ function SettingsModal(props) {
|
||||
return { ...d, providers }
|
||||
})
|
||||
}
|
||||
const addProvider = () => {
|
||||
setDraft((d) => ({ ...d, providers: (d.providers || []).concat([{
|
||||
id: uid('p'), name: '新服务', baseUrl: '', fallbacks: [], genPath: '/images/generations', editPath: '/images/edits',
|
||||
keys: [{ id: uid('k'), name: 'Key 分组', source: 'literal', value: '' }], models: [], layerModels: [],
|
||||
}]) }))
|
||||
}
|
||||
const addKey = (pi) => {
|
||||
setKey(pi, (draft.providers[pi].keys || []).length, { id: uid('k'), name: 'Key 分组', source: 'literal', value: '' })
|
||||
}
|
||||
@@ -416,25 +476,14 @@ function SettingsModal(props) {
|
||||
} catch (e) { setFolderMsg('补存失败:' + String((e && e.message) || e)) }
|
||||
}
|
||||
// 「图片与图库」:并入「通用」页;定时清理已去掉(桌面端不需要按天数自动删图)
|
||||
const imageLibSection = el('div', null,
|
||||
el('label', { className: 'iwb-check' },
|
||||
el('input', { type: 'checkbox', checked: draft.canvas.backupOriginals === true, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, backupOriginals: e.target.checked } })) }, null),
|
||||
' 入库时同时保留原图(否则只存缩略图,导出时可能只剩远程链接)'),
|
||||
el('div', { className: 'iwb-hint' }, isDesk()
|
||||
? '桌面端取原图走原生 HTTP,不受图床跨域限制;只有图床需要登录、链接过期或图片被删除时才拿不到原图。'
|
||||
: '远程图床若不允许跨域读取(CORS),则无法本地抓取,仍只用其链接兜底展示。'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: backfillOutputOriginals }, '补存缺失的原图'),
|
||||
),
|
||||
)
|
||||
const imageLibSection = makeImageLibSection(draft, setDraft, backfillOutputOriginals)
|
||||
// ---- 生图服务 provider 卡片 ----
|
||||
const provCards = Sections ? Sections.renderProvCards({
|
||||
DEFAULT_SHAPE_TPL, I, W_SHAPE_KINDS, addAddr, addKey, addLayerModel, addModel, api, delAddr, delKey, delLayerModel, delModel, delProv, draft, layerModelInput, modelInput, modelSupportsQuality, setAddr, setDefault, setKey, setLayerModelInput, setModelInput, setModelKind, setModelQuality, setProv, setShapeText, shapeText, speed, speedTest, toggleLayerModel, toggleModel, wNormalizeLayerModels, wPrivateToolsOn,
|
||||
DEFAULT_SHAPE_TPL, I, W_SHAPE_KINDS, addAddr, addKey, addLayerModel, addModel, addProvider, api, delAddr, delKey, delLayerModel, delModel, delProv, draft, layerModelInput, makeProviderDefault, modelInput, modelSupportsQuality, provSel, setAddr, setDefault, setKey, setLayerModelInput, setModelInput, setModelKind, setModelQuality, setProv, setProvSel, setShapeText, shapeText, speed, speedTest, toggleLayerModel, toggleModel, wNormalizeLayerModels, wPrivateToolsOn,
|
||||
}) : null
|
||||
const genTab = el('div', null,
|
||||
el('div', { className: 'iwb-hint' }, '支持任意 OpenAI 兼容接口(/v1/images/generations 与 /v1/images/edits)。Key 保存在服务端 data/config.json(本地文件)。'),
|
||||
provCards,
|
||||
el('button', { className: 'iwb-btn', onClick: addProvider }, '+ 添加服务'),
|
||||
)
|
||||
const llmTab = Sections ? Sections.renderLlmTab({
|
||||
addLlmAddr, addLlmKey, addLlmModel, addLlmProvider, api, delLlmAddr, delLlmKey, delLlmModel, delLlmProvider, draft, llmAddrInput, llmAddrRes, llmAddrTesting, llmKeyInput, llmModelInput, llmTestMsg, llmTestSel, llmTesting, llmWarn, msg, setLlm, setLlmAddr, setLlmAddrDefault, setLlmAddrInput, setLlmDefaultModel, setLlmKey, setLlmKeyInput, setLlmModelInput, setLlmProv, setLlmTestSel, testLlm, testLlmAddrs,
|
||||
@@ -445,7 +494,6 @@ function SettingsModal(props) {
|
||||
const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null
|
||||
if (!A || !A.AppearanceTab) return el('div', { className: 'iwb-hint' }, '外观模块未就绪(请刷新页面)')
|
||||
return el('div', { className: 'iwb-section' },
|
||||
el('div', { className: 'iwb-section-title' }, '外观'),
|
||||
el(A.AppearanceTab, { draft, setDraft, theme, setTheme, applyTheme }),
|
||||
)
|
||||
})()
|
||||
@@ -550,13 +598,15 @@ function SettingsModal(props) {
|
||||
const autoBackupSection = Sections ? Sections.renderAutoBackupSection({
|
||||
ab, fmtAgo, props,
|
||||
}) : el('div', { className: 'iwb-hint' }, 'autoBackupSection 未就绪(请刷新页面)')
|
||||
const backupTab = el('div', { className: 'iwb-section' },
|
||||
el('div', { className: 'iwb-backup-inline-hint' }, '备份会导出所选数据;还原会覆盖当前数据并自动刷新页面。'),
|
||||
BackupModalComp
|
||||
? el(BackupModalComp, { embedded: true, onClose: props.onClose, onSaveNow: props.onSaveNow })
|
||||
: el('div', { className: 'iwb-hint' }, '备份组件未就绪(请刷新页面)'),
|
||||
// 桌面版没有这套「localStorage 快照」:真实数据在资料目录,快照价值近零 ⇒ 只在网页版显示
|
||||
isDesk() ? null : autoBackupSection,
|
||||
const backupTab = el('div', { className: 'iwb-gset-page' },
|
||||
el(SetGroup, { title: '备份与还原' },
|
||||
el('div', { className: 'iwb-gset-hint' }, '备份会导出所选数据;还原会覆盖当前数据并自动刷新页面。'),
|
||||
BackupModalComp
|
||||
? el(BackupModalComp, { embedded: true, onClose: props.onClose, onSaveNow: props.onSaveNow })
|
||||
: el('div', { className: 'iwb-hint' }, '备份组件未就绪(请刷新页面)'),
|
||||
// 桌面版没有这套「localStorage 快照」:真实数据在资料目录,快照价值近零 ⇒ 只在网页版显示
|
||||
isDesk() ? null : autoBackupSection,
|
||||
),
|
||||
)
|
||||
|
||||
// 可拖动窗口 + 外观实时预览(实现见 src/ui-modal-drag.js)
|
||||
@@ -592,6 +642,7 @@ function SettingsModal(props) {
|
||||
el('div', { className: 'iwb-modal-foot' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-primary', disabled: saving, onClick: () => { try { if (appearanceKit) appearanceKit.markSaved() } catch (e) { /* ignore */ } ; if (save) save() } }, saving ? '保存中…' : '保存配置'),
|
||||
),
|
||||
el('div', { className: 'iwb-settings-resize', title: '拖动调整窗口大小', onPointerDown: attachSettingsResize }),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -163,6 +163,25 @@
|
||||
if (kind === 'install') setRestart(true)
|
||||
} finally { setBusy('') }
|
||||
}
|
||||
// 全部更新:按已安装清单逐个安装市场里的可更新版本;逐个失败不阻断其余
|
||||
const updateAll = async function () {
|
||||
if (!D || !D.market) return
|
||||
const ids = Object.keys(inst).filter(function (id) {
|
||||
const m = findM(id); const iv = inst[id] && inst[id].version
|
||||
return !!(m.version && iv && cmpV(m.version, iv) > 0)
|
||||
})
|
||||
if (!ids.length) { setMsg('没有可更新的插件'); return }
|
||||
setBusy('__updateall__')
|
||||
let ok = 0; const fail = []
|
||||
for (const id of ids) {
|
||||
try { const r = await D.market.install(id); if (r && r.ok) ok++; else fail.push(id) } catch (e) { fail.push(id) }
|
||||
}
|
||||
setBusy('')
|
||||
await refresh()
|
||||
if (ok) setRestart(true)
|
||||
setMsg('已更新 ' + ok + '/' + ids.length + ' 个插件' + (fail.length ? (';失败:' + fail.join('、')) : '') + (ok ? ',重启应用后生效' : ''))
|
||||
}
|
||||
|
||||
// 用 src 模块加载脚本(不引 app.js 全局),成功后再写启用状态
|
||||
const loadRuntimePlugin = async function (id) {
|
||||
const rec = (wRuntimePlugins || []).find(function (r) { return r && r.id === id })
|
||||
@@ -234,8 +253,8 @@
|
||||
|
||||
// ── 管理页:横向列表(名称/版本/作者 + 描述 + 操作 + 开关),像 Obsidian「第三方插件」 ──
|
||||
const manageView = function () {
|
||||
return el('div', { className: 'iwb-set-page' },
|
||||
el('div', { className: 'iwb-set-page-title' }, '插件'),
|
||||
return el('div', { className: 'iwb-gset-page' },
|
||||
el('div', { className: 'iwb-gset-page-title' }, '插件'),
|
||||
el('div', { className: 'iwb-mk-setrow' },
|
||||
el('div', { className: 'iwb-mk-setrow-main' },
|
||||
el('div', { className: 'iwb-mk-setrow-title' }, '插件市场'),
|
||||
@@ -249,6 +268,7 @@
|
||||
el('div', { className: 'iwb-hint' }, (installedRows.length ? ('你目前已经安装了 ' + installedRows.length + ' 个插件') : '还没有安装插件') + (updatable ? (',其中 ' + updatable + ' 个可更新') : '')),
|
||||
),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: refresh }, '检查更新'),
|
||||
updatable ? el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-primary', disabled: !!busy, title: '更新全部可更新的插件', onClick: function () { updateAll() } }, busy === '__updateall__' ? '更新中…' : '全部更新') : null,
|
||||
),
|
||||
el('div', { className: 'iwb-mk-setrow' },
|
||||
el('div', { className: 'iwb-mk-setrow-main' },
|
||||
@@ -359,8 +379,8 @@
|
||||
|
||||
// ── 市场页:卡片墙 + 安装(与 market.maqiart.eu.org 同一套数据/视觉)──
|
||||
const marketView = function () {
|
||||
return el('div', { className: 'iwb-set-page' },
|
||||
el('div', { className: 'iwb-set-page-title' },
|
||||
return el('div', { className: 'iwb-gset-page' },
|
||||
el('div', { className: 'iwb-gset-page-title' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', style: { marginRight: 10 }, onClick: function () { setView('manage') } }, '返回'),
|
||||
'插件市场',
|
||||
),
|
||||
@@ -440,8 +460,8 @@
|
||||
const remoteIdle = wRuntimePlugins.filter((r) => !pluginItems.some((p) => p.id === r.id) && r.status === 'idle')
|
||||
const remoteFailed = wRuntimePlugins.filter((r) => !pluginItems.some((p) => p.id === r.id) && r.status !== 'idle')
|
||||
if (!pluginItems.length && !remoteIdle.length && !remoteFailed.length) return el('div', { className: 'iwb-hint' }, '暂无已注册插件。插件随应用一起发布,启用后其面板 / 命令 / 节点类型才会出现。')
|
||||
return el('div', { className: 'iwb-set-page' },
|
||||
el('div', { className: 'iwb-set-page-title' }, '插件管理'),
|
||||
return el('div', { className: 'iwb-gset-page' },
|
||||
el('div', { className: 'iwb-gset-page-title' }, '插件管理'),
|
||||
isDesk() && (() => {
|
||||
const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null
|
||||
const extCount = (wRuntimePlugins || []).filter((r) => r && r.source === 'external').length
|
||||
@@ -509,6 +529,14 @@
|
||||
}
|
||||
|
||||
// 版本与更新(独立组件:自己持有提示状态,不污染 generalTab 的 hook 顺序)
|
||||
// 设置分组:标题在页面底色上,内容放在浅色圆角容器里(Obsidian 式)
|
||||
function GSetGroup (props) {
|
||||
return el('div', { className: 'iwb-gset-group' },
|
||||
el('div', { className: 'iwb-gset-group-h' }, props.title),
|
||||
props.children ? el('div', { className: 'iwb-gset-group-body' }, props.children) : null,
|
||||
)
|
||||
}
|
||||
|
||||
function VersionBlock (props) {
|
||||
const version = props && props.version ? String(props.version) : ''
|
||||
const [msg, setMsg] = React.useState('')
|
||||
@@ -534,16 +562,16 @@
|
||||
setMsg('安装完成,正在重启…')
|
||||
} catch (e) { setMsg('更新失败:' + String((e && e.message) || e)) }
|
||||
}
|
||||
return el('div', null,
|
||||
el('div', { className: 'iwb-section-sub' }, '版本与更新'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-label' }, '版本'),
|
||||
el('span', { className: 'iwb-hint', style: { flex: '1 1 auto' } }, version || '未知'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: check }, '检查更新'),
|
||||
found ? el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-primary', onClick: install }, '立即更新') : null,
|
||||
return el(GSetGroup, { title: '版本与更新' }, el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '版本'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('span', { className: 'iwb-hint' }, version || '未知'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: check }, '检查更新'),
|
||||
found ? el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-primary', onClick: install }, '立即更新') : null,
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-hint' }, '更新源:download.maqiart.eu.org/updates/latest.json(签名校验通过才会安装)'),
|
||||
msg ? el('div', { className: 'iwb-hint' }, msg) : null,
|
||||
el('div', { className: 'iwb-gset-hint' }, '更新源:download.maqiart.eu.org/updates/latest.json(签名校验通过才会安装)'),
|
||||
msg ? el('div', { className: 'iwb-gset-hint' }, msg) : null,
|
||||
)
|
||||
}
|
||||
// 桌面端专属:默认下载文件夹。独立组件持有 useState ⇒ 不干扰 generalTab 的 hook 顺序。
|
||||
@@ -585,48 +613,65 @@
|
||||
await F.migrateTo(d)
|
||||
} catch (e) { setNote('转移失败:' + String((e && e.message) || e)) }
|
||||
}
|
||||
return el('div', null,
|
||||
el('div', { className: 'iwb-section-sub' }, '数据库目录'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', readOnly: true, value: dataDir, title: dataDir }),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: openData }, '打开'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: pickDataDir }, '切换…'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', title: '把整库复制到新目录后再切换(原目录保留)', onClick: migrateData }, '转移…'),
|
||||
return el('div', { className: 'iwb-gset-stack' },
|
||||
el(GSetGroup, { title: '数据与目录', desc: '设置、提示词、画布、图库清单与所有图片都存在资料目录。' }, el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '数据库目录'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('input', { className: 'iwb-input iwb-grow', readOnly: true, value: dataDir, title: dataDir }),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: openData }, '打开'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: pickDataDir }, '切换…'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', title: '把整库复制到新目录后再切换(原目录保留)', onClick: migrateData }, '转移…'),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-hint' }, 'data.json / canvases / library / images 都是普通文件。',
|
||||
el('details', { className: 'iwb-more' },
|
||||
el('summary', null, '切换与转移的区别'),
|
||||
el('div', null, '「切换」只换指针,指到已有旧目录即可搬家换机;「转移」把整库复制到新位置再切换,原目录不动。'),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '维护'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: async () => {
|
||||
try {
|
||||
const rDry = await F.gcImages({ dryRun: true })
|
||||
if (!rDry.ok) { setNote('检查失败:' + rDry.error); return }
|
||||
if (!rDry.orphans) { setNote('没有未引用的图片'); return }
|
||||
const lines = ['发现 ' + rDry.orphans + ' 个文件没有被画布/图库引用。']
|
||||
if (rDry.keptByCanvas) lines.push('其中 ' + rDry.keptByCanvas + ' 张虽然登记表里没有,但画布仍在引用 → 会自动保留。')
|
||||
if (rDry.dangling) lines.push('另有 ' + rDry.dangling + ' 处画布引用已经找不到图片(之前丢的,本次不影响它们)。')
|
||||
lines.push('移动到 trash/(不直接删除,可在回收站找回)?')
|
||||
if (!(await askConfirm(lines.join('\n'), { title: '清理未引用图片', okText: '移动' }))) return
|
||||
const rGo = await F.gcImages({ dryRun: false })
|
||||
setNote(rGo.ok
|
||||
? ('已移入 trash/:' + rGo.moved + ' 个文件' + (rGo.dangling ? (';另有 ' + rGo.dangling + ' 处引用已缺图') : ''))
|
||||
: ('清理失败:' + rGo.error))
|
||||
} catch (e) { setNote('清理失败:' + String((e && e.message) || e)) }
|
||||
} }, '清理未引用图片'),
|
||||
el('span', { className: 'iwb-hint' }, '移到 trash/,可在回收站找回'),
|
||||
),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-hint' }, '设置、提示词、画布、图库清单与所有图片都在这里(data.json / canvases / library / images)。'),
|
||||
el('div', { className: 'iwb-hint' }, '「切换」只换指针(指到已有的旧目录即可搬家换机);「转移」把整库复制到新位置再切换,原目录不动。'),
|
||||
el('div', { className: 'iwb-section-sub' }, '维护'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: async () => {
|
||||
try {
|
||||
const rDry = await F.gcImages({ dryRun: true })
|
||||
if (!rDry.ok) { setNote('检查失败:' + rDry.error); return }
|
||||
if (!rDry.orphans) { setNote('没有未引用的图片'); return }
|
||||
// 确认弹窗必须把「会不会动到在用的图」讲清楚:这是破坏性动作,不能只报一个数字。
|
||||
const lines = ['发现 ' + rDry.orphans + ' 个文件没有被画布/图库引用。']
|
||||
if (rDry.keptByCanvas) lines.push('其中 ' + rDry.keptByCanvas + ' 张虽然登记表里没有,但画布仍在引用 → 会自动保留。')
|
||||
if (rDry.dangling) lines.push('另有 ' + rDry.dangling + ' 处画布引用已经找不到图片(之前丢的,本次不影响它们)。')
|
||||
lines.push('移动到 trash/(不直接删除,可在回收站找回)?')
|
||||
if (!(await askConfirm(lines.join('\n'), { title: '清理未引用图片', okText: '移动' }))) return
|
||||
const rGo = await F.gcImages({ dryRun: false })
|
||||
setNote(rGo.ok
|
||||
? ('已移入 trash/:' + rGo.moved + ' 个文件' + (rGo.dangling ? (';另有 ' + rGo.dangling + ' 处引用已缺图') : ''))
|
||||
: ('清理失败:' + rGo.error))
|
||||
} catch (e) { setNote('清理失败:' + String((e && e.message) || e)) }
|
||||
} }, '清理未引用图片'),
|
||||
el(GSetGroup, { title: '图片导出' }, el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '导出目录'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('input', { className: 'iwb-input iwb-grow', readOnly: true, placeholder: '未设置:每次弹系统另存为', value: dir }),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: pick }, '选择…'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: clear }, '清除'),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '自动下载'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('label', { className: 'iwb-check', title: dir ? '勾选后出图完成自动保存到上面的目录' : '需先选择导出目录才能开启自动下载' },
|
||||
el('input', { type: 'checkbox', checked: autoDl, disabled: !dir, onChange: (e) => toggleAutoDl(e.target.checked) }, null),
|
||||
' 出图完成后自动保存',
|
||||
),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-hint' }, '未设置目录时,点「下载」弹系统另存为;设置后直接存到该目录。'),
|
||||
),
|
||||
el('div', { className: 'iwb-section-sub' }, '图片导出目录'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', readOnly: true, placeholder: '未设置:每次弹系统另存为', value: dir }),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: pick }, '选择…'),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: clear }, '清除'),
|
||||
),
|
||||
el('label', { className: 'iwb-check', title: dir ? '勾选后出图完成自动保存到上面的目录' : '需先选择导出目录才能开启自动下载' },
|
||||
el('input', { type: 'checkbox', checked: autoDl, disabled: !dir, onChange: (e) => toggleAutoDl(e.target.checked) }, null),
|
||||
' 自动下载'),
|
||||
el('div', { className: 'iwb-hint' }, '设了目录:点「下载」直接存到这里,不弹框;没设目录:点「下载」时弹选择框。'),
|
||||
el('div', { className: 'iwb-hint' }, '勾选「自动下载」:出图完成后自动保存到上面的目录(需先选目录)。'),
|
||||
note ? el('div', { className: 'iwb-hint' }, note) : null,
|
||||
note ? el('div', { className: 'iwb-gset-hint' }, note) : null,
|
||||
)
|
||||
}
|
||||
// 桌面端:数据位置说明 + 「打开数据目录」(网页版退回原来的浏览器文案)
|
||||
@@ -651,43 +696,52 @@
|
||||
|
||||
function renderGeneralTab (ctx) {
|
||||
const { TASK_STALL_END_MAX, TASK_STALL_END_MIN, appVersion, draft, imageLibSection, setDraft } = ctx
|
||||
const generalTab = el('div', { className: 'iwb-section' },
|
||||
el('div', { className: 'iwb-section-title' }, '数据与目录'),
|
||||
// 桌面端才有目录概念;网页版退回原来的浏览器说明
|
||||
isDesk() ? el(DownloadDirBlock, null) : el(DataDirRow, null),
|
||||
el('div', { style: { height: 16 } }),
|
||||
el('div', { className: 'iwb-section-sub' }, '生成'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('label', { className: 'iwb-label' }, '等待多久后允许提前结束(分钟)'),
|
||||
el('input', { className: 'iwb-input', type: 'number', min: 1, max: 60, step: 1, value: Math.round((draft.canvas.taskStallEndMs || 300000) / 60000), onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, (Number(e.target.value) || 5) * 60000)) } })) }),
|
||||
return el('div', { className: 'iwb-gset-page' },
|
||||
el(VersionBlock, { version: appVersion }),
|
||||
isDesk() ? el(DownloadDirBlock, null) : el(GSetGroup, { title: '数据与目录' }, el(DataDirRow, null),
|
||||
),
|
||||
el('div', { className: 'iwb-hint' }, '任务条按钮:未开始时「生成」→ 已提交后「等待」→ 超过该时长仍无新进展才出现「结束」,可在不误触的前提下提前结束该任务(不影响同批其他任务)。'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('label', { className: 'iwb-check' },
|
||||
el('input', { type: 'checkbox', checked: draft.canvas.lodLowZoom !== false, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, lodLowZoom: !!e.target.checked } })) }),
|
||||
'缩放到 15% 以下时简化节点(不显示图片,更省资源)',
|
||||
el(GSetGroup, { title: '图片与图库' }, imageLibSection || null,
|
||||
),
|
||||
el(GSetGroup, { title: '生成' }, el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '提前结束等待'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('input', { className: 'iwb-input iwb-num', type: 'number', min: 1, max: 60, step: 1, value: Math.round((draft.canvas.taskStallEndMs || 300000) / 60000), onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, (Number(e.target.value) || 5) * 60000)) } })) }),
|
||||
el('span', { className: 'iwb-hint' }, '分钟'),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-hint' }, '任务条:生成 → 等待 → 超过该时长仍无进展才出现「结束」。',
|
||||
el('details', { className: 'iwb-more' },
|
||||
el('summary', null, '更多说明'),
|
||||
el('div', null, '可在不误触的前提下提前结束该任务,不影响同批其他任务。'),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '低缩放简化'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('label', { className: 'iwb-check' },
|
||||
el('input', { type: 'checkbox', checked: draft.canvas.lodLowZoom !== false, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, lodLowZoom: !!e.target.checked } })) }),
|
||||
'缩放到 15% 以下时简化节点(不显示图片)',
|
||||
),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-hint' }, '关闭后任何缩放都渲染完整节点,节点多的大画布会更吃资源。'),
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('span', { className: 'iwb-gset-row-label' }, '提示音'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('label', { className: 'iwb-check' },
|
||||
el('input', { type: 'checkbox', checked: draft.canvas.soundEnabled === true, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, soundEnabled: e.target.checked } })) }, null),
|
||||
'生成完成时提示音',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-hint' }, '关掉后任何缩放比例都渲染完整节点(含图片)。节点很多的大画布缩得很小时,关掉会明显更吃资源。'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('label', { className: 'iwb-check' }, el('input', { type: 'checkbox', checked: draft.canvas.soundEnabled === true, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, soundEnabled: e.target.checked } })) }, null), ' 生成完成提示音'),
|
||||
),
|
||||
el('div', { style: { height: 16 } }),
|
||||
// 原「图片保存」页并入这里(定时清理已去掉)
|
||||
imageLibSection || null,
|
||||
el('div', { style: { height: 16 } }),
|
||||
el(VersionBlock, { version: appVersion }),
|
||||
// 桌面端没有服务端、也没有「浏览器本地模式」这回事 ⇒ 整段不渲染
|
||||
isDesk() ? null : el('div', { className: 'iwb-section-sub' }, '访问口令'),
|
||||
isDesk() ? null : el('div', { className: 'iwb-hint' }, '口令是服务端(Node 版 image-workbench-app)的 Basic Auth 功能;当前为浏览器本地模式(数据存在你的浏览器),页面与数据本就只在本机,无需设置口令。'),
|
||||
)
|
||||
return generalTab
|
||||
}
|
||||
|
||||
function renderTransferSection (ctx) {
|
||||
const { comp, hostFields, ih, it, setComp, setIH, setIt } = ctx
|
||||
const transferSection = el('div', { className: 'iwb-section' },
|
||||
el('div', { className: 'iwb-section-title' }, '传输方式(参考图如何发送)'),
|
||||
const transferSection = el('div', { className: 'iwb-gset-page' },
|
||||
el(GSetGroup, { title: '传输方式' },
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-label' }, '参考图上限'),
|
||||
el('input', { className: 'iwb-input iwb-num', type: 'number', min: 1, max: 12, value: Number(it.maxRefs) || 3, title: '单次参考图数量上限(接口默认 1-3,自定义接口可调大)', onChange: (e) => setIt({ maxRefs: Number(e.target.value) }) }, null),
|
||||
@@ -702,7 +756,8 @@
|
||||
),
|
||||
),
|
||||
hostFields,
|
||||
el('div', { className: 'iwb-section-sub' }, '压缩(超阈值自动压缩后发送)'),
|
||||
),
|
||||
el(GSetGroup, { title: '压缩' },
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('label', { className: 'iwb-check' }, el('input', { type: 'checkbox', checked: comp.enabled !== false, onChange: (e) => setComp({ enabled: e.target.checked }) }, null), ' 启用'),
|
||||
el('input', { className: 'iwb-input iwb-num', type: 'number', min: 1, value: comp.maxMB || 8, title: '超过该大小(MB)才压缩', onChange: (e) => setComp({ maxMB: Number(e.target.value) }) }, null),
|
||||
@@ -716,6 +771,7 @@
|
||||
el('select', { className: 'iwb-input iwb-grow', value: comp.format || 'keep', onChange: (e) => setComp({ format: e.target.value }) },
|
||||
el('option', { value: 'keep' }, '保持原格式'), el('option', { value: 'jpeg' }, '统一转 JPEG')),
|
||||
),
|
||||
),
|
||||
)
|
||||
return transferSection
|
||||
}
|
||||
@@ -750,7 +806,7 @@
|
||||
|
||||
function renderPluginSettingsPage (ctx) {
|
||||
const { PluginHost, activePlugin, setMsg, setPluginsRev, setTab } = ctx
|
||||
const pluginSettingsPage = activePlugin ? el('div', { className: 'iwb-set-page' },
|
||||
const pluginSettingsPage = activePlugin ? el('div', { className: 'iwb-gset-page' },
|
||||
el('div', { className: 'iwb-mk-setrow' },
|
||||
el('div', { className: 'iwb-mk-setrow-main' },
|
||||
el('div', { className: 'iwb-mk-setrow-title' }, activePlugin.name,
|
||||
@@ -835,9 +891,7 @@
|
||||
|
||||
function renderLlmTab (ctx) {
|
||||
const { addLlmAddr, addLlmKey, addLlmModel, addLlmProvider, api, delLlmAddr, delLlmKey, delLlmModel, delLlmProvider, draft, llmAddrInput, llmAddrRes, llmAddrTesting, llmKeyInput, llmModelInput, llmTestMsg, llmTestSel, llmTesting, llmWarn, msg, setLlm, setLlmAddr, setLlmAddrDefault, setLlmAddrInput, setLlmDefaultModel, setLlmKey, setLlmKeyInput, setLlmModelInput, setLlmProv, setLlmTestSel, testLlm, testLlmAddrs } = ctx
|
||||
const llmTab = el('div', { className: 'iwb-section' },
|
||||
el('div', { className: 'iwb-section-title' }, 'LLM 渠道(可选,用于提示词润色)'),
|
||||
el('div', { className: 'iwb-hint' }, '可选 · 用于提示词润色;润色使用「默认渠道」。'),
|
||||
const llmTab = el('div', { className: 'iwb-gset-page' },
|
||||
(draft.llm.providers || []).length
|
||||
? draft.llm.providers.map((p, pi) => {
|
||||
const isDef = p.id === draft.llm.defaultProviderId
|
||||
@@ -905,19 +959,35 @@
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('button', { className: 'iwb-btn', onClick: addLlmProvider }, '+ 添加渠道'),
|
||||
),
|
||||
el('div', { className: 'iwb-label', title: '全局模板;LLM 节点内可覆盖' }, '默认润色指令'),
|
||||
el('textarea', { className: 'iwb-input iwb-hdrbox', style: { minHeight: '40px', maxHeight: '64px', overflowY: 'auto' }, value: draft.llm.defaultInstruction || '', onChange: (e) => setLlm({ defaultInstruction: e.target.value }) }, null),
|
||||
llmWarn ? el('div', { className: 'iwb-hint', style: { color: '#b91c1c' } }, llmWarn) : null,
|
||||
el('div', { className: 'iwb-hint' }, '流程可不经过 LLM(直接连生图);节点未填指令时用此模板。'),
|
||||
el(GSetGroup, { title: '默认润色指令' },
|
||||
el('textarea', { className: 'iwb-input iwb-hdrbox', style: { minHeight: '40px', maxHeight: '64px', overflowY: 'auto' }, value: draft.llm.defaultInstruction || '', onChange: (e) => setLlm({ defaultInstruction: e.target.value }) }, null),
|
||||
llmWarn ? el('div', { className: 'iwb-hint', style: { color: '#b91c1c' } }, llmWarn) : null,
|
||||
el('div', { className: 'iwb-gset-hint' }, '流程可不经过 LLM(直接连生图);节点未填指令时用此模板。'),
|
||||
),
|
||||
)
|
||||
return llmTab
|
||||
}
|
||||
|
||||
function renderProvCards (ctx) {
|
||||
const { DEFAULT_SHAPE_TPL, I, W_SHAPE_KINDS, addAddr, addKey, addLayerModel, addModel, api, delAddr, delKey, delLayerModel, delModel, delProv, draft, layerModelInput, modelInput, modelSupportsQuality, setAddr, setDefault, setKey, setLayerModelInput, setModelInput, setModelKind, setModelQuality, setProv, setShapeText, shapeText, speed, speedTest, toggleLayerModel, toggleModel, wNormalizeLayerModels, wPrivateToolsOn } = ctx
|
||||
const { DEFAULT_SHAPE_TPL, I, W_SHAPE_KINDS, addAddr, addKey, addLayerModel, addModel, addProvider, api, delAddr, delKey, delLayerModel, delModel, delProv, draft, layerModelInput, makeProviderDefault, modelInput, modelSupportsQuality, provSel, setAddr, setDefault, setKey, setLayerModelInput, setModelInput, setModelKind, setModelQuality, setProv, setProvSel, setShapeText, shapeText, speed, speedTest, toggleLayerModel, toggleModel, wNormalizeLayerModels, wPrivateToolsOn } = ctx
|
||||
const provCards = []
|
||||
for (let pi = 0; pi < (draft.providers || []).length; pi++) {
|
||||
const p = draft.providers[pi]
|
||||
const providersAll = draft.providers || []
|
||||
const selectedId = provSel && providersAll.some((p) => p.id === provSel) ? provSel : ((providersAll[0] && providersAll[0].id) || '')
|
||||
const chips = el('div', { className: 'iwb-prov-chips', role: 'tablist', 'aria-label': '服务商' },
|
||||
providersAll.map((p, i) => el('button', {
|
||||
key: p.id, type: 'button', role: 'tab', 'aria-selected': p.id === selectedId ? 'true' : 'false',
|
||||
className: 'iwb-prov-chip' + (p.id === selectedId ? ' on' : ''),
|
||||
title: (p.name || '未命名服务') + ':' + (1 + (p.fallbacks || []).length) + ' 个地址 · ' + (p.models || []).length + ' 个模型',
|
||||
onClick: () => setProvSel && setProvSel(p.id),
|
||||
},
|
||||
el('span', { className: 'iwb-prov-chip-name' }, p.name || '未命名服务'),
|
||||
i === 0 ? el('span', { className: 'iwb-prov-chip-badge' }, '主') : null,
|
||||
)),
|
||||
el('button', { type: 'button', className: 'iwb-btn iwb-btn-sm iwb-prov-add', onClick: addProvider, title: '添加一个生图服务商' }, '+ 添加服务商'),
|
||||
)
|
||||
for (let pi = 0; pi < providersAll.length; pi++) {
|
||||
const p = providersAll[pi]
|
||||
if (p.id !== selectedId) continue
|
||||
const keyRows = []
|
||||
for (let ki = 0; ki < (p.keys || []).length; ki++) {
|
||||
const k = p.keys[ki]
|
||||
@@ -951,19 +1021,8 @@
|
||||
const rulesVal = (shapeText[rulesKey] !== undefined)
|
||||
? shapeText[rulesKey]
|
||||
: JSON.stringify(p.modelRules || ((typeof window !== 'undefined' && window.IWBGenerationRequestShape && window.IWBGenerationRequestShape.DEFAULT_RULES) || []), null, 1)
|
||||
const shapeBox = el('div', { className: 'iwb-shape-box' },
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-hint iwb-addr-tag' }, '厂商'),
|
||||
el('select', {
|
||||
className: 'iwb-input iwb-grow', 'aria-label': '厂商类型', value: shapeKind,
|
||||
onChange: (e) => setProv(pi, { kind: e.target.value }),
|
||||
},
|
||||
el('option', { value: 'openai' }, 'OpenAI 兼容(像素 size,默认)'),
|
||||
el('option', { value: 'gemini' }, 'Google Gemini / Nano Banana(比例 + K 档)'),
|
||||
el('option', { value: 'doubao' }, '豆包 / Seedream(K 档或像素)'),
|
||||
el('option', { value: 'custom' }, '自定义(请求体模板)'),
|
||||
),
|
||||
),
|
||||
const shapeMore = el('details', { className: 'iwb-shape-more', open: shapeKind === 'custom' || !!shapeText[pi + ':err'] },
|
||||
el('summary', null, '模型名规则(JSON,高级)'),
|
||||
shapeKind === 'custom' ? el('div', null,
|
||||
el('div', { className: 'iwb-hint' }, '请求体模板(JSON)。占位符:$model $prompt $n $size $ratio $ratio_x $res $res_k $width $height'),
|
||||
el('textarea', {
|
||||
@@ -989,6 +1048,21 @@
|
||||
}, null),
|
||||
shapeText[pi + ':err'] ? el('div', { className: 'iwb-hint' }, shapeText[pi + ':err']) : null,
|
||||
)
|
||||
const shapeBox = el('div', { className: 'iwb-shape-box' },
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-hint iwb-addr-tag' }, '厂商'),
|
||||
el('select', {
|
||||
className: 'iwb-input iwb-grow', 'aria-label': '厂商类型', value: shapeKind,
|
||||
onChange: (e) => setProv(pi, { kind: e.target.value }),
|
||||
},
|
||||
el('option', { value: 'openai' }, 'OpenAI 兼容(像素 size,默认)'),
|
||||
el('option', { value: 'gemini' }, 'Google Gemini / Nano Banana(比例 + K 档)'),
|
||||
el('option', { value: 'doubao' }, '豆包 / Seedream(K 档或像素)'),
|
||||
el('option', { value: 'custom' }, '自定义(请求体模板)'),
|
||||
),
|
||||
),
|
||||
shapeMore,
|
||||
)
|
||||
const sp = speed && speed.providerId === p.id ? speed : null
|
||||
const modelRows = (p.models || []).map((m) => el('div', { key: m.name, className: 'iwb-modelrow' },
|
||||
el('label', { className: 'iwb-check iwb-modelrow-main', title: m.name + '(勾选=在生图节点下拉里可见)' },
|
||||
@@ -1020,9 +1094,14 @@
|
||||
el('option', { value: 'doubao' }, 'doubao'),
|
||||
el('option', { value: 'custom' }, 'custom'),
|
||||
),
|
||||
m.source !== 'builtin'
|
||||
? el('button', { className: 'iwb-btn iwb-btn-xs iwb-btn-danger', title: '删除模型', 'aria-label': '删除模型 ' + m.name, onClick: () => delModel(pi, m.name) }, I('trash'))
|
||||
: el('span', { className: 'iwb-hint', title: '内置模型只能隐藏,不能删除' }, '内置'),
|
||||
el('details', { className: 'iwb-model-more' },
|
||||
el('summary', { className: 'iwb-model-more-btn', title: '更多操作', 'aria-label': '更多操作 ' + m.name }, '⋯'),
|
||||
el('div', { className: 'iwb-ctxmenu iwb-model-more-menu' },
|
||||
m.source !== 'builtin'
|
||||
? el('button', { className: 'iwb-model-more-del', title: '删除模型', 'aria-label': '删除模型 ' + m.name, onClick: () => delModel(pi, m.name) }, '删除模型')
|
||||
: el('div', { className: 'iwb-model-more-hint' }, '内置模型不可删除'),
|
||||
),
|
||||
),
|
||||
))
|
||||
// 分层模型行:结构与生图模型行一致(同一套 .iwb-modellist/.iwb-modelrow 样式);
|
||||
// 内置项既不能删也不能隐藏(隐藏会让分层节点没有模型可选)。
|
||||
@@ -1031,16 +1110,25 @@
|
||||
el('input', { type: 'checkbox', checked: true, disabled: m.source === 'builtin', onChange: (e) => toggleLayerModel(pi, m.name, e.target.checked) }, null),
|
||||
el('span', null, m.name),
|
||||
),
|
||||
m.source !== 'builtin'
|
||||
? el('button', { className: 'iwb-btn iwb-btn-xs iwb-btn-danger', title: '删除分层模型', 'aria-label': '删除分层模型 ' + m.name, onClick: () => delLayerModel(pi, m.name) }, I('trash'))
|
||||
: el('span', { className: 'iwb-hint', title: '内置分层模型:唯一实测可用的图层分离模型,不可删除也不可隐藏' }, '内置'),
|
||||
el('details', { className: 'iwb-model-more' },
|
||||
el('summary', { className: 'iwb-model-more-btn', title: '更多操作', 'aria-label': '更多操作 ' + m.name }, '⋯'),
|
||||
el('div', { className: 'iwb-ctxmenu iwb-model-more-menu' },
|
||||
m.source !== 'builtin'
|
||||
? el('button', { className: 'iwb-model-more-del', title: '删除分层模型', 'aria-label': '删除分层模型 ' + m.name, onClick: () => delLayerModel(pi, m.name) }, '删除分层模型')
|
||||
: el('div', { className: 'iwb-model-more-hint' }, '内置分层模型不可删除'),
|
||||
),
|
||||
),
|
||||
))
|
||||
provCards.push(el('div', { key: p.id, className: 'iwb-provider-card' },
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', value: p.name || '', placeholder: '服务名称', onChange: (e) => setProv(pi, { name: e.target.value }) }),
|
||||
el(GSetGroup, { title: '服务' },
|
||||
el('div', { className: 'iwb-prov-head' },
|
||||
el('input', { className: 'iwb-input iwb-prov-name', value: p.name || '', placeholder: '服务名称', 'aria-label': '服务名称', onChange: (e) => setProv(pi, { name: e.target.value }) }),
|
||||
el('span', { className: 'iwb-prov-badge' }, pi === 0 ? '主服务' : '备用服务'),
|
||||
el('span', { className: 'iwb-prov-sum' }, (1 + (p.fallbacks || []).length) + ' 地址 · ' + (p.models || []).length + ' 模型'),
|
||||
pi > 0 ? el('button', { className: 'iwb-btn iwb-btn-sm', title: '移到第一位,作为默认服务', onClick: () => makeProviderDefault && makeProviderDefault(pi) }, '设为默认') : null,
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-danger', onClick: () => delProv(pi) }, '删除服务'),
|
||||
),
|
||||
el('div', { className: 'iwb-section-sub' }, '服务器地址(多条自动切换)'),
|
||||
)),
|
||||
el(GSetGroup, { title: '服务器地址', desc: '多条自动切换' },
|
||||
addrRows,
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => addAddr(pi) }, '+ 添加地址'),
|
||||
@@ -1059,34 +1147,42 @@
|
||||
sp.results.some((r) => r.ok && r.cors === false) ? el('div', { className: 'iwb-hint' }, '有地址未开放跨域读状态码:显示的耗时是「连得上」的估算值,按它排序选最快即可,不影响生图。') : null,
|
||||
sp.results.length && sp.results.every((r) => !r.ok) && sp.results[0].error ? el('div', { className: 'iwb-hint' }, '全部失败 · ' + String(sp.results[0].error)) : null,
|
||||
) : null,
|
||||
el('div', { className: 'iwb-row' },
|
||||
),
|
||||
el(GSetGroup, { title: '接口路径' },
|
||||
el('div', { className: 'iwb-gset-row' },
|
||||
el('div', { className: 'iwb-gset-row-label' }, '生图 / 编辑'),
|
||||
el('div', { className: 'iwb-gset-row-ctl' },
|
||||
el('input', { className: 'iwb-input iwb-grow', value: p.genPath || '', placeholder: '生图路径,默认 /images/generations', onChange: (e) => setProv(pi, { genPath: e.target.value }) }),
|
||||
el('input', { className: 'iwb-input iwb-grow', value: p.editPath || '', placeholder: '编辑路径,默认 /images/edits', onChange: (e) => setProv(pi, { editPath: e.target.value }) }),
|
||||
)),
|
||||
),
|
||||
el('div', { className: 'iwb-label' }, 'API Key 分组'),
|
||||
el(GSetGroup, { title: 'API Key' },
|
||||
keyRows,
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => addKey(pi) }, '+ 添加 Key 分组'),
|
||||
el('div', { className: 'iwb-section-sub' }, '厂商分类(决定请求体怎么发尺寸)'),
|
||||
),
|
||||
el(GSetGroup, { title: '请求分类', desc: '决定请求体怎么发尺寸' },
|
||||
shapeBox,
|
||||
el('div', { className: 'iwb-section-sub' }, '模型显隐(生图节点下拉只显示可见项)'),
|
||||
),
|
||||
el(GSetGroup, { title: '模型', desc: '生图节点下拉只显示可见项' },
|
||||
el('div', { className: 'iwb-modellist' }, modelRows.length ? modelRows : el('div', { className: 'iwb-hint' }, '暂无模型 · 手动添加')),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', placeholder: '手动添加模型名', value: modelInput[pi] || '', onChange: (e) => setModelInput((m) => ({ ...m, [pi]: e.target.value })) }),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => { addModel(pi, (modelInput[pi] || '').trim()); setModelInput((m) => ({ ...m, [pi]: '' })) } }, '+ 添加'),
|
||||
),
|
||||
),
|
||||
// 分层模型区块属于私有功能:开关关闭时整段不渲染(普通用户看不到任何痕迹)
|
||||
...(wPrivateToolsOn ? [
|
||||
el('div', { className: 'iwb-section-sub' }, '分层模型(分层节点下拉只显示可见项,与生图模型清单互不影响)'),
|
||||
el(GSetGroup, { title: '分层模型', desc: '分层节点下拉只显示可见项,与生图模型清单互不影响' },
|
||||
el('div', { className: 'iwb-modellist' }, layerModelRows.length ? layerModelRows : el('div', { className: 'iwb-hint' }, '暂无分层模型')),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', placeholder: '手动添加分层模型名(如 doubao-seedream-5-0-pro-260628)', value: layerModelInput[pi] || '', onChange: (e) => setLayerModelInput((m) => ({ ...m, [pi]: e.target.value })) }),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => { addLayerModel(pi, (layerModelInput[pi] || '').trim()); setLayerModelInput((m) => ({ ...m, [pi]: '' })) } }, '+ 添加'),
|
||||
),
|
||||
)),
|
||||
] : []),
|
||||
))
|
||||
}
|
||||
// ---- Tab 内容 ----
|
||||
return provCards
|
||||
return [chips].concat(provCards)
|
||||
}
|
||||
|
||||
function renderHostFields (ctx) {
|
||||
|
||||
@@ -0,0 +1,480 @@
|
||||
// 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 才算过)
|
||||
//
|
||||
// 8 个场景 × 亮/暗 = 16 张,覆盖「壳层 / 画布 / 浮层 / 抽屉 / 插件面板 / 右键菜单 /
|
||||
// 插件管理 / 插件市场」八类界面。⑦⑧ 是 M6 重做插件面板时补的:那一整段样式此前**没有基线**,
|
||||
// 六次叠加的改动全靠人眼看,等于最乱的地方最没保护。
|
||||
// 稳定化:固定 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)
|
||||
}
|
||||
|
||||
// ── ⑦⑧ 组件夹具 ────────────────────────────────────────────────────────
|
||||
// 为什么不用整页截图:插件管理/市场这一屏由 DesktopPluginsTab 渲染,而它在
|
||||
// `isDesk()` 为 false 时(网页 e2e 环境)走的是另一条分支(.iwb-plugin-row 清单),
|
||||
// 这条最乱的样式反而截不到。夹具用同一套类名 + 真实 dist/style.css 渲染,
|
||||
// 覆盖「设置行 / 列表行 / 开关 / 工具条 / 筛选胶囊 / 卡片」六种形态。
|
||||
const PANEL_HTML = `
|
||||
<div id="stage" style="background:var(--iwb-bg);padding:20px 24px">
|
||||
<div class="iwb-modal-body" style="max-width:none">
|
||||
<div class="iwb-set-page">
|
||||
<div class="iwb-set-page-title">插件</div>
|
||||
<div class="iwb-mk-setrow">
|
||||
<div class="iwb-mk-setrow-main">
|
||||
<div class="iwb-mk-setrow-title">插件市场</div>
|
||||
<div class="iwb-hint">浏览并安装由官方 / 社区制作的插件</div>
|
||||
</div>
|
||||
<button class="iwb-btn iwb-btn-sm">浏览</button>
|
||||
</div>
|
||||
<div class="iwb-mk-setrow">
|
||||
<div class="iwb-mk-setrow-main">
|
||||
<div class="iwb-mk-setrow-title">插件安装情况</div>
|
||||
<div class="iwb-hint">你目前已经安装了 8 个插件,其中 2 个可更新</div>
|
||||
</div>
|
||||
<button class="iwb-btn iwb-btn-sm">检查更新</button>
|
||||
</div>
|
||||
<div class="iwb-mk-setrow">
|
||||
<div class="iwb-mk-setrow-main">
|
||||
<div class="iwb-mk-setrow-title">开发者模式</div>
|
||||
<div class="iwb-hint">加载 plugins/local/<id>/plugin.js(未签名,仅本地调试)</div>
|
||||
</div>
|
||||
<label class="iwb-switch"><input type="checkbox" checked><span class="iwb-switch-track"><span class="iwb-switch-dot"></span></span></label>
|
||||
</div>
|
||||
<div class="iwb-section-sub">已安装插件</div>
|
||||
<div class="iwb-mk-list">
|
||||
<div class="iwb-mk-row">
|
||||
<span class="iwb-mk-avatar" style="background:#dbeafe">✎</span>
|
||||
<div class="iwb-mk-row-main">
|
||||
<div class="iwb-mk-row-title">
|
||||
<span class="iwb-mk-row-name">标注 / 修图</span>
|
||||
<span class="iwb-mk-row-ver">v1.20.7</span>
|
||||
<span class="iwb-mk-row-author">官方</span>
|
||||
<span class="iwb-plugin-tag">已加载</span>
|
||||
</div>
|
||||
<div class="iwb-mk-row-desc">在图片上画箭头、文字、马赛克,支持批量导出</div>
|
||||
</div>
|
||||
<div class="iwb-mk-row-actions">
|
||||
<button class="iwb-btn iwb-btn-sm">设置</button>
|
||||
<button class="iwb-btn iwb-btn-sm">移除</button>
|
||||
<label class="iwb-switch"><input type="checkbox" checked disabled><span class="iwb-switch-track"><span class="iwb-switch-dot"></span></span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-row">
|
||||
<span class="iwb-mk-avatar" style="background:#dcfce7">◈</span>
|
||||
<div class="iwb-mk-row-main">
|
||||
<div class="iwb-mk-row-title">
|
||||
<span class="iwb-mk-row-name">位图转矢量</span>
|
||||
<span class="iwb-mk-row-ver">v0.6.1</span>
|
||||
<span class="iwb-mk-row-author">官方</span>
|
||||
<span class="iwb-plugin-tag iwb-plugin-tag-warn">未加载</span>
|
||||
</div>
|
||||
<div class="iwb-mk-row-desc">把位图描成 SVG,可调颜色数量与平滑度</div>
|
||||
</div>
|
||||
<div class="iwb-mk-row-actions">
|
||||
<button class="iwb-btn iwb-btn-sm">设置</button>
|
||||
<button class="iwb-btn iwb-btn-sm">移除</button>
|
||||
<label class="iwb-switch"><input type="checkbox"><span class="iwb-switch-track"><span class="iwb-switch-dot"></span></span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-row">
|
||||
<span class="iwb-mk-avatar" style="background:#fef3c7">⇩</span>
|
||||
<div class="iwb-mk-row-main">
|
||||
<div class="iwb-mk-row-title">
|
||||
<span class="iwb-mk-row-name">批量导出</span>
|
||||
<span class="iwb-mk-row-ver">v1.2.1</span>
|
||||
<span class="iwb-mk-row-author">官方</span>
|
||||
<span class="iwb-plugin-tag">可更新</span>
|
||||
</div>
|
||||
<div class="iwb-mk-row-desc">按预设尺寸批量导出,支持透明 PNG 与白底 JPG 双版本</div>
|
||||
</div>
|
||||
<div class="iwb-mk-row-actions">
|
||||
<button class="iwb-btn iwb-btn-sm">更新</button>
|
||||
<button class="iwb-btn iwb-btn-sm">设置</button>
|
||||
<button class="iwb-btn iwb-btn-sm">移除</button>
|
||||
<label class="iwb-switch"><input type="checkbox" checked><span class="iwb-switch-track"><span class="iwb-switch-dot"></span></span></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
const MARKET_HTML = `
|
||||
<div id="stage" style="background:var(--iwb-bg);padding:20px 24px">
|
||||
<div class="iwb-modal-body" style="max-width:none">
|
||||
<div class="iwb-set-page">
|
||||
<div class="iwb-set-page-title">插件市场</div>
|
||||
<div class="iwb-mk-subtitle">共 4 个插件 · 资料目录/plugins/</div>
|
||||
<div class="iwb-mk-toolbar">
|
||||
<input class="iwb-input iwb-grow" placeholder="搜索插件,例如:出图、抠图、矢量…">
|
||||
<div class="iwb-mk-filters">
|
||||
<button class="iwb-mk-chip on">标注</button>
|
||||
<button class="iwb-mk-chip">修图</button>
|
||||
<button class="iwb-mk-chip">矢量</button>
|
||||
<button class="iwb-mk-chip">导出</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-filters">
|
||||
<button class="iwb-mk-chip on">全部 4</button>
|
||||
<button class="iwb-mk-chip">已安装 2</button>
|
||||
<button class="iwb-mk-chip">未安装 2</button>
|
||||
</div>
|
||||
<div class="iwb-mk-grid">
|
||||
<div class="iwb-mk-card">
|
||||
<div class="iwb-mk-head">
|
||||
<span class="iwb-mk-avatar" style="background:#dbeafe">✎</span>
|
||||
<div class="iwb-mk-titles">
|
||||
<div class="iwb-mk-name">标注 / 修图<span class="iwb-mk-badge">已安装</span></div>
|
||||
<div class="iwb-mk-sub">官方 · v1.20.7 · 442 KB</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-desc">在图片上画箭头、文字、马赛克,支持批量导出</div>
|
||||
<div class="iwb-mk-foot">
|
||||
<div class="iwb-mk-tags"><span class="iwb-mk-tag">标注</span><span class="iwb-mk-tag">修图</span></div>
|
||||
<div class="iwb-mk-actions"><button class="iwb-btn iwb-btn-sm">移除</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-card">
|
||||
<div class="iwb-mk-head">
|
||||
<span class="iwb-mk-avatar" style="background:#dcfce7">◈</span>
|
||||
<div class="iwb-mk-titles">
|
||||
<div class="iwb-mk-name">位图转矢量</div>
|
||||
<div class="iwb-mk-sub">官方 · v0.6.1 · 143 KB</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-desc">把位图描成 SVG,可调颜色数量与平滑度</div>
|
||||
<div class="iwb-mk-foot">
|
||||
<div class="iwb-mk-tags"><span class="iwb-mk-tag">矢量</span></div>
|
||||
<div class="iwb-mk-actions"><button class="iwb-btn iwb-btn-sm iwb-btn-primary">安装</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-card">
|
||||
<div class="iwb-mk-head">
|
||||
<span class="iwb-mk-avatar" style="background:#fef3c7">⇩</span>
|
||||
<div class="iwb-mk-titles">
|
||||
<div class="iwb-mk-name">批量导出</div>
|
||||
<div class="iwb-mk-sub">官方 · v1.2.1 · 44 KB</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-desc">按预设尺寸批量导出,支持透明 PNG 与白底 JPG 双版本</div>
|
||||
<div class="iwb-mk-foot">
|
||||
<div class="iwb-mk-tags"><span class="iwb-mk-tag">导出</span><span class="iwb-mk-tag">批处理</span></div>
|
||||
<div class="iwb-mk-actions"><button class="iwb-btn iwb-btn-sm">移除</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-card">
|
||||
<div class="iwb-mk-head">
|
||||
<span class="iwb-mk-avatar" style="background:#f3e8ff">◐</span>
|
||||
<div class="iwb-mk-titles">
|
||||
<div class="iwb-mk-name">风格来源</div>
|
||||
<div class="iwb-mk-sub">社区 · v1.3.3 · 69 KB</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-mk-desc">从参考图提取配色与风格关键词</div>
|
||||
<div class="iwb-mk-foot">
|
||||
<div class="iwb-mk-tags"><span class="iwb-mk-tag">风格</span></div>
|
||||
<div class="iwb-mk-actions"><button class="iwb-btn iwb-btn-sm iwb-btn-primary">安装</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
async function bootPanel(page, theme, html) {
|
||||
await page.goto('about:blank')
|
||||
await page.setContent(html, { waitUntil: 'domcontentloaded' })
|
||||
await page.addStyleTag({ path: require('node:path').join(__dirname, '..', 'dist', 'style.css') })
|
||||
// 夹具里所有过渡必须彻底关掉:开关的 .15s 背景过渡在截图时可能停在最后一帧,
|
||||
// 两次截图差 1~3 级灰度、只有几个像素,却会让 threshold:0 的基线变成随机红灯。
|
||||
await page.addStyleTag({ content: '*,*::before,*::after{transition:none!important;animation:none!important}' })
|
||||
await page.evaluate((t) => { document.documentElement.classList.toggle('theme-dark', t === 'dark') }, theme)
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
test('⑦ 插件管理(设置行 + 列表 + 开关)', async ({ page }) => {
|
||||
await bootPanel(page, theme, PANEL_HTML)
|
||||
await shot(page, '07-plugins-manage-' + theme)
|
||||
})
|
||||
|
||||
test('⑧ 插件市场(工具条 + 筛选 + 卡片墙)', async ({ page }) => {
|
||||
await bootPanel(page, theme, MARKET_HTML)
|
||||
await shot(page, '08-plugins-market-' + theme)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// ── ⑨⑩ 提示词库弹窗夹具 ───────────────────────────────────────────────
|
||||
// 真实对话框由插件 JS 生成、依赖 Tauri 宿主,网页环境点不出来;这里用同一套类名 +
|
||||
// 真实 dist/style.css + plugins/promptlib/styles.css 渲染,做「编辑 / 详情」两屏基线。
|
||||
// 只覆盖静态外观:不测交互逻辑(交互由 tests/plugin-promptlib-render-test.js 守)。
|
||||
const PLP_EDIT_HTML = `
|
||||
<div id="stage" style="background:var(--iwb-bg);padding:24px;display:flex;justify-content:center">
|
||||
<div class="iwb-plp-dialog iwb-plp-dialog-edit" style="position:relative;margin:0;width:1180px;height:700px;display:flex;flex-direction:column">
|
||||
<div class="iwb-plp-dhead"><span class="iwb-plp-grip"></span><span class="iwb-toolbar-title">编辑提示词</span><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">取消</button><button class="iwb-btn iwb-btn-primary iwb-btn-sm">保存</button></div>
|
||||
<div class="iwb-plp-dbody">
|
||||
<div class="iwb-plp-eleft">
|
||||
<div class="iwb-plp-ecov"></div>
|
||||
<div class="iwb-plp-lrow"><span>名称</span><textarea class="iwb-input iwb-plp-namebox">女生喜欢的小红书封面</textarea></div>
|
||||
<div class="iwb-plp-lrow"><span>分组</span><input class="iwb-input" value="小红书"></div>
|
||||
<div class="iwb-plp-lrow iwb-plp-lrow-tags"><span>标签</span><div class="iwb-plp-tagwrap"><div class="iwb-plp-tagchips"><span class="iwb-plp-tagchip">收藏<i class="iwb-plp-tagx">×</i></span></div><div class="iwb-plp-tagrow"><input class="iwb-input iwb-plp-tagin" placeholder="添加标签"><button class="iwb-plp-tagadd">+</button></div></div></div>
|
||||
</div>
|
||||
<div class="iwb-plp-emid">
|
||||
<div class="iwb-plp-etool"><button class="iwb-btn iwb-btn-sm iwb-plp-insvar">+ 插入变量</button><span class="iwb-hint">在光标处插入 {变量},并自动聚焦变量名</span></div>
|
||||
<div class="iwb-plp-ewrap"><div class="iwb-plp-hl">参考图片内容,保持图片内容一致性,{写实摄影} 风格,符合{女生} 喜好</div><textarea class="iwb-input iwb-plp-etext">参考图片内容,保持图片内容一致性,{写实摄影} 风格,符合{女生} 喜好</textarea></div>
|
||||
</div>
|
||||
<div class="iwb-plp-esplit"></div>
|
||||
<div class="iwb-plp-eright">
|
||||
<div class="iwb-plp-vars"><div class="iwb-plp-vhead"><span>变量</span><span class="iwb-plp-vhint">与正文双向同步 · 点 i 写说明</span></div><div class="iwb-plp-vrows">
|
||||
<div class="iwb-plp-vitem"><div class="iwb-plp-vrow2"><input class="iwb-input iwb-plp-vname" value="写实摄影"><button class="iwb-plp-vi is-open">i</button></div><input class="iwb-input iwb-plp-vdesc" value="写实摄影风格"></div>
|
||||
<div class="iwb-plp-vitem"><div class="iwb-plp-vrow2"><input class="iwb-input iwb-plp-vname" value="女生"><button class="iwb-plp-vi">i</button></div></div>
|
||||
<div class="iwb-plp-vitem"><div class="iwb-plp-vrow2"><input class="iwb-input iwb-plp-vname" value="价格与利益点"><button class="iwb-plp-vi">i</button></div></div>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-plp-dfooter"><button class="iwb-btn iwb-btn-sm">另存副本</button><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">插入画布</button><button class="iwb-btn iwb-btn-primary iwb-btn-sm">保存</button></div>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
const PLP_DETAIL_HTML = `
|
||||
<div id="stage" style="background:var(--iwb-bg);padding:24px;display:flex;justify-content:center">
|
||||
<div class="iwb-plp-dialog iwb-plp-dialog-detail" style="position:relative;margin:0;width:1180px;height:700px;display:flex;flex-direction:column">
|
||||
<div class="iwb-plp-dhead"><span class="iwb-plp-grip"></span><span class="iwb-toolbar-title">提示词详情</span><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">编辑</button><button class="iwb-btn iwb-btn-sm">✕</button></div>
|
||||
<div class="iwb-plp-dbody">
|
||||
<div class="iwb-plp-dleftcol">
|
||||
<div class="iwb-plp-dcov"></div>
|
||||
<div class="iwb-plp-dtitle">女生喜欢的小红书封面</div>
|
||||
<div class="iwb-plp-dmeta">
|
||||
<div class="iwb-plp-dmrow"><span class="iwb-plp-dmk">分组:</span><div class="iwb-plp-dmv"><span class="iwb-plp-dgroup">小红书</span></div></div>
|
||||
<div class="iwb-plp-dmrow"><span class="iwb-plp-dmk">标签:</span><div class="iwb-plp-dmv"><span class="iwb-plp-dtag">#收藏</span></div></div>
|
||||
<div class="iwb-plp-dmrow"><span class="iwb-plp-dmk">字数:</span><div class="iwb-plp-dmv"><span class="iwb-plp-dlen">119 字</span></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-plp-dright">
|
||||
<div class="iwb-plp-dsec">提示词内容</div>
|
||||
<div class="iwb-plp-dtext">参考图片内容,保持图片内容一致性,商品图片保持包装一致,修改图片的风格为小红书封面风格,<span class="iwb-plp-dvar">{写实摄影}</span> 风格,书写标题字,手绘辅助装饰及辅助文案,符合<span class="iwb-plp-dvar">{女生}</span> 喜好的配色,突出<span class="iwb-plp-dvar">{价格与利益点}</span>,画面简洁,不需要给产品配名称,符合品牌的调性。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-plp-dfooter"><button class="iwb-btn iwb-btn-sm iwb-btn-danger">删除</button><span class="iwb-drawer-spacer"></span><button class="iwb-btn iwb-btn-sm">复制全文</button><button class="iwb-btn iwb-btn-sm">插入模板节点</button><button class="iwb-btn iwb-btn-sm">插入图片</button><button class="iwb-btn iwb-btn-primary iwb-btn-sm">插入画布</button></div>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
async function bootPromptlib (page, theme, html) {
|
||||
await bootPanel(page, theme, html)
|
||||
await page.addStyleTag({ path: require('node:path').join(__dirname, '..', 'dist', 'plugins', 'promptlib', 'styles.css') })
|
||||
await page.waitForTimeout(50)
|
||||
}
|
||||
|
||||
for (const theme of ['light', 'dark']) {
|
||||
test.describe('视觉基线 · promptlib · ' + theme, () => {
|
||||
test('⑨ 提示词编辑弹窗', async ({ page }) => {
|
||||
await bootPromptlib(page, theme, PLP_EDIT_HTML)
|
||||
await shot(page, '09-promptlib-edit-' + theme)
|
||||
})
|
||||
test('⑩ 提示词详情弹窗', async ({ page }) => {
|
||||
await bootPromptlib(page, theme, PLP_DETAIL_HTML)
|
||||
await shot(page, '10-promptlib-detail-' + theme)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ── ⑪ 生图服务设置(多服务商 · 单栏切换) ─────────────────────────────
|
||||
// 设置页入口在网页环境是左下角导航齿轮(.iwb-nav-item[title="设置"]);
|
||||
// 这里预置两个服务商,验证 chips + 单份详情的视觉基线。
|
||||
const SETTINGS_CFG = {
|
||||
providers: [
|
||||
{
|
||||
id: 'p-visual-a', name: 'TuZi', baseUrl: 'https://apicdn.tu-zi.com/v1',
|
||||
fallbacks: ['https://apius.tu-zi.com/v1'], genPath: '/images/generations', editPath: '/images/edits',
|
||||
keys: [{ id: 'k1', name: 'Key', value: '', masked: 'sk-••••tCZT' }],
|
||||
models: [{ name: 'gpt-image-2-1k', visible: true }, { name: 'gpt-image-2', visible: true }],
|
||||
layerModels: [],
|
||||
},
|
||||
{ id: 'p-visual-b', name: '即梦 Dreamina', baseUrl: 'https://x.example/v1', fallbacks: [], keys: [], models: [] },
|
||||
],
|
||||
canvas: {},
|
||||
}
|
||||
|
||||
async function bootSettings (page, theme) {
|
||||
await page.addInitScript(({ cfg, theme }) => {
|
||||
localStorage.clear()
|
||||
localStorage.setItem('iwb_web_cfg', JSON.stringify(cfg))
|
||||
localStorage.setItem('iwb_theme', theme)
|
||||
}, { cfg: SETTINGS_CFG, theme })
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' })
|
||||
await page.evaluate(() => { const el = document.querySelector('.iwb-nav-item[title="设置"]'); if (el) el.click() })
|
||||
await expect(page.locator('.iwb-prov-chip').first()).toBeVisible({ timeout: 15000 })
|
||||
await expect(page.locator('.iwb-provider-card')).toHaveCount(1)
|
||||
await settle(page)
|
||||
}
|
||||
|
||||
for (const theme of ['light', 'dark']) {
|
||||
test.describe('视觉基线 · 设置 · ' + theme, () => {
|
||||
test('⑪ 生图服务(多服务商)', async ({ page }) => {
|
||||
await bootSettings(page, theme)
|
||||
await shot(page, '11-provider-settings-' + theme)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ── ⑫ 通用设置(卡片化重排) ─────────────────────────────────────────
|
||||
for (const theme of ['light', 'dark']) {
|
||||
test.describe('视觉基线 · 通用设置 · ' + theme, () => {
|
||||
test('⑫ 通用(数据/图片/生成/版本)', async ({ page }) => {
|
||||
await bootSettings(page, theme)
|
||||
await page.locator('.iwb-tab', { hasText: '通用' }).first().click()
|
||||
await expect(page.locator('.iwb-gset-group-body').first()).toBeVisible({ timeout: 15000 })
|
||||
await shot(page, '12-general-settings-' + 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: 74 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 80 KiB |
|
After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 88 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 / 插件变量名不变)')
|
||||
@@ -0,0 +1,95 @@
|
||||
'use strict'
|
||||
// 设计 token 棘轮 + 完整性守卫(M5-T5.2 / T5.3)
|
||||
//
|
||||
// 为什么是「棘轮」而不是「全清零」:M4 结束时 style.css 里还有 170 处写死字号、415 处写死间距,
|
||||
// 一次清零等于重写一遍样式表。棘轮把「数字不许涨」变成机械规则,迁移可以分版本做,
|
||||
// 而**新代码**从今天起不可能再增加存量(涨一个就红)。
|
||||
//
|
||||
// 数字口径唯一来源是 scripts/token-audit.js --json —— 这里不重新实现一遍正则:
|
||||
// 两套口径一旦漂移,就会变成「守卫绿、审计红」这种最难查的分歧。
|
||||
//
|
||||
// 三条断言:
|
||||
// A. 每一项计数 ≤ tests/fixtures/token-baseline.json(只降不升)
|
||||
// B. 引用了但从未定义的变量 = 0(`var(--iwb-radius-pill)` 这种拼错必须当场红,
|
||||
// 而不是等到浏览器里那条声明静默失效)
|
||||
// C. 没有 `var(--x, var(--x))` 自我兜底 —— 兜底值等于引用值,等于「失效时再失效一次」,
|
||||
// 既掩盖问题又没有默认值可用
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execFileSync } = require('child_process')
|
||||
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const baseline = JSON.parse(fs.readFileSync(path.join(root, 'tests', 'fixtures', 'token-baseline.json'), 'utf8'))
|
||||
const audit = JSON.parse(execFileSync(process.execPath, [path.join(root, 'scripts', 'token-audit.js'), '--json'], { cwd: root, encoding: 'utf8', maxBuffer: 32 * 1024 * 1024 }))
|
||||
|
||||
const now = {
|
||||
undefinedRefs: audit.undefinedRefs.length,
|
||||
deadTokens: audit.deadTokens.length,
|
||||
hex: audit.hard['十六进制色值'],
|
||||
rgb: audit.hard['rgba()/rgb()'],
|
||||
fontSize: audit.hard['font-size 写死'],
|
||||
radius: audit.hard['border-radius 写死'],
|
||||
spacing: audit.hard['padding/margin/gap 写死'],
|
||||
zIndexDecl: audit.hard['z-index 声明'],
|
||||
fontSizeDistinct: audit.fontSizes.distinct.length,
|
||||
radiusDistinct: audit.radii.distinct.length,
|
||||
spacingDistinct: audit.spacings.distinct.length,
|
||||
zIndexDistinct: audit.zindex.distinct.length,
|
||||
shadowDistinct: audit.shadows.distinct
|
||||
}
|
||||
|
||||
// ── A. 只降不升 ──
|
||||
// 基线里有的项必须都在(防手滑删项让某项「凭空消失」),当前也必须有同名项(防改名后静默跳过)
|
||||
assert.deepStrictEqual(
|
||||
Object.keys(now).sort(),
|
||||
Object.keys(baseline.counts).sort(),
|
||||
'棘轮口径与基线键不一致:审计脚本加了/改了指标却没更新基线(或反之)'
|
||||
)
|
||||
|
||||
const LABEL = {
|
||||
undefinedRefs: '引用未定义变量',
|
||||
deadTokens: '定义了没用的变量',
|
||||
hex: '十六进制色值',
|
||||
rgb: 'rgba()/rgb()',
|
||||
fontSize: 'font-size 写死',
|
||||
radius: 'border-radius 写死',
|
||||
spacing: 'padding/margin/gap 写死',
|
||||
zIndexDecl: 'z-index 声明',
|
||||
fontSizeDistinct: '字号取值种数',
|
||||
radiusDistinct: '圆角取值种数',
|
||||
spacingDistinct: '间距取值种数',
|
||||
zIndexDistinct: 'z-index 取值种数',
|
||||
shadowDistinct: '阴影写法种数'
|
||||
}
|
||||
|
||||
const grew = []
|
||||
for (const k of Object.keys(now)) {
|
||||
if (now[k] > baseline.counts[k]) grew.push(LABEL[k] + ':' + baseline.counts[k] + ' → ' + now[k] + '(+' + (now[k] - baseline.counts[k]) + ')')
|
||||
}
|
||||
assert.deepStrictEqual(grew, [],
|
||||
'以下计数涨了 —— 新增样式请用 token(--iwb-font-* / --iwb-radius-* / --iwb-space-* / --iwb-z-* / 语义色):\n ' + grew.join('\n ') +
|
||||
'\n确属必要的例外:用行内 /*iwb:raw-until=<版本>*/(会到期)或 /*iwb:content*/(画布内容色),不要直接把基线数字调大。')
|
||||
|
||||
// ── B. 引用必须存在 ──
|
||||
assert.deepStrictEqual(audit.undefinedRefs, [],
|
||||
'有 var() 引用了从未定义的变量:' + audit.undefinedRefs.join(' ') + '(拼错的 token 名会让整条声明静默失效)')
|
||||
|
||||
// ── C. 自我兜底 ──
|
||||
const cssFiles = ['style.css'].concat(
|
||||
fs.readdirSync(path.join(root, 'src')).filter((f) => f.endsWith('.css') && f !== 'design-tokens.css').map((f) => 'src/' + f)
|
||||
)
|
||||
const selfFallback = []
|
||||
for (const f of cssFiles) {
|
||||
const src = fs.readFileSync(path.join(root, f), 'utf8')
|
||||
src.split('\n').forEach((line, i) => {
|
||||
const m = /var\(\s*(--[a-z0-9-]+)\s*,\s*var\(\s*(--[a-z0-9-]+)/i.exec(line)
|
||||
if (m && m[1] === m[2]) selfFallback.push(f + ':' + (i + 1) + ' ' + m[1])
|
||||
})
|
||||
}
|
||||
assert.deepStrictEqual(selfFallback, [], 'var() 用自己做兜底(等于没有兜底):' + selfFallback.join(' | '))
|
||||
|
||||
const drop = Object.keys(now).filter((k) => now[k] < baseline.counts[k])
|
||||
console.log('token-ratchet: ' + Object.keys(now).length + ' 项计数均未超过基线'
|
||||
+ (drop.length ? '(可下调基线:' + drop.map((k) => LABEL[k] + ' ' + baseline.counts[k] + '→' + now[k]).join(',') + ')' : ''))
|
||||
console.log('token-ratchet: 引用未定义变量 0、自我兜底 0')
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"files": {}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"_comment": "设计 token 棘轮基线(M5-T5.2)。数字只允许下降,不允许上升 —— 涨了就说明新代码写了裸值,改用 token 或(确有必要时)在 PR 里说明并下调别的项把总数补回来。口径来源:node scripts/token-audit.js --json",
|
||||
"measuredAt": "2026-11-23",
|
||||
"measuredVersion": "3.26.51",
|
||||
"counts": {
|
||||
"undefinedRefs": 0,
|
||||
"deadTokens": 32,
|
||||
"hex": 79,
|
||||
"rgb": 55,
|
||||
"fontSize": 159,
|
||||
"radius": 95,
|
||||
"spacing": 377,
|
||||
"zIndexDecl": 71,
|
||||
"fontSizeDistinct": 13,
|
||||
"radiusDistinct": 17,
|
||||
"spacingDistinct": 26,
|
||||
"zIndexDistinct": 31,
|
||||
"shadowDistinct": 44
|
||||
}
|
||||
}
|
||||
@@ -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 用品牌色淡染,视觉上不一样)
|
||||
|
||||
@@ -24,13 +24,16 @@ const CFG = {
|
||||
}
|
||||
|
||||
async function openSettings (page) {
|
||||
const cands = [
|
||||
page.locator('.iwb-home-side-item', { hasText: '设置' }),
|
||||
page.locator('.iwb-home-menu-item', { hasText: '设置' }),
|
||||
page.locator('[title="服务与 Key 设置"]'),
|
||||
]
|
||||
for (const c of cands) if (await c.count() > 0) { await c.first().click(); break }
|
||||
await expect(page.locator('button', { hasText: '+ 添加服务' }).first()).toBeVisible({ timeout: 10000 })
|
||||
const nav = page.locator('.iwb-nav-item[title="设置"]')
|
||||
if (await nav.count() > 0) { await nav.first().click() } else {
|
||||
const cands = [
|
||||
page.locator('.iwb-home-side-item', { hasText: '设置' }),
|
||||
page.locator('.iwb-home-menu-item', { hasText: '设置' }),
|
||||
page.locator('[title="服务与 Key 设置"]'),
|
||||
]
|
||||
for (const c of cands) if (await c.count() > 0) { await c.first().click(); break }
|
||||
}
|
||||
await expect(page.locator('.iwb-prov-chip').first()).toBeVisible({ timeout: 10000 })
|
||||
}
|
||||
|
||||
const readCfg = (page) => page.evaluate(() => {
|
||||
@@ -52,14 +55,20 @@ test('① 渠道可新增与删除,且改动会写入配置', async ({ page })
|
||||
await openSettings(page)
|
||||
|
||||
const cards = page.locator('.iwb-provider-card')
|
||||
const chips = page.locator('.iwb-prov-chip')
|
||||
await expect(cards).toHaveCount(1, { timeout: 8000 })
|
||||
await expect(chips).toHaveCount(1, { timeout: 8000 })
|
||||
|
||||
await page.locator('button', { hasText: '+ 添加服务' }).first().click()
|
||||
await expect(cards).toHaveCount(2, { timeout: 8000 })
|
||||
|
||||
// 删最后一个(不动种子渠道)
|
||||
await page.locator('.iwb-provider-card button', { hasText: '删除服务' }).last().click()
|
||||
await page.locator('button', { hasText: '+ 添加服务商' }).first().click()
|
||||
await expect(chips).toHaveCount(2, { timeout: 8000 })
|
||||
// 单栏设计:同时只渲染一份详情(新服务自动选中)
|
||||
await expect(cards).toHaveCount(1, { timeout: 8000 })
|
||||
await expect(page.locator('.iwb-prov-name')).toHaveValue('新服务')
|
||||
|
||||
// 删当前(新加的)服务商;不删种子渠道
|
||||
await page.locator('.iwb-provider-card button', { hasText: '删除服务' }).first().click()
|
||||
await expect(chips).toHaveCount(1, { timeout: 8000 })
|
||||
await expect(page.locator('.iwb-prov-name')).toHaveValue('CRUD 渠道')
|
||||
|
||||
await page.locator('button', { hasText: '保存配置' }).first().click()
|
||||
await expect.poll(async () => ((await readCfg(page)).providers || []).length, { timeout: 10000 }).toBe(1)
|
||||
@@ -94,6 +103,7 @@ test('② 模型可新增与删除,且改动会写入配置', async ({ page })
|
||||
await expect(rows).toHaveCount(2, { timeout: 8000 })
|
||||
|
||||
// 删除刚加的 → 回到 1 行
|
||||
await card.locator('.iwb-model-more-btn').last().click()
|
||||
await card.locator('[title="删除模型"]').last().click()
|
||||
await expect(rows).toHaveCount(1, { timeout: 8000 })
|
||||
|
||||
|
||||
@@ -13,14 +13,17 @@ test('设置里可配厂商类型 / 自定义模板 / 模型级覆盖', async ({
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' })
|
||||
await page.waitForTimeout(600)
|
||||
// 打开设置(入口因视图而异 → 依次尝试,任一命中即可)
|
||||
const cands = [
|
||||
page.locator('.iwb-home-side-item', { hasText: '设置' }),
|
||||
page.locator('.iwb-home-menu-item', { hasText: '设置' }),
|
||||
page.locator('[title="服务与 Key 设置"]'),
|
||||
]
|
||||
let opened = false
|
||||
for (const c of cands) { if (await c.count() > 0) { await c.first().click(); opened = true; break } }
|
||||
expect(opened, '应能找到设置入口').toBe(true)
|
||||
const nav = page.locator('.iwb-nav-item[title="设置"]')
|
||||
if (await nav.count() > 0) { await nav.first().click() } else {
|
||||
const cands = [
|
||||
page.locator('.iwb-home-side-item', { hasText: '设置' }),
|
||||
page.locator('.iwb-home-menu-item', { hasText: '设置' }),
|
||||
page.locator('[title="服务与 Key 设置"]'),
|
||||
]
|
||||
let opened = false
|
||||
for (const c of cands) { if (await c.count() > 0) { await c.first().click(); opened = true; break } }
|
||||
expect(opened, '应能找到设置入口').toBe(true)
|
||||
}
|
||||
await page.waitForTimeout(700)
|
||||
const kindSel = page.locator('select[aria-label="厂商类型"]').first()
|
||||
await expect(kindSel).toBeVisible()
|
||||
|
||||
@@ -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,135 @@
|
||||
// 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 与插件都不再产出),不该重新出现')
|
||||
}
|
||||
|
||||
// ── 5. 节点正文文本区不是控件面(v3.26.52,用户截图反馈)──
|
||||
// 病灶:灰色提示词/文本节点里文字后面是白色,编辑时还多一个方框。
|
||||
// ① `.iwb-node .iwb-textarea` 把 --iwb-field(亮色=纯白)刷到**所有**文本区,
|
||||
// 优先级(0,2,0) 盖掉 `.iwb-textarea-plain`(0,1,0) 的 transparent;
|
||||
// ② `.iwb-textarea:focus` 写在 plain:focus 之后且同优先级,2px 聚焦光晕又冒出来。
|
||||
// 规则:正文文本区透明继承卡片底色(含 data-bg 自定义色),常态与编辑态都不画控件框;
|
||||
// 全局 D8 键盘焦点环在这里也关掉(它会再画一个 2px 方框),焦点反馈改由节点选中框承担。
|
||||
const prose = blocks.find((b) => b.sel === '.iwb-node .iwb-textarea-plain')
|
||||
assert.ok(prose, '找不到 .iwb-node .iwb-textarea-plain 规则')
|
||||
assert.ok(/background:\s*transparent/.test(prose.body), '节点正文文本区必须透明继承卡片底色')
|
||||
assert.ok(
|
||||
!/var\(--iwb-(?:field|layer|layer2|panel)\)/.test(prose.body),
|
||||
'节点正文文本区不得铺控件面/面板色(--iwb-field 只给可交互控件)'
|
||||
)
|
||||
assert.ok(/border:\s*0/.test(prose.body), '节点正文文本区不得有控件边框')
|
||||
assert.ok(/box-shadow:\s*none/.test(prose.body), '节点正文文本区不得有阴影')
|
||||
|
||||
const proseFocus = blocks.find((b) => /\.iwb-node \.iwb-textarea-plain:focus/.test(b.sel))
|
||||
assert.ok(proseFocus, '找不到节点正文文本区的聚焦规则')
|
||||
assert.ok(/box-shadow:\s*none/.test(proseFocus.body), '编辑态不得出现聚焦方框(2px 光晕)')
|
||||
assert.ok(/outline:\s*none/.test(proseFocus.body), '编辑态不得出现全局键盘焦点环(同样是个方框)')
|
||||
assert.ok(
|
||||
css.indexOf('.iwb-node .iwb-textarea-plain:focus') > css.indexOf('.iwb-input:focus, .iwb-textarea:focus'),
|
||||
'节点正文的聚焦规则必须写在基础 .iwb-textarea:focus 之后(同优先级靠后生效)'
|
||||
)
|
||||
const scopedField = blocks.find((b) => b.sel.startsWith('.iwb-node .iwb-input'))
|
||||
assert.ok(scopedField, '找不到节点控件面规则')
|
||||
assert.ok(
|
||||
scopedField.sel.includes(':not(.iwb-textarea-plain)'),
|
||||
'控件面(--iwb-field)规则必须排除正文文本区'
|
||||
)
|
||||
|
||||
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')
|
||||
@@ -0,0 +1,77 @@
|
||||
'use strict'
|
||||
// 插件尺度契约棘轮(2026-11-23)
|
||||
// 目的:插件 CSS 的字号 / 圆角 / 间距散值「只降不升」。
|
||||
// 规则(docs/standards/design-tokens.md):
|
||||
// 字号 11/12/13/14/15/17/20/24;圆角 6/8/10/12/14/999;间距 0/2/4/6/8/10/12/16/20/24/32/40/48/64
|
||||
// 存量不一次清零(会逼人加白名单),用基线棘轮:新增文件必须干净,存量文件计数不得增加。
|
||||
// 迁移时刻意下调后基线不会自动降 —— 用 --update 重新生成(人工确认)。
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const assert = require('assert')
|
||||
|
||||
const ROOT = path.join(__dirname, '..')
|
||||
const PLUGINS = path.join(ROOT, 'plugins')
|
||||
const BASELINE = path.join(__dirname, 'fixtures', 'plugin-scale-baseline.json')
|
||||
|
||||
const FONT = new Set([11, 12, 13, 14, 15, 17, 20, 24])
|
||||
const RADIUS = new Set([6, 8, 10, 12, 14, 999])
|
||||
const SPACE = new Set([0, 2, 4, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 64])
|
||||
|
||||
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 (e.name.endsWith('.css')) out.push(p)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function scan () {
|
||||
const res = {}
|
||||
for (const f of walk(PLUGINS, [])) {
|
||||
const rel = path.relative(ROOT, f).split(path.sep).join('/')
|
||||
const src = fs.readFileSync(f, 'utf8')
|
||||
const r = { font: 0, radius: 0, space: 0 }
|
||||
for (const m of src.matchAll(/([a-z-]+)\s*:\s*([^;{}]+)/g)) {
|
||||
const prop = m[1].toLowerCase()
|
||||
const val = m[2].trim()
|
||||
if (val.includes('var(')) continue
|
||||
if (prop === 'font-size') {
|
||||
const px = /([0-9.]+)px/.exec(val)
|
||||
if (px && !FONT.has(Number(px[1]))) r.font++
|
||||
} else if (prop === 'border-radius') {
|
||||
for (const px of val.matchAll(/([0-9.]+)px/g)) if (!RADIUS.has(Number(px[1]))) r.radius++
|
||||
} else if (/^(gap|row-gap|column-gap)$/.test(prop) || /^(padding|margin)/.test(prop)) {
|
||||
for (const px of val.matchAll(/([0-9.]+)px/g)) if (!SPACE.has(Number(px[1]))) r.space++
|
||||
}
|
||||
}
|
||||
if (r.font || r.radius || r.space) res[rel] = r
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
const current = scan()
|
||||
|
||||
if (process.argv.includes('--update')) {
|
||||
fs.mkdirSync(path.dirname(BASELINE), { recursive: true })
|
||||
fs.writeFileSync(BASELINE, JSON.stringify({ files: current }, null, 2) + '\n')
|
||||
console.log('plugin scale baseline updated:' + Object.keys(current).length + ' 个文件')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const baseline = fs.existsSync(BASELINE) ? JSON.parse(fs.readFileSync(BASELINE, 'utf8')).files || {} : {}
|
||||
const bad = []
|
||||
for (const [file, cur] of Object.entries(current)) {
|
||||
const base = baseline[file] || { font: 0, radius: 0, space: 0 }
|
||||
for (const k of ['font', 'radius', 'space']) {
|
||||
if (cur[k] > (base[k] || 0)) bad.push(file + ' → ' + k + ' ' + (base[k] || 0) + ' → ' + cur[k])
|
||||
}
|
||||
}
|
||||
if (bad.length) {
|
||||
assert.fail('插件尺度散值不得增加(字号/圆角/间距用 design-tokens 闭集):\n' + bad.slice(0, 20).join('\n') +
|
||||
'\n迁移完成后可运行 node tests/plugin-scale-contract-test.js --update 更新基线。')
|
||||
}
|
||||
const total = Object.values(current).reduce((n, r) => n + r.font + r.radius + r.space, 0)
|
||||
console.log('plugin scale contract checks passed(' + Object.keys(current).length + ' 个插件样式文件,存量散值 ' + total + ' 处,未增加)')
|
||||
@@ -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,78 @@
|
||||
'use strict'
|
||||
// 对比度回归守卫(M5-T5.4)
|
||||
//
|
||||
// 为什么需要它:暗色主题的对比度不是「写死一个值」就完了 —— derive() 用 mix + clampAgainst
|
||||
// 现算,任何一次调色(把 panel 提亮、把 layer 压深、把文字权重从 .30 改成 .34)都可能让
|
||||
// 某对「文字 × 表面」掉到阈值以下,而**肉眼在编辑器里看不出来**(唯一能看出来的用户会截图说
|
||||
// 「这个字看不清」,但我们拿不到他的主题参数)。
|
||||
//
|
||||
// 阈值取 theme-tokens.js 的 RATIO(单一源,禁止在这里再写 4.5 / 7 这种魔数):
|
||||
// text 7.0(AAA 正文)/ text2 4.5(AA 正文)/ dim 3.0(AA 大字下限)/ canvas 6.0(节点标题,预留 opacity .8)/ onBrand 4.5
|
||||
// 计划里写的「text ≥4.5、tertiary ≥3.0、on-brand ≥4.5」是**下限**,实现取更严的 7.0/3.0/4.5。
|
||||
//
|
||||
// 亮暗两套主题都跑;DEFAULTS 之外的配色(用户在设置里改过的)不在本守卫范围 ——
|
||||
// 那条路由 clampText 在运行时兜底。
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const sandbox = {}
|
||||
new Function('window', fs.readFileSync(path.join(root, 'src', 'theme-tokens.js'), 'utf8'))(sandbox)
|
||||
const T = sandbox.IWBThemeTokens
|
||||
assert.ok(T && typeof T.derive === 'function', 'theme-tokens.js 没暴露 IWBThemeTokens.derive')
|
||||
|
||||
// 承载文字的整套表面。canvas 单独处理:画布上只有节点标题,它用 canvasText(阈值 6,
|
||||
// 且要预留 opacity .8 的余量)—— 界面文字本来就不该直接压在画布底上,混进通用集合会误报。
|
||||
const SURFACES = ['bg', 'panel', 'layer', 'layer2', 'nodeBg', 'field', 'pluginSurface', 'pluginCard', 'pluginInset', 'pluginHover', 'hover', 'dockBg', 'chrome', 'inset']
|
||||
|
||||
const rows = []
|
||||
function check (theme, fgName, fg, surfaces, min, label) {
|
||||
for (const s of surfaces) {
|
||||
const bg = theme[s]
|
||||
if (!bg || !/^#[0-9a-f]{6}$/i.test(bg)) continue
|
||||
const r = T.contrast(fg, bg)
|
||||
rows.push({ name: fgName + ' × ' + s, ratio: r, min, label, ok: r + 1e-9 >= min })
|
||||
}
|
||||
}
|
||||
|
||||
for (const dark of [false, true]) {
|
||||
const t = T.derive(T.DEFAULTS, dark)
|
||||
const label = dark ? '暗色' : '亮色'
|
||||
const present = SURFACES.filter((s) => t[s])
|
||||
check(t, 'text', t.text, present, T.RATIO.text, label)
|
||||
check(t, 'text2', t.text2, present, T.RATIO.text2, label)
|
||||
check(t, 'textDim', t.textDim, present, T.RATIO.dim, label)
|
||||
check(t, 'brandText', t.brandText, present, T.RATIO.text2, label)
|
||||
check(t, 'canvasText', t.canvasText, ['canvasBg'], T.RATIO.canvas, label)
|
||||
check(t, 'nodeText2', t.nodeText2, ['nodeBg', 'layer', 'panel'], T.RATIO.text2, label)
|
||||
// M6 补漏:状态色(ok/err/warn)在 .iwb-status-ok / .iwb-ratio.ok / 插件标签里是**直接当文字色**
|
||||
// 用的,M5 的 114 对只覆盖了 text/text2/dim/brandText,把它们漏了 —— 于是亮色 --iwb-ok
|
||||
// 长期是 #22c55e(对浅页面 2.13)也一路绿灯。状态文字同样按 AA 正文要求 ≥4.5。
|
||||
const STATUS_SURFACES = ['bg', 'panel', 'layer', 'layer2']
|
||||
for (const k of ['ok', 'err', 'warn']) check(t, k, t[k], STATUS_SURFACES, T.RATIO.text2, label)
|
||||
// 品牌底上的字:onBrand 是按对比度自动选的黑/白,选错了就会「主按钮白字压浅蓝」
|
||||
rows.push({
|
||||
name: 'onBrand × brand',
|
||||
ratio: T.contrast(t.onBrand, t.brand),
|
||||
min: T.RATIO.onBrand,
|
||||
label,
|
||||
ok: T.contrast(t.onBrand, t.brand) + 1e-9 >= T.RATIO.onBrand
|
||||
})
|
||||
}
|
||||
|
||||
const bad = rows.filter((r) => !r.ok)
|
||||
if (bad.length) {
|
||||
console.log('对比度不达标(阈值来自 theme-tokens.js 的 RATIO):')
|
||||
for (const r of bad) console.log(' ✗ ' + r.label + ' ' + r.name.padEnd(26) + r.ratio.toFixed(2) + ' < ' + r.min)
|
||||
console.log('\n最低的三对(含达标的):')
|
||||
for (const r of rows.slice().sort((a, b) => a.ratio - b.ratio).slice(0, 3)) {
|
||||
console.log(' · ' + r.label + ' ' + r.name.padEnd(26) + r.ratio.toFixed(2) + '(下限 ' + r.min + ')')
|
||||
}
|
||||
}
|
||||
assert.deepStrictEqual(bad.map((r) => r.label + ' ' + r.name + ' ' + r.ratio.toFixed(2) + '<' + r.min), [],
|
||||
'文字与表面的对比度掉到阈值以下 —— 调色时改坏了,改回去或用 clampAgainst 重新夹紧')
|
||||
|
||||
const minRow = rows.slice().sort((a, b) => a.ratio - b.ratio)[0]
|
||||
console.log('token-contrast: ' + rows.length + ' 对(亮/暗 × 文字 × 表面)全部达标;最紧的一对是 '
|
||||
+ minRow.label + ' ' + minRow.name + ' = ' + minRow.ratio.toFixed(2) + '(下限 ' + minRow.min + ')')
|
||||
@@ -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')
|
||||