Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
648d4549a9 | ||
|
|
fbd3def41c | ||
|
|
0584991a51 | ||
|
|
118482b136 | ||
|
|
89d34aae26 | ||
|
|
7e00acdc01 | ||
|
|
c8a332fdac | ||
|
|
ab15ea3a93 | ||
|
|
c98de41df3 | ||
|
|
bed29b3674 | ||
|
|
bae7ea9c96 | ||
|
|
58e0af5074 | ||
|
|
6f7f1108c2 | ||
|
|
af681f72fb | ||
|
|
2280cf3479 | ||
|
|
719b810091 | ||
|
|
87bb2f9c19 | ||
|
|
ab23a0d90a | ||
|
|
0cdeadf0cd | ||
|
|
16f33128da | ||
|
|
a3b85be79c | ||
|
|
559e3e774e | ||
|
|
b32ba158be | ||
|
|
39b2181b86 | ||
|
|
b12463cf0a | ||
|
|
9f8fb273d1 | ||
|
|
df3e99b0ee | ||
|
|
a11b682784 | ||
|
|
00fca7b112 | ||
|
|
afbd04938a | ||
|
|
a1164a4d60 | ||
|
|
a0e7bcb860 | ||
|
|
fd9ed89620 | ||
|
|
a7430bb5f2 | ||
|
|
330bd455e4 | ||
|
|
777da4f5ed | ||
|
|
0e2a8ae50a | ||
|
|
778c62c688 | ||
|
|
ab348179cf | ||
|
|
e148963aec | ||
|
|
e57d6d0a57 | ||
|
|
d740f2565e | ||
|
|
8d110f285c | ||
|
|
189ba3b8f8 | ||
|
|
475c048694 | ||
|
|
858144aabe | ||
|
|
33631d1176 | ||
|
|
2ff1ccd2d1 | ||
|
|
3894c697ac | ||
|
|
87e5851b72 | ||
|
|
c59aa4c3e8 | ||
|
|
1dd0652825 | ||
|
|
4c16bcafbb | ||
|
|
8f5803d75a | ||
|
|
db550fac8a | ||
|
|
0ff4859268 | ||
|
|
c98b14df5b | ||
|
|
c3bbff9f57 | ||
|
|
7577b66b78 | ||
|
|
1f94249282 | ||
|
|
d9848e2e52 | ||
|
|
a86606e2cc | ||
|
|
48a68a7e8a | ||
|
|
ec9ca02a82 | ||
|
|
c3b76ec444 | ||
|
|
dc5c1a6b0a | ||
|
|
a8b9296558 | ||
|
|
ab8579dcef | ||
|
|
9cbd5fa673 | ||
|
|
ac6a0062c3 | ||
|
|
2e62769421 | ||
|
|
42033a54ab | ||
|
|
48232bec5c | ||
|
|
7b2bb0d58e | ||
|
|
1c7cbd9726 | ||
|
|
630949eac7 | ||
|
|
9edc635ed8 | ||
|
|
a0f86bf09c | ||
|
|
f5859b7596 | ||
|
|
3cc53eec4b | ||
|
|
380d39146d | ||
|
|
81e73bd89b | ||
|
|
4cf0947e76 | ||
|
|
ba2918ff95 | ||
|
|
bb9e7f487f | ||
|
|
6102b7358a | ||
|
|
287da25a24 | ||
|
|
14457c04f2 | ||
|
|
e996975bf9 | ||
|
|
d81c085972 | ||
|
|
aeba3d3785 | ||
|
|
6d9842ecd3 | ||
|
|
f948a45fcc | ||
|
|
c3bbe1a75a | ||
|
|
0b9d7d4cfc | ||
|
|
7d106d2f2c | ||
|
|
a95e38d2f7 | ||
|
|
f0ccaf79d3 | ||
|
|
ae6549354d | ||
|
|
32e2c037ff | ||
|
|
8c115c6f7d | ||
|
|
308324a749 | ||
|
|
8bac6bc701 | ||
|
|
c7f7d54db8 | ||
|
|
9463db2538 | ||
|
|
5246a1ef85 | ||
|
|
f8d547353f | ||
|
|
61dbbb83d3 | ||
|
|
fd5f7c7a17 | ||
|
|
61c31b3203 | ||
|
|
75e81ebc29 | ||
|
|
aa9a54cdc2 | ||
|
|
7caa564ea1 | ||
|
|
f62ec18b0f | ||
|
|
4e8f3215a5 | ||
|
|
ee09343011 | ||
|
|
2b2eb263cd | ||
|
|
25335ddd3d | ||
|
|
2c1a7e01e9 | ||
|
|
d86031bd76 | ||
|
|
6fe52f0ece | ||
|
|
2ffe95f0aa | ||
|
|
f4ab497c73 | ||
|
|
2f79d12c54 | ||
|
|
95b6f45bfd | ||
|
|
b59120beb4 | ||
|
|
49d11744a6 | ||
|
|
420e87628e | ||
|
|
ebde29c9d7 | ||
|
|
15b3352f8f | ||
|
|
8fdcf3b3dc | ||
|
|
fa0b97bdf6 | ||
|
|
37fe86c88c | ||
|
|
c20834b623 | ||
|
|
10ad8618d7 | ||
|
|
fd1a9c636b | ||
|
|
8398a389fe | ||
|
|
8487ef2c91 | ||
|
|
9f88b3a71c | ||
|
|
f0c39fb1c4 | ||
|
|
5fe41ffad4 | ||
|
|
7f38d31ac2 | ||
|
|
301669a148 | ||
|
|
d36bbe3b91 | ||
|
|
768d01360d | ||
|
|
fce4fedad6 | ||
|
|
a6d4f5cc63 | ||
|
|
dde8e861e8 | ||
|
|
e8894d6864 | ||
|
|
3a70e16ead | ||
|
|
c346256115 | ||
|
|
2d3aba2ed2 | ||
|
|
9893d1121d | ||
|
|
1b36960e4f | ||
|
|
0bc96494e9 | ||
|
|
dd24679c3a | ||
|
|
9c8867fdae | ||
|
|
c0e4efc06e | ||
|
|
9222144d22 | ||
|
|
ac4446d4a0 | ||
|
|
1606e0cd7c | ||
|
|
17a8681897 | ||
|
|
c34cadc7d9 | ||
|
|
a4d0f8ab79 | ||
|
|
a56ad1829b | ||
|
|
bbd1e090b5 | ||
|
|
fd76c76589 | ||
|
|
71cd7bc41e | ||
|
|
af9d261636 | ||
|
|
7c20ca90ee | ||
|
|
8755e7327c | ||
|
|
dc311ec0a9 | ||
|
|
eddd635846 | ||
|
|
c22d28320e | ||
|
|
c6e3488aed | ||
|
|
e1c4501f00 | ||
|
|
42304bc88f | ||
|
|
f83ed2e08a | ||
|
|
559945281f | ||
|
|
fcbeab6cb1 | ||
|
|
499f16a2df | ||
|
|
1677f86129 | ||
|
|
8872c2fa47 | ||
|
|
56b39b9829 | ||
|
|
711822092e | ||
|
|
c330d3ecf8 | ||
|
|
65ea7dff9d | ||
|
|
409233670c | ||
|
|
a9f36c26e7 | ||
|
|
8b539ca03e | ||
|
|
4315072394 | ||
|
|
8742bbd256 | ||
|
|
b674aae1bc | ||
|
|
3563e54bd0 | ||
|
|
d5787ca44a | ||
|
|
c411fbe851 | ||
|
|
bda61026ff | ||
|
|
3ab39fd522 | ||
|
|
3993673ee6 | ||
|
|
c962859837 | ||
|
|
0276efd813 | ||
|
|
68480551c6 | ||
|
|
434cf0d92d | ||
|
|
eb19811c8f | ||
|
|
7228436b6f | ||
|
|
a5b8b8b693 | ||
|
|
9f4abdbf44 | ||
|
|
39294cec38 | ||
|
|
1862d55563 | ||
|
|
b756ae0ce7 | ||
|
|
71d4a34197 | ||
|
|
5df4f626ee | ||
|
|
ff6e8ec883 | ||
|
|
fe94d89a46 | ||
|
|
d3ef0f3940 | ||
|
|
ae41246f5a | ||
|
|
1fed4d4df3 | ||
|
|
73936ae076 | ||
|
|
67a379a0cf | ||
|
|
48829aea5d | ||
|
|
61b6df94c5 | ||
|
|
02ccb87ec7 | ||
|
|
5137f38b7f | ||
|
|
2c46b0b756 | ||
|
|
b4d8a7ba6a | ||
|
|
a594efc64a | ||
|
|
a4928d472c | ||
|
|
a8b0999a1b | ||
|
|
ce8a837923 | ||
|
|
5947e0c18b | ||
|
|
a204298fee | ||
|
|
955423eac6 | ||
|
|
7ff3dd57f4 | ||
|
|
2cadad7ea7 | ||
|
|
6ff6ab6a9f | ||
|
|
a1ac3dffe1 | ||
|
|
4b7dc6ee40 | ||
|
|
a409fa6206 | ||
|
|
b2a0135467 | ||
|
|
c6e259a2b0 | ||
|
|
a8c2cd9d97 | ||
|
|
bca71e53b9 | ||
|
|
200c1d35b1 | ||
|
|
fae497289d | ||
|
|
0cf7af230f |
No files matched your search
+275
@@ -16,6 +16,281 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.24.86(2026-11-16)补记
|
||||
|
||||
- 历史条目补录:该 tag 当时未在 CHANGELOG 记录(release-records 守卫要求 tag 与条目双向一致),内容按当时提交补一句占位说明。
|
||||
|
||||
## v3.26.249(2026-12-05)保存可靠性:落定窗口补存 + 写盘失败重试
|
||||
|
||||
- 修「启动/切画布/同步落定窗口内的第一次编辑被静默丢弃」:commitCanvas 打标 dirtyBeforeSettle,落定后(含 1.2s 同步定时器结束、关窗兜底 flush)补一次保存
|
||||
- 修「写盘失败一次就永久丢」:画布/库文件写失败的键回填脏集合,3 秒后限次重试(连续最多 3 次,用户再改动重置;盘满/无权限不空转),有失败时 flush 返回 false
|
||||
- 守卫:tests/canvas-save-settle-test.js(7 条)、storage-flush-persist 增加写失败注入用例,两者旧实现均必红
|
||||
- 参考图:网络图保留 URL 输入行(248 内容,249 一并带上)
|
||||
|
||||
## v3.26.248(2026-12-04)参考图:网络图保留 URL 输入行
|
||||
|
||||
- 246 的隐藏条件是「有 data/localRef/localName 就整行不渲染」,网络图后台缓存写入 localRef 后输入框就消失(用户截图复现)
|
||||
- 改为按来源判定:url 为 http(s) 即网络图 ⇒ URL 输入行常驻(缓存后仍可改链接);空节点保留;本地图片仍不渲染
|
||||
- 改 URL 时一并清掉旧网络图的 localRef/ref,避免回车后仍显示上一张
|
||||
- 守卫同步:网络图缓存后仍保留 URL 行 / 本地图不渲染
|
||||
|
||||
### v3.26.248 补记(2026-12-05)启动落定窗口内的编辑不再丢失
|
||||
|
||||
- 现象:启动后(loaded=false)或切画布/同步后 1.2s(refs.syncing=true)内的第一次编辑被静默丢弃 —— 界面已改、文件 mtime 不变,落定后再改才正常
|
||||
- 根因:保存 effect 在这些状态下走 else 分支,且只在 refs.savePending 已为 true 时才补排;而 savePending 只在 saveDebounced 内被置位,第一次编辑前它是 false;skipInitialPersistence 又把载入后那一次保存跳过
|
||||
- 修法:commitCanvas 在未落定时打标 dirtyBeforeSettle;保存 effect 在 loaded && !syncing 时补一次 saveDebounced;切画布/同步的 1.2s 定时器结束时同样补一次(syncing 非响应式,不会重跑 effect)
|
||||
- 关窗/隐藏兜底 flush 也认这个标记(落定前编辑后立刻关窗同样不丢),写成功后清标记
|
||||
- 守卫:tests/canvas-save-settle-test.js 7 条(旧实现必红);Workbench 行数棘轮 2,706 → 2,710(+4,时序逻辑依赖 loaded/syncing,抽不走)
|
||||
- 存储侧:画布/库文件写失败不再「一次失败永久丢」——失败键回填脏集合,3 秒后限次重试(连续最多 3 次,用户再改动重置;盘满/无权限时不空转);flush 有失败时返回 false
|
||||
- tests/storage-flush-persist-test.js 补写失败注入用例(旧实现必红)
|
||||
|
||||
## v3.26.247(2026-12-04)修存储写盘通道被永久卡死(画布改动重启即丢)
|
||||
|
||||
- 根因:244 的「内容未变不写盘」让启动那次 flush 变全同步,`writing = (async(){…finally{writing=null}})()` 在函数体没有 await 时先执行 finally、再被赋值成一个永不清理的已解决 promise ⇒ 之后每次 flush 都直接 return,整个会话不再写盘(画布/设置/图库索引全停写)
|
||||
- 修法:flush 先赋值 `writing = p` 再 `await p`,收尾用 `if (writing === p) writing = null` 判定,彻底避开同步完成竞态
|
||||
- 三处一次性维护(图库缩略图回填 / 图库自愈重建 / 清内联缩略图)改为经 storage.setItem 写,补上 244 新增的 libDirty 标记
|
||||
- 新增 tests/storage-flush-persist-test.js:真实 storage-file + 假 Tauri fs,断言「启动 → 连续 flush → 编辑 → 落盘 → 重载仍在」,并验证旧实现必红
|
||||
|
||||
## v3.26.246(2026-12-05)参考图:气泡图标对调、本地图去掉 URL 输入
|
||||
|
||||
- 气泡图标对调:替换 = 图片+号(ref),上传到图库 = 上行箭头(upload)
|
||||
- 本地图片不再渲染 URL 输入行(只有空节点与纯网络图有);删掉 hover 显示规则与失效样式
|
||||
- 守卫同步:图标对调、本地图无 URL 行
|
||||
|
||||
## v3.26.245(2026-12-05)参考图节点:上传图库移到气泡、本地图去掉网址行
|
||||
|
||||
- 「上传到图库」移到选中气泡(图标 ref,与「替换」的 upload 区分);上传逻辑抽到 src/runtime-ref-upload.js
|
||||
- 气泡移除「改名」按钮(所有节点):双击标题文字 / F2 / 右键菜单 仍可改名;帮助文案同步
|
||||
- 本地图片默认隐藏 URL 行(悬停/选中才显示);空节点与纯网络图保留
|
||||
- 删除图片右侧多余的「URL 图片」小字
|
||||
|
||||
## v3.26.244(2026-12-04)存储写入收敛(修重启后全部画布被重写)
|
||||
|
||||
- storage.setItem 内容未变直接跳过(不标脏、不触发 flush)
|
||||
- wsWriteKeys 不再每次保存重写全部画布:lastUsed 移出分板文件(只进索引)
|
||||
- library/*.json 只写内容真的变了的键;data.json 用内容签名判重(不含 at)
|
||||
- data.json 残留旧 iwb_ws_ 副本与磁盘文件一致时不再标脏迁移
|
||||
- 效果:不编辑的情况下,重启只读不写;画布 mtime 只在真正编辑时变化
|
||||
|
||||
## v3.26.243(2026-12-04)文件版下载(实验,默认关闭)
|
||||
|
||||
- 新增 Rust fetch_image_to:系统网络栈流式写文件(tokio::fs),不经过 base64;dst 限制在资料目录内、拒绝 ..
|
||||
- 存储层 putFileFrom:接管临时文件进资产库(同卷 rename / 跨卷 copy),返回引用
|
||||
- ingest 文件通道:useFile/fetchFile/writeFileRef;文件版失败只回退 base64 一次;引用 key 按 URL 去重
|
||||
- 取消:cancel_fetch + 500ms 轮询,挂起连接也能及时中断;retry 会重置文件版标记
|
||||
- 接管后按文件生成 768 缩略图预热;cache/tmp 24h 清理
|
||||
- 开关:canvas.rustFileDownload=true 或 IWB_RUST_FILE=1(默认关闭,行为与 242 一致)
|
||||
|
||||
## v3.26.242(2026-12-04)图片取字节统一走系统网络栈
|
||||
|
||||
- 新增统一入口 wRustFetchBlob(fetch_image_b64):三处 http.fetch 兜底全部替换 —— 白名单外图床(生成服务商 CDN / 第三方图床)也能取到图。
|
||||
- 远程参考图缓存、远程显示缩略图、节点「上传到在线图库」、自动下载兜底:全部改为 Rust 优先、WebView fetch 兜底。
|
||||
- storeOutputThumb / downloadUrl:桌面端先走 Rust 再回退,少一次必然失败的 CORS 请求。
|
||||
- 出图后的 320 缩略图:桌面端改用原生缩放(img_thumbs),失败回退 canvas;仍输出 JPEG。
|
||||
- wRustFetchBlob 校验 Content-Type,拒绝把 HTML 错误页当图片存。
|
||||
- 显示缩略图只对 http(s) 走 Rust,data:/blob: 不再浪费一次 IPC。
|
||||
- 修远程参考图缓存从未生效:attach 的 getState 闭包拿到首帧 loaded=false,enabled 恒为 false;改用 cacheUiRef 读当前视图(画布无 localRef 的根因)。
|
||||
|
||||
## v3.26.241(2026-12-04)输出节点老图重开画布不显示
|
||||
|
||||
- 输出节点缩略图改为本地优先补取:重开画布后老记录没有 hydration 数据时,按 thumbHash → images/gallery 原图现生成 320(与图库同一套),命中写回缓存并重绘。
|
||||
- 不再依赖已失效的远程链接;双击预览仍走本地原图。
|
||||
|
||||
## v3.26.240(2026-12-03)下载改系统网络栈 + 并发可调
|
||||
|
||||
- 图片下载改走 Rust fetch_image_b64(reqwest,系统网络栈):不受 CORS/WebView 限制,修「浏览器能下、任务队列卡在 55% 不动」;失败仍回退 WebView fetch。
|
||||
- 同时下载默认 30(设置 → 通用 → 生成 → 同时下载,1–64 可调),改设置下一轮立即生效。
|
||||
- 修并发限制从未生效的老 bug:pump() 的 active++ 原在延迟任务里,会把整个队列一次性放出去。
|
||||
- 新增/扩展 tests/image-ingest-test.js(Rust 优先/回退、并发按设置生效)。
|
||||
- 任务图:插件文本节点接了多张参考图时合并为 1 个任务(此前一条边一个任务);相册一图一任务不受影响。
|
||||
- 任务图:图 + 文本混合上游也合并为 1 个任务(此前会多生成一张没图的)。
|
||||
- 落地:取消/重下的在飞结果作废(不再双写或把 link-only 复活);abort 后不再回退二次抓取。
|
||||
- 输出节点:ready 但本地 URL 未就绪时不再回退远程,修新图「从上往下」渐进重下。
|
||||
- 输出节点双击预览改用图库条目(origIdb → 磁盘原图),不再直接喂远程 URL;打开即有缩略图、原图本地解析。
|
||||
|
||||
## v3.26.239(2026-12-03)清理未引用修正 + 模板节点连图修复
|
||||
|
||||
- 设置「清理未引用图片」:`images/thumbs/*_<max>` 缩略图缓存不再计入未引用、不再搬进 trash;弹窗文案与实现对齐(画布在用=保留、登记表缺失=已丢失无法恢复);trash 同名冲突加时间戳。
|
||||
- 生成任务图:插件文本节点接了上游(如参考图)时不再丢自己的文本 —— 修「参考图 → 提示词模板 → 生图」只发图不发提示词导致的 400 INVALID_ARGUMENT。
|
||||
- 新增守卫 `tests/plugin-text-node-refs-test.js`(6 条,进 test:unit)。
|
||||
- 插件:promptlib 1.14.14(模板节点输入端口 / 变量内容支持长文本多行 / 节点双击标题回填 / 编辑防误关)。
|
||||
|
||||
## v3.26.238(2026-12-03)图片读取/下载口径统一(本地优先 + 图库行名)
|
||||
|
||||
- 新增本地原图读取:`galleryOriginalOf`(预览,原生按 2048 解码)/ `galleryOriginalBlob`(下载,原始字节),老记录不再退 320 缩略图。
|
||||
- 任务队列预览改为只读本地(origIdb → images/gallery 原图);本地没有就提示「先下载」,远程链接不再参与预览。
|
||||
- 下载统一本地优先(`wResolveOutputSrc` 先读本地字节);输出节点 / 预览 / 批量下载的文件名统一用图库行名(未落地回退 image.png、image-001.png)。
|
||||
- 新增规范 `docs/standards/image-read-and-download.md` 与守卫 `tests/image-download-contract-test.js`(命名写死、预览直连远程都会被拦)。
|
||||
- 棘轮:app.js 9345→9354(+9)、Workbench 2686→2687(+1),原因已写在常量注释。
|
||||
- 构建链:`copy-plugins` 统一按 LF 写入 dist;`check-dist` 增加 dist/plugins 与 index.json 哈希校验(修 Windows autocrlf 下 style-source 被 SRI 拒绝)。
|
||||
|
||||
## v3.26.237(2026-12-03)任务队列页头/页签固定、页脚不再被压
|
||||
|
||||
- 插件根节点改为占满整页高度(`.iwb-tq{height:100%}`),宿主不再整页滚动;只有列表自己滚。
|
||||
- 列表加 overflow-y:auto:修「行内容溢出压在页脚说明上」与「页头/筛选页签随列表滚走」。
|
||||
- 任务队列预览取源改「原图优先」:老记录(无 origIdb)不再被 320 缩略图放大,改为原图链接优先、缩略图只兜底。
|
||||
- 插件 taskqueue 1.0.3。
|
||||
|
||||
## v3.26.236(2026-12-03)顶栏标签条彻底固定
|
||||
|
||||
- 工作区标签条 portal 到 body + position:fixed,脱离 overlay 的滚动/层叠;插件页改 position:fixed。
|
||||
- 修 235 在 WebView2 下仍会被整页滚动带走的问题。
|
||||
|
||||
## v3.26.235(2026-12-03)任务队列修复(选中/滚动/缩略图/定位)
|
||||
|
||||
- 修任务队列入口在离开页面后仍高亮(activePage 增加 shellView==='page' 判断)。
|
||||
- 锁住插件整页滚动(只有 body 滚);工作区标签条改 fixed,页头不再被滚走。
|
||||
- 队列缩略图/预览优先图库稳定字节(row.idb / row.origIdb),localUrl 最后;img onerror 回退占位。
|
||||
- `archiveGenerationResults` 支持 meta(boardId/boardName/nodeId),兜底入队不再「未知画布」。
|
||||
- 下载中超过 60 秒显示「可能卡住」并提供「重新下载」(cancel + retry);等待时长可见。
|
||||
- 插件 taskqueue 1.0.2。
|
||||
|
||||
## v3.26.234(2026-12-03)任务队列体验修正
|
||||
|
||||
- 修任务队列页打开时画布图标仍选中(nav view 空串回退 canvas)。
|
||||
- 缩略图复用图库已有的 320 缩略图(按 url 取 idb);占位图标修 SVG 命名空间;一次最多读 120 条并缓存。
|
||||
- 标题改用提示词前 24 字 + 「第 N 张」;旧记录用「历史记录 · 时间 · #id」兜底;显示画布名(旧记录显示未知画布,不补)。
|
||||
- 状态细分为「已入图库 / 待入库 / 下载中·排队中 / 下载失败 / 未下载」;失败行主按钮改为「下载」(land 会建图库行并重试),去掉含义模糊的「重试」。
|
||||
- 插件 taskqueue 1.0.1。
|
||||
|
||||
## v3.26.233(2026-12-03)任务队列(左栏整页插件)
|
||||
|
||||
- 新增宿主 `queue` / `pages` 能力:全局生图账本(url/状态/画布/节点/模型/尺寸)、记录上限、下载落地图库、重试、复制原始链接、定位节点、点击缩略图预览。
|
||||
- 新增插件 `taskqueue 1.0.0`:左栏一级入口「任务队列」整页;可启用/禁用;插件关闭时宿主仍按上限记账。
|
||||
- 账本独立落 `library/task-queue/index.json`;上限 `canvas.taskQueueMax` 默认 500(100~5000),淘汰最旧不影响图库文件。
|
||||
- 图库保持只显示已落地图片;「下载」= 建索引行 + 入落地队列,图库自动刷新。
|
||||
|
||||
## v3.26.232(2026-12-03)NEW 标记层叠修正
|
||||
|
||||
- 修「NEW 标记实际不可见」:角标在图片浮层(.iwb-dl-ov)之前、又没有 z-index,被图片盖住;把角标移到浮层之后(同为 positioned 元素,靠 DOM 顺序压在上面),不新增 z-index 声明。
|
||||
- 实测:真实单元格 DOM(角标 + 图片浮层)下,角标像素为品牌色、在图片之上;点击仍不挡图。
|
||||
|
||||
## v3.26.231(2026-12-03)NEW 标记排除未落地
|
||||
|
||||
- 修「未落地且没有上一张可显示」时仍显示 NEW:isNew 增加 failed 状态排除,与「下载中/未落地不显示 NEW」一致。
|
||||
|
||||
## v3.26.230(2026-12-03)新图 NEW 标记 + 图库插件 1.9.12
|
||||
|
||||
- 输出节点新图左上角新增「NEW」标记:只标本次启动后生成、且已显示的新图;点击/双击即消失。
|
||||
- 设置 → 生成 →「新图标记」可自定义显示时长(默认 120 秒,0 = 不自动消失);不跨重启。
|
||||
- 图库插件 gallery 1.9.12:卡片下载钮改为与输出面板一致的 SVG 图标 / 26px / 无阴影(需在市场更新插件)。
|
||||
|
||||
## v3.26.229(2026-12-03)图库下载圆钮对齐输出面板
|
||||
|
||||
- 图库卡片的下载按钮改到右下角圆形图标(26px),与输出节点一致;修宿主旧规则把按钮居中在底部的问题。
|
||||
- 只改宿主 CSS(body .iwb-history-embedded 作用域覆盖),不动插件产物、不改类名、不动 z-index/token。
|
||||
|
||||
## v3.26.228(2026-12-03)输出节点下载圆钮
|
||||
|
||||
- 输出节点结果图的下载浮层从底部横条改为右下角圆形图标:只占一个角,矮图不再被横条挡住中心。
|
||||
- 只新增 .iwb-dl-corner / .iwb-dl-round 规则;容器 pointer-events:none、按钮 auto;不动 z-index、不动 token、不动图库。旧的横条样式保留可回退。
|
||||
|
||||
## v3.26.227(2026-12-03)图库一致性快修
|
||||
|
||||
- add 按 url 幂等(已存在复用、本批去重),从源头杜绝同一张图两条索引。
|
||||
- 整批补漏前先等单张归档队列排空;每批结束自动按 url 去重(不再只在启动时去重)。
|
||||
- markOk 前校验原图真的落盘;索引建行保留 orig 字段(修「文件在但图库一直不显示」)。
|
||||
- 图库面板打开/刷新时做一次轻量自愈(去重 + 补标 ok),不用重启就能恢复。
|
||||
|
||||
## v3.26.226(2026-12-02)先落地再显示(单次下载)
|
||||
|
||||
- 结果图改为「先落地、再显示」:落地队列成为唯一下载器,输出格在新图本地字节就绪前继续显示上一张(不再白板),就绪后整体替换。
|
||||
- 不再为缩略图/原图二次抓远程:图库索引与 320 缩略图统一由落地字节生成;自动下载也优先等落地字节(最多 20s)。
|
||||
- 下载中显示百分比(有 content-length 时),失败保留旧图 + 「未落地」可点重试。
|
||||
- 图库只展示已落地(orig=ok)的图,pending/missing 静默隐藏,修「缩略图加载失败」空卡。
|
||||
|
||||
## v3.26.225(2026-12-02)撤销失败态
|
||||
|
||||
- onLoad 时清除 is-broken / is-broken-cell:首帧本地 blob 失效打上的失败态,在回退远程加载成功后撤销,避免「加载失败」与半透明一直盖在正常图上。
|
||||
|
||||
## v3.26.224(2026-12-02)白板期可见
|
||||
|
||||
- 角标默认显示、图片 onLoad 后由 CSS 收起;骨架垫在图片下方(未绘制时可见),白板期不再没有任何提示。
|
||||
|
||||
## v3.26.223(2026-12-02)图库去重 + 超时续传
|
||||
|
||||
- 启动时按 url 去重图库索引(修 220 遗留的重复条目,同 url 优先保留已落地原图的那条)。
|
||||
- 超时失败不再判永久失败:窗口重新聚焦时自动放回队列重试。
|
||||
|
||||
## v3.26.222(2026-12-02)归档补漏判定修正
|
||||
|
||||
- 归档补漏改按 item 级 url 判定(条目形状是 items[{url}],原先读 e.url 恒为 undefined → 重复入库)。
|
||||
|
||||
## v3.26.221(2026-12-02)回到渐进渲染
|
||||
|
||||
- 有远程 url 时不再用骨架遮挡(回到 203 的渐进渲染观感);骨架仅在连 url 都没有时出现。
|
||||
- 落地下载超时由 60s 改为 300s(只作真挂死的安全阀,不误杀慢 CDN)。
|
||||
|
||||
## v3.26.220(2026-12-02)图库少一张 + 落地超时
|
||||
|
||||
- 修「一次出多张、图库少一张」:wasArchived 按条目对象记,单张归档标记后批量归档整批跳过;现在已标记但图库索引里查不到该 url 的仍会补入库。
|
||||
- 落地下载超时 25s → 60s(实测该 CDN 常超 25s)。
|
||||
|
||||
## v3.26.219(2026-12-02)入库诊断
|
||||
|
||||
- 记录 add-outputs(in/accepted/skipNoOk/skipNoUrl)与 archive(entries/pending),用于定位「出图多张、图库少一张」。
|
||||
|
||||
## v3.26.218(2026-12-02)落地下载超时
|
||||
|
||||
- 落地队列的下载加 25s 超时:fetch 挂住时不再永久停在「下载中」,按失败重试并最终降级。
|
||||
|
||||
## v3.26.217(2026-12-02)打类目标修正
|
||||
|
||||
- 加载/失败态改用 closest(.iwb-out-cell)(img 被下载浮层包裹,parentElement 不是单元格);含 216 的骨架撑高。
|
||||
|
||||
## v3.26.216(2026-12-02)骨架撑高
|
||||
|
||||
- 输出单元格骨架由绝对定位改为撑高(min-height 140px),出图前不再塌成一条线。
|
||||
|
||||
## v3.26.215(2026-12-02)失败态可见
|
||||
|
||||
- 加载/失败态改用父容器打类(去掉 :has 依赖,兼容老 WebView2);破图收起骨架与角标并显示「加载失败」。
|
||||
|
||||
## v3.26.214(2026-12-02)加载态与失败回退
|
||||
|
||||
- 骨架与「下载中」角标改以图片 onLoad 为准(CSS :has 联动),消除「角标已撤、图还没出来」的空窗。
|
||||
- onError 两级回退(本地 blob → 远程 url),都失败标 is-broken(半透明),不再显示破图。
|
||||
|
||||
## v3.26.213(2026-12-02)骨架 TDZ 修复
|
||||
|
||||
- 修输出单元格骨架的 TDZ(_localSrc 先声明再用,上一版五态全崩);骨架仅对远程 url 生效。
|
||||
|
||||
## v3.26.212(2026-12-02)输出单元格加载骨架
|
||||
|
||||
- 无本地源时在单元格垫一层「下载中…」骨架,避免大图区域纯空白;有缩略图时仍走 LOD 显示。
|
||||
|
||||
## v3.26.211(2026-12-02)角标空指针修复
|
||||
|
||||
- 修输出单元格角标在「视图未命中 + 远程 url」时抛 TypeError(先取安全状态再判);未落地优先于下载中。
|
||||
|
||||
## v3.26.210(2026-12-02)输出节点恢复「下载中」角标 + 分层修正
|
||||
|
||||
- 恢复输出单元格的「下载中」角标:判定改为「无本地源且结果为远程 url」,不再依赖落地视图是否命中。
|
||||
- 落地状态视图改为宿主注入(src 不再直接读 window.IWBImageIngestView),修 architecture-boundary-guard;ResultImg 回到纯展示。
|
||||
|
||||
## v3.26.209(2026-12-02)对账不再常驻轮询
|
||||
|
||||
- 索引对账由「每 30s」改为「启动 3s 后 + 窗口重新获得焦点时」,闲置零开销(用户要求)。
|
||||
|
||||
## v3.26.208(2026-12-02)落地可观测 + 对账兜底
|
||||
|
||||
- ingest 补 enqueue/ready/failed 三类日志(kind=gallery-orig,双写 _boot.log),下载失败不再静默。
|
||||
- 新增索引对账:启动 3s 后与每 30s 各扫一次,把「索引未 ok 但落地已有本地引用」的条目补写原图(幂等)。
|
||||
|
||||
## v3.26.207(2026-12-02)结果落地重试
|
||||
|
||||
- 修「批量出图部分原图不进 gallery」:ready 事件早于图库索引写入时,原来静默 return;现在记 orig-defer 并在 1s / 3s 后各重试一次,命中即补写原图。
|
||||
|
||||
## v3.26.206(2026-12-02)结果落地管线 / 图库原图 / 回滚下载钮改造
|
||||
|
||||
- 新增「结果落地队列」:出图后后台把远程图下到本地(幂等、重试 1/2/4s×3、并发 2、失败保留 URL、重启续跑),节点与图库不再直连 CDN。
|
||||
- 落地成功即把**原图**写进 images/gallery(out_orig_)并把图库索引 orig 置 ok(写 ModularOutputStore,插件读的就是这份);修「仅缩略图」不消失。
|
||||
- 节点取图回到 LOD 优先(本地源才走缩略图),避免每张图整幅解码原图。
|
||||
- 图库缩略图优先用落地得到的本地副本,不再为同一张图二次请求远程。
|
||||
- 回滚 204/205 的下载钮圆钮改造与 --iwb-dl-* token(导致图库加载异常、下拉弹层被压);恢复 203 的横条下载按钮。
|
||||
- 修 .iwb-pop-anchor 的 z-index 被误删(模型/尺寸下拉打不开)。
|
||||
- 补 result-img 单测的 useEffect 桩(183 起既有失败)。
|
||||
|
||||
## v3.26.182(2026-12-01)标注覆盖落地 / 空闲 CPU / 画布平移
|
||||
|
||||
- 修「标注插件覆盖后图片丢失」:写回后清空 localRef/ref(旧引用曾压过新数据)、失效缩略图缓存并重渲染;>200KB 的新图无损转 __blob 引用,DOM 不再挂 1.2MB base64(这也是空闲 CPU 15% 的主因)。
|
||||
|
||||
+6
-3
@@ -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 140 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test:unit 145 个单测文件(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)
|
||||
@@ -105,8 +105,8 @@ IWB_WRITE_BOUNDARY_SNAPSHOT=1 node tests/architecture-boundary-guard-test.js #
|
||||
|
||||
| 守卫 | 位置 | 现在的上限 |
|
||||
|---|---|---|
|
||||
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **8,860**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,454** |
|
||||
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **9,529**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,710** |
|
||||
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
|
||||
|
||||
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
|
||||
@@ -183,6 +183,9 @@ release: vX.Y.Z 发版
|
||||
| 记在哪 | 记什么 |
|
||||
|---|---|
|
||||
| [`docs/standards/engineering-rulebook.md`](docs/standards/engineering-rulebook.md) | 新增的**工程规则**(§13.x,按主题编号) |
|
||||
| [`docs/standards/image-read-and-download.md`](docs/standards/image-read-and-download.md) | **图片读取/下载口径**(取源顺序、命名;新增预览/下载入口先对照) |
|
||||
| [`docs/standards/deploy-domains.md`](docs/standards/deploy-domains.md) | **域名边界**(网页版 / 下载站 / 插件市场互不干扰) |
|
||||
| [`docs/standards/native-network-audit-2026-12-04.md`](docs/standards/native-network-audit-2026-12-04.md) | **网页写法 → 原生**审计(哪些 fetch/解码该换 Rust、白名单坑、实施顺序) |
|
||||
| [`docs/standards/architecture-current-state.md`](docs/standards/architecture-current-state.md) | 改动的**现状事实**(常量、模块数、已知缺陷) |
|
||||
| [`CHANGELOG.md`](CHANGELOG.md) | 用户可见的变更(发版时) |
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 504 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 529 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
@@ -0,0 +1,485 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>任务队列 · UI 原型</title>
|
||||
<style>
|
||||
/* 设计 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-accent-on-surface: color-mix(in srgb, var(--iwb-brand) 45%, var(--iwb-text)); /* 强调色当文字/图标用:与正文色混,亮色更沉、暗色更亮,两端过 4.5:1 */
|
||||
--iwb-accent-tint: color-mix(in srgb, var(--iwb-brand) 18%, transparent); /* 强调色淡底:选中标签/药丸的底(与 --iwb-accent-on-surface 配对使用) */
|
||||
--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-sel-surface: #eff0f1;
|
||||
--iwb-sel-ring: #383838;
|
||||
--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;
|
||||
--iwb-err-bg: #f1e1e1;
|
||||
--iwb-err-bd: #dfa4a4;
|
||||
--iwb-ok-bg: #e0ebe4;
|
||||
--iwb-ok-bd: #a1cab0;
|
||||
--iwb-warn-bg: #f0e7df;
|
||||
--iwb-warn-bd: #deb99d;
|
||||
/* —— 尺度层(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-2xs: 10px; /* 极小标注:徽标角标/画布坐标/缩略图角标(2026-11-24 承认它,此前 29 处裸写) */
|
||||
--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-bw: 1px; /* 描边宽度(2026-11-24):常规分隔/控件边框 */
|
||||
--iwb-bw-strong: 2px; /* 强调描边:选中/焦点/危险操作(不要再用 2px 裸值) */
|
||||
--iwb-icon-sm: 14px; /* 小图标:行内/按钮内 */
|
||||
--iwb-icon-md: 16px; /* 标准图标:工具栏/菜单 */
|
||||
--iwb-icon-lg: 18px; /* 大图标:导航/空态 */
|
||||
--iwb-opacity-disabled: 0.45; /* 禁用态透明度(此前 0.45/0.55 混用) */
|
||||
--iwb-opacity-muted: 0.7; /* 次要/未激活元素透明度 */
|
||||
--iwb-ease-out: cubic-bezier(0.16, 1, 0.3, 1); /* 入场/展开缓动:快出慢停 */
|
||||
--iwb-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); /* 状态切换缓动 */
|
||||
--iwb-motion-fast: 0.12s; /* M6 动效:悬停/开关/小位移 */
|
||||
--iwb-motion-base: 0.15s; /* M6 动效:面板展开/尺寸变化 */
|
||||
--iwb-motion-slow: 0.3s; /* M6 动效:整屏过渡/抽屉 */
|
||||
--iwb-motion-hover: 0.15s; /* L2 悬停:卡片/结果图浮层统一时长 */
|
||||
--iwb-ease-hover: cubic-bezier(0.16, 1, 0.3, 1); /* L2 悬停:快出慢停 */
|
||||
--iwb-hover-lift: -2px; /* L2 悬停:上浮位移 */
|
||||
--iwb-hover-scale: 1.02; /* L2 悬停:缩放(相册格子单独用 1.08) */
|
||||
--iwb-hover-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); /* L2 悬停:投影(单值,供 filter: drop-shadow 用;box-shadow 会多一种写法) */
|
||||
--iwb-hover-border: var(--iwb-brand); /* L2 悬停:描边色 */
|
||||
--iwb-scrim: rgba(0, 0, 0, 0.62); /* 图片上的遮罩渐变底:下载浮层/预览条(两套主题都用深色,保证白字可读) */
|
||||
--iwb-selection-ring: var(--iwb-brand); /* 选中描边(跟随强调色) */
|
||||
--iwb-selection-on: var(--iwb-on-brand); /* 选中描边的隔离内环(品牌底上的文字色) */
|
||||
--iwb-selection-bg: color-mix(in srgb, var(--iwb-brand) 12%, transparent); /* 选中格淡底(不压黑缩略图) */
|
||||
--iwb-selection-halo: color-mix(in srgb, var(--iwb-brand) 45%, transparent); /* 选中外发光(与 hover 区分) */
|
||||
--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-sel-surface: #313234;
|
||||
--iwb-sel-ring: #e8e8e8;
|
||||
/* —— 文字 / 品牌 —— */
|
||||
--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));
|
||||
}
|
||||
|
||||
|
||||
/* component.settings:由 gen-tokens 生成,勿手改;布局属性仍在 style.css */
|
||||
.iwb-settings-modal {
|
||||
--iwb-set-label-w: 180px; /* 标签列宽 */
|
||||
--iwb-set-col-gap: var(--iwb-space-16); /* 标签列与控件列间距 */
|
||||
--iwb-set-row-h: 40px; /* 设置行高 */
|
||||
--iwb-set-row-pad-y: var(--iwb-space-8); /* 行上下内边距 */
|
||||
--iwb-set-group-gap: var(--iwb-space-32); /* 分组之间(规范 §3.11:32px) */
|
||||
--iwb-set-title-gap: var(--iwb-space-8); /* 分组标题与分组体间距 */
|
||||
--iwb-set-group-bg: hsl(0 0% 97.6%); /* 分组体底色:设计值 #F9F9F9(用 hsl 表达以过 hex 闸门) */
|
||||
--iwb-set-group-radius: var(--iwb-radius-card); /* 分组体圆角 */
|
||||
--iwb-set-group-pad-x: var(--iwb-space-20); /* 分组体左右内边距 */
|
||||
--iwb-set-group-pad-y: var(--iwb-space-12); /* 分组体上下内边距 */
|
||||
--iwb-set-divider: color-mix(in srgb, var(--iwb-border) 55%, transparent); /* 行分隔线 */
|
||||
--iwb-set-hint-color: var(--iwb-text-dim); /* 说明文字色 */
|
||||
--iwb-set-hint-size: var(--iwb-font-xs); /* 说明文字字号 */
|
||||
--iwb-set-hint-gap: var(--iwb-space-2); /* 说明文字上间距 */
|
||||
--iwb-set-input-border: color-mix(in srgb, var(--iwb-border) 40%, var(--iwb-panel)); /* 输入框描边 */
|
||||
--iwb-set-check-size: 16px; /* 复选项尺寸 */
|
||||
--iwb-set-check-radius: 4px; /* 复选项圆角 */
|
||||
--iwb-set-btn-gap: var(--iwb-space-8); /* 操作按钮间距 */
|
||||
}
|
||||
|
||||
/* component.settings · 暗色覆盖 */
|
||||
.theme-dark .iwb-settings-modal {
|
||||
--iwb-set-group-bg: color-mix(in srgb, var(--iwb-text) 8%, var(--iwb-panel)); /* 暗色分组体:文字色 8% 混面板 */
|
||||
}
|
||||
|
||||
/* component.popover:由 gen-tokens 生成,勿手改;布局属性仍在 style.css */
|
||||
.iwb-pop {
|
||||
--iwb-pop-w: 360px; /* 面板宽度(窄屏靠 max-width 兜底) */
|
||||
--iwb-pop-pad-y: var(--iwb-space-10); /* 面板上下内边距 */
|
||||
--iwb-pop-pad-x: var(--iwb-space-12); /* 面板左右内边距 */
|
||||
--iwb-pop-gap: var(--iwb-space-8); /* 分组之间 */
|
||||
--iwb-pop-radius: var(--iwb-radius-popover); /* 面板圆角 */
|
||||
--iwb-pop-title-size: var(--iwb-font-base); /* 面板标题字号 */
|
||||
--iwb-pop-chip-h: 28px; /* 选择项/下拉/数字框高度 */
|
||||
--iwb-pop-chip-pad-x: var(--iwb-space-10); /* 选择项左右内边距 */
|
||||
--iwb-pop-chip-radius: 6px; /* 选择项圆角 */
|
||||
--iwb-pop-chip-gap: var(--iwb-space-6); /* 选择项间距 */
|
||||
--iwb-pop-chip-size: var(--iwb-font-md); /* 选择项字号 */
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; background: var(--iwb-bg); color: var(--iwb-text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; font-size: var(--iwb-font-base); line-height: 1.45; }
|
||||
.app { display: flex; height: 100vh; overflow: hidden; }
|
||||
.rail { width: 56px; flex: 0 0 56px; background: var(--iwb-dock-bg); border-right: 1px solid var(--iwb-border); display: flex; flex-direction: column; align-items: center; padding: var(--iwb-space-10) 0; gap: var(--iwb-space-6); }
|
||||
.rail .logo { width: 30px; height: 30px; border-radius: var(--iwb-radius-control); background: var(--iwb-brand); color: var(--iwb-on-brand); display: grid; place-items: center; font-size: var(--iwb-font-sm); font-weight: 700; margin-bottom: var(--iwb-space-6); }
|
||||
.rail .item { width: 36px; height: 36px; border-radius: var(--iwb-radius-control); display: grid; place-items: center; color: var(--iwb-text2); cursor: default; }
|
||||
.rail .item svg { width: var(--iwb-icon-lg); height: var(--iwb-icon-lg); }
|
||||
.rail .item:hover { background: var(--iwb-hover); color: var(--iwb-text); }
|
||||
.rail .item.active { background: var(--iwb-accent-tint); color: var(--iwb-accent-on-surface); }
|
||||
.page { flex: 1; min-width: 0; padding: var(--iwb-space-24) var(--iwb-space-32) var(--iwb-space-16); display: flex; flex-direction: column; gap: var(--iwb-space-16); overflow: hidden; }
|
||||
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--iwb-space-16); }
|
||||
.title { font-size: var(--iwb-font-2xl); font-weight: 650; letter-spacing: .01em; }
|
||||
.sub { display: block; margin-top: 2px; font-size: var(--iwb-font-sm); font-weight: 400; color: var(--iwb-text2); }
|
||||
.tools { display: flex; align-items: center; gap: var(--iwb-space-8); flex-wrap: wrap; justify-content: flex-end; }
|
||||
.field { display: inline-flex; align-items: center; gap: var(--iwb-space-6); font-size: var(--iwb-font-sm); color: var(--iwb-text2); }
|
||||
select, button { font: inherit; }
|
||||
select { height: 30px; padding: 0 var(--iwb-space-10); color: var(--iwb-text); background: var(--iwb-field); border: 1px solid var(--iwb-border2); border-radius: var(--iwb-radius-control); }
|
||||
.btn { height: 30px; padding: 0 var(--iwb-space-12); border-radius: var(--iwb-radius-control); border: 1px solid var(--iwb-border2); background: var(--iwb-panel); color: var(--iwb-text); display: inline-flex; align-items: center; gap: var(--iwb-space-6); cursor: pointer; font-size: var(--iwb-font-sm); white-space: nowrap; }
|
||||
.btn:hover { background: var(--iwb-hover); border-color: var(--iwb-hover-border); }
|
||||
.btn.primary { background: var(--iwb-brand); color: var(--iwb-on-brand); border-color: var(--iwb-brand); }
|
||||
.btn.primary:hover { filter: brightness(1.05); }
|
||||
.btn.ghost { background: transparent; }
|
||||
.btn:disabled { opacity: .5; cursor: default; background: var(--iwb-layer); color: var(--iwb-text2); border-color: var(--iwb-border); }
|
||||
.tabs { display: flex; gap: var(--iwb-space-4); border-bottom: 1px solid var(--iwb-border); padding-bottom: 0; }
|
||||
.tab { padding: var(--iwb-space-6) var(--iwb-space-10); font-size: var(--iwb-font-sm); color: var(--iwb-text2); border-radius: var(--iwb-radius-control) var(--iwb-radius-control) 0 0; cursor: pointer; display: inline-flex; align-items: center; gap: var(--iwb-space-6); }
|
||||
.tab:hover { color: var(--iwb-text); background: var(--iwb-hover); }
|
||||
.tab.active { color: var(--iwb-accent-on-surface); background: var(--iwb-accent-tint); }
|
||||
.tab .n { font-size: var(--iwb-font-2xs); color: var(--iwb-text2); background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-full); padding: 0 6px; line-height: 15px; }
|
||||
.tab.active .n { color: var(--iwb-accent-on-surface); background: transparent; border-color: var(--iwb-accent-on-surface); }
|
||||
.list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: var(--iwb-space-8); padding-right: 2px; }
|
||||
.row { display: grid; grid-template-columns: 96px minmax(0,1fr) auto; gap: var(--iwb-space-12); align-items: center; padding: var(--iwb-space-10); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-card); transition: border-color .15s, background .15s; }
|
||||
.row:hover { border-color: var(--iwb-hover-border); }
|
||||
.row.failed { border-color: var(--iwb-err-bd); background: color-mix(in srgb, var(--iwb-err) 9%, var(--iwb-panel)); }
|
||||
.thumb { cursor: zoom-in; width: 96px; height: 64px; border-radius: var(--iwb-radius-control); border: 1px solid var(--iwb-border); background: var(--iwb-layer2); overflow: hidden; position: relative; display: grid; place-items: center; }
|
||||
.thumb svg, .thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
|
||||
.thumb .ph { color: var(--iwb-text2); display: grid; place-items: center; gap: 2px; font-size: var(--iwb-font-2xs); }
|
||||
.thumb .ph svg { width: 20px; height: 20px; }
|
||||
.thumb .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--iwb-layer); }
|
||||
.thumb .prog i { display: block; height: 100%; width: 42%; background: var(--iwb-brand); }
|
||||
.main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
||||
.line1 { display: flex; align-items: center; gap: var(--iwb-space-8); min-width: 0; }
|
||||
.name { font-size: var(--iwb-font-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.badge { flex: 0 0 auto; height: 18px; padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-2xs); line-height: 18px; border: 1px solid var(--iwb-border2); color: var(--iwb-text2); background: var(--iwb-layer); }
|
||||
.badge.ok { color: var(--iwb-ok); border-color: var(--iwb-ok-bd); background: var(--iwb-ok-bg); }
|
||||
.badge.err { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
|
||||
.badge.warn { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
|
||||
.meta { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.errline { font-size: var(--iwb-font-xs); color: var(--iwb-err); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.actions { display: flex; align-items: center; gap: var(--iwb-space-6); flex-wrap: wrap; justify-content: flex-end; }
|
||||
.foot { font-size: var(--iwb-font-xs); color: var(--iwb-text2); display: flex; justify-content: space-between; gap: var(--iwb-space-12); }
|
||||
.foot .hint { color: var(--iwb-text-dim); }
|
||||
.empty { padding: var(--iwb-space-32); text-align: center; color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
|
||||
@media (max-width: 860px) { .page { padding: var(--iwb-space-16); } .row { grid-template-columns: 72px minmax(0,1fr); } .actions { grid-column: 2; justify-content: flex-start; } .thumb { width: 72px; height: 50px; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<aside class="rail" aria-label="主导航">
|
||||
<div class="logo">IW</div>
|
||||
<div class="item" title="首页"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg></div>
|
||||
<div class="item" title="画布"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/></svg></div>
|
||||
<div class="item" title="插件"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"/></svg></div>
|
||||
<div class="item active" title="任务队列"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M4 6h12M4 12h12M4 18h8"/><circle cx="19" cy="18" r="2.2"/></svg></div>
|
||||
</aside>
|
||||
<main class="page">
|
||||
<header class="head">
|
||||
<div>
|
||||
<div class="title">任务队列</div>
|
||||
<span class="sub">全局生图记录 · 数据由宿主保存,插件关闭也继续记录</span>
|
||||
</div>
|
||||
<div class="tools">
|
||||
<label class="field">记录上限
|
||||
<select id="limit"><option>200</option><option selected>500</option><option>1000</option><option>2000</option><option>5000</option></select>
|
||||
</label>
|
||||
<button class="btn ghost" id="clear">清空记录</button>
|
||||
<button class="btn ghost" id="theme">深色</button>
|
||||
</div>
|
||||
</header>
|
||||
<nav class="tabs" id="tabs">
|
||||
<div class="tab active" data-f="all">全部 <span class="n">6</span></div>
|
||||
<div class="tab" data-f="ok">已完成 <span class="n">2</span></div>
|
||||
<div class="tab" data-f="down">下载中 <span class="n">1</span></div>
|
||||
<div class="tab" data-f="fail">失败 <span class="n">1</span></div>
|
||||
<div class="tab" data-f="only">仅记录 <span class="n">2</span></div>
|
||||
</nav>
|
||||
<section class="list" id="list">
|
||||
<!-- 已完成 -->
|
||||
<div class="row" data-s="ok">
|
||||
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="24" font-size="13" font-weight="700" fill="#111">古茗草莓</text><text x="8" y="40" font-size="13" font-weight="700" fill="#111">新品专场</text><text x="8" y="55" font-size="9" fill="#555">单杯不到12r</text></svg></div>
|
||||
<div class="main">
|
||||
<div class="line1"><span class="name">pop 手绘体设计 · 第 1 张</span><span class="badge ok">已完成</span></div>
|
||||
<div class="meta">品牌视觉 · 12-03 14:20 · 1536×1024 · gpt-image-2.6</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn" disabled>已在图库</button>
|
||||
<button class="btn ghost">复制原始链接</button>
|
||||
<button class="btn ghost">定位</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 下载中 -->
|
||||
<div class="row" data-s="down">
|
||||
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="26" font-size="13" font-weight="700" fill="#111">艺术字体</text><text x="8" y="44" font-size="11" fill="#111">买一送一</text></svg><div class="prog"><i></i></div></div>
|
||||
<div class="main">
|
||||
<div class="line1"><span class="name">艺术字体 · 第 1 张</span><span class="badge">下载中 42%</span></div>
|
||||
<div class="meta">活动海报 · 12-03 14:22 · 1536×1024 · 正在写入 images/gallery</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn" disabled>下载中…</button>
|
||||
<button class="btn ghost">复制原始链接</button>
|
||||
<button class="btn ghost">定位</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 失败 -->
|
||||
<div class="row failed" data-s="fail">
|
||||
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="26" font-size="12" font-weight="700" fill="#111">披萨新品</text><text x="8" y="44" font-size="12" font-weight="700" fill="#111">买一送一</text></svg></div>
|
||||
<div class="main">
|
||||
<div class="line1"><span class="name">艺术字体 · 第 2 张</span><span class="badge err">失败</span></div>
|
||||
<div class="meta">活动海报 · 12-03 14:25 · 1536×1024</div>
|
||||
<div class="errline">timeout · 已重试 3 次 · 原始链接仍可复制</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn primary">重试</button>
|
||||
<button class="btn ghost">复制原始链接</button>
|
||||
<button class="btn ghost">定位</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 仅记录 -->
|
||||
<div class="row" data-s="only">
|
||||
<div class="thumb" title="点击预览"><div class="ph"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg><span>仅记录</span></div></div>
|
||||
<div class="main">
|
||||
<div class="line1"><span class="name">披萨新品 · 买一送一</span><span class="badge warn">仅记录</span></div>
|
||||
<div class="meta">活动海报 · 12-02 18:10 · 1536×1024 · gpt-image-2.5</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn primary">下载</button>
|
||||
<button class="btn ghost">复制原始链接</button>
|
||||
<button class="btn ghost">定位</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 已完成,画布已删除 -->
|
||||
<div class="row" data-s="ok">
|
||||
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="24" font-size="12" font-weight="700" fill="#111">pop 手绘体</text><text x="8" y="42" font-size="10" fill="#555">新品上市</text></svg></div>
|
||||
<div class="main">
|
||||
<div class="line1"><span class="name">pop 手绘体设计 · 第 2 张</span><span class="badge ok">已完成</span></div>
|
||||
<div class="meta">品牌视觉 · 12-01 09:40 · 1536×1024</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn" disabled>已在图库</button>
|
||||
<button class="btn ghost">复制原始链接</button>
|
||||
<button class="btn ghost" disabled>画布已删除</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 仅记录,节点已删除 -->
|
||||
<div class="row" data-s="only">
|
||||
<div class="thumb" title="点击预览"><div class="ph"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg><span>仅记录</span></div></div>
|
||||
<div class="main">
|
||||
<div class="line1"><span class="name">艺术字体 · 第 3 张</span><span class="badge warn">仅记录</span></div>
|
||||
<div class="meta">活动海报 · 11-30 16:05 · 1536×1024</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn primary">下载</button>
|
||||
<button class="btn ghost">复制原始链接</button>
|
||||
<button class="btn ghost" disabled>节点已删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<footer class="foot">
|
||||
<span>记录只保留链接与本机状态;上限内自动淘汰最旧记录,不影响 images/gallery 里的文件。</span>
|
||||
<span class="hint">点击「下载」= 落地到图库(图库会自动刷新出现)</span>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
<script>
|
||||
const html = document.documentElement
|
||||
const themeBtn = document.getElementById('theme')
|
||||
themeBtn.addEventListener('click', () => { html.classList.toggle('theme-dark'); themeBtn.textContent = html.classList.contains('theme-dark') ? '浅色' : '深色' })
|
||||
const tabs = Array.from(document.querySelectorAll('#tabs .tab'))
|
||||
const rows = Array.from(document.querySelectorAll('#list .row'))
|
||||
tabs.forEach((t) => t.addEventListener('click', () => {
|
||||
tabs.forEach((x) => x.classList.toggle('active', x === t))
|
||||
const f = t.getAttribute('data-f')
|
||||
rows.forEach((r) => { r.style.display = (f === 'all' || r.getAttribute('data-s') === f) ? '' : 'none' })
|
||||
}))
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,163 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN" data-theme="light">
|
||||
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>任务队列 · UI 方案</title>
|
||||
<style>
|
||||
:root{--bg:#f6f7f9;--panel:#fff;--panel2:#fafbfc;--line:#e8eaee;--line2:#dfe2e8;--text:#1a1a1a;--text2:#6b7280;--text3:#9aa1ab;--brand:#f59e0b;--brand-weak:#fff7e6;--brand-line:#f5d08a;--ok:#16a34a;--ok-weak:#eefaf0;--err:#dc2626;--err-weak:#fdeeee;--r:10px;--rs:8px;--shadow:0 1px 2px rgba(16,24,40,.04),0 8px 24px rgba(16,24,40,.06)}
|
||||
html[data-theme="dark"]{--bg:#121212;--panel:#1c1c1c;--panel2:#202020;--line:#2a2a2a;--line2:#343434;--text:#e9e9ea;--text2:#9a9a9a;--text3:#6f6f6f;--brand:#f5a623;--brand-weak:#2a2114;--brand-line:#5a4420;--ok:#4ade80;--ok-weak:#16281b;--err:#f87171;--err-weak:#2c1a1a;--shadow:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35)}
|
||||
*{box-sizing:border-box}
|
||||
body{margin:0;background:var(--bg);color:var(--text);font:13px/1.5 -apple-system,"PingFang SC","Microsoft YaHei",sans-serif}
|
||||
.app{display:flex;min-height:100vh}
|
||||
.rail{width:52px;flex:0 0 52px;background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column;align-items:center;padding:10px 0;gap:6px}
|
||||
.rail .logo{width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg,#111,#444);margin-bottom:8px}
|
||||
.rail button{width:36px;height:36px;border:0;border-radius:10px;background:transparent;color:var(--text2);display:grid;place-items:center;cursor:pointer}
|
||||
.rail button:hover{background:var(--panel2);color:var(--text)}
|
||||
.rail button.on{background:var(--text);color:var(--panel)}
|
||||
.rail .spacer{flex:1}
|
||||
.rail svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
||||
.main{flex:1;min-width:0;display:flex;flex-direction:column}
|
||||
.head{padding:20px 24px 0;display:flex;align-items:center;gap:12px}
|
||||
.head h1{margin:0;font-size:20px;font-weight:650}
|
||||
.head .right{margin-left:auto;display:flex;gap:8px}
|
||||
.ghost{height:30px;padding:0 12px;border:1px solid var(--line2);border-radius:var(--rs);background:var(--panel);color:var(--text2);cursor:pointer;font-size:12px}
|
||||
.ghost:hover{background:var(--panel2);color:var(--text)}
|
||||
.tabs{display:flex;gap:22px;padding:14px 24px 0;border-bottom:1px solid var(--line);margin-top:8px}
|
||||
.tab{position:relative;padding:0 0 10px;border:0;background:none;color:var(--text2);font-size:13px;cursor:pointer}
|
||||
.tab b{font-weight:600;margin-left:3px;color:var(--text3);font-size:12px}
|
||||
.tab.on{color:var(--text);font-weight:600}
|
||||
.tab.on:after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;background:var(--brand);border-radius:2px}
|
||||
.filters{display:flex;align-items:center;gap:8px;padding:12px 24px;flex-wrap:wrap}
|
||||
.chip{height:30px;padding:0 10px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);color:var(--text2);cursor:pointer;display:inline-flex;align-items:center;gap:6px;font-size:12px}
|
||||
.chip.on{border-color:var(--brand);background:var(--brand-weak);color:var(--text)}
|
||||
.search{flex:1;min-width:220px;height:32px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);display:flex;align-items:center;gap:8px;padding:0 10px;color:var(--text3)}
|
||||
.search input{border:0;outline:0;background:none;flex:1;font-size:12px;color:var(--text)}
|
||||
.date{height:30px;padding:0 10px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);display:inline-flex;align-items:center;color:var(--text3);font-size:12px}
|
||||
.dates{display:flex;align-items:center;gap:8px;color:var(--text2);font-size:12px}
|
||||
.list{padding:4px 24px 120px;display:flex;flex-direction:column;gap:8px}
|
||||
.row{position:relative;display:flex;gap:14px;padding:14px;background:var(--panel);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow)}
|
||||
.row:hover{border-color:var(--line2)}
|
||||
.row.sel{border-color:var(--brand);box-shadow:0 0 0 1px var(--brand-line),var(--shadow)}
|
||||
.thumb{position:relative;width:88px;height:88px;flex:0 0 88px;border-radius:var(--rs);overflow:hidden;background:var(--panel2);border:1px solid var(--line)}
|
||||
.thumb .ph{position:absolute;inset:0;display:grid;place-items:center;color:var(--text3);font-size:10px;letter-spacing:.5px}
|
||||
.thumb .img{position:absolute;inset:0;background:radial-gradient(120% 90% at 15% 10%,#ffe9c9 0,transparent 55%),radial-gradient(90% 70% at 85% 0,#d7f0e3 0,transparent 60%),linear-gradient(160deg,#efe6d8,#d9cbb8 45%,#bfae98)}
|
||||
.thumb .img.b{background:radial-gradient(100% 80% at 20% 20%,#dfe8ff 0,transparent 60%),linear-gradient(160deg,#e9edff,#c7d3f5 50%,#a9b8e8)}
|
||||
.thumb .img.c{background:radial-gradient(100% 80% at 70% 10%,#ffe3e0 0,transparent 60%),linear-gradient(160deg,#ffe9e5,#efc9c1 55%,#d9a99f)}
|
||||
.thumb .badge{position:absolute;left:6px;top:6px;padding:1px 6px;border-radius:6px;font-size:10px;background:rgba(0,0,0,.55);color:#fff}
|
||||
.thumb .prog{position:absolute;left:0;right:0;bottom:0;height:4px;background:rgba(0,0,0,.12)}
|
||||
.thumb .prog i{display:block;height:100%;background:var(--brand);width:62%}
|
||||
.thumb .err{position:absolute;inset:0;display:grid;place-items:center;background:var(--err-weak);color:var(--err);font-size:22px}
|
||||
.body{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}
|
||||
.title{font-size:13.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.meta{display:flex;align-items:center;gap:10px;color:var(--text3);font-size:12px;flex-wrap:wrap}
|
||||
.dot{width:3px;height:3px;border-radius:50%;background:var(--line2)}
|
||||
.state{display:inline-flex;align-items:center;gap:5px;padding:1px 7px;border-radius:999px;font-size:11px;border:1px solid transparent}
|
||||
.state.ok{color:var(--ok);background:var(--ok-weak);border-color:rgba(22,163,74,.25)}
|
||||
.state.err{color:var(--err);background:var(--err-weak);border-color:rgba(220,38,38,.25)}
|
||||
.state.dl{color:#b45309;background:var(--brand-weak);border-color:var(--brand-line)}
|
||||
.state.wait{color:var(--text2);background:var(--panel2);border-color:var(--line2)}
|
||||
.link{color:var(--brand);cursor:pointer;border-bottom:1px dashed rgba(245,158,11,.5)}
|
||||
.errbar{margin-top:2px;padding:7px 10px;border-radius:8px;background:var(--err-weak);color:var(--err);font-size:12px;display:flex;gap:8px}
|
||||
.errbar .rid{color:var(--text3);font-size:11px}
|
||||
.actions{display:flex;align-items:center;gap:4px;flex:0 0 auto}
|
||||
.ico{width:30px;height:30px;border:0;border-radius:8px;background:transparent;color:var(--text3);display:grid;place-items:center;cursor:pointer;font-size:14px}
|
||||
.ico:hover{background:var(--panel2);color:var(--text)}
|
||||
.primary{height:30px;padding:0 14px;border:0;border-radius:999px;background:var(--brand);color:#fff;font-size:12px;font-weight:600;cursor:pointer}
|
||||
.primary:hover{filter:brightness(.96)}
|
||||
.primary.ghostish{background:var(--panel);color:var(--text);border:1px solid var(--line2)}
|
||||
.batchbar{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--panel);border:1px solid var(--line2);border-radius:12px;box-shadow:var(--shadow);display:flex;align-items:center;gap:10px;padding:8px 12px}
|
||||
.batchbar .n{font-size:12px;color:var(--text2)}
|
||||
.batchbar button{height:28px;padding:0 10px;border-radius:8px;border:1px solid var(--line2);background:var(--panel);color:var(--text);font-size:12px;cursor:pointer}
|
||||
.drawer{position:fixed;top:0;right:0;bottom:0;width:400px;background:var(--panel);border-left:1px solid var(--line);box-shadow:-12px 0 32px rgba(16,24,40,.1);padding:18px;overflow:auto}
|
||||
.drawer h3{margin:0 0 4px;font-size:15px}
|
||||
.drawer .sub{color:var(--text3);font-size:12px;margin-bottom:14px}
|
||||
.kv{display:grid;grid-template-columns:78px 1fr;gap:8px 10px;font-size:12px;margin-bottom:14px}
|
||||
.kv .k{color:var(--text3)}
|
||||
.kv .v{word-break:break-all}
|
||||
.kv code{font-family:ui-monospace,Menlo,monospace;font-size:11.5px;background:var(--panel2);border:1px solid var(--line);border-radius:6px;padding:2px 6px}
|
||||
.sect{font-size:11px;letter-spacing:.6px;color:var(--text3);margin:16px 0 8px}
|
||||
.row2{display:flex;gap:8px;flex-wrap:wrap}
|
||||
.warn{margin-top:10px;padding:8px 10px;border-radius:8px;background:var(--brand-weak);border:1px solid var(--brand-line);color:#8a5a00;font-size:11.5px}
|
||||
.hint{position:fixed;right:16px;bottom:16px;font-size:11px;color:var(--text3);background:var(--panel);border:1px dashed var(--line2);border-radius:8px;padding:6px 10px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<aside class="rail">
|
||||
<div class="logo"></div>
|
||||
<button title="首页"><svg viewBox="0 0 24 24"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg></button>
|
||||
<button title="画布"><svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/></svg></button>
|
||||
<button class="on" title="任务队列(新增)"><svg viewBox="0 0 24 24"><path d="M4 6h16"/><path d="M4 12h16"/><path d="M4 18h10"/><circle cx="19" cy="18" r="2.2"/></svg></button>
|
||||
<button title="插件"><svg viewBox="0 0 24 24"><path d="M12 3l8 4.5v9L12 21l-8-4.5v-9L12 3z"/><path d="M12 12l8-4.5M12 12v9M12 12L4 7.5"/></svg></button>
|
||||
<div class="spacer"></div>
|
||||
<button title="帮助"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M9.5 9a2.5 2.5 0 1 1 3.6 2.3c-.7.4-1.1 1-1.1 1.8"/><path d="M12 17h.01"/></svg></button>
|
||||
<button title="设置"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M4 12h2M18 12h2M12 4v2M12 18v2"/></svg></button>
|
||||
</aside>
|
||||
<main class="main">
|
||||
<div class="head"><h1>任务队列</h1><div class="right"><button class="ghost" id="themeBtn">切换深色</button><button class="ghost">全部重试</button><button class="ghost">清理已完成</button></div></div>
|
||||
<div class="tabs"><button class="tab on">全部 <b>124</b></button><button class="tab">下载中 <b>1</b></button><button class="tab">失败 <b>1</b></button><button class="tab">已完成 <b>121</b></button><button class="tab">历史 <b>1111</b></button></div>
|
||||
<div class="filters">
|
||||
<button class="chip on">▾ 筛选</button><button class="chip on">图片</button><button class="chip">视频</button><button class="chip">音频</button><button class="chip">文本</button>
|
||||
<label class="search">🔍<input placeholder="搜索提示词、文件名或原始链接"></label>
|
||||
<div class="dates"><span>创建日期</span><span class="date">2026-12-01</span><span>至</span><span class="date">2026-12-02</span></div>
|
||||
<button class="chip">多选</button>
|
||||
</div>
|
||||
<div class="list">
|
||||
<div class="row sel" data-drawer="1"><div class="thumb"><div class="img"></div><span class="badge">下载 62%</span><div class="prog"><i></i></div></div>
|
||||
<div class="body"><div class="title">去掉画面顶部的文案与文案的装饰,保留背景与商品和装饰内容。</div>
|
||||
<div class="meta"><span class="state dl">下载中 62%</span><span>gpt-image-2.6</span><span class="dot"></span><span>1824×2288</span><span class="dot"></span><span>1.8 / 2.9 MB</span></div>
|
||||
<div class="meta"><span>2026-12-02 11:04:10</span><span class="dot"></span><span>耗时 1m 13s</span><span class="dot"></span><a class="link">查看原始链接</a></div></div>
|
||||
<div class="actions"><button class="ico" title="取消下载">×</button><button class="primary ghostish">暂停</button></div></div>
|
||||
<div class="row" data-drawer="1"><div class="thumb"><div class="err">!</div><span class="badge">未落地</span></div>
|
||||
<div class="body"><div class="title">减少图片边缘四周的植物,提高清晰度</div>
|
||||
<div class="meta"><span class="state err">下载失败 · 已重试 3 次</span><span>gpt-image-2.6</span><span class="dot"></span><span>1824×2288</span></div>
|
||||
<div class="meta"><span>2026-12-02 10:51:22</span><span class="dot"></span><span>原始链接仍可用</span></div>
|
||||
<div class="errbar">连接超时(CDN 返回 504)<span class="rid">request id 202612020905172288</span></div></div>
|
||||
<div class="actions"><button class="ico" title="复制链接">⧉</button><button class="ico" title="浏览器打开">↗</button><button class="ico" title="删除">🗑</button><button class="primary">重试</button></div></div>
|
||||
<div class="row" data-drawer="1"><div class="thumb"><div class="img b"></div><span class="badge">2048</span></div>
|
||||
<div class="body"><div class="title">去掉图片边缘四周的植物,提高清晰度</div>
|
||||
<div class="meta"><span class="state ok">已完成</span><span>gpt-image-2.6-vip</span><span class="dot"></span><span>批量 1/1</span><span class="dot"></span><span>1824×2288</span><span class="dot"></span><span>2.9 MB</span></div>
|
||||
<div class="meta"><span>2026-12-02 10:43:08</span><span class="dot"></span><span>58s</span><span class="dot"></span><a class="link">打开预览</a><span class="dot"></span><a class="link">原始链接</a></div></div>
|
||||
<div class="actions"><button class="ico" title="下载原图">↓</button><button class="ico" title="复制链接">⧉</button><button class="ico" title="定位节点">◎</button><button class="ico" title="删除">🗑</button><button class="primary">插入画布</button></div></div>
|
||||
<div class="row" data-drawer="1"><div class="thumb"><div class="img c"></div><span class="badge">2048</span></div>
|
||||
<div class="body"><div class="title">扩图,向 4 周扩图</div>
|
||||
<div class="meta"><span class="state ok">已完成</span><span>gpt-image-2.6-vip</span><span class="dot"></span><span>1868×2288</span><span class="dot"></span><span>3.2 MB</span></div>
|
||||
<div class="meta"><span>2026-12-02 10:02:17</span><span class="dot"></span><a class="link">打开预览</a><span class="dot"></span><a class="link">原始链接</a></div></div>
|
||||
<div class="actions"><button class="ico" title="下载原图">↓</button><button class="ico" title="复制链接">⧉</button><button class="primary">插入画布</button></div></div>
|
||||
<div class="row" data-drawer="1"><div class="thumb"><div class="ph">本地已清理</div><span class="badge">仅链接</span></div>
|
||||
<div class="body"><div class="title">去掉画面顶部的文案与文案的装饰,保留背景与商品和装饰内容。</div>
|
||||
<div class="meta"><span class="state wait">仅保留链接</span><span>gpt-image-2.6</span><span class="dot"></span><span>1824×2288</span></div>
|
||||
<div class="meta"><span>2026-12-01 16:58:23</span><span class="dot"></span><a class="link">复制原始链接</a><span class="dot"></span><span>可重新下载</span></div></div>
|
||||
<div class="actions"><button class="ico" title="复制链接">⧉</button><button class="primary">重新下载</button></div></div>
|
||||
<div class="row" data-drawer="1"><div class="thumb"><div class="img"></div></div>
|
||||
<div class="body"><div class="title">把背景换成浅灰色,保留商品与投影</div>
|
||||
<div class="meta"><span class="state ok">已完成</span><span>gpt-image-2.6</span><span class="dot"></span><span>1536×1536</span><span class="dot"></span><span>1.4 MB</span></div>
|
||||
<div class="meta"><span>2026-12-01 15:20:44</span><span class="dot"></span><span>47s</span><span class="dot"></span><a class="link">打开预览</a></div></div>
|
||||
<div class="actions"><button class="ico" title="下载原图">↓</button><button class="primary">插入画布</button></div></div>
|
||||
</div>
|
||||
</main>
|
||||
<aside class="drawer" id="drawer">
|
||||
<h3>去掉图片边缘四周的植物,提高清晰度</h3>
|
||||
<div class="sub">2026-12-02 10:43:08 · 58s · gpt-image-2.6-vip</div>
|
||||
<div class="kv">
|
||||
<div class="k">原始链接</div><div class="v"><code>https://cdn.example.com/gen/8f3a…-1824.png</code></div>
|
||||
<div class="k">本地副本</div><div class="v">已落地 · 2.9 MB · <code>__blob:3f7c…</code></div>
|
||||
<div class="k">显示层</div><div class="v">长边 2048(≈9 MB 纹理,导出仍用原图)</div>
|
||||
<div class="k">来源</div><div class="v">节点「出图 3」 · 画板「主图」</div>
|
||||
</div>
|
||||
<div class="sect">操作</div>
|
||||
<div class="row2"><button class="primary">插入画布</button><button class="chip">复制图片</button><button class="chip">复制链接</button><button class="chip">下载原图</button></div>
|
||||
<div class="sect">重新获取</div>
|
||||
<div class="row2"><button class="chip">重新下载(覆盖本地)</button><button class="chip">仅保留链接</button></div>
|
||||
<div class="warn">本地字节被清理后,这条会变成「仅保留链接」;原始链接随时可重新下载,不会丢。</div>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="batchbar"><span class="n">已选 1 项</span><button>插入画布</button><button>批量下载</button><button>复制链接</button><button>删除</button></div>
|
||||
<div class="hint">mockup:点行看详情 · 右上角切换深色</div>
|
||||
<script>
|
||||
var html=document.documentElement;
|
||||
document.getElementById("themeBtn").onclick=function(){html.dataset.theme=html.dataset.theme==="dark"?"light":"dark";this.textContent=html.dataset.theme==="dark"?"切换浅色":"切换深色"};
|
||||
document.querySelectorAll(".tab").forEach(function(b){b.onclick=function(){document.querySelectorAll(".tab").forEach(function(x){x.classList.remove("on")});b.classList.add("on")}});
|
||||
document.querySelectorAll(".row").forEach(function(r){r.onclick=function(e){if(e.target.closest("button"))return;document.getElementById("drawer").style.transform="none"}});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,108 @@
|
||||
# 任务队列(左栏整页插件)执行计划 · 2026-12-03
|
||||
|
||||
> 上游讨论:`docs/plans/task-queue-plan.md`(2026-12-02)、`docs/mockups/task-queue-v2.html`。
|
||||
> 本文是**本次实施口径**:宿主记账 + 插件整页 + 左栏入口;图库保持「只显示已落地」。
|
||||
|
||||
## 1. 目标 / 非目标
|
||||
|
||||
**目标**
|
||||
- 记录每一次生成结果(url、状态、画布/节点、时间、模型/尺寸),全局跨画布。
|
||||
- 记录由**宿主**保存;插件关闭也继续记录,重新开启即可看到历史。
|
||||
- 左栏一级入口「任务队列」(插件整页),可启用/禁用。
|
||||
- 行内主操作「下载」= 落地到 `images/gallery`,图库自动刷新出现。
|
||||
- 支持「重试 / 复制原始链接 / 定位节点 / 点击缩略图预览」。
|
||||
- 记录上限可在插件页设置(宿主配置),超限淘汰最旧;淘汰不影响图库文件。
|
||||
|
||||
**非目标**
|
||||
- 不做自动对账(图库保持只读展示,不扫描、不补录)。
|
||||
- 不处理本版本之前的旧记录(无 meta 显示「未知画板」)。
|
||||
- 不做详情抽屉、批量选择、进度详情页。
|
||||
- 不新增下载器:复用 `image-ingest`。
|
||||
|
||||
## 2. 数据与存储
|
||||
|
||||
- 账本:沿用 `image-ingest-store`(全局 key `iwb_ingest_idx`)。
|
||||
- 新增 meta(入队时写):`boardId / boardName / nodeId / prompt / model / size / at`。
|
||||
- 桌面端独立文件:`src/storage-file.js` 的 `LIB_FILES` 增加
|
||||
`iwb_ingest_idx: 'task-queue/index.json'`(不塞 data.json)。
|
||||
- 上限:配置 `canvas.taskQueueMax`,默认 500,范围 100~5000;store 写入时按上限淘汰最旧(不删图片)。
|
||||
- 备份/导出:确认包含 `library/task-queue/index.json`,不包含则补清单。
|
||||
|
||||
## 3. 宿主能力
|
||||
|
||||
### 3.1 `queue` 能力(新)`src/plugin-api-queue.js`
|
||||
|
||||
- `list({status, limit, query})`:返回账本记录(含 meta、状态、url、`thumbUrl`:仅 ready 的本地缩略图/objectURL)。
|
||||
- `retry(id)`:重新入队。
|
||||
- `land(id)`:建图库索引行(按 url 幂等)→ 入队 → 已有本地字节则立即补写;图库自动刷新。
|
||||
- `preview(id)`:用现有 `ImagePreview` 打开,列表=所有可预览记录(本地优先,否则远程 url)。
|
||||
- `copyLink(id)`:复制完整原始链接(页面不展示链接)。
|
||||
- `locate(id)`:按 `boardId` 切画布、加载后选中 `nodeId`;画布/节点缺失返回错误。
|
||||
- `stats()`:各状态计数。
|
||||
- `clear()`:清空非进行中的记录(不动图库/文件)。
|
||||
- `getLimit()/setLimit(n)`:读写 `canvas.taskQueueMax`,立即裁剪。
|
||||
- `onChanged(fn)`:订阅账本变更(下载进度/状态)。
|
||||
|
||||
### 3.2 `pages` 能力(新)
|
||||
|
||||
- `plugin-host.js`:`CAPABILITIES` 加 `pages`,`CAPABILITY_API_KEYS.pages = 'ui'`。
|
||||
- 插件 `ctx.ui.registerPage({id,title,icon,mount})`;禁用插件自动移除;若当前正停在该页,自动切回画布。
|
||||
- `ui-nav-rail.js` 增加插件页图标;app.js 增加 `pluginPage` 状态与页面容器(`.iwb-plugin-page`)。
|
||||
|
||||
## 4. 插件 `taskqueue`(左栏整页)
|
||||
|
||||
- 源仓:`~/open/github/iwb-plugins-desktop/taskqueue`(package.json + src/index.js + styles.css)。
|
||||
- 清单:`capabilities: ['pages','queue']`,page `{id:'taskqueue', title:'任务队列', icon:'list'}`。
|
||||
- UI 按 `docs/mockups/task-queue-v2.html`:
|
||||
- 页签:全部 / 已完成 / 下载中 / 失败 / 仅记录(计数)。
|
||||
- 行:缩略图(可点击预览)、标题、状态徽标、画布·时间·尺寸/模型;失败行错误摘要。
|
||||
- 操作:**下载**(主)/ 重试 / 复制原始链接 / 定位;删除态提示「画布已删除 / 节点已删除」。
|
||||
- 顶部:记录上限下拉(200/500/1000/2000/5000)、清空记录。
|
||||
- 颜色/字体/圆角/间距全部用 `var(--iwb-*)`;结构尺寸可字面量(与 gallery 一致)。
|
||||
|
||||
## 5. 代码改动清单
|
||||
|
||||
| 文件 | 改动 |
|
||||
| --- | --- |
|
||||
| `src/image-ingest-store.js` | 上限可注入(函数)、`trim()`、`clear()`;meta 透传 |
|
||||
| `src/image-ingest.js` | `enqueue` 支持 meta;`clearFinished()`(保留进行中) |
|
||||
| `src/storage-file.js` | `LIB_FILES` 加 `iwb_ingest_idx` |
|
||||
| `src/runtime-workbench-logic.js` | `liveUpsert` 入队时补 board/node/prompt/model/size meta |
|
||||
| `src/plugin-api-queue.js`(新) | queue 能力桥(setImpl/api/emit) |
|
||||
| `src/plugin-api-pages.js`(新)或并入 plugin-host | pages 注册桥 |
|
||||
| `src/plugin-host.js` | 注册 `queue` / `pages` 能力 |
|
||||
| `src/ui-nav-rail.js` | 渲染插件页入口 |
|
||||
| `app.js` | queue/pages 能力实现;land/preview/locate/clear/limit;页面状态与容器;ingest onEvent 通知插件 |
|
||||
| `plugins/taskqueue/*`(新) | 整页插件 |
|
||||
| `plugins/index.json` / `manifest` / `market` | 新插件产物与市场 |
|
||||
| `tests/*` | queue 能力契约、插件渲染/空态、上限裁剪、locate 错误 |
|
||||
| docs | 本计划、CHANGELOG、锚点/事实同步 |
|
||||
|
||||
## 6. 关键实现口径
|
||||
|
||||
- `land(id)`:`wAddOutputs([{ok:true,url,...}])`(幂等)→ `enqueue({url,source:'task-queue'})` → 若 view 已 ready 立即 `wFillOutputFromIngest`;图库靠 `wGalleryChanged` 自动刷新。
|
||||
- 预览:`setPreview({list, idx})`,list 项 `{url, w, h, name}`;本地 ready 用 `wResolveImg(ref)`,否则用原始 url;失败提示「预览失败」。
|
||||
- `locate`:`setActiveWsId(boardId)` → `openTab` → `loadWsInto` → 等加载 → `setSel([nodeId])` + 居中;失败返回 `{ok:false,error}`。
|
||||
- 上限:`setLimit` 写配置并 `store.trim()`;插件页只调用 API。
|
||||
- 账本淘汰只删记录,不删 `images/gallery`、不动图库索引。
|
||||
- 插件禁用:账本继续记录(宿主),页面入口消失;重新启用可见历史。
|
||||
|
||||
## 7. 验收
|
||||
|
||||
1. 生成 1 张:左栏任务队列出现 1 条;点「下载」→ `images/gallery` 出现、图库自动显示;重复点不产生第二条/第二份文件。
|
||||
2. 失败记录:状态失败 + 错误摘要;点重试成功;复制链接可用。
|
||||
3. 点击缩略图打开预览;本地秒开,仅记录走远程;失效提示。
|
||||
4. 定位:跳到对应画布并选中节点;画布/节点删除时提示。
|
||||
5. 上限改 200:记录裁剪到 200 条,图库文件不变。
|
||||
6. 禁用插件:记账继续(上限内);启用后历史仍在。
|
||||
7. 跨画布:在 A 画布生成、切到 B 画布,队列仍能看到 A 的记录并定位。
|
||||
8. 门禁:build / eslint / typecheck / 单测 / tokens / plugin 契约 / facts。
|
||||
|
||||
## 8. 交付节奏
|
||||
|
||||
- 代码 + 本地验证完成 → 通知用户,**不构建**;等用户确认后再 bump 版本、出测试包、发插件市场。
|
||||
|
||||
## 9. 实施状态(2026-12-03)
|
||||
|
||||
- 已完成:宿主 `queue`/`pages` 能力、账本 meta/独立文件 `library/task-queue/index.json`、上限配置 `canvas.taskQueueMax`、左栏整页插件 `taskqueue 1.0.0`、下载落地/预览/定位/复制链接/清空/重试、真实应用页面与注入记录验证。
|
||||
- 待确认:bump 版本、出测试包、上传插件市场(taskqueue 1.0.0)。
|
||||
@@ -0,0 +1,97 @@
|
||||
# 任务队列(左栏页)方案 · 2026-12-02
|
||||
|
||||
> 交互样式见 docs/mockups/task-queue.html(可点行看详情、右上角切深色),截图 task-queue-light.png / -dark.png。
|
||||
> 本文只谈设计与落地口径,代码未动。
|
||||
|
||||
## 1. 定位
|
||||
|
||||
左栏新增一级入口「任务队列」:记录**每一次收到图片链接的事实**——生成结果、插件产出、外链参考图——
|
||||
即使本地字节被清理,也能从原始链接重新取回;并能定位到画布上对应的节点。
|
||||
|
||||
它不是一个新系统,而是「结果落地管线」的**账本 + 操作台**:
|
||||
- 执行器:src/image-ingest.js(后台下载 / 重试 / 断点恢复)
|
||||
- 账本:src/task-queue-store.js(一条记录 = 一次 ingest 任务)
|
||||
- 界面:src/ui-task-queue.js(本方案)
|
||||
|
||||
## 2. 数据模型(一条记录)
|
||||
|
||||
| 字段 | 说明 |
|
||||
| --- | --- |
|
||||
| id / createdAt / updatedAt | 记录标识与时间 |
|
||||
| source | gen(生成)/ plugin(插件产出)/ remote-ref(外链参考)/ manual(手动导入) |
|
||||
| status | queued / downloading / ready / failed / link-only / missing |
|
||||
| url | **原始链接,永不改写**(生成/导出/重试都以它为准) |
|
||||
| localRef / displayRef / thumbRef | 原图字节 / 显示层(长边 2048)/ 缩略图(320) |
|
||||
| bytes / sha256 / w / h / mime | 落地后回填 |
|
||||
| prompt / model / size / batch / durationMs | 生成信息,用于搜索与展示 |
|
||||
| nodeId / boardId / wsId | 定位到画布节点 |
|
||||
| retries / lastError / requestId | 失败可诊断 |
|
||||
| pinned | 被画布或图库引用时置位,清理时跳过 |
|
||||
|
||||
## 3. 状态机
|
||||
|
||||
queued → downloading(进度) → ready →(清理策略触发)→ link-only
|
||||
↘ failed(重试 1s/2s/4s,最多 3 次)
|
||||
ready/link-only →(字节丢失)→ missing(可一键回源)
|
||||
|
||||
- 幂等键:记录 id;同一 url 重复触发不重复下载
|
||||
- 断点:任务表落 IDB,重启后 queued 继续、downloading 重新排队
|
||||
- 原子写:临时键 → 校验 bytes(有 content-length 比对)→ 提交索引 → 才算 ready
|
||||
|
||||
## 4. 交互(对照样式图)
|
||||
|
||||
1. 左栏第 3 个图标(列表+圆点)→ 整页;与首页/画布/插件同级
|
||||
2. 顶部页签:全部 / 下载中 / 失败 / 已完成 / 历史,均带计数
|
||||
3. 筛选行:类型 chips(图片/视频/音频/文本)、搜索(提示词 / 文件名 / 原始链接)、创建日期区间、多选
|
||||
4. 行结构:缩略图(下载中叠进度条与百分比;失败盖错误标)→ 标题=提示词 → 第一行元信息(状态徽标 / 模型 / 批量 / 尺寸 / 字节)→ 第二行(时间 / 耗时 / 打开预览 / 原始链接)
|
||||
5. 行操作(hover 显示图标,主操作常驻按钮):下载原图 / 复制链接 / 插入画布 / 定位节点 / 重试 / 删除
|
||||
6. 失败行:红色错误条 + request id + 「重试」;原始链接仍可用(可复制/浏览器打开)
|
||||
7. 详情抽屉(点行打开):原始链接(可复制,默认打码)、本地副本状态与 blob 引用、显示层说明、来源节点与画板、操作(插入 / 复制图片 / 复制链接 / 下载 / 重新下载 / 仅保留链接)
|
||||
8. 多选:底部浮动条(已选 N 项 → 插入画布 / 批量下载 / 复制链接 / 删除)
|
||||
9. 空态:没有记录时给一句「出图后会自动出现在这里」+ 前往画布
|
||||
10. 离线态:只读展示已有记录,下载类操作置灰并提示
|
||||
|
||||
## 5. 保留与清理
|
||||
|
||||
- 默认保留 30 天 / 500 条(可设置);pinned 记录永不自动清理
|
||||
- 「仅保留链接」:释放原图字节,保留元数据与 URL(历史页签可见,可重新下载)
|
||||
- 清理只删字节,不删记录;删除记录才移除行
|
||||
|
||||
## 6. 安全
|
||||
|
||||
- 原始链接常带签名参数:列表里默认打码(显示前 24 字符 + …),点「显示」才完整展示
|
||||
- 复制/打开外链走现有的 openExternal(系统浏览器),不内嵌 iframe
|
||||
|
||||
## 7. 性能
|
||||
|
||||
- 列表虚拟化(与图库同一套),只渲染可视区
|
||||
- 缩略图 320,绝不为了列表去解码原图
|
||||
- 索引分页读取;下载进度用事件节流(≥200ms 一次)
|
||||
|
||||
## 8. 改动清单(代码,全部落在 src)
|
||||
|
||||
| 文件 | 改动 |
|
||||
| --- | --- |
|
||||
| src/task-queue-store.js(新) | 索引 CRUD、状态机、清理策略、pinned 判定 |
|
||||
| src/ui-task-queue.js(新) | 页面组件(页签/筛选/列表/抽屉/批量条) |
|
||||
| src/image-ingest.js(新,见落地管线方案) | 后台下载、重试、断点、派生 |
|
||||
| src/ui-nav-rail.js | 增加 rail 项与 props.onQueue |
|
||||
| app.js | 只加装配:页面状态 + 把 ingest 事件接到 store(预计 +8 行,需同步上调 MAX_APP_JS_LINES 并记账) |
|
||||
| src/ui-components.js | 结果图支持「下载中/失败」两种状态外观 |
|
||||
|
||||
## 9. 分期
|
||||
|
||||
| 阶段 | 范围 | 预估 |
|
||||
| --- | --- | --- |
|
||||
| P1 | 只读账本:记录已有生成结果与原始链接,列表 + 详情 + 复制/下载/重新下载 + 定位节点 | 1 天 |
|
||||
| P2 | 接 ingest:实时进度、失败重试、断点恢复;节点与图库改吃本地副本 | 1 天 |
|
||||
| P3 | 显示层派生(长边 2048)+ 清理策略 + 批量操作 | 0.5 天 |
|
||||
|
||||
## 10. 验收
|
||||
|
||||
- 出图后 3 秒内列表出现该条;下载中能看到进度;完成后节点/图库/队列三处一致
|
||||
- 断网:行显示失败 + request id;恢复网络点重试成功
|
||||
- 清理字节后行变「仅保留链接」,点重新下载能取回
|
||||
- 同一条只下载一次(网络面板 1 次请求)
|
||||
- 链接默认打码,点显示才完整
|
||||
- 7000 节点画布下打开队列页,滚动不掉帧
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(桌面版)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-12-02**(**2026-12-02 复算 · v3.26.183**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = b721febd`(线上 `v3.26.183+b721febd` —— 2026-12-02 **图片写回收口**:插件写回三入口统一到 src/image-writeback.js(同步布尔 / 落盘校验 / 建图引用化),阈值只剩 IMPORT_INLINE_MAX,orig 一起引用化并进撤销快照;上一条 `v3.26.182+738b70c` —— 2026-11-30 **图库链路收尾**:宫格不再读原图(原生 320 tier)、缩略图原子写 + 同键合并 + 补 .png、空闲预热;插件图片策略 v2(thumb/preview/original/budget)全量落地。上一条 `v3.26.129+a7da7f7` —— 2026-11-30 **插件源读数**:诊断页显示加载器实际读取的插件目录、索引条数、id@version 版本表与报错。上一条 `v3.26.128+9bcf6d7` —— 2026-11-30 **浏览器窗口空闲休眠**:它是独立 WKWebView(实测整树 +480MB),失焦满 30 分钟自动 close。上一条 `v3.26.127+ed762ad` —— 2026-11-30 **DOM 规模进诊断**:顶部显示 DOM 元素总数 + 停靠面板子树 + 图库卡片数,用来量化「面板开着」的真实成本(实测主窗口 29 节点却有 348MB WebKit malloc,大头在插件面板 DOM)。上一条 `v3.26.126+94d9952` —— 2026-11-30 **诊断增强**:新增 Rust app_memory_breakdown(逐进程 footprint + 分类 Dirty/Reclaimable),诊断页新增「内存拆解(分进程)」与「图片管线」(原生解码次数/峰值 + 缩略图磁盘 512/256/768 统计)。上一条 `v3.26.125+5d70782` —— 2026-11-30 **内存口径修正**:ps 的 RSS 会把每个 WebKit 子进程映射的共享框架各算一遍,四进程求和虚高 1.5~2 倍;改为 footprint(1) 的 phys_footprint(活动监视器同源),并只认比本进程更年轻的 WebKit 子进程。实测 WebContent footprint 653MB 中 dirty 仅 32MB、CG raster 1.7MB、Image IO 0 ⇒ 图片内存已压到底。上一条 `v3.26.124+a0526e7` —— 2026-11-30 **插件图片策略 v2**:宿主三层 ctx.images(thumb/preview/original/budget) + 原生解码闸门(并发 ≤2,>1024px ≤1);album 1.2.4 / promptlib 1.14.10 / batch-export 1.2.3 / annotate 1.20.9 / vectorize 0.6.2 / white-bg 1.2.2 / cutout 1.0.4 全部改走宿主小图;check-plugins-sync 增加图片策略守卫(warn)。上一条 `v3.26.123+309963c` —— 2026-11-30 **缩略图改原生生成**:WebKit 忽略 createImageBitmap 的 resize 选项,JS 生成缩略图要整幅解码 4K 原图(21MB/张),100 多张 ⇒ WebContent 1GB+;新增 Tauri 命令 img_thumbs(Rust image crate,按目标尺寸解码/编码),webview 只接触几十 KB 小图、原图永不进 WebKit 图片缓存。上一条 `v3.26.121+71fe162` —— 2026-11-30 **内存可观测性 + LOD 256 档**:新增 Rust 命令 app_memory_tree_mb(Windows Toolhelp32 / mac ps 建树)→ 诊断页「进程实测 XXX MB」,内存护栏优先用它;createImageBitmap 改 resizeWidth 在解码阶段降采样;新增 256 小档缩略图(纯内存)按 need 分档;macOS 的 WKWebView 子进程按 etime(±180s) 认领,避免把 Safari 算进来。上一条 `v3.26.120+eaf2512` —— 2026-11-30 **图库面板开一次涨 200MB**:`gallery-sync.thumbFor` 原先让宫格每张图都过 `displayThumbOf`,给每张 mint 一个 objectURL 并进 `displayThumbs`(300 上限);关面板后 URL 仍被缓存持有、解码位图不释放。现改为直接吃磁盘 320 缩略图(~20KB data URL)、不过 displayThumbOf;插件 gallery 1.9.6→1.9.7:卡片缓存 400→60 且淘汰时显式摘 `<img src>`。上一条 `v3.26.119+db55d45` —— 2026-11-30 **诊断修复**:三处导出调用点写的 `window.__IWB_SAVE_BLOB__` 从未定义,桌面端「导出诊断 JSON / 导出节点组」必然抛错,已统一走顶层 `wSaveBlob`;`procEstMB` 的解码位图改按 min(自然尺寸, 渲染尺寸×dpr) 累加(原按 512²×4 低报 3~4 倍);「估算进程」改称「画布估算」并注明不含宿主进程;读不出的旧 `{__cache}` 引用按 key 记住失败、本会话不再重试,诊断新增「失效引用 N」;上一条 `v3.26.118+3944fc5` —— 2026-11-30 **内存第二批收敛**:显示缩略图 640→512(124 张图的解码位图 200MB→128MB)、缩略图生成并发 4→2、图片字节缓存 96→64MB、远程 http(s) 图不再进缩略图队列(跨域必败,只换来 thumb-fail 日志)、内存护栏改看 `procEstMB`(估算进程 = JS 堆 + 字节缓存 + 解码位图,阈值 800MB;只盯 JS 堆时 106 张图堆 20MB / 位图 200MB,护栏永远不动);上一条 `v3.26.117+3809c38` —— 2026-11-30 **内存:图片字节预算 + 绝对占用护栏 + 诊断页「立即回收内存」**(Windows 测试版,未发布):`image-blob-store` 的 LRU 补字节预算(96MB ≈ 20 张原图,原来只按 200 条封顶 ⇒ 4~7.5MB 原图最多常驻 1.5GB)并Line truncated
|
||||
> 日期 **2026-12-02**(**2026-12-02 复算 · v3.26.184**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = 7e00acdc`(线上 `v3.26.248+7e00acdc` —— 2026-12-04 **参考图 URL 行**:网络图按 url 判定来源,缓存出 localRef 后仍保留 URL 输入行;2026-12-04 **写盘通道修复**:flush 先赋值再 await,修「244 后启动那次全同步 flush 把 writing 卡成已解决 promise ⇒ 整个会话不再写盘(画布改动重启即丢)」;2026-12-04 **图片取数收口**:图片取字节统一走 Rust(fetch_image_b64;文件版 fetch_image_to 默认关)、存储写入收敛(重启不再批量刷画布 mtime)、参考图「上传到图库」移到选中气泡并与替换图标对调、本地图不再渲染 URL 行;2026-12-02 **图片写回收口**:插件写回三入口统一到 src/image-writeback.js(同步布尔 / 落盘校验 / 建图引用化),阈值只剩 IMPORT_INLINE_MAX,orig 一起引用化并进撤销快照;上一条 `v3.26.182+738b70c` —— 2026-11-30 **图库链路收尾**:宫格不再读原图(原生 320 tier)、缩略图原子写 + 同键合并 + 补 .png、空闲预热;插件图片策略 v2(thumb/preview/original/budget)全量落地。上一条 `v3.26.129+a7da7f7` —— 2026-11-30 **插件源读数**:诊断页显示加载器实际读取的插件目录、索引条数、id@version 版本表与报错。上一条 `v3.26.128+9bcf6d7` —— 2026-11-30 **浏览器窗口空闲休眠**:它是独立 WKWebView(实测整树 +480MB),失焦满 30 分钟自动 close。上一条 `v3.26.127+ed762ad` —— 2026-11-30 **DOM 规模进诊断**:顶部显示 DOM 元素总数 + 停靠面板子树 + 图库卡片数,用来量化「面板开着」的真实成本(实测主窗口 29 节点却有 348MB WebKit malloc,大头在插件面板 DOM)。上一条 `v3.26.126+94d9952` —— 2026-11-30 **诊断增强**:新增 Rust app_memory_breakdown(逐进程 footprint + 分类 Dirty/Reclaimable),诊断页新增「内存拆解(分进程)」与「图片管线」(原生解码次数/峰值 + 缩略图磁盘 512/256/768 统计)。上一条 `v3.26.125+5d70782` —— 2026-11-30 **内存口径修正**:ps 的 RSS 会把每个 WebKit 子进程映射的共享框架各算一遍,四进程求和虚高 1.5~2 倍;改为 footprint(1) 的 phys_footprint(活动监视器同源),并只认比本进程更年轻的 WebKit 子进程。实测 WebContent footprint 653MB 中 dirty 仅 32MB、CG raster 1.7MB、Image IO 0 ⇒ 图片内存已压到底。上一条 `v3.26.124+a0526e7` —— 2026-11-30 **插件图片策略 v2**:宿主三层 ctx.images(thumb/preview/original/budget) + 原生解码闸门(并发 ≤2,>1024px ≤1);album 1.2.4 / promptlib 1.14.10 / batch-export 1.2.3 / annotate 1.20.9 / vectorize 0.6.2 / white-bg 1.2.2 / cutout 1.0.4 全部改走宿主小图;check-plugins-sync 增加图片策略守卫(warn)。上一条 `v3.26.123+309963c` —— 2026-11-30 **缩略图改原生生成**:WebKit 忽略 createImageBitmap 的 resize 选项,JS 生成缩略图要整幅解码 4K 原图(21MB/张),100 多张 ⇒ WebContent 1GB+;新增 Tauri 命令 img_thumbs(Rust image crate,按目标尺寸解码/编码),webview 只接触几十 KB 小图、原图永不进 WebKit 图片缓存。上一条 `v3.26.121+71fe162` —— 2026-11-30 **内存可观测性 + LOD 256 档**:新增 Rust 命令 app_memory_tree_mb(Windows Toolhelp32 / mac ps 建树)→ 诊断页「进程实测 XXX MB」,内存护栏优先用它;createImageBitmap 改 resizeWidth 在解码阶段降采样;新增 256 小档缩略图(纯内存)按 need 分档;macOS 的 WKWebView 子进程按 etime(±180s) 认领,避免把 Safari 算进来。上一条 `v3.26.120+eaf2512` —— 2026-11-30 **图库面板开一次涨 200MB**:`gallery-sync.thumbFor` 原先让宫格每张图都过 `displayThumbOf`,给每张 mint 一个 objectURL 并进 `displayThumbs`(300 上限);关面板后 URL 仍被缓存持有、解码位图不释放。现改为直接吃磁盘 320 缩略图(~20KB data URL)、不过 displayThumbOf;插件 gallery 1.9.6→1.9.7:卡片缓存 400→60 且淘汰时显式摘 `<img src>`。上一条 `v3.26.119+db55d45` —— 2026-11-30 **诊断修复**:三处导出调用点写的 `window.__IWB_SAVE_BLOB__` 从未定义,桌面端「导出诊断 JSON / 导出节点组」必然抛错,已统一走顶层 `wSaveBlob`;`procEstMB` 的解码位图改按 min(自然尺寸, 渲染尺寸×dpr) 累加(原按 512²×4 低报 3~4 倍);「估算进程」改称「画布估算」并注明不含宿主进程;读不出的旧 `{__cache}` 引用按 key 记住失败、本会话不再重试,诊断新增「失效引用 N」;上一条 `v3.26.118+3944fc5` —— 2026-11-30 **内存第二批收敛**:显示缩略图 640→512(124 张图的解码位图 200MB→128MB)、缩略图生成并发 4→2、图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 迁出)
|
||||
@@ -22,7 +22,7 @@
|
||||
- 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob_<hash>_<len>`** (A) `app.js:2143`;`{__cache}`(Cache Storage)为兜底;\`ref_\`(`app.js` 内定义的 `IDB_REF_PREFIX = 'ref_'`)为 legacy 形态 (A)。
|
||||
- 大图判定:`isBigDataUrl` = `data:` 且 `length > 3000` (A) `app.js:2018`;**画布保存保留阈值** `< 16384` 才原样保留 (A) `app.js:2182`。**两处阈值并存,含义不同**。
|
||||
- 单测是**源码契约测试**:`tests/` 目录共 **493** 处源码文本钉点(`source.includes` / `source.indexOf` / `/re/.test(source)`),分布在 **20** 个文件(其中 `iwb-v32-web-test.js` 一个就占 **407**)→ **结构性重构会先打红测试**。**该数字已由 `tests/source-text-ratchet-test.js` 的「只减不增」棘轮守门**(2026-10-20 起守卫范围从 1 个文件扩到全目录:新增任何一处源码文本钉点都会打红)。**2026-11-12 复算**(`npm run audit:pins`,v3.24.76):二分 STRUCT **417** / NAME **76**;形态 **POS 403 / NEG 87 / COUNT 3**;难度 **易 62 / 中 316 / 难 115**。钉点减法第一批(v3.24.72)把 **537 → 505**:8 条探针钉点改为「门禁内 spec 是否真的读该计数器」、5 条改为运行时断言(生产态 `window` 上无探针)、10 条改为 DOM 断言(质量档位禁用 / 传输页无三模式按钮 / 模型项 title)、4 条改为运行时对象断言(健康检查两域、策略对象冻结)、其余 9 条有同文件 DOM 等价断言或仅剩 NEG。第二批(v3.24.76)把 **505 → 493**:94-5~7 三条「多标签释放语义」(10 处正则)换成 `tests/iwb-tabs-release.spec.js` 的 3 条真 e2e,剩 1 条「消费方契约」(断言该 spec 在门禁内且 spec 源码真的读两个探针);另 2 条 `wPurgeIntent.add` 钉点改为读 `src/workspace-purge.js`。**这一批一换就查出 3 个真缺陷**(objectURL 从未释放 / 彻底删除留孤儿标签 · session / 刷新后误回收打开标签的图)—— 见 CHANGELOG v3.24.76。
|
||||
- `app.js` = 单 IIFE **8,860 行**(**双层预算**:绝对上限 8,860 / 占总源码 ≤ 40%,现 **25.8%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,454 行**(上限 **2,454**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **125** 个模块 / 25,540 行,`sourceModules` 125 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
|
||||
- `app.js` = 单 IIFE **9,519 行**(**双层预算**:绝对上限 9,529 / 占总源码 ≤ 40%,现 **26.4%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,710 行**(上限 **2,710**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **129** 个模块 / 26,546 行,`sourceModules` 129 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
|
||||
- 门禁:`npm run verify` = `verify:ci`(`build` → `node --check app.js` → `node --check dist/app.js` → `check-dist.js` → `lint`(ESLint 正确性规则,`src/` + `app.js`,P4-16a)→ `test:unit` → `test` → `test:facts`)+ `test:e2e` (A) `package.json`。
|
||||
|
||||
## 1.5 内存基线(2026-11-30,v3.26.115,Windows / WebView2 实测)
|
||||
@@ -192,7 +192,7 @@
|
||||
- 同一张图被 3 个节点引用、hydrate 成 3 个不同 objectURL 时,preview/display 缓存各自 miss → 重复解码(与 F2 相邻)。
|
||||
- **F10|`refs.genScheduler` 是桩** (A) → 未接线,暂无运行时影响(P3)。
|
||||
- **F11|已建但未接线的模块层(2026-10-17 接线审计;2026-10-18 复核更正)** (A)
|
||||
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**125 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
|
||||
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**129 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
|
||||
- **仅被测试引用(9 模块 + 2 导出)**:`canvas-domain`、`generation-retry`、`generation-service`、`runtime-recovery-runner`、`runtime-state-bridge`、`runtime-store`、`storage-reconcile`、`storage-result`、`workspace-service`;导出 `IWBStorageHealthFactory`、`IWBPluginHostFactory`。(`storage-result` 是**存储层共享结果类型**,被 6 个存储模块读取,**非死代码**;`runtime-store` 为状态模型 epic 地基。)
|
||||
- **app.js 零引用(1 模块 + 3 导出)**:模块 `generation-controller`;导出 `IWBRuntimeMetricsFactory`、`IWBStorageRuntimeFactory`、`IWBUIComponents`。`canvas-relations` 已随 `06cf211` 删除(本文档早前把它列为"唯一可删者",实际已删)。零引用证据 = `grep -rn "<名字>" .`(排除 `node_modules|dist|vendor|test-results`)**只命中其自身赋值行**。
|
||||
- **半接线 / 未接线**:`IWBRuntimeStateBridge` **无 app.js 引用(仅测试)**;`IWBRuntimeRunContext` **已接线**(`runNode` 读取运行上下文);`IWBGenerationController` 是完整但**从未被调用**的工厂;`ModularWorkspaceStore`(`app.js` 内)是 `storage-workspace` 的**预留接线 seam**(当前无下游使用,保留);`window.IWBImageFolder` 自注册后读回(装载路径)。
|
||||
@@ -208,7 +208,7 @@
|
||||
| `storage-reconcile` | 存储对账(`createReconciler`/`check`) | 内联对账 | 存储层收口 |
|
||||
| `runtime-recovery-runner` | 执行恢复候选(`candidate`/`valid`/`run`) | 内联恢复 | 断点恢复 |
|
||||
| `canvas-domain` | 画布域模型(`commit`/`updateNode`/`deleteNodes`…) | `CanvasStore` 那一套 | Workbench 解耦(P2-9) |
|
||||
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**104** 项)与 `sourceModules` 顺序(**125** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**108** 项)与 `sourceModules` 顺序(**129** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
|
||||
## 12. 易踩的坑
|
||||
|
||||
@@ -279,7 +279,7 @@
|
||||
|
||||
**信任模型(必须明示)**:形态 A 的插件是**可信代码**(与核心同权限、无沙箱);启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27 教训:前端开关一定可被绕过)。
|
||||
|
||||
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**104** 项)与 `sourceModules` 顺序(**125** 项);新增模块、新增耦合、新增 dev 探针都**必须有意重生成对应快照**(`IWB_WRITE_BOUNDARY_SNAPSHOT=1`)。契约与行为的可执行验证在 `tests/plugin-host-test.js`(宿主单测)与 `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 + `iwb-dev-probe`,不进 34 门禁)。
|
||||
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**108** 项)与 `sourceModules` 顺序(**129** 项);新增模块、新增耦合、新增 dev 探针都**必须有意重生成对应快照**(`IWB_WRITE_BOUNDARY_SNAPSHOT=1`)。契约与行为的可执行验证在 `tests/plugin-host-test.js`(宿主单测)与 `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 + `iwb-dev-probe`,不进 34 门禁)。
|
||||
|
||||
**关键陷阱**:`normalizeNodes`(现位于 `src/canvas-normalize.js`)会**静默丢弃**不在 `NODE_H` 里的节点类型 ⇒ 新增节点类型必须先登记 `NODE_H`,否则节点一刷新就消失(§13.27 规则三的同一失败模式)。
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# 域名边界(2026-12-03 用户裁定)
|
||||
|
||||
三个域名属于**两个互不干扰的项目**。桌面版的发布流程只允许碰后两个。
|
||||
|
||||
| 域名 | 归属 | 托管 | 允许谁改 |
|
||||
|---|---|---|---|
|
||||
| `iwb.maqiart.eu.org` | **网页版项目(独立)** | Cloudflare Pages(独立项目) | 只有网页版项目自己。桌面版发布流程**不得**改它的 DNS / Pages / 内容 / 重定向 |
|
||||
| `download.maqiart.eu.org` | 桌面版下载站 | NAS `/vol8/web/iwb-download` | 桌面版发布(`publish-update.sh` / `release.sh` / 手工 scp) |
|
||||
| `market.maqiart.eu.org` | 桌面版插件市场 | NAS `/vol8/web/iwb-market` | 桌面版插件发布(`gen-market.js` + scp) |
|
||||
|
||||
## 硬规则
|
||||
|
||||
- `iwb.maqiart.eu.org` 是网页版,**与桌面版无关**;即使它挂掉/522,也不要用桌面版站点去「接管」这个地址。
|
||||
- 发布脚本、Cloudflare 操作、DNS 改动,动手前先确认目标是上表里的哪个域名;不确定就别动。
|
||||
- 网页版与桌面版的代码/产物/插件清单各自独立,不要互相覆盖。
|
||||
|
||||
## 历史
|
||||
|
||||
- 2026-12-01:网页版退役期间,曾用 `CNAME → iwb-redirect-979.pages.dev` 把 `iwb.maqiart.eu.org` 301 到下载站。
|
||||
- 2026-12-03:用户恢复网页版访问,并明确「以后不要动这个地址、两个项目不要相互干扰」。本文件为长期约束。
|
||||
@@ -0,0 +1,69 @@
|
||||
# 图片读取与下载口径(2026-12-03 定稿)
|
||||
|
||||
> **这是规范**:同一张图,不管从输出节点、图库、任务队列还是预览打开/下载/复制,
|
||||
> **取源顺序与文件名只有一套**。新代码按本文写;`tests/image-download-contract-test.js` 会拦住已知的偏离写法。
|
||||
>
|
||||
> 背景与踩坑记录见 [`image-read-lessons-2026-12-03.md`](image-read-lessons-2026-12-03.md)。
|
||||
|
||||
## 0. 术语
|
||||
|
||||
| 词 | 含义 |
|
||||
|---|---|
|
||||
| 原图 | 用户要看的完整分辨率图片。桌面端 = `images/gallery/<文件>` 或 `origIdb` 字节 |
|
||||
| 缩略图 | 320px 级小图(`row.idb` / `images/thumbs/`),**只用于列表、宫格、占位** |
|
||||
| 图库行 | 输出索引里的一行(`f.name` / `f.url` / `f.orig` / `f.origIdb` / `f.idb`) |
|
||||
| 会话副本 | `IWBImageIngestView.localUrl`,本次运行内有效,重启即失效 |
|
||||
| 远程 URL | 生成结果上游地址(图床),会过期、跨域、慢 |
|
||||
|
||||
## 1. 取源顺序(唯一口径)
|
||||
|
||||
按顺序取,**拿到一层就停**:
|
||||
|
||||
1. **`origIdb`** —— 图库行写入的原图字节(新记录)
|
||||
2. **`images/gallery/<文件>`** —— 本地原图文件(老记录没有 `origIdb`;入口 `IWBStorageFile.galleryOriginalOf` / `galleryOriginalBlob`)
|
||||
3. **会话副本** —— `IWBImageIngestView.localUrl`(任务队列专用)
|
||||
4. **远程 URL** —— 仅「下载 / 插入画布」允许兜底
|
||||
5. **320 缩略图** —— 只做占位底图,**永远不当原图**
|
||||
|
||||
硬规则:
|
||||
|
||||
- **预览不许直连远程**:本地没有原图就提示「先下载」,不打开预览,也不把 320 缩略图放大冒充原图。
|
||||
- **下载必须本地优先**:`wResolveOutputSrc` 先 `origIdb` → 本地原图文件 → 数据 → 远程。
|
||||
- 缩略图可以「先出画面」,但 `ImagePreview` / 节点体必须在原图到达后替换掉它(现有的「先糊后清」逻辑)。
|
||||
- 「能显示 = 本地有图」是产品判据:显示不出来就是没落地,不是网络慢。
|
||||
|
||||
### 各场景落点
|
||||
|
||||
| 场景 | 入口 | 取源 |
|
||||
|---|---|---|
|
||||
| 任务队列预览 | `queue.preview` → `ImagePreview` | 本地原图;无则提示未下载 |
|
||||
| 图库预览 | `gallery.preview` → `ImagePreview` | `origIdb` → 本地原图文件 |
|
||||
| 输出节点双击 | `props.onPreview` → `ImagePreview` | 同上(条目带 `name` 时按行名读本地) |
|
||||
| 输出节点 ↓、预览下载、图库下载 | `wResolveOutputSrc` | 本地优先 |
|
||||
| 插件 `ctx.images.preview/thumb` | `wPluginPreview` | 已有分层(thumb/preview/original) |
|
||||
|
||||
## 2. 下载文件名
|
||||
|
||||
**一律用图库行名 `f.name`**(经 `wOutNameOf(url)` 按 url 查行)。
|
||||
|
||||
| 场景 | 文件名 |
|
||||
|---|---|
|
||||
| 图库卡片下载 | `f.name` |
|
||||
| 输出节点 ↓ | `wOutNameOf(url) \|\| 'image.png'` |
|
||||
| 预览「下载当前图片」 | 图库条目用 `entry.name`,其余 `wOutNameOf(url) \|\| 'image.png'` |
|
||||
| 输出节点批量下载 | `wOutNameOf(url) \|\| 'image-001.png'` |
|
||||
| 任务队列「下载」 | 落地到图库,不产生浏览器下载 |
|
||||
|
||||
禁止:给 `downloadUrl(...)` 传写死的业务文件名。`image.png` / `image-00N.png` 只允许作为「还没落地、没有行名」的兜底。
|
||||
|
||||
## 3. 相关入口(实现索引)
|
||||
|
||||
- `src/storage-file.js`:`galleryOriginalOf(row, max)`(预览,原生按尺寸解码、落 thumbs 缓存)、`galleryOriginalBlob(row)`(下载,原始字节,不重编码)
|
||||
- `app.js`:`wResolveOutputSrc`(下载取源)、`wOutNameOf`(命名)、`queue.preview`(任务队列预览)
|
||||
- `src/ui-canvas-view.js`:`ImagePreview` 统一解析 `{__gallery, name, origIdb, idb}` 条目
|
||||
- `src/ui-node-bodies.js`:输出节点下载 / 预览入口
|
||||
|
||||
## 4. 检查
|
||||
|
||||
- `node tests/image-download-contract-test.js`(已进 `npm run test:unit`)
|
||||
- 新增下载/预览入口时,先对照本表;守卫不覆盖的写法,**改守卫**再写代码。
|
||||
@@ -0,0 +1,47 @@
|
||||
# 图片本地读取改造 · 经验与踩坑(2026-12-03)
|
||||
|
||||
> 对应规范:[`image-read-and-download.md`](image-read-and-download.md)。本文只记「为什么」和踩过的坑,
|
||||
> 下次改图片读取/预览/下载前先看这里。
|
||||
|
||||
## 1. 老记录为什么会被「放大发糊」
|
||||
|
||||
- 图库行有两种原图形态:**新记录**写 `origIdb`(IndexedDB 字节);**老记录**只有磁盘文件 `images/gallery/<文件>`,索引里 `origIdb` 是空的。
|
||||
- 任务队列预览曾经按 `origIdb → idb → localUrl` 取源。老记录没有 `origIdb`,直接落 `idb` —— 那是 **320 缩略图**,全屏一放大必然糊。
|
||||
- 教训:**`idb` 永远是缩略图,不是原图**。任何「原图」路径都不允许读 `idb`。
|
||||
- 判定方法:新图清晰、老图糊,且糊得很均匀 → 先怀疑取到了 320 档。
|
||||
|
||||
## 2. 「本地有」不等于「IndexedDB 里有」
|
||||
|
||||
- 桌面端的权威原图是 `images/gallery` 的**文件**;`origIdb` 只是其中一种缓存形态。
|
||||
- 所以「本地优先」必须包含**按行名读磁盘**这一步(`galleryOriginalOf` / `galleryOriginalBlob`),否则老记录只能退远程或缩略图。
|
||||
- `assets` 的键约定:`out_orig_<name>`;行里 `origIdb` 为空时可以按这个约定回查。
|
||||
|
||||
## 3. 预览只读本地之后的产品语义
|
||||
|
||||
- 能显示 = 本地有图;显示不出来 = 没落地。
|
||||
- 本地没有原图时给提示「先下载」,**不要**偷偷回退远程 —— 否则用户以为图在本地,断网/过期就整片破图。
|
||||
- 缩略图只做「先糊后清」的底图,不能作为最终图。
|
||||
|
||||
## 4. 预览路径与缓存归属(容易踩内存坑)
|
||||
|
||||
- `galleryOriginalOf` 返回的 objectURL **归 storage 持有**(`thumbUrlCache`,不 revoke)。
|
||||
- `ImagePreview` 自己的 `urlsRef` 会在淘汰时 `URL.revokeObjectURL`;**不要把 storage 的 URL 塞进 `remember()`**,否则一处淘汰、另一处还在用 → 破图。
|
||||
- 反过来:`galleryOriginalBlob` 给的是原始字节,可以交给预览的下载/复制链路自行登记 URL。
|
||||
|
||||
## 5. 下载命名的坑
|
||||
|
||||
- 改之前:图库下载用行名 `gen_...png`,输出节点写死 `image.png`。同一张图两个名字,用户对不上。
|
||||
- 统一规则:**行名优先,未落地才回退**。新增下载入口一律走 `wOutNameOf(url)`。
|
||||
- 守卫 `tests/image-download-contract-test.js` 会拦「写死业务文件名 / 预览直连远程 / 把 idb 当原图」。
|
||||
|
||||
## 6. 任务队列页头被滚走 / 页脚被压(同日,相关布局坑)
|
||||
|
||||
- 现象一:筛选页签、页头随列表滚走。原因:整页容器和列表都在滚。
|
||||
- 现象二:列表行压在页脚说明上。原因:宿主滚动容器高度固定,插件根节点 `flex: column` 里的列表被压缩到 540px,但列表没设 `overflow`,内容溢出画在页脚上。
|
||||
- 修法:插件根 `.iwb-tq{height:100%}` + 列表 `.iwb-tq-list{overflow-y:auto}` —— 只有列表自己滚。
|
||||
- 教训:**「谁滚」只能有一个**;滚动容器里再放一个 `flex:1; min-height:0` 的子块,必须给它 `overflow`,否则内容会溢出到兄弟元素上。
|
||||
|
||||
## 7. 工程约束
|
||||
|
||||
- `app.js` 有行数棘轮(新能力优先落 `src/<domain>-*.js`);本次因下载命名 + 队列预览同期改,棘轮 9345→9354、Workbench 2686→2687,注释已写日期/差/原因。
|
||||
- 改完跑:`npm run build && node --check dist/app.js && npx eslint src app.js && npm run typecheck && npm run test:unit && npm run test:facts`。
|
||||
@@ -0,0 +1,120 @@
|
||||
# 桌面端「网页写法 → 原生」审计(2026-12-04)
|
||||
|
||||
> 用途:盘点仍依赖 WebView 网络/浏览器 API 的地方,判断哪些该换成 Rust(系统网络栈/原生解码),
|
||||
> 以及**为什么**。只做审计,不含实施。复查记录见最后一节(含对初版判断的更正)。
|
||||
|
||||
## 0. 现状数字(`grep` 统计,src + app.js)
|
||||
|
||||
| 项 | 数量 | 说明 |
|
||||
|---|---|---|
|
||||
| `fetch(` | 39 | 仍以 WebView 网络栈为主 |
|
||||
| `http.fetch` / `fetch_image_b64` | 4 | 已有的 Rust 取字节入口 |
|
||||
| `FileReader` | 17 | Blob → dataURL 的 base64 往返 |
|
||||
| `createImageBitmap` | 18 | WebView 内解码 |
|
||||
| `toBlob(` / `toDataURL(` | 10 | WebView 内编码 |
|
||||
| `XMLHttpRequest` | 0 | 已无 |
|
||||
|
||||
**关键前提**:Tauri 的 `tauri/http` 插件受 `capabilities` 域名白名单约束(目前只有 volces / aliyuncs / myqcloud / qiniucdn / cloudfront / googleusercontent / openai / oaistatic / blob.core.windows.net / 自有三个域名)。
|
||||
白名单外的主机(生成服务商 CDN、任意第三方图床)走 `http.fetch` 会直接失败。
|
||||
**自定义命令 `fetch_image_b64`(240 新增)不受白名单限制**,这是后续替换的正确入口。
|
||||
|
||||
## 1. P1:功能会被 CORS / 白名单卡住
|
||||
|
||||
| # | 位置 | 现状 | 影响 | 建议 |
|
||||
|---|---|---|---|---|
|
||||
| 1 | `src/image-remote-cache.js:30,67` | 远程参考图预热用 `fetch(url)` | 跨域失败 → 参考图永远不落本地(每次开画布重下;插件取图拿不到 localRef) | 改 `fetch_image_b64`,成功再 `wImgRefWrite` |
|
||||
| 2 | `src/image-display-thumb.js:63` | 远程图生成显示缩略图用 `fetch(v)` | 跨域失败 → 节点只能显示远程大图(渐进加载/过期破图) | Rust 取字节后用原生缩放 |
|
||||
| 3 | `src/ui-node-bodies.js:779` | 「上传到在线图库」前 `fetch(d.url)` 取字节 | 跨域失败 → 该图无法转在线链接 | Rust 取字节 |
|
||||
| 4 | `app.js:4860`(downloadUrl ③) | 兜底用 `wTauri.http.fetch` | **白名单外的主机兜底无效** | 换成 `fetch_image_b64` |
|
||||
| 5 | `app.js:2125`(storeOutputThumb 代理) | 同上 | 白名单外图床仍抓不到原图/缩略图 | 换成 `fetch_image_b64` |
|
||||
| 6 | `app.js:2315`(gallery-sync desktopFetch) | 同上 | 远程图库条目取原图受限 | 换成 `fetch_image_b64` |
|
||||
|
||||
## 2. P2:能工作,但顺序或实现不是最优
|
||||
|
||||
| # | 位置 | 现状 | 建议 |
|
||||
|---|---|---|---|
|
||||
| 7 | `app.js:2113` storeOutputThumb | 先 `fetch`(多半 CORS 失败)再走 Rust 代理 | 桌面端把 Rust 提到第一位,少一次必然失败的请求 |
|
||||
| 8 | `app.js:4795` downloadUrl | ①fetch → ②IDB → ③Rust → ④新标签 | 桌面端调整 ③ 到 ① 之前(对已知不可跨域的主机更快) |
|
||||
| 9 | `src/image-compress.js:197` `toMaxEdge` | OffscreenCanvas + `createImageBitmap` + `toBlob` | 桌面改走原生 `resizeDataUrl`(img_thumbs),Web 保留原路径 |
|
||||
| 10 | `app.js:2145/2164` 320 缩略图 | 用 `compressDataUrl`(WebView 解码) | 同上,原生缩放更省内存 |
|
||||
| 11 | `src/generation-provider-ping.js` | `fetch` + `no-cors` 兜底(已能工作) | Rust 能读到真实状态码/更准的延迟;可选 |
|
||||
| 12 | `src/runtime-download-auto.js:56` | 本地优先,取不到才 `fetch` | 兜底改 Rust,跨域图床也能自动保存 |
|
||||
|
||||
## 3. P3:架构/清洁项(不急着做)
|
||||
|
||||
| # | 位置 | 说明 |
|
||||
|---|---|---|
|
||||
| 13 | `src/storage-zip.js:79` `DecompressionStream` | 仅备份导入用;WebView2 支持,量大时再考虑 Rust 解压 |
|
||||
| 14 | `src/storage-zip.js:127` `wCreateStoreZip` | 备份导出用 STORE(不压缩)纯 JS 拼包;可选 Rust |
|
||||
| 15 | `app.js` `caches.*` / `__cache` 引用 | 桌面 Cache Storage 不是权威存储,老 `__cache` 读不出(已知 4 条坏引用);建议退役并迁 `__blob` |
|
||||
| 16 | `blob → dataURL`(17 处 FileReader) | base64 往返有 1.33× 内存放大;长期可让 Rust 直接落盘/给路径 |
|
||||
| 17 | `new Image()` 探测尺寸(5 处) | 小图/封面场景,收益低 |
|
||||
|
||||
## 4. 复查后确认「不需要动」的(初版误判,已更正)
|
||||
|
||||
| 位置 | 初判 | 复查结论 |
|
||||
|---|---|---|
|
||||
| `app.js:1866` imageFolderApi | P1 远程取图 | **网页版专用**:`if (wIsTauri()) return false`,桌面不走 |
|
||||
| `src/generation-provider-ping.js` | P1 会被 CORS 卡死 | 已有 `mode:'no-cors'` 兜底,功能正常;只降为 P2 优化 |
|
||||
| `navigator.clipboard.read` | P3 建议原生 | 已走 `clipboard-native.js`(Rust `clipboard_read_image`),无需处理 |
|
||||
| `sw.js` 注册 | P3 桌面无意义 | 已用 `wFileStoreOn()` 短路,无需处理 |
|
||||
| `downloadUrl` 整体 | P1 | 已有 Rust 兜底,只是顺序与白名单问题(见 P1-4) |
|
||||
|
||||
## 5. 补充发现(初版漏掉)
|
||||
|
||||
1. **白名单是隐藏坑**:`http.fetch` 不等于「系统网络栈全放行」。仓库里已有 3 处用它兜底(downloadUrl / storeOutputThumb / gallery-sync),对白名单外图床都无效;统一换 `fetch_image_b64` 才能真正兜住。
|
||||
2. **320 缩略图也在 WebView 里解码**(storeOutputThumb → compressDataUrl),不只是「插入画布缩档」;换原生后出图后的内存峰值会明显下降。
|
||||
3. **备份导出是 STORE 不压缩**(体积大、上传慢),但只在手动备份时发生,优先级低。
|
||||
4. **图片引用仍有两种形态并存**(`__blob` 与旧 `__cache`),排查成本高;建议在下次存储清理时统一。
|
||||
|
||||
## 6. 建议实施顺序
|
||||
|
||||
1. **P1-4/5/6**:把三处 `http.fetch` 换成 `fetch_image_b64`(改动小、立刻解决白名单外主机取不到图)。
|
||||
2. **P1-1/2/3**:远程参考图缓存、远程显示缩略图、上传取字节改 Rust。
|
||||
3. **P2-7/8**:downloadUrl / storeOutputThumb 顺序调整(体验:少一次失败等待)。
|
||||
4. **P2-9/10**:压缩/缩略图走原生(内存与 CPU 收益最大,但改动面也最大)。
|
||||
5. P3 按需。
|
||||
|
||||
风险与约束:
|
||||
- 每处都要保留 Web 兜底(`wIsTauri()` 分流),网页版不维护但代码不能炸。
|
||||
- `fetch_image_b64` 返回 base64,大图有 1.33× 放大;批量场景要考虑「Rust 直写临时文件」的后续演进。
|
||||
- 改完用「断网 + 白名单外图床」各验一次,避免只在自家 CDN 上通过。
|
||||
|
||||
## 7. 实施状态(2026-12-04 落地)
|
||||
|
||||
已完成:
|
||||
- P1-4/5/6:三处 `http.fetch` 全部替换为 `fetch_image_b64`(`wRustFetchBlob` 统一入口)。白名单外图床也能取字节。
|
||||
- P1-1/2/3:远程参考图缓存(image-remote-cache)、远程显示缩略图(image-display-thumb)、节点「上传到在线图库」取字节,均改为 Rust 优先、WebView fetch 兜底。
|
||||
- P2-7:storeOutputThumb 桌面端先走 Rust,再回退 fetch。
|
||||
- P2-8:downloadUrl 桌面端先走 Rust(0 步),再 fetch/IDB/新标签。
|
||||
- P2-10:出图后的 320 缩略图桌面端改用原生 `resizeDataUrl`(img_thumbs),失败回退 canvas 压缩。
|
||||
- P2-12:自动下载的远程兜底接入 Rust。
|
||||
|
||||
未做(附原因):
|
||||
- P2-9 插入画布缩档(`toMaxEdge`):JS 路径对 PNG 保持无损,原生 `img_thumbs` 固定输出 JPEG,直接替换会丢透明;需要原生支持 PNG 透传后再做。
|
||||
- P2-11 服务商测速:现有 `no-cors` 兜底已能工作;Rust 只能读到 `http-xxx` 错误串,拿不到真实状态码,收益有限,暂缓。
|
||||
- P3:`__cache` 退役、zip 解压/导出、base64 往返、`new Image()` 探测,留待后续清理轮。
|
||||
|
||||
验证:`image-download-contract` 新增 5 条守卫(不再出现 `http.fetch`、统一入口存在、三模块支持注入);单测全绿。
|
||||
|
||||
## 8. 文件版下载(2026-12-04,默认关闭)
|
||||
|
||||
- Rust 新增 §fetch_image_to(url, dst)§:reqwest 流式 chunk → 64KB 级写盘,失败删半成品;返回 bytes/mime/path。
|
||||
- 存储层新增 §putFileFrom(srcPath, {key,mime})§:同卷 rename、跨卷 copy+remove,然后登记 assets 并 flush。
|
||||
- ingest 新增文件通道:§useFile/fetchFile/writeFileRef§;开启时先走文件版,失败/关闭自动回退 base64 路径。
|
||||
- 开关:§localStorage['IWB_RUST_FILE']='1'§(默认关)。
|
||||
- 验证:单测 ⑮ 覆盖「文件通道不经过 fetchBytes」;cargo check 通过;默认关闭时行为不变。
|
||||
- 剩余:Windows 真机验证(大图、跨卷、权限、失败清理);稳定后再考虑翻默认;下载/复制可直接拷文件(后续)。
|
||||
|
||||
### 8.1 复查后的加固(同日)
|
||||
- Rust `fetch_image_to` 增加 `base` 参数:dst 必须落在资料目录内、拒绝 `..`(防插件/脚本写任意路径)。
|
||||
- 落盘改用 `tokio::fs` 异步写(不再用 std::fs 阻塞 async 运行时)。
|
||||
- 文件接管后按路径生成 768 缩略图并 prime,首帧不再整幅解码原图。
|
||||
- `maintain()` 增加 `cache/tmp` 清理(保留 24h)。
|
||||
- 设置保存白名单补 `rustFileDownload`,改设置不会把开关冲掉。
|
||||
|
||||
### 8.2 剩余项处理(同日)
|
||||
- 回退只做一次:文件版全部重试失败后重新入队跑 base64(`__baseFallback`),不再每个 attempt 双下载。
|
||||
- 引用 key 按 URL 去重(`imgblob_f<hash(url)>_<bytes>`),同一 URL 重下不会产生新文件。
|
||||
- 取消:Rust `cancel_fetch(req_id)` + 抓取循环每块检查;ingest `cancel()` 会通知中断并删半成品。
|
||||
- 跨卷 copy 仍整文件读一次(临时目录在资料目录内,通常走 rename),保留为已知边界。
|
||||
@@ -105,3 +105,10 @@ node scripts/gen-market.js && node scripts/gen-market-page.js
|
||||
- 插件版本独立于客户端版本:客户端 3.26.x 与插件 1.9.x/1.14.x 互不绑定。
|
||||
- 插件改动**不需要**重打客户端(桌面包不含插件);发完市场,用户重启客户端即生效。
|
||||
- 客户端需要新插件能力(新宿主 API)时,先在桌面仓实现并发布客户端,再升插件版本依赖它——顺序不能反。
|
||||
|
||||
## 8. 换行符与 SRI(2026-12-03 Windows 实测)
|
||||
|
||||
- 现象:Windows 构建机(`core.autocrlf=true`)出的包里,`plugin-style-source.*.js` 的 SRI 校验失败,WebView2 拒绝执行该插件;构建本身不报错。
|
||||
- 根因:插件产物是逐字拷进 dist 的,CRLF 让字节和 `plugins/index.json` 里记的哈希对不上;`git status` 看不出(text 归一化)。
|
||||
- 已修:`scripts/copy-plugins.js` 写 dist 时对 `.js/.css/.json/.html/.svg/.txt/.md` 统一转 LF;`scripts/check-dist.js` 新增「dist/plugins 逐条 vs index.json 哈希」校验(`verify:ci` 会跑)。
|
||||
- 以后新增「逐字拷贝」的文件类型,必须同时进 `TEXT_EXT` 或保持二进制,别让它带着平台换行进包。
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
## 5. 与构建机(work)协作
|
||||
|
||||
> **交付节奏(2026-12-02 用户明确)**:用户报问题后,先只做分析与方案,**不要立即改代码、不要构建任何版本(含 Windows 测试包)**;等用户明确说「开始/可以做」再动手。构建前必须得到确认。
|
||||
|
||||
> **分工红线(2026-12-02 用户明确)**:**所有代码修改只在 mac 侧执行**(mac 上负责实施的 agent)。
|
||||
> win 构建机只做「拉取指定 SHA → 构建/打包 → 回报路径/字节/sha256/FileVersion」这类流程性动作,
|
||||
> **不具备也不承担改代码的能力**;遇到需要改源码/测试/文档的情况,一律回报给 mac 侧处理,不许在 win 侧就地改。
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.184",
|
||||
"version": "3.26.249",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
@@ -10,7 +10,7 @@
|
||||
"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/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-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/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-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/gallery-sync-test.js && node tests/image-blob-store-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/clipboard-native-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/image-writeback-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/pluLine truncated
|
||||
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-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/album-task-graph-test.js && node tests/plugin-text-node-refs-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-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/gallery-sync-test.js && node tests/image-blob-store-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/clipboard-native-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/image-writeback-test.js && node tests/image-ingest-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/uiLine truncated
|
||||
"test:diagnostics": "node tests/runtime-diagnostics-hotpath-test.js",
|
||||
"test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js",
|
||||
"check:plugins": "node scripts/check-plugins-sync.js",
|
||||
|
||||
+30
-4
@@ -76,6 +76,28 @@
|
||||
svg.appendChild(p)
|
||||
return p
|
||||
}
|
||||
// 2026-12-03:卡片下载图标与输出面板同款(同一组 path / 线宽 / 14px)。
|
||||
// 之前是文本 '↓',字形随字体渲染,和宿主按钮对不齐。
|
||||
function dlGlyph () {
|
||||
var svg = document.createElementNS(SVG_NS, 'svg')
|
||||
svg.setAttribute('viewBox', '0 0 24 24')
|
||||
svg.setAttribute('width', '14')
|
||||
svg.setAttribute('height', '14')
|
||||
svg.setAttribute('fill', 'none')
|
||||
svg.setAttribute('stroke', 'currentColor')
|
||||
svg.setAttribute('stroke-width', '2')
|
||||
svg.setAttribute('stroke-linecap', 'round')
|
||||
svg.setAttribute('stroke-linejoin', 'round')
|
||||
svg.setAttribute('aria-hidden', 'true')
|
||||
svgPath(svg, 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4')
|
||||
var pl = document.createElementNS(SVG_NS, 'polyline')
|
||||
pl.setAttribute('points', '7 10 12 15 17 10')
|
||||
svg.appendChild(pl)
|
||||
var ln = document.createElementNS(SVG_NS, 'line')
|
||||
ln.setAttribute('x1', '12'); ln.setAttribute('x2', '12'); ln.setAttribute('y1', '15'); ln.setAttribute('y2', '3')
|
||||
svg.appendChild(ln)
|
||||
return svg
|
||||
}
|
||||
function sel (options, value) {
|
||||
var s = el('select', { class: 'iwb-input iwb-select-compact' })
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
@@ -578,12 +600,16 @@
|
||||
b.addEventListener('click', function (e) { e.stopPropagation(); fn() })
|
||||
return b
|
||||
}
|
||||
// v1.7.2:图片卡片上只留「下载」;插入仍可从顶部工具栏或右键菜单进入。
|
||||
acts.appendChild(act('下载', '下载到本地', function () { doDownload([it.name]) }))
|
||||
// 2026-12-02(用户裁定):卡片上的「下载」胶囊改成右下角圆形图标 —— 矮图不再被横条压住中心;
|
||||
// 只留图标不加文案(title/aria-label 兜底)。插入仍走顶部工具栏与右键菜单。
|
||||
var dlBtn = el('button', { class: 'iwb-gal-dl', title: '下载到本地', 'aria-label': '下载' }, dlGlyph())
|
||||
dlBtn.addEventListener('click', function (e) { e.stopPropagation(); doDownload([it.name]) })
|
||||
acts.appendChild(dlBtn)
|
||||
// 不要再改 class:定位样式挂在 .iwb-history-actions 上,改名会让按钮掉出卡片
|
||||
box.appendChild(acts)
|
||||
// 角标/勾选最后挂:不要 z-index(插件层级闸门禁止裸值),靠 DOM 顺序盖在图片上
|
||||
if (origBadge) box.appendChild(origBadge)
|
||||
if (on) box.appendChild(el('span', { class: 'iwb-history-check', title: '已选中' }))
|
||||
// 2026-12-02:选中只留外框,不再挂角标图标(用户裁定)
|
||||
box.__iwbItem = it
|
||||
box.__iwbBoot = boot
|
||||
nodeCache[it.name] = box
|
||||
@@ -849,7 +875,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.9.9',
|
||||
version: '1.9.12',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "gallery",
|
||||
"name": "图库",
|
||||
"version": "1.9.9",
|
||||
"version": "1.9.12",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"图库"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
|
||||
"styles.css": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4"
|
||||
"main.js": "017277118b96545cd7cae386b37dca9b23a44593f53e0e858aedf901b994a153",
|
||||
"styles.css": "d0479dad661370dfa23d85e4470c5885cbe38fb3b4de9097ad084c952e16d516"
|
||||
}
|
||||
}
|
||||
@@ -84,19 +84,28 @@
|
||||
min-height: 84px; padding: 8px; border-radius: 6px; border: 1px dashed var(--iwb-border);
|
||||
font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all;
|
||||
}
|
||||
/* v1.7.3:把「下载」做成卡片底部渐变的下载浮层(与输出节点同一套语义)。
|
||||
条本身 pointer-events:none,只有悬停后按钮可点,避免挡住卡片点击/双击预览。 */
|
||||
/* 2026-12-02(用户裁定):卡片下载从「底部横条」改为「右下角圆形图标」。
|
||||
—— 矮图(宽幅)不再被横条压住中心,除按钮外整张图都能点。
|
||||
尺寸/圆角/间距抽成 --iwb-dl-* 变量,宿主 style.css 用同名变量(同一套 token 口径,后续可提升到主题层)。 */
|
||||
.iwb-history-actions {
|
||||
position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px;
|
||||
padding: var(--iwb-space-16) var(--iwb-space-4) var(--iwb-space-4); border-radius: 0 0 6px 6px;
|
||||
background-image: linear-gradient(to top, rgba(0, 0, 0, .62), transparent);
|
||||
position: absolute; right: var(--iwb-dl-inset, 8px); bottom: var(--iwb-dl-inset, 8px);
|
||||
display: flex; gap: var(--iwb-dl-gap, 4px);
|
||||
opacity: 0; transition: opacity var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out);
|
||||
pointer-events: none;
|
||||
}
|
||||
.iwb-history-embedded .iwb-history-item:hover .iwb-history-actions,
|
||||
.iwb-history-embedded .iwb-history-item:focus-within .iwb-history-actions { opacity: 1; pointer-events: auto; }
|
||||
.iwb-history-actions .iwb-btn-sm { padding: 2px 8px; font-size: 11px; border: none; background: var(--iwb-panel); color: var(--iwb-text); }
|
||||
.iwb-history-actions .iwb-btn-sm:hover { background: var(--iwb-panel); color: var(--iwb-brand); }
|
||||
/* 2026-12-03:与输出面板的圆钮完全对齐(26px / 无阴影 / SVG 14px / hover 只变底色)。 */
|
||||
.iwb-gal-dl {
|
||||
width: var(--iwb-dl-size, 26px); height: var(--iwb-dl-size, 26px);
|
||||
border-radius: var(--iwb-dl-radius, 999px);
|
||||
border: 1px solid var(--iwb-border2);
|
||||
background: var(--iwb-panel); color: var(--iwb-text);
|
||||
display: grid; place-items: center; padding: 0; cursor: pointer;
|
||||
font-size: var(--iwb-font-xs); line-height: 1;
|
||||
}
|
||||
.iwb-gal-dl svg { width: 14px; height: 14px; }
|
||||
.iwb-gal-dl:hover { background: var(--iwb-hover); color: var(--iwb-text); }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.iwb-history-embedded .iwb-history-item img { transition: none; }
|
||||
.iwb-history-embedded .iwb-history-item:hover img { transform: none; }
|
||||
|
||||
+17
-6
@@ -33,10 +33,10 @@
|
||||
"dir": "gallery",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.9.9",
|
||||
"version": "1.9.12",
|
||||
"files": {
|
||||
"main.js": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
|
||||
"styles.css": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4"
|
||||
"main.js": "017277118b96545cd7cae386b37dca9b23a44593f53e0e858aedf901b994a153",
|
||||
"styles.css": "d0479dad661370dfa23d85e4470c5885cbe38fb3b4de9097ad084c952e16d516"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -55,10 +55,10 @@
|
||||
"dir": "promptlib",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.15",
|
||||
"files": {
|
||||
"main.js": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
|
||||
"styles.css": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07"
|
||||
"main.js": "1358d8fb185577e67a928b4f79a15215c726fba53ade39860d1d2e299697e4cc",
|
||||
"styles.css": "a086b172cc8261b9f346e612b5f76cc085d5a1e486657d0c656cb87c675f238c"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -96,5 +96,16 @@
|
||||
"file": "plugin-xianyi-cutout.f7898f6e0fe9.js",
|
||||
"version": "1.0.4",
|
||||
"integrity": "sha256-94mPbg/p+Pikvfkc59u+U4wPJ+45jc46JTlNptVZIB0="
|
||||
},
|
||||
{
|
||||
"id": "taskqueue",
|
||||
"dir": "taskqueue",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.0.3",
|
||||
"files": {
|
||||
"main.js": "5f08181338062c9327f22e742be7e1e161a32d2e1bc41ae775a73e0e15b9f3a9",
|
||||
"styles.css": "4de612a1d25cb74a76f1888fdde32c0f617cc6ab5cc1a0f0bd6ff1adccc757e4"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -140,5 +140,16 @@
|
||||
"批量",
|
||||
"出图"
|
||||
]
|
||||
},
|
||||
"taskqueue": {
|
||||
"name": "任务队列",
|
||||
"desc": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
|
||||
"author": "official",
|
||||
"icon": "⏳",
|
||||
"color": "#eef6f6",
|
||||
"tags": [
|
||||
"工具",
|
||||
"记录"
|
||||
]
|
||||
}
|
||||
}
|
||||
+125
-38
@@ -85,7 +85,7 @@
|
||||
// 看不到 mount() 内部的函数(曾导致 "Can't find variable: fillTpl")。
|
||||
function detectVars (text) {
|
||||
var out = [], seen = {}
|
||||
var re = /\{([^{}\n]{1,60})\}/g, m
|
||||
var re = /\{([^{}]*)\}/g, m
|
||||
var str = String(text || '')
|
||||
while ((m = re.exec(str))) {
|
||||
var k = String(m[1] || '').trim()
|
||||
@@ -96,7 +96,7 @@
|
||||
return out
|
||||
}
|
||||
function fillTpl (tpl, vals) {
|
||||
return String(tpl || '').replace(/\{([^{}\n]{1,60})\}/g, function (all, k) {
|
||||
return String(tpl || '').replace(/\{([^{}]*)\}/g, function (all, k) {
|
||||
var key = String(k || '').trim()
|
||||
var v = (vals && Object.prototype.hasOwnProperty.call(vals, key)) ? String(vals[key] == null ? '' : vals[key]) : ''
|
||||
return v ? v : all
|
||||
@@ -125,27 +125,36 @@
|
||||
ta.style.overflowY = h > max + 1 ? 'auto' : 'hidden'
|
||||
}
|
||||
|
||||
// `{…}` 里能放多少字:v1.13.0 起占位符里放的是「内容」原文(用户裁定),所以这条上限
|
||||
// 按「一句内容」定,不再按短变量名定。**必须与下面所有正则里的 {1,60} 保持一致**:
|
||||
// 识别用 60、替换用更小的值,就会出现「识别到了但替换不到」⇒ 变量那段被 outputText 整段删掉。
|
||||
var KEY_MAX = 60
|
||||
// 变量「内容」框的最大高度(约 10 行后框内滚动)。下限由 rows=3 + CSS min-height 保证。
|
||||
// v1.13.0:用户要求「默认最高行数多加 4 行」⇒ 6 行(132px)→ 10 行(212px,行高 1.65×12px≈19.8)。
|
||||
var VDEF_MAX = 212
|
||||
// 内容 → 正文里的占位符键:`{…}` 只能单行、不超过 KEY_MAX 字、不含花括号。
|
||||
// v1.15.0(2026-12-03,用户裁定):正文 `{}` 里放「内容」原文,**不限长度、允许多行**;只禁花括号。
|
||||
// 下面 6 处正则必须保持一致(都以「最近的一对花括号」为界),否则会「识别到但替换不到」。
|
||||
// 变量「内容」框的最大高度(超出后框内滚动;面板本身可拖大)。
|
||||
var VDEF_MAX = 320
|
||||
// 节点输入框:默认最多 20 行(行高 1.5×12px=18px),超过后折叠,可「展开」看全;永不出滚动条。
|
||||
var NIN_LINES = 20
|
||||
var NIN_LINE_H = 18
|
||||
var NIN_MAX = NIN_LINES * NIN_LINE_H + 8
|
||||
// 空值只显示灰字提示时的上限:避免一条几千字的默认内容把刚放下的节点撑很高。
|
||||
var NIN_PH_MAX = 120
|
||||
// 内容 → 正文里的占位符键:任意长、可多行,但不能含花括号(边界会分不清)。
|
||||
// 不满足就返回空串 ⇒ 调用方保留原键(正文不跟随),绝不硬塞进 `{}` —— 塞进去会让变量
|
||||
// 直接识别不到,下次 sync 就把它从变量列表里清掉,用户刚写的内容当场丢失。
|
||||
function contentKeyOf (s) {
|
||||
// 2026-12-03(用户裁定):正文 `{}` 里就是内容原文,允许长文本与多行;只禁花括号(否则边界分不清)。
|
||||
var t = String(s || '').trim()
|
||||
if (!t || t.length > KEY_MAX) return ''
|
||||
if (/[{}\n\r]/.test(t)) return ''
|
||||
if (!t) return ''
|
||||
if (/[{}]/.test(t)) return ''
|
||||
return t
|
||||
}
|
||||
|
||||
// 提交给下游/生图的文本:填完变量后,把未填的 {占位} 从输出里剔除(只在编辑器里展示)。
|
||||
function outputText (tpl, vals) {
|
||||
var s = fillTpl(tpl, vals)
|
||||
return s.replace(/[{][^{}]{1,60}[}]/g, ' ').replace(/[ ]{2,}/g, ' ').trim()
|
||||
// 2026-12-03:先剔除「没有值」的占位,再填值 —— 填完不再扫花括号,避免把值里的 {} 一起删掉。
|
||||
var s = String(tpl || '').replace(/\{([^{}]*)\}/g, function (all, k) {
|
||||
var key = String(k || '').trim()
|
||||
var has = !!(vals && Object.prototype.hasOwnProperty.call(vals, key) && String(vals[key] == null ? '' : vals[key]) !== '')
|
||||
return has ? all : ' '
|
||||
})
|
||||
return fillTpl(s, vals).replace(/[ ]{2,}/g, ' ').trim()
|
||||
}
|
||||
|
||||
function varsOf (p) {
|
||||
@@ -1143,9 +1152,17 @@
|
||||
function up () { global.removeEventListener('pointermove', mv); global.removeEventListener('pointerup', up); saveDlg(key, live) }
|
||||
global.addEventListener('pointermove', mv); global.addEventListener('pointerup', up)
|
||||
})
|
||||
mask.addEventListener('pointerdown', function (e) { if (e.target === mask) close() })
|
||||
// 2026-12-03:关闭前给调用方一次拦截机会(编辑词例用它做「未保存确认」);
|
||||
// maskClose:false 时点空白不关闭(防止误点丢编辑)。
|
||||
function requestClose () {
|
||||
if (typeof opts.confirmClose === 'function') {
|
||||
try { opts.confirmClose(close); return } catch (e) { /* 回退到直接关闭 */ }
|
||||
}
|
||||
close()
|
||||
}
|
||||
mask.addEventListener('pointerdown', function (e) { if (opts.maskClose !== false && e.target === mask) requestClose() })
|
||||
function onKey (e) {
|
||||
if (e.key === 'Escape') { e.stopPropagation(); close() } else if ((e.metaKey || e.ctrlKey) && e.key === 'Enter' && opts.onSaveKey) { e.preventDefault(); opts.onSaveKey() }
|
||||
if (e.key === 'Escape') { e.stopPropagation(); requestClose() } else if ((e.metaKey || e.ctrlKey) && e.key === 'Enter' && opts.onSaveKey) { e.preventDefault(); opts.onSaveKey() }
|
||||
}
|
||||
function close () {
|
||||
saveDlg(key, live)
|
||||
@@ -1164,7 +1181,7 @@
|
||||
// label = 变量名称:只影响节点左栏显示(最多 4 字,超出省略),空则显示 key
|
||||
// def = 内容:正文里 `{}` 里的那段字,也是节点输入框留空时真正传给下游的值
|
||||
// desc = 说明:可选,填了就优先于内容作为节点输入框的灰字提示
|
||||
// 约束:`{}` 里不能换行、不能超过 KEY_MAX(60) 字。不满足时正文保留原键并在摘要里提示,
|
||||
// 约束:`{}` 里不能含花括号。不满足时正文保留原键并在摘要里提示,
|
||||
// 绝不硬塞 —— 塞进去变量就识别不到了,下次 sync 会把它从列表里清掉,内容当场丢失。
|
||||
// 收起态只留一行「名称 + 内容字数」,展开出现名称/内容/说明;允许多个同时展开。
|
||||
function makeVarsEditor (text, initial, onTextChange, opts) {
|
||||
@@ -1202,8 +1219,9 @@
|
||||
// 摘要:内容字数 + 说明 + 「正文未同步」告警(内容塞不进 `{}` 时才会出现)。
|
||||
function summaryOf (v) {
|
||||
var body = bodyOf(v)
|
||||
var base = (body ? '内容 ' + body.length + ' 字' : '未填内容') + (v.desc ? ' · 有说明' : '')
|
||||
if (v.def && !contentKeyOf(v.def)) base += ' · 正文未同步(需单行 ≤' + KEY_MAX + ' 字)'
|
||||
var nl = body ? body.split('\n').length : 0
|
||||
var base = (body ? '内容 ' + body.length + ' 字' + (nl > 1 ? ' · ' + nl + ' 行' : '') : '未填内容') + (v.desc ? ' · 有说明' : '')
|
||||
if (v.def && !contentKeyOf(v.def)) base += ' · 内容里不能有 { }(无法同步到正文)'
|
||||
return base
|
||||
}
|
||||
function field (labelText, ctrl) {
|
||||
@@ -1247,7 +1265,7 @@
|
||||
// v1.12.3:内容固定从 3 行起步(rows=3),可继续长到 VDEF_MAX 后框内滚动。
|
||||
// 上一版 rows=1 且「append 之前」就 autoGrowArea ⇒ 元素不在文档里时 scrollHeight 读不到,
|
||||
// 高度被 CSS min-height 兜成一行,长文案在框里被裁切(用户截图里就是这个现象)。
|
||||
var area = el('textarea', { class: 'iwb-input iwb-plp-vdef', rows: '3', placeholder: '内容(单行 ≤' + KEY_MAX + ' 字)' })
|
||||
var area = el('textarea', { class: 'iwb-input iwb-plp-vdef', rows: '3', placeholder: '内容(可多行,不能含 { })' })
|
||||
area.value = bodyOf(v)
|
||||
area.addEventListener('input', function () {
|
||||
v.def = area.value
|
||||
@@ -1744,7 +1762,7 @@
|
||||
var txt = el('div', { class: 'iwb-plp-dtext' })
|
||||
;(function paintText () {
|
||||
var str = String(p.text || '')
|
||||
var re = /[{]([^{}]{1,60})[}]/g, last = 0, m
|
||||
var re = /[{]([^{}]*)[}]/g, last = 0, m
|
||||
while ((m = re.exec(str))) {
|
||||
if (m.index > last) txt.appendChild(document.createTextNode(str.slice(last, m.index)))
|
||||
txt.appendChild(el('span', { class: 'iwb-plp-dvar', text: m[0] }))
|
||||
@@ -1809,11 +1827,17 @@
|
||||
var cancelBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '取消' })
|
||||
var saveBtn = el('button', { class: 'iwb-btn iwb-btn-primary iwb-btn-sm', text: isNew ? '创建' : '保存' })
|
||||
var dirty = false
|
||||
function closeWithGuard (done) {
|
||||
if (!dirty) { done(); return }
|
||||
ask('有未保存的修改,确定放弃?', { title: '放弃修改', okText: '放弃' }).then(function (ok) { if (ok) done() })
|
||||
}
|
||||
openDialog({
|
||||
key: 'edit',
|
||||
title: isNew ? '新建词例' : '编辑词例',
|
||||
width: 880, height: 640,
|
||||
actions: [cancelBtn, saveBtn],
|
||||
maskClose: false,
|
||||
confirmClose: function (done) { closeWithGuard(done) },
|
||||
onSaveKey: function () { doSave() },
|
||||
build: function (bodyEl, footEl, close) {
|
||||
var left = el('div', { class: 'iwb-plp-eleft' })
|
||||
@@ -1898,7 +1922,7 @@
|
||||
function paintHl () {
|
||||
var v = textIn.value || ''
|
||||
hl.textContent = ''
|
||||
var re = /[{]([^{}]{1,60})[}]/g, last = 0, m
|
||||
var re = /[{]([^{}]*)[}]/g, last = 0, m
|
||||
while ((m = re.exec(v))) {
|
||||
if (m.index > last) hl.appendChild(document.createTextNode(v.slice(last, m.index)))
|
||||
hl.appendChild(el('span', { class: 'iwb-plp-hlvar', text: m[0] }))
|
||||
@@ -1938,7 +1962,7 @@
|
||||
var e = Math.min(Math.max(lastSel.e == null ? s : lastSel.e, s), v.length)
|
||||
var picked = s !== e ? String(v.slice(s, e)).trim() : ''
|
||||
// v1.13.0(用户裁定):`{}` 里放的就是内容原文 ⇒ 选中的原文直接当占位符。
|
||||
// 塞不进 `{}` 时才退到「变量N」:没选中、含换行、或超过 KEY_MAX 字。
|
||||
// 塞不进 `{}` 时才退到「变量N」:没选中,或选中的文字里带花括号。
|
||||
// (1.12.0 曾把长句一律改成变量N + 原文进内容,用户否掉了:正文该跟着内容走。)
|
||||
var embed = contentKeyOf(picked)
|
||||
var used = {}
|
||||
@@ -2017,7 +2041,9 @@
|
||||
}).catch(function () { saveBtn.disabled = false; notify('保存失败', 'err') })
|
||||
}
|
||||
saveBtn.addEventListener('click', doSave)
|
||||
cancelBtn.addEventListener('click', function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } })
|
||||
cancelBtn.addEventListener('click', function () {
|
||||
closeWithGuard(function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } })
|
||||
})
|
||||
dupBtn.addEventListener('click', function () {
|
||||
var c = collect()
|
||||
close()
|
||||
@@ -2244,7 +2270,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'promptlib',
|
||||
name: '提示词库',
|
||||
version: '1.14.11',
|
||||
version: '1.14.15',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite', 'nodeActions', 'commands'],
|
||||
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
|
||||
@@ -2361,7 +2387,7 @@
|
||||
if (st.title.textContent !== name) st.title.textContent = name
|
||||
var tpl = String(d.tpl || '')
|
||||
var defs = Array.isArray(d.vdefs) && d.vdefs.length ? d.vdefs : (function () {
|
||||
var out = [], seen = {}, re = /\{([^{}\n]{1,60})\}/g, m
|
||||
var out = [], seen = {}, re = /\{([^{}]*)\}/g, m
|
||||
while ((m = re.exec(tpl))) {
|
||||
var k = String(m[1] || '').trim()
|
||||
if (!k || seen[k]) continue
|
||||
@@ -2386,16 +2412,73 @@
|
||||
defs.forEach(function (v) {
|
||||
var row = el('div', { class: 'iwb-plp-nrow' })
|
||||
var nk = el('span', { class: 'iwb-plp-nk', text: v.label || v.key })
|
||||
nk.title = v.label || v.key
|
||||
nk.title = (v.label || v.key) + '(双击回填原内容)'
|
||||
row.appendChild(nk)
|
||||
// v1.12.0:单行 input → 自适应 textarea(rows=1 起,最多约 5 行后框内滚动)。
|
||||
// 以前长文案挤在 24px 单行框里,只能左右拖动看末尾。
|
||||
// v1.12.3:值默认为空(用户裁定);不填说明时用「内容」当灰字提示,与说明同一样式。
|
||||
// v1.12.0:单行 input → 自适应 textarea。
|
||||
// v1.15.0:节点上最多 20 行(NIN_MAX),超出折叠成「展开」,永不出滚动条;节点高度跟着内容走。
|
||||
var inp = el('textarea', { class: 'iwb-input iwb-plp-nin', rows: '1', placeholder: v.desc || v.def || ('填写 ' + (v.label || v.key)) })
|
||||
inp.value = String((d.vars && d.vars[v.key]) || '')
|
||||
inp.addEventListener('input', function () { autoGrowArea(inp, 96); scheduleUpdate(st, d) })
|
||||
// 失焦后重测:清空输入框时焦点在框内,placeholder 高度没量到,blur 时补一次
|
||||
inp.addEventListener('blur', function () { autoGrowArea(inp, 96) })
|
||||
var more = el('button', { class: 'iwb-plp-nmore', type: 'button' })
|
||||
more.style.display = 'none'
|
||||
if (!st.expanded) st.expanded = {}
|
||||
if (!st.refreshH) st.refreshH = {}
|
||||
var cell = el('div', { class: 'iwb-plp-ncell' }, inp, more)
|
||||
var refreshH = function () {
|
||||
var has = String(inp.value || '') !== ''
|
||||
// 空值的高度靠灰字提示撑:浏览器不把 placeholder 计入 scrollHeight,
|
||||
// 未聚焦时临时塞进 value 量一次再恢复(沿用旧 autoGrowArea 的做法,不打断输入法)。
|
||||
var restore = ''
|
||||
if (!has && (typeof document === 'undefined' || document.activeElement !== inp)) {
|
||||
var ph = ''
|
||||
try { ph = String(inp.getAttribute('placeholder') || '') } catch (e0) { ph = '' }
|
||||
if (ph) { restore = ph; inp.value = ph }
|
||||
}
|
||||
inp.style.height = 'auto'
|
||||
var full = Number(inp.scrollHeight) || 0
|
||||
if (restore) inp.value = ''
|
||||
var expanded = !!st.expanded[v.key]
|
||||
var max = has ? NIN_MAX : NIN_PH_MAX
|
||||
inp.style.height = Math.min(full, expanded ? full : max) + 'px'
|
||||
inp.style.overflowY = 'hidden'
|
||||
if (has && full > NIN_MAX) {
|
||||
more.style.display = ''
|
||||
more.textContent = expanded ? '收起' : ('展开(共 ' + String(inp.value || '').length + ' 字)')
|
||||
} else more.style.display = 'none'
|
||||
}
|
||||
// 宽度变化(拖对话框 / 改节点宽度 / 窗口缩放)时重测;只认宽度,避免高度变化自己触发自己。
|
||||
st.__lastW = st.__lastW || {}
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
try {
|
||||
var ro = new ResizeObserver(function () {
|
||||
var w = inp.clientWidth
|
||||
if (w === st.__lastW[v.key]) return
|
||||
st.__lastW[v.key] = w
|
||||
refreshH()
|
||||
})
|
||||
ro.observe(inp)
|
||||
} catch (eRO) { /* ignore */ }
|
||||
}
|
||||
st.refreshH[v.key] = refreshH
|
||||
more.addEventListener('pointerdown', function (e) { e.stopPropagation() })
|
||||
more.addEventListener('click', function (e) {
|
||||
e.preventDefault(); e.stopPropagation()
|
||||
st.expanded[v.key] = !st.expanded[v.key]
|
||||
refreshH()
|
||||
})
|
||||
// 双击左侧标题:把这条变量的「内容」回填进输入框(仅当输入框为空),方便接着改长文。
|
||||
nk.addEventListener('dblclick', function (e) {
|
||||
e.preventDefault(); e.stopPropagation()
|
||||
if (String(inp.value || '') !== '') return
|
||||
var def = st.defOf(v.key)
|
||||
if (!def) { notify('这条变量没有预设内容'); return }
|
||||
inp.value = def
|
||||
st.expanded[v.key] = true
|
||||
refreshH()
|
||||
try { inp.focus(); inp.setSelectionRange(inp.value.length, inp.value.length) } catch (err) { /* ignore */ }
|
||||
scheduleUpdate(st, d)
|
||||
})
|
||||
inp.addEventListener('input', function () { refreshH(); scheduleUpdate(st, d) })
|
||||
inp.addEventListener('blur', function () { refreshH() })
|
||||
// 宿主的可交互控件白名单是 input/select/button…(src/ui-node-card.js:281,不含 textarea)⇒
|
||||
// 不拦的话按住文本框拖选文字会把整个节点拖走。
|
||||
inp.addEventListener('pointerdown', function (e) {
|
||||
@@ -2408,11 +2491,14 @@
|
||||
if (inp.scrollHeight > inp.clientHeight + 1) e.stopPropagation()
|
||||
}, { passive: true })
|
||||
st.inputs[v.key] = inp
|
||||
row.appendChild(inp)
|
||||
row.appendChild(cell)
|
||||
st.vars.appendChild(row)
|
||||
// 必须 append 之后再量:脱离文档的元素 scrollHeight 不可靠(会量不到 placeholder 的折行)
|
||||
autoGrowArea(inp, 96)
|
||||
setTimeout(function () { autoGrowArea(inp, 96) }, 0)
|
||||
refreshH()
|
||||
setTimeout(refreshH, 0)
|
||||
// 字体/布局晚一拍才定下来:再补两次,避免「打开时偏矮、点一下才对」
|
||||
try { (typeof requestAnimationFrame === 'function' ? requestAnimationFrame : function (f) { setTimeout(f, 16) })(refreshH) } catch (e1) { /* ignore */ }
|
||||
setTimeout(refreshH, 120)
|
||||
})
|
||||
if (!defs.length) st.vars.appendChild(el('div', { class: 'iwb-plp-nempty', text: '正文里没有 {变量}' }))
|
||||
try {
|
||||
@@ -2428,7 +2514,7 @@
|
||||
var inp = st.inputs[v.key]
|
||||
if (!inp) return
|
||||
var ph = v.desc || v.def || ('填写 ' + (v.label || v.key))
|
||||
if (inp.placeholder !== ph) { inp.placeholder = ph; autoGrowArea(inp, 96) }
|
||||
if (inp.placeholder !== ph) { inp.placeholder = ph; try { st.refreshH && st.refreshH[v.key] && st.refreshH[v.key]() } catch (e2) { /* ignore */ } }
|
||||
})
|
||||
|
||||
// 缩略图:封面可能是 dataURL,也可能是插件文件引用
|
||||
@@ -2471,7 +2557,8 @@
|
||||
}
|
||||
if (ctx.nodes && typeof ctx.nodes.register === 'function') {
|
||||
try {
|
||||
ctx.nodes.register({ id: 'ptpl', title: '提示词模板', defaults: { outKind: 'prompt' }, ports: { in: false, out: true }, height: 360, render: renderTplNode })
|
||||
// 2026-12-03(用户):补输入端口 —— 参考图节点可以接到模板上(宿主的 nodeRefsOf 会把入边 ref 透传给下游生图)。
|
||||
ctx.nodes.register({ id: 'ptpl', title: '提示词模板', defaults: { outKind: 'prompt' }, ports: { in: true, out: true }, height: 360, render: renderTplNode })
|
||||
} catch (e) {
|
||||
try { ctx.storage && ctx.storage.set('lastError', 'node:' + String((e && e.message) || e)) } catch (e2) { /* ignore */ }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "promptlib",
|
||||
"name": "提示词库",
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.15",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"提示词"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
|
||||
"styles.css": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07"
|
||||
"main.js": "1358d8fb185577e67a928b4f79a15215c726fba53ade39860d1d2e299697e4cc",
|
||||
"styles.css": "a086b172cc8261b9f346e612b5f76cc085d5a1e486657d0c656cb87c675f238c"
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@
|
||||
/* v1.12.1:标签列定宽(此前是 flex:0 0 auto,宽度跟着名称长短变 ⇒ 每个变量输入框左边缘错位)。
|
||||
v1.13.0:用户要求按 4 字定宽 ⇒ 56px(12px 字号 × 4 + 8px 余量)。超过 4 字的名称省略号截断,完整名称在 title 里。 */
|
||||
.iwb-plp-nrow{display:flex;align-items:flex-start;gap:6px;min-height:26px}
|
||||
.iwb-plp-nk{flex:0 0 56px;width:56px;max-width:56px;padding-top:4px;color:var(--iwb-text2,#5b6472);font-size: 12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.iwb-plp-nk{flex:0 0 56px;width:56px;max-width:56px;padding-top:4px;color:var(--iwb-text2,#5b6472);font-size: 12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none}
|
||||
.iwb-plp-nin{flex:1 1 auto;min-width:0;height:auto;min-height:24px;padding:2px 8px;line-height:1.5;font-size: 12px;resize:none;overflow-y:hidden}
|
||||
/* v1.14.2:参考图开关移到头部(与样式节点一致)——做成浅色药丸,不再是底部分隔行 */
|
||||
.iwb-plp-nref{display:inline-flex;align-items:center;gap:6px;margin-top:6px;padding:2px 8px;border-radius:6px;background:var(--iwb-layer,#f0f1f4);color:var(--iwb-text2,#4d5668);font-size: 12px;cursor:pointer;align-self:flex-start}
|
||||
@@ -605,3 +605,9 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
|
||||
.iwb-plp-dialog .iwb-plp-vrow2{padding:0 var(--iwb-space-4)}
|
||||
.iwb-plp-dialog .iwb-plp-vrow2:hover{background:var(--iwb-plugin-hover);border-radius:var(--iwb-radius-control, var(--iwb-radius-card))}
|
||||
.iwb-plp-vitem.is-open .iwb-plp-vcaret{color:var(--iwb-plp-accent, var(--iwb-text2))}
|
||||
|
||||
/* v1.15.0:节点变量输入框(20 行内自然长高,超出折叠;无滚动条) */
|
||||
.iwb-plp-ncell{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}
|
||||
.iwb-plp-ncell .iwb-plp-nin{width:100%;flex:0 0 auto}
|
||||
.iwb-plp-nmore{align-self:flex-start;border:0;background:transparent;color:var(--iwb-brand-text,#2f6bff);font-size:11px;line-height:1.4;padding:0 0 2px;cursor:pointer}
|
||||
.iwb-plp-nmore:hover{text-decoration:underline}
|
||||
@@ -0,0 +1,249 @@
|
||||
// iwb-plugin: 任务队列 —— 左栏整页
|
||||
//
|
||||
// 数据全部在宿主:账本(image-ingest-store)、下载/重试(image-ingest)、落地图库、定位节点、记录上限。
|
||||
// 插件只做视图与手动操作;禁用插件时宿主仍记账(上限内)。
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
if (!global.IWBPluginHost) return
|
||||
|
||||
var PAGE_ID = 'taskqueue-page'
|
||||
var TABS = [['all', '全部'], ['ok', '已完成'], ['down', '下载中'], ['fail', '失败'], ['only', '仅记录']]
|
||||
var STATUS = { ok: '已完成', down: '下载中', fail: '失败', only: '仅记录' }
|
||||
var LIMITS = [100, 200, 500, 1000, 2000, 5000]
|
||||
|
||||
function el (tag, attrs) {
|
||||
var node = document.createElement(tag)
|
||||
if (attrs) {
|
||||
for (var k in attrs) {
|
||||
if (!Object.prototype.hasOwnProperty.call(attrs, k)) continue
|
||||
var v = attrs[k]
|
||||
if (v === null || v === undefined) continue
|
||||
if (k === 'class') node.className = v
|
||||
else if (k === 'text') node.textContent = v
|
||||
else if (k === 'style') node.setAttribute('style', v)
|
||||
else node.setAttribute(k, v)
|
||||
}
|
||||
}
|
||||
for (var i = 2; i < arguments.length; i++) append(node, arguments[i])
|
||||
return node
|
||||
}
|
||||
function append (node, v) {
|
||||
if (v === null || v === undefined || v === false) return
|
||||
if (Array.isArray(v)) { for (var i = 0; i < v.length; i++) append(node, v[i]); return }
|
||||
node.appendChild(typeof v === 'string' ? document.createTextNode(v) : v)
|
||||
}
|
||||
function clear (node) { while (node.firstChild) node.removeChild(node.firstChild) }
|
||||
var SVG_NS = 'http://www.w3.org/2000/svg'
|
||||
function svgEl (tag, attrs) {
|
||||
var node = document.createElementNS(SVG_NS, tag)
|
||||
if (attrs) for (var k in attrs) if (Object.prototype.hasOwnProperty.call(attrs, k)) node.setAttribute(k, attrs[k])
|
||||
return node
|
||||
}
|
||||
function fmtTime (ms) {
|
||||
var d = new Date(Number(ms) || 0)
|
||||
if (!isFinite(d.getTime())) return ''
|
||||
var p = function (n) { return (n < 10 ? '0' : '') + n }
|
||||
return p(d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes())
|
||||
}
|
||||
function fmtSize (w, h) { return (w > 0 && h > 0) ? (w + '×' + h) : '' }
|
||||
function titleOf (it) {
|
||||
var m = it.meta || {}
|
||||
var base = String(m.promptText || m.prompt || '').trim()
|
||||
if (!base) return '历史记录 · ' + fmtTime(it.createdAt) + ' · #' + String(it.id || '').slice(-4)
|
||||
if (base.length > 24) base = base.slice(0, 24) + '…'
|
||||
if (m.variant) base += ' · 第 ' + m.variant + ' 张'
|
||||
return base
|
||||
}
|
||||
|
||||
function mount (host, ctx) {
|
||||
clear(host)
|
||||
if (!ctx || !ctx.queue) { host.textContent = '任务队列能力未就绪(请更新客户端)'; return function () {} }
|
||||
host.classList.add('iwb-plugin-node-body', 'iwb-tq')
|
||||
var state = { filter: 'all', limit: 500, items: [], total: 0, loading: true, msg: '' }
|
||||
var timer = 0
|
||||
var unsub = function () {}
|
||||
|
||||
var head = el('div', { class: 'iwb-tq-head' })
|
||||
var sub = el('div', { class: 'iwb-tq-sub', text: '全局生图记录 · 数据由宿主保存,插件关闭也继续记录' })
|
||||
var tools = el('div', { class: 'iwb-tq-tools' })
|
||||
var limitSel = el('select', { class: 'iwb-input iwb-tq-limit', 'aria-label': '记录上限' })
|
||||
for (var li = 0; li < LIMITS.length; li++) limitSel.appendChild(el('option', { value: String(LIMITS[li]), text: String(LIMITS[li]) + ' 条' }))
|
||||
var clearBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-ghost', text: '清空记录' })
|
||||
var refreshBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-ghost', text: '刷新' })
|
||||
tools.appendChild(el('span', { class: 'iwb-tq-tool-lbl', text: '记录上限' }))
|
||||
tools.appendChild(limitSel)
|
||||
tools.appendChild(clearBtn)
|
||||
tools.appendChild(refreshBtn)
|
||||
append(head, [sub, tools])
|
||||
|
||||
var tabs = el('div', { class: 'iwb-tq-tabs' })
|
||||
var tabEls = {}
|
||||
for (var ti = 0; ti < TABS.length; ti++) {
|
||||
var key = TABS[ti][0]
|
||||
var t = el('button', { class: 'iwb-tq-tab' + (key === 'all' ? ' on' : ''), 'data-k': key },
|
||||
el('span', { text: TABS[ti][1] }), el('span', { class: 'iwb-tq-n', text: '0' }))
|
||||
tabEls[key] = t
|
||||
tabs.appendChild(t)
|
||||
}
|
||||
var list = el('div', { class: 'iwb-tq-list' })
|
||||
var foot = el('div', { class: 'iwb-tq-foot' })
|
||||
// 2026-12-03:整页高度由宿主给满(.iwb-tq{height:100%}),只有列表自己滚;
|
||||
// 页头/页签/底部说明全程不动,也不会再出现列表撑出容器压住底部说明。
|
||||
append(host, [head, tabs, list, foot])
|
||||
|
||||
function setMsg (m) { state.msg = m || ''; renderFoot() }
|
||||
function renderFoot () {
|
||||
clear(foot)
|
||||
append(foot, [
|
||||
el('span', { text: '记录只保留链接与本机状态;上限内自动淘汰最旧记录,不影响 images/gallery 里的文件。' }),
|
||||
el('span', { class: 'iwb-tq-hint', text: state.msg || '点击「下载」= 落地到图库(图库会自动刷新出现)' }),
|
||||
])
|
||||
}
|
||||
|
||||
function setCounts (stats) {
|
||||
var s = stats || {}
|
||||
var map = { all: s.total || 0, ok: s.ok || 0, down: s.down || 0, fail: s.fail || 0, only: s.only || 0 }
|
||||
for (var k in tabEls) {
|
||||
var n = tabEls[k].querySelector('.iwb-tq-n')
|
||||
if (n) n.textContent = String(map[k] || 0)
|
||||
}
|
||||
}
|
||||
|
||||
function phEl (it) {
|
||||
return el('div', { class: 'iwb-tq-ph' },
|
||||
(function () { var s = svgEl('svg', { viewBox: '0 0 24 24', width: '20', height: '20', fill: 'none', stroke: 'currentColor', 'stroke-width': '1.6', 'aria-hidden': 'true' }); s.appendChild(svgEl('path', { d: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4' })); s.appendChild(svgEl('polyline', { points: '7 10 12 15 17 10' })); s.appendChild(svgEl('line', { x1: '12', x2: '12', y1: '15', y2: '3' })); return s })(),
|
||||
el('span', { text: it && it.kind === 'only' ? '仅记录' : '' }))
|
||||
}
|
||||
function thumbOf (it) {
|
||||
if (it.thumbUrl) {
|
||||
var img = el('img', { class: 'iwb-tq-img', src: it.thumbUrl, alt: '', draggable: 'false' })
|
||||
img.addEventListener('error', function () { try { if (img.parentNode) img.parentNode.replaceChild(phEl(it), img) } catch (e) { /* ignore */ } })
|
||||
return img
|
||||
}
|
||||
return phEl(it)
|
||||
}
|
||||
|
||||
function stuckMin (it) {
|
||||
if (!it || it.kind !== 'down' || it.status !== 'downloading') return 0
|
||||
var t = Number(it.updatedAt) || Number(it.createdAt) || 0
|
||||
if (!t) return 0
|
||||
var ms = Date.now() - t
|
||||
return ms > 60000 ? Math.floor(ms / 60000) : 0
|
||||
}
|
||||
function badgeOf (it) {
|
||||
if (it.kind === 'ok') return el('span', { class: 'iwb-tq-badge ' + (it.inGallery ? 'ok' : 'warn'), text: it.inGallery ? '已入图库' : '待入库' })
|
||||
if (it.kind === 'down') {
|
||||
var sm = stuckMin(it)
|
||||
if (sm) return el('span', { class: 'iwb-tq-badge warn', text: '可能卡住 · ' + sm + ' 分' })
|
||||
var label = it.status === 'queued' ? '排队中' : '下载中'
|
||||
if (it.status === 'downloading' && it.progress > 0) label += ' ' + Math.round(it.progress * 100) + '%'
|
||||
return el('span', { class: 'iwb-tq-badge', text: label })
|
||||
}
|
||||
if (it.kind === 'fail') return el('span', { class: 'iwb-tq-badge fail', text: '下载失败' })
|
||||
return el('span', { class: 'iwb-tq-badge warn', text: '未下载' })
|
||||
}
|
||||
|
||||
function btn (label, cls, onClick) {
|
||||
var b = el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn' + (cls ? ' ' + cls : ''), text: label })
|
||||
b.addEventListener('click', function (e) { e.stopPropagation(); onClick(b) })
|
||||
return b
|
||||
}
|
||||
|
||||
function rowOf (it) {
|
||||
var meta = it.meta || {}
|
||||
var thumb = el('div', { class: 'iwb-tq-thumb', title: '点击预览' }, thumbOf(it))
|
||||
thumb.addEventListener('click', function () { try { Promise.resolve(ctx.queue.preview(it.id)).catch(function () { setMsg('预览失败') }) } catch (e) { setMsg('预览失败') } })
|
||||
var line1 = el('div', { class: 'iwb-tq-line1' }, el('span', { class: 'iwb-tq-name', text: titleOf(it), title: String(meta.promptText || meta.prompt || '') }), badgeOf(it))
|
||||
var bits = []
|
||||
bits.push(meta.boardName || '未知画布')
|
||||
if (it.createdAt) bits.push(fmtTime(it.createdAt))
|
||||
var sz = fmtSize(it.w, it.h); if (sz) bits.push(sz)
|
||||
if (meta.model) bits.push(meta.model)
|
||||
var metaLine = el('div', { class: 'iwb-tq-meta', text: bits.join(' · ') })
|
||||
var main = el('div', { class: 'iwb-tq-main' }, line1, metaLine)
|
||||
if (it.kind === 'fail' && it.error) main.appendChild(el('div', { class: 'iwb-tq-err', text: it.error + (it.retries ? (' · 已重试 ' + it.retries + ' 次') : '') }))
|
||||
var acts = el('div', { class: 'iwb-tq-actions' })
|
||||
if (it.kind === 'ok' && it.inGallery) acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '已在图库', disabled: 'disabled' }))
|
||||
else if (it.kind === 'down' && !stuckMin(it)) acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '下载中…', disabled: 'disabled' }))
|
||||
else if (it.kind === 'down') acts.appendChild(btn('重新下载', 'iwb-tq-primary', function () { Promise.resolve(ctx.queue.restart(it.id)).then(function () { setMsg('已重新排队'); schedule() }).catch(function () { setMsg('重新下载失败') }) }))
|
||||
else acts.appendChild(btn('下载', 'iwb-tq-primary', function (b) { b.disabled = true; ctx.queue.land(it.id).then(function (r) { b.disabled = false; setMsg(r && r.already ? '已在图库' : (r && r.ok ? '已加入落地队列,图库会自动刷新' : '下载失败')) ; schedule() }).catch(function () { b.disabled = false; setMsg('下载失败') }) }))
|
||||
acts.appendChild(btn('复制原始链接', '', function () { ctx.queue.copyLink(it.id).then(function (r) { setMsg(r && r.ok ? '链接已复制' : '复制失败') }).catch(function () { setMsg('复制失败') }) }))
|
||||
var loc = btn('定位', '', function (b) { b.disabled = true; ctx.queue.locate(it.id).then(function (r) { b.disabled = false; setMsg(r && r.ok ? '已定位到节点' : ({ 'board-missing': '画布已删除', 'node-missing': '节点已删除', 'missing-meta': '没有定位信息' }[r && r.error] || '定位失败')) }).catch(function () { b.disabled = false; setMsg('定位失败') }) })
|
||||
if (!(meta.boardId && meta.nodeId)) { loc.disabled = true; loc.title = '没有画布/节点信息' }
|
||||
acts.appendChild(loc)
|
||||
return el('div', { class: 'iwb-tq-row ' + (it.kind || '') }, thumb, main, acts)
|
||||
}
|
||||
|
||||
function renderList () {
|
||||
clear(list)
|
||||
if (!state.items.length) {
|
||||
list.appendChild(el('div', { class: 'iwb-tq-empty', text: state.loading ? '加载中…' : '暂无记录 · 生成后会自动出现在这里' }))
|
||||
return
|
||||
}
|
||||
for (var i = 0; i < state.items.length; i++) list.appendChild(rowOf(state.items[i]))
|
||||
}
|
||||
|
||||
function load () {
|
||||
state.loading = true
|
||||
renderList()
|
||||
Promise.all([
|
||||
ctx.queue.list({ status: state.filter, limit: state.limit }),
|
||||
ctx.queue.stats(),
|
||||
ctx.queue.getLimit(),
|
||||
]).then(function (rs) {
|
||||
var r = rs[0] || {}
|
||||
state.items = Array.isArray(r.items) ? r.items : []
|
||||
state.total = Number(r.total) || state.items.length
|
||||
state.loading = false
|
||||
setCounts(rs[1])
|
||||
var lim = Number(rs[2]) || 500
|
||||
if (LIMITS.indexOf(lim) < 0) lim = 500
|
||||
limitSel.value = String(lim)
|
||||
state.limit = lim
|
||||
renderList()
|
||||
}).catch(function () {
|
||||
state.loading = false; state.items = []; renderList(); setMsg('加载失败')
|
||||
})
|
||||
}
|
||||
function schedule () { clearTimeout(timer); timer = setTimeout(load, 250) }
|
||||
|
||||
for (var k in tabEls) (function (key) {
|
||||
tabEls[key].addEventListener('click', function () {
|
||||
state.filter = key
|
||||
for (var kk in tabEls) tabEls[kk].classList.toggle('on', kk === key)
|
||||
load()
|
||||
})
|
||||
})(k)
|
||||
limitSel.addEventListener('change', function () {
|
||||
var n = Number(limitSel.value) || 500
|
||||
state.limit = n
|
||||
ctx.queue.setLimit(n).then(function () { setMsg('记录上限已改为 ' + n) ; load() }).catch(function () { setMsg('修改上限失败') })
|
||||
})
|
||||
clearBtn.addEventListener('click', function () {
|
||||
if (!global.confirm('清空已完成/失败的记录?不会删除图库文件。')) return
|
||||
ctx.queue.clear().then(function () { setMsg('已清空记录'); load() }).catch(function () { setMsg('清空失败') })
|
||||
})
|
||||
refreshBtn.addEventListener('click', function () { load() })
|
||||
|
||||
renderFoot()
|
||||
load()
|
||||
try { unsub = ctx.queue.onChanged(schedule) || function () {} } catch (e) { unsub = function () {} }
|
||||
return function () { clearTimeout(timer); try { unsub() } catch (e) { /* ignore */ } }
|
||||
}
|
||||
|
||||
global.IWBPluginHost.register({
|
||||
id: 'taskqueue',
|
||||
name: '任务队列',
|
||||
version: '1.0.3',
|
||||
apiVersion: 1,
|
||||
capabilities: ['pages', 'queue'],
|
||||
}, function (ctx) {
|
||||
ctx.ui.registerPage({
|
||||
id: PAGE_ID,
|
||||
title: '任务队列',
|
||||
icon: 'queue',
|
||||
mount: function (host) { return mount(host, ctx) },
|
||||
})
|
||||
return {}
|
||||
})
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"id": "taskqueue",
|
||||
"name": "任务队列",
|
||||
"version": "1.0.3",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"description": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
|
||||
"author": "official",
|
||||
"icon": "⏳",
|
||||
"tags": [
|
||||
"工具",
|
||||
"记录"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "5f08181338062c9327f22e742be7e1e161a32d2e1bc41ae775a73e0e15b9f3a9",
|
||||
"styles.css": "4de612a1d25cb74a76f1888fdde32c0f617cc6ab5cc1a0f0bd6ff1adccc757e4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/* 任务队列页(插件)—— 颜色/字号/圆角/间距全部走宿主 token;结构尺寸允许字面量。 */
|
||||
.iwb-tq { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: var(--iwb-space-10); }
|
||||
.iwb-tq-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--iwb-space-16); flex-wrap: nowrap; }
|
||||
.iwb-tq-sub { color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
|
||||
.iwb-tq-tools { display: flex; align-items: center; gap: var(--iwb-space-8); flex: 0 0 auto; flex-wrap: nowrap; }
|
||||
.iwb-tq-tool-lbl { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; }
|
||||
.iwb-tq-limit { height: 28px; padding: 0 var(--iwb-space-8); flex: 0 0 auto; width: auto; min-width: 76px; max-width: 96px; }
|
||||
.iwb-tq-ghost { background: var(--iwb-panel); white-space: nowrap; flex: 0 0 auto; }
|
||||
.iwb-tq-tabs { display: flex; gap: var(--iwb-space-4); border-bottom: 1px solid var(--iwb-border); }
|
||||
.iwb-tq-tab { display: inline-flex; align-items: center; gap: var(--iwb-space-6); padding: var(--iwb-space-6) var(--iwb-space-10); border: 0; background: transparent; color: var(--iwb-text2); font: inherit; font-size: var(--iwb-font-sm); border-radius: var(--iwb-radius-card) var(--iwb-radius-card) 0 0; cursor: pointer; }
|
||||
.iwb-tq-tab:hover { color: var(--iwb-text); background: var(--iwb-hover); }
|
||||
.iwb-tq-tab.on { color: var(--iwb-accent-on-surface); background: var(--iwb-accent-tint); }
|
||||
.iwb-tq-n { font-size: var(--iwb-font-2xs); line-height: 15px; padding: 0 var(--iwb-space-6); border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border); color: var(--iwb-text2); }
|
||||
.iwb-tq-tab.on .iwb-tq-n { border-color: var(--iwb-accent-on-surface); color: var(--iwb-accent-on-surface); background: transparent; }
|
||||
.iwb-tq-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; display: flex; flex-direction: column; gap: var(--iwb-space-8); }
|
||||
.iwb-tq-row { display: grid; grid-template-columns: 96px minmax(0,1fr) auto; gap: var(--iwb-space-12); align-items: center; padding: var(--iwb-space-10); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-card); }
|
||||
.iwb-tq-row:hover { border-color: var(--iwb-hover-border); }
|
||||
.iwb-tq-row.fail { border-color: var(--iwb-err-bd); background: color-mix(in srgb, var(--iwb-err) 9%, var(--iwb-panel)); }
|
||||
.iwb-tq-thumb { width: 96px; height: 64px; border-radius: var(--iwb-radius-control); border: 1px solid var(--iwb-border); background: var(--iwb-layer2); overflow: hidden; display: grid; place-items: center; cursor: zoom-in; position: relative; }
|
||||
.iwb-tq-img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||
.iwb-tq-ph { display: grid; place-items: center; gap: var(--iwb-space-2); color: var(--iwb-text2); font-size: var(--iwb-font-2xs); }
|
||||
.iwb-tq-ph svg { width: 20px; height: 20px; }
|
||||
.iwb-tq-main { min-width: 0; display: flex; flex-direction: column; gap: var(--iwb-space-4); }
|
||||
.iwb-tq-line1 { display: flex; align-items: center; gap: var(--iwb-space-8); min-width: 0; }
|
||||
.iwb-tq-name { font-size: var(--iwb-font-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.iwb-tq-badge { flex: 0 0 auto; height: 18px; line-height: 18px; padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border2); background: var(--iwb-layer); color: var(--iwb-text2); font-size: var(--iwb-font-2xs); }
|
||||
.iwb-tq-badge.ok { color: var(--iwb-ok); border-color: var(--iwb-ok-bd); background: var(--iwb-ok-bg); }
|
||||
.iwb-tq-badge.fail { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
|
||||
.iwb-tq-badge.only { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
|
||||
.iwb-tq-badge.warn { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
|
||||
.iwb-tq-meta { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.iwb-tq-err { font-size: var(--iwb-font-xs); color: var(--iwb-err); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.iwb-tq-actions { display: flex; align-items: center; gap: var(--iwb-space-6); flex-wrap: wrap; justify-content: flex-end; }
|
||||
.iwb-tq-btn { white-space: nowrap; }
|
||||
.iwb-tq-btn.iwb-tq-primary { background: var(--iwb-brand); color: var(--iwb-on-brand); border-color: var(--iwb-brand); }
|
||||
.iwb-tq-btn.iwb-tq-primary:hover { filter: brightness(1.05); }
|
||||
.iwb-tq-empty { padding: var(--iwb-space-32); text-align: center; color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
|
||||
.iwb-tq-foot { display: flex; justify-content: space-between; gap: var(--iwb-space-12); color: var(--iwb-text2); font-size: var(--iwb-font-xs); }
|
||||
.iwb-tq-hint { color: var(--iwb-text-dim); }
|
||||
@media (max-width: 900px) { .iwb-tq-row { grid-template-columns: 72px minmax(0,1fr); } .iwb-tq-actions { grid-column: 2; justify-content: flex-start; } .iwb-tq-thumb { width: 72px; height: 50px; } }
|
||||
@@ -73,6 +73,7 @@ const sourceModules = [
|
||||
'storage-outputs.js',
|
||||
'storage-backup.js',
|
||||
'storage-zip.js',
|
||||
'runtime-ref-upload.js',
|
||||
'plugin-promptlib-backup.js',
|
||||
'runtime-constants.js',
|
||||
'canvas-store.js',
|
||||
@@ -84,6 +85,7 @@ const sourceModules = [
|
||||
'ui-components.js',
|
||||
'plugin-data.js',
|
||||
'plugin-api-gallery.js',
|
||||
'plugin-api-queue.js',
|
||||
'plugin-api-grouplib.js',
|
||||
'plugin-api-promptlib.js',
|
||||
'plugin-host.js',
|
||||
@@ -108,6 +110,8 @@ const sourceModules = [
|
||||
'image-display-thumb.js',
|
||||
'image-cache-migrate.js',
|
||||
'image-writeback.js',
|
||||
'image-ingest.js',
|
||||
'image-ingest-store.js',
|
||||
'runtime-frame-probe.js',
|
||||
'image-remote-cache.js',
|
||||
'gallery-sync.js',
|
||||
|
||||
@@ -75,3 +75,34 @@ for (const f of ['favicon.svg', 'manifest.webmanifest', 'icon-192.png', 'icon-51
|
||||
}
|
||||
if (!fs.existsSync(path.join(dist, 'sw.js'))) fail('dist/sw.js 必须保留(更新检测 + 图片缓存)')
|
||||
pass('PWA 图标/manifest 未进 dist,index.html 无引用;sw.js 保留')
|
||||
|
||||
// 7. dist/plugins 逐条与 plugins/index.json 的哈希一致(2026-12-03)。
|
||||
// 动机:Windows 构建机 autocrlf 会把插件 .js 检出成 CRLF,SRI 对不上 → WebView2 拒绝执行该插件,
|
||||
// 而构建本身不报错(style-source 真实踩过)。这条在 verify:ci 里跑,跨平台都能拦住。
|
||||
const crypto = require('crypto')
|
||||
const pluginsDist = path.join(dist, 'plugins')
|
||||
const pluginsIdxPath = path.join(pluginsDist, 'index.json')
|
||||
if (!fs.existsSync(pluginsIdxPath)) fail('dist/plugins/index.json 不存在')
|
||||
const pidx = JSON.parse(fs.readFileSync(pluginsIdxPath, 'utf8'))
|
||||
const sha256of = (p) => crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex')
|
||||
let pin = 0
|
||||
for (const ent of (pidx || [])) {
|
||||
if (ent.file) {
|
||||
const p = path.join(pluginsDist, ent.file)
|
||||
if (!fs.existsSync(p)) fail('dist/plugins/' + ent.file + ' 不存在')
|
||||
if (ent.integrity) {
|
||||
const want = 'sha256-' + crypto.createHash('sha256').update(fs.readFileSync(p)).digest('base64')
|
||||
if (want !== ent.integrity) fail('dist/plugins/' + ent.file + ' 的 SRI 与 index.json 不一致(换行符/字节被改动?)')
|
||||
}
|
||||
if (ent.sha256 && sha256of(p) !== ent.sha256) fail('dist/plugins/' + ent.file + ' 的 sha256 与 index.json 不一致')
|
||||
pin++
|
||||
} else if (ent.dir) {
|
||||
for (const [rel, want] of Object.entries(ent.files || {})) {
|
||||
const p = path.join(pluginsDist, ent.dir, rel)
|
||||
if (!fs.existsSync(p)) fail('dist/plugins/' + ent.dir + '/' + rel + ' 不存在')
|
||||
if (sha256of(p) !== want) fail('dist/plugins/' + ent.dir + '/' + rel + ' 的 sha256 与 index.json 不一致(换行符/字节被改动?)')
|
||||
pin++
|
||||
}
|
||||
}
|
||||
}
|
||||
pass('dist/plugins 与 index.json 哈希一致(' + pin + ' 个文件)')
|
||||
+29
-2
@@ -16,9 +16,35 @@ if (!fs.existsSync(src)) {
|
||||
}
|
||||
fs.mkdirSync(dst, { recursive: true })
|
||||
|
||||
// 2026-12-03:文本类插件文件统一按 LF 写入 dist。
|
||||
// Windows 构建机 core.autocrlf=true 时,检出的 .js 是 CRLF;直接 copyFile 会让 dist 里的字节
|
||||
// 与 plugins/index.json 记的 SRI/sha256 对不上 → WebView2 拒绝执行(style-source 真实踩过)。
|
||||
const TEXT_EXT = new Set(['.js', '.css', '.json', '.html', '.svg', '.txt', '.md'])
|
||||
function copyNormalized(from, to) {
|
||||
if (TEXT_EXT.has(path.extname(from).toLowerCase())) {
|
||||
const buf = fs.readFileSync(from)
|
||||
const txt = buf.toString('utf8')
|
||||
if (txt.indexOf('\r\n') >= 0) {
|
||||
fs.writeFileSync(to, txt.replace(/\r\n/g, '\n'))
|
||||
return
|
||||
}
|
||||
}
|
||||
fs.copyFileSync(from, to)
|
||||
}
|
||||
function normalizeTree(dir) {
|
||||
for (const name of fs.readdirSync(dir)) {
|
||||
const abs = path.join(dir, name)
|
||||
const st = fs.statSync(abs)
|
||||
if (st.isDirectory()) { normalizeTree(abs); continue }
|
||||
if (!TEXT_EXT.has(path.extname(name).toLowerCase())) continue
|
||||
const txt = fs.readFileSync(abs, 'utf8')
|
||||
if (txt.indexOf('\r\n') >= 0) fs.writeFileSync(abs, txt.replace(/\r\n/g, '\n'))
|
||||
}
|
||||
}
|
||||
|
||||
let count = 0
|
||||
for (const name of fs.readdirSync(src)) {
|
||||
fs.copyFileSync(path.join(src, name), path.join(dst, name))
|
||||
copyNormalized(path.join(src, name), path.join(dst, name))
|
||||
count++
|
||||
}
|
||||
// v3.25.41(M1):目录插件 <plugins>/<id>/{manifest.json,main.js} 一并进包(应用按 /plugins/<id>/… 取)
|
||||
@@ -30,8 +56,9 @@ for (const name of fs.readdirSync(pluginsRoot)) {
|
||||
if (name === 'runtime' || name === 'local') continue
|
||||
if (!fs.existsSync(path.join(abs, 'manifest.json'))) continue
|
||||
fs.cpSync(abs, path.join(dst, name), { recursive: true })
|
||||
normalizeTree(path.join(dst, name))
|
||||
folders++
|
||||
}
|
||||
// 索引与插件文件必须同源同包:应用按 index.json 里的 filename / dir 去 /plugins/ 取
|
||||
fs.copyFileSync(path.join(root, 'plugins', 'index.json'), path.join(dst, 'index.json'))
|
||||
copyNormalized(path.join(root, 'plugins', 'index.json'), path.join(dst, 'index.json'))
|
||||
console.log('[copy-plugins] 已拷入 ' + count + ' 个文件 + ' + folders + ' 个目录插件 → dist/plugins/')
|
||||
@@ -10,7 +10,7 @@ const crypto = require('crypto')
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const srcRoot = process.argv[2] ? path.resolve(process.argv[2]) : path.resolve(root, '..', 'iwb-plugins-desktop')
|
||||
const outDir = path.join(root, 'plugins', 'runtime')
|
||||
const IDS = ['album', 'batch-export', 'blank-canvas', 'browser', 'gallery', 'grouplib', 'promptlib', 'image-annotate', 'image-vectorize', 'sticky', 'style-source', 'white-bg-800', 'xianyi-cutout']
|
||||
const IDS = ['album', 'batch-export', 'blank-canvas', 'browser', 'gallery', 'grouplib', 'promptlib', 'image-annotate', 'image-vectorize', 'sticky', 'style-source', 'white-bg-800', 'xianyi-cutout', 'taskqueue']
|
||||
// v3.25.41(M1):目录化插件试点 —— 这些 id 产出 <id>/{manifest.json,main.js},其余仍是单文件(双轨兼容)
|
||||
// ⚠️ 2026-11-20 修正:桌面包不随包发插件(scripts/strip-plugins.js),插件只能从市场装,
|
||||
// 而市场目前只支持单文件 ⇒ 目录形态暂不用于生产插件,等 M3(zip 安装)落地再启用。
|
||||
|
||||
+2
-2
@@ -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.183-mx5fvvkg">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.241-mx8nc0zp">
|
||||
<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.183</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.241</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.183 · 9.7 MB · .dmg<div class="hash">sha256 dc2d519f38ad5029…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.183_aarch64.dmg?h=dc2d519f38ad">下载</a>
|
||||
<div class="meta">版本 3.26.241 · 9.7 MB · .dmg<div class="hash">sha256 103dbe139978dbdd…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.241_aarch64.dmg?h=103dbe139978">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.26.183 · 10.1 MB · .dmg<div class="hash">sha256 d6decca171fcddfa…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.183_x64.dmg?h=d6decca171fc">下载</a>
|
||||
<div class="meta">版本 3.26.241 · 10.2 MB · .dmg<div class="hash">sha256 5d403a64b127212b…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.241_x64.dmg?h=5d403a64b127">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
<div class="meta">版本 3.26.183 · 5.3 MB · .exe<div class="hash">sha256 02d1264162eaed0d…</div></div>
|
||||
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.183_x64-setup.exe?h=02d1264162ea">下载</a>
|
||||
<div class="meta">版本 3.26.241 · 5.3 MB · .exe<div class="hash">sha256 e1f82479be4804ca…</div></div>
|
||||
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.241_x64-setup.exe?h=e1f82479be48">下载</a>
|
||||
</div>
|
||||
|
||||
<h2>系统要求</h2>
|
||||
@@ -97,6 +97,22 @@
|
||||
</ol>
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<div class="row">
|
||||
<div class="name">3.26.241<div class="hint">输出节点老图本地缩略图兜底</div></div>
|
||||
<div class="meta">2026-12-03<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.240<div class="hint">下载走系统网络栈;任务合并/预览/落地修复</div></div>
|
||||
<div class="meta">2026-12-03<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.238<div class="hint">任务队列页头/页签固定;图片读取/下载本地优先 + 命名统一图库行名</div></div>
|
||||
<div class="meta">2026-12-03<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.184</div>
|
||||
<div class="meta">2026-12-02<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.183</div>
|
||||
<div class="meta">2026-12-02<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
@@ -823,7 +839,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-12-02
|
||||
本页由 <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-12-03
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
|
||||
+11
-11
@@ -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.183-mx5fvvkg">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.241-mx8nc0zp">
|
||||
</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,20 +17,20 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.183</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.241</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.183-mx5fvvkg" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.241-mx8nc0zp" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.26.183 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.26.241 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.183</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 13 个插件</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.241</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 14 个插件</a>
|
||||
</div>
|
||||
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
|
||||
</div></section>
|
||||
@@ -79,7 +79,7 @@
|
||||
</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.9.9 · 官方</div></div></div>
|
||||
<div><div class="nm">图库</div><div class="ver">v1.9.12 · 官方</div></div></div>
|
||||
<div class="desc">右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)</div>
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">图库</span></div>
|
||||
</div>
|
||||
@@ -90,15 +90,15 @@
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">节点组</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top:22px"><a class="btn" href="/plugins/">查看全部 13 个插件</a></div>
|
||||
<div style="margin-top:22px"><a class="btn" href="/plugins/">查看全部 14 个插件</a></div>
|
||||
</div></section>
|
||||
|
||||
<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.183_aarch64.dmg?h=dc2d519f38ad"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 9.7 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.26.183_x64.dmg?h=d6decca171fc"><div class="n">macOS · Intel</div><div class="s">x86_64 · 10.1 MB · .dmg</div></a>
|
||||
<a href="/updates/windows-x86_64/image-workbench_3.26.183_x64-setup.exe?h=02d1264162ea"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.3 MB · .exe</div></a></div>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.241_aarch64.dmg?h=103dbe139978"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 9.7 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.26.241_x64.dmg?h=5d403a64b127"><div class="n">macOS · Intel</div><div class="s">x86_64 · 10.2 MB · .dmg</div></a>
|
||||
<a href="/updates/windows-x86_64/image-workbench_3.26.241_x64-setup.exe?h=e1f82479be48"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.3 MB · .exe</div></a></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>
|
||||
|
||||
+54
-20
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"updatedAt": "2026-12-02T00:54:41.997Z",
|
||||
"updatedAt": "2026-12-04T07:12:28.721Z",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "album",
|
||||
@@ -147,26 +147,26 @@
|
||||
"资源",
|
||||
"图库"
|
||||
],
|
||||
"version": "1.9.9",
|
||||
"version": "1.9.12",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/gallery-1.9.9.zip",
|
||||
"bundleSize": 57020,
|
||||
"bundleSha256": "ed3847edf88818f060c9d00e56cac32dcf797a0b97d08ae0c2cf1df4fb79e55c",
|
||||
"bundle": "plugins/gallery-1.9.12.zip",
|
||||
"bundleSize": 58788,
|
||||
"bundleSha256": "faf9e06c07e40b370867f9d28cfd0a69f6c9ddd77d7f8f4a7fdd6431a8da53e2",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "7041e7fba02511f2638e83b8087e9c724fc7dac2d63e0ffbc3a7c536e8ced33f",
|
||||
"size": 526
|
||||
"sha256": "2d93e891c43679101ecc86538fb5bb376fa64f8e8a098511b9e63446f5db8931",
|
||||
"size": 527
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
|
||||
"size": 47513
|
||||
"sha256": "017277118b96545cd7cae386b37dca9b23a44593f53e0e858aedf901b994a153",
|
||||
"size": 48954
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4",
|
||||
"size": 8671
|
||||
"sha256": "d0479dad661370dfa23d85e4470c5885cbe38fb3b4de9097ad084c952e16d516",
|
||||
"size": 8997
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -215,26 +215,26 @@
|
||||
"资源",
|
||||
"提示词"
|
||||
],
|
||||
"version": "1.14.11",
|
||||
"version": "1.14.15",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/promptlib-1.14.11.zip",
|
||||
"bundleSize": 190823,
|
||||
"bundleSha256": "fd6e1f0733757e35a2b202d018db5e3b9a418062c4555a2747d95e8bd6061d07",
|
||||
"bundle": "plugins/promptlib-1.14.15.zip",
|
||||
"bundleSize": 196105,
|
||||
"bundleSha256": "571be709b1f9e6da2e8f669319af4168da01c96102f41bb611a993e2238443de",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "5a14bdf3a2b3334e4c78a9dc2c0f8c90d253b7113724dc5daa534936ec1551d2",
|
||||
"sha256": "c81c302b5c824018e074b1da08c4e59b89f2c84e29393aceb63eaf77fa0476c9",
|
||||
"size": 542
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
|
||||
"size": 142646
|
||||
"sha256": "1358d8fb185577e67a928b4f79a15215c726fba53ade39860d1d2e299697e4cc",
|
||||
"size": 147420
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07",
|
||||
"size": 47325
|
||||
"sha256": "a086b172cc8261b9f346e612b5f76cc085d5a1e486657d0c656cb87c675f238c",
|
||||
"size": 47833
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -435,6 +435,40 @@
|
||||
"size": 4527,
|
||||
"sha256": "f7898f6e0fe9f8f8a4bdf91ce7dbbe538c0f27ee398dce3a25394da6d559201d",
|
||||
"integrity": "sha256-94mPbg/p+Pikvfkc59u+U4wPJ+45jc46JTlNptVZIB0="
|
||||
},
|
||||
{
|
||||
"id": "taskqueue",
|
||||
"name": "任务队列",
|
||||
"desc": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
|
||||
"author": "official",
|
||||
"icon": "⏳",
|
||||
"color": "#eef6f6",
|
||||
"tags": [
|
||||
"工具",
|
||||
"记录"
|
||||
],
|
||||
"version": "1.0.3",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/taskqueue-1.0.3.zip",
|
||||
"bundleSize": 19127,
|
||||
"bundleSha256": "c414710b3e1e7dac931a80f765dafd4e4bc8b0a8d3c4abfc54f84363cc010a47",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "18830aec4c11dd8f0e55e4c4bb431fd00130cb12920c4d176d9c80eb38032821",
|
||||
"size": 563
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "5f08181338062c9327f22e742be7e1e161a32d2e1bc41ae775a73e0e15b9f3a9",
|
||||
"size": 13189
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
"sha256": "4de612a1d25cb74a76f1888fdde32c0f617cc6ab5cc1a0f0bd6ff1adccc757e4",
|
||||
"size": 5065
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
+13
-5
@@ -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.183-mx5fvvkg">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.241-mx8nc0zp">
|
||||
</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,13 +16,13 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.183</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.241</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero" style="padding:64px 0 8px;text-align:left"><div class="wrap">
|
||||
<h1 style="font-size:40px;margin:0">插件市场</h1>
|
||||
<p class="sub" style="margin:14px 0 0;text-align:left;max-width:720px">共 13 个插件。安装方式:应用内 <b>设置 → 插件 → 浏览</b>,点「安装」后重启生效。</p>
|
||||
<p class="sub" style="margin:14px 0 0;text-align:left;max-width:720px">共 14 个插件。安装方式:应用内 <b>设置 → 插件 → 浏览</b>,点「安装」后重启生效。</p>
|
||||
</div></section>
|
||||
<section class="section" style="border-top:0;padding-top:24px"><div class="wrap">
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap;margin:0 0 18px" id="chips">
|
||||
@@ -47,6 +47,8 @@
|
||||
<button class="tag" data-tag="电商" style="cursor:pointer;padding:5px 12px">电商</button>
|
||||
<button class="tag" data-tag="抠图" style="cursor:pointer;padding:5px 12px">抠图</button>
|
||||
<button class="tag" data-tag="去背景" style="cursor:pointer;padding:5px 12px">去背景</button>
|
||||
<button class="tag" data-tag="工具" style="cursor:pointer;padding:5px 12px">工具</button>
|
||||
<button class="tag" data-tag="记录" style="cursor:pointer;padding:5px 12px">记录</button>
|
||||
</div>
|
||||
<input id="q" placeholder="搜索插件,例如:出图、抠图、矢量…" style="width:100%;max-width:420px;height:40px;padding:0 14px;border:1px solid var(--line);border-radius:10px;font-size:14px;outline:none;margin-bottom:22px">
|
||||
<div class="grid c3" id="list">
|
||||
@@ -76,7 +78,7 @@
|
||||
</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.9.9 · 官方</div></div></div>
|
||||
<div><div class="nm">图库</div><div class="ver">v1.9.12 · 官方</div></div></div>
|
||||
<div class="desc">右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)</div>
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">图库</span></div>
|
||||
</div>
|
||||
@@ -88,7 +90,7 @@
|
||||
</div>
|
||||
<div class="pcard" data-name="提示词库 promptlib 右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供) 资源 提示词" data-tags="资源,提示词">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">📖</span>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.14.11 · 官方</div></div></div>
|
||||
<div><div class="nm">提示词库</div><div class="ver">v1.14.15 · 官方</div></div></div>
|
||||
<div class="desc">右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)</div>
|
||||
<div class="tags"><span class="tag">资源</span><span class="tag">提示词</span></div>
|
||||
</div>
|
||||
@@ -128,6 +130,12 @@
|
||||
<div class="desc">接入鲜艺抠图模型的一键去背景</div>
|
||||
<div class="tags"><span class="tag">抠图</span><span class="tag">去背景</span></div>
|
||||
</div>
|
||||
<div class="pcard" data-name="任务队列 taskqueue 全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存) 工具 记录" data-tags="工具,记录">
|
||||
<div class="head"><span class="av" style="background:#eef6f6">⏳</span>
|
||||
<div><div class="nm">任务队列</div><div class="ver">v1.0.3 · 官方</div></div></div>
|
||||
<div class="desc">全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)</div>
|
||||
<div class="tags"><span class="tag">工具</span><span class="tag">记录</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="note" style="margin-top:26px">插件安装后会写进你的资料目录 <code>~/Documents/ImageWorkbench/plugins/</code>;卸载只删插件文件,不动画布与图库。</div>
|
||||
</div></section>
|
||||
|
||||
+113
-1
@@ -1,8 +1,120 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-12-02T01:11:24.514Z",
|
||||
"updatedAt": "2026-12-03T22:44:36.375Z",
|
||||
"releases": [
|
||||
{
|
||||
"version": "3.26.241",
|
||||
"date": "2026-12-03",
|
||||
"notes": "输出节点老图本地缩略图兜底",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.241_aarch64.dmg",
|
||||
"size": 10168165,
|
||||
"sha256": "103dbe139978dbddfad35db9dfd56734f1653aaa4b1e89ea12bf0070b8ebb3b4",
|
||||
"h": "103dbe139978",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.241_x64.dmg",
|
||||
"size": 10652808,
|
||||
"sha256": "5d403a64b127212bb6eeb8140ae2eded7000b7d3d7e84353dc4da584e7f67132",
|
||||
"h": "5d403a64b127",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.241_x64-setup.exe",
|
||||
"size": 5598298,
|
||||
"sha256": "e1f82479be4804ca8059d4b8d27248ce906fc9aa6a9175a478b18787e25ec8ca",
|
||||
"h": "e1f82479be48",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.240",
|
||||
"date": "2026-12-03",
|
||||
"notes": "下载走系统网络栈;任务合并/预览/落地修复",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.240_aarch64.dmg",
|
||||
"size": 10166296,
|
||||
"sha256": "9d816d2457ae36895696a687c86723ddbada417c88fefde7476be66e8d69629b",
|
||||
"h": "9d816d2457ae",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.240_x64.dmg",
|
||||
"size": 10653729,
|
||||
"sha256": "e4534595bb28c7111b400969627b39c5c7dbf3a279f48b825397053701ac70b4",
|
||||
"h": "e4534595bb28",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.240_x64-setup.exe",
|
||||
"size": 5602307,
|
||||
"sha256": "005bc2663a3c5cc14d2dc3b907fc25bbdebced5df51b75076bb577c1b435ae4f",
|
||||
"h": "005bc2663a3c",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.238",
|
||||
"date": "2026-12-03",
|
||||
"notes": "任务队列页头/页签固定;图片读取/下载本地优先 + 命名统一图库行名",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.238_aarch64.dmg",
|
||||
"size": 10152907,
|
||||
"sha256": "9ecea14ff71c7ef0fa91e28241f2a77ca5fea09dee0fa5e3e1024ee01edc0f8f",
|
||||
"h": "9ecea14ff71c",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.238_x64.dmg",
|
||||
"size": 10610501,
|
||||
"sha256": "0cef46585d874ba20522aeecbfe9b10e8e52fbf1ea0ec5a8261eb8a10a789595",
|
||||
"h": "0cef46585d87",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.238_x64-setup.exe",
|
||||
"size": 5601034,
|
||||
"sha256": "d77c051770a139d50aaa4e914763375abb85836d502b98cd13da8000aa9c3511",
|
||||
"h": "d77c051770a1",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.184",
|
||||
"date": "2026-12-02",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.184_aarch64.dmg",
|
||||
"size": 10145011,
|
||||
"sha256": "2358abf9f64ff17a4c3339f66cd4dd3bb17aea875b1af62335d329d5f32d8e80",
|
||||
"h": "2358abf9f64f",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.184_x64.dmg",
|
||||
"size": 10601813,
|
||||
"sha256": "24d1030ba35016995181b712e65feba818e556257560b716434bace21ee334fc",
|
||||
"h": "24d1030ba350",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.184_x64-setup.exe",
|
||||
"size": 5589965,
|
||||
"sha256": "d26a90dda86df474ce278751ec9c1f05916fd96f58c3f754538d987526507c92",
|
||||
"h": "d26a90dda86d",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.183",
|
||||
"date": "2026-12-02",
|
||||
|
||||
Generated
+2
-1
@@ -2014,7 +2014,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.184"
|
||||
version = "3.26.249"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
@@ -2034,6 +2034,7 @@ dependencies = [
|
||||
"tauri-plugin-notification",
|
||||
"tauri-plugin-single-instance",
|
||||
"tauri-plugin-updater",
|
||||
"tokio",
|
||||
"url",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.184"
|
||||
version = "3.26.249"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
@@ -27,6 +27,8 @@ log = "0.4"
|
||||
# 画布内嵌网页已下线(v3.25.27),但 get_window 仍要留着 —— save_geom/托盘/单实例都靠它,
|
||||
# 且它比 get_webview_window 更稳(后者一旦窗口里有非同名 webview 就返回 None,见 v3.25.26)。
|
||||
tauri = { version = "2.12.5", features = ["tray-icon", "image-png", "unstable"] }
|
||||
# 2026-12-04:文件版下载用 tokio::fs 异步写盘(避免阻塞 async 运行时)
|
||||
tokio = { version = "1", features = ["fs", "io-util", "time"] }
|
||||
url = "2"
|
||||
tauri-plugin-log = "2"
|
||||
tauri-plugin-dialog = "2"
|
||||
|
||||
+132
-1
@@ -292,6 +292,134 @@ fn do_thumbs(src: &str, jobs: &[ThumbJob]) -> Result<serde_json::Value, String>
|
||||
Ok(serde_json::json!({ "ok": true, "files": out }))
|
||||
}
|
||||
|
||||
// 2026-12-03(用户裁定):图片下载走系统网络栈。
|
||||
// 为什么:WebView 的 fetch 是跨域 XHR,图床/CDN 会限速、挂起或按防盗链策略直接不回包
|
||||
// (实测任务队列卡在 55% 不动);Rust 侧 reqwest 与浏览器导航同一栈,不受 CORS 约束。
|
||||
// 返回 base64 + mime + 字节数;不写盘、不解析图片,调用方自己决定落到哪里。
|
||||
// 2026-12-04:文件版下载的取消标记表(req_id → 标志)。cancel_fetch 置位,抓取循环每块检查一次。
|
||||
static FETCH_CANCELS: std::sync::OnceLock<std::sync::Mutex<std::collections::HashMap<String, std::sync::Arc<std::sync::atomic::AtomicBool>>>> = std::sync::OnceLock::new();
|
||||
fn fetch_cancels() -> &'static std::sync::Mutex<std::collections::HashMap<String, std::sync::Arc<std::sync::atomic::AtomicBool>>> {
|
||||
FETCH_CANCELS.get_or_init(|| std::sync::Mutex::new(std::collections::HashMap::new()))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn cancel_fetch(req_id: String) -> bool {
|
||||
if let Ok(map) = fetch_cancels().lock() {
|
||||
if let Some(flag) = map.get(&req_id) {
|
||||
flag.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
// 2026-12-04(文件版下载,默认关闭):流式写文件,避免整包 base64 过 IPC。
|
||||
// 目标路径由 JS 提供(资料目录下的 cache/tmp/),这里只负责抓字节 + 落盘;失败会删半成品。
|
||||
#[tauri::command]
|
||||
async fn fetch_image_to(url: String, dst: String, base: Option<String>, req_id: Option<String>) -> Result<serde_json::Value, String> {
|
||||
use tokio::io::AsyncWriteExt;
|
||||
let client = tauri_plugin_http::reqwest::Client::builder()
|
||||
.connect_timeout(std::time::Duration::from_secs(15))
|
||||
.timeout(std::time::Duration::from_secs(300))
|
||||
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36")
|
||||
.build()
|
||||
.map_err(|e| e.to_string())?;
|
||||
let mut resp = client.get(&url).send().await.map_err(|e| e.to_string())?;
|
||||
let status = resp.status();
|
||||
if !status.is_success() {
|
||||
return Ok(serde_json::json!({ "ok": false, "error": format!("http-{}", status.as_u16()) }));
|
||||
}
|
||||
let mime = resp
|
||||
.headers()
|
||||
.get(tauri_plugin_http::reqwest::header::CONTENT_TYPE)
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream")
|
||||
.to_string();
|
||||
let path = std::path::PathBuf::from(&dst);
|
||||
// 2026-12-04:dst 由 JS 传入,命令又会被插件调用 —— 限制在资料目录(base)内,并拒绝 ..。
|
||||
if dst.contains("..") {
|
||||
return Ok(serde_json::json!({ "ok": false, "error": "bad-path" }));
|
||||
}
|
||||
if let Some(b) = &base {
|
||||
let base_path = std::path::PathBuf::from(b);
|
||||
if !path.starts_with(&base_path) {
|
||||
return Ok(serde_json::json!({ "ok": false, "error": "path-outside-base" }));
|
||||
}
|
||||
}
|
||||
if let Some(parent) = path.parent() {
|
||||
tokio::fs::create_dir_all(parent).await.map_err(|e| e.to_string())?;
|
||||
}
|
||||
// 2026-12-04:改用 tokio::fs 异步写,避免 std::fs 阻塞 async 运行时。
|
||||
let mut file = tokio::fs::File::create(&path).await.map_err(|e| e.to_string())?;
|
||||
let cancel_flag = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
let req_key = req_id.unwrap_or_default();
|
||||
if !req_key.is_empty() {
|
||||
if let Ok(mut map) = fetch_cancels().lock() { map.insert(req_key.clone(), cancel_flag.clone()); }
|
||||
}
|
||||
let mut bytes: u64 = 0;
|
||||
loop {
|
||||
if cancel_flag.load(std::sync::atomic::Ordering::SeqCst) {
|
||||
let _ = tokio::fs::remove_file(&path).await;
|
||||
if !req_key.is_empty() { if let Ok(mut map) = fetch_cancels().lock() { map.remove(&req_key); } }
|
||||
return Ok(serde_json::json!({ "ok": false, "error": "cancelled" }));
|
||||
}
|
||||
// 2026-12-04:每 500ms 醒一次检查取消标记 —— 服务端吊住不回包时也能及时取消/退出,
|
||||
// 不再等满 300s 总超时。
|
||||
match tokio::time::timeout(std::time::Duration::from_millis(500), resp.chunk()).await {
|
||||
Err(_elapsed) => continue,
|
||||
Ok(Ok(Some(chunk))) => {
|
||||
if let Err(e) = file.write_all(&chunk).await {
|
||||
let _ = tokio::fs::remove_file(&path).await;
|
||||
return Ok(serde_json::json!({ "ok": false, "error": e.to_string() }));
|
||||
}
|
||||
bytes += chunk.len() as u64;
|
||||
}
|
||||
Ok(Ok(None)) => break,
|
||||
Ok(Err(e)) => {
|
||||
let _ = tokio::fs::remove_file(&path).await;
|
||||
return Ok(serde_json::json!({ "ok": false, "error": e.to_string() }));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Err(e) = file.flush().await {
|
||||
let _ = tokio::fs::remove_file(&path).await;
|
||||
return Ok(serde_json::json!({ "ok": false, "error": e.to_string() }));
|
||||
}
|
||||
if !req_key.is_empty() { if let Ok(mut map) = fetch_cancels().lock() { map.remove(&req_key); } }
|
||||
Ok(serde_json::json!({ "ok": true, "bytes": bytes, "mime": mime, "path": dst }))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn fetch_image_b64(url: String, referer: Option<String>) -> Result<serde_json::Value, String> {
|
||||
use base64::Engine as _;
|
||||
let client = tauri_plugin_http::reqwest::Client::builder()
|
||||
.connect_timeout(std::time::Duration::from_secs(15))
|
||||
.timeout(std::time::Duration::from_secs(120))
|
||||
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36")
|
||||
.build()
|
||||
.map_err(|e| e.to_string())?;
|
||||
let mut req = client.get(&url);
|
||||
if let Some(r) = referer {
|
||||
if !r.is_empty() {
|
||||
req = req.header(tauri_plugin_http::reqwest::header::REFERER, r);
|
||||
}
|
||||
}
|
||||
let resp = req.send().await.map_err(|e| e.to_string())?;
|
||||
let status = resp.status();
|
||||
if !status.is_success() {
|
||||
return Ok(serde_json::json!({ "ok": false, "error": format!("http-{}", status.as_u16()) }));
|
||||
}
|
||||
let mime = resp
|
||||
.headers()
|
||||
.get(tauri_plugin_http::reqwest::header::CONTENT_TYPE)
|
||||
.and_then(|v| v.to_str().ok())
|
||||
.unwrap_or("application/octet-stream")
|
||||
.to_string();
|
||||
let bytes = resp.bytes().await.map_err(|e| e.to_string())?;
|
||||
let b64 = base64::engine::general_purpose::STANDARD.encode(&bytes);
|
||||
Ok(serde_json::json!({ "ok": true, "mime": mime, "bytes": bytes.len(), "b64": b64 }))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn img_thumbs(src: String, jobs: Vec<ThumbJob>) -> Result<serde_json::Value, String> {
|
||||
tauri::async_runtime::spawn_blocking(move || do_thumbs(&src, &jobs))
|
||||
@@ -2055,7 +2183,10 @@ pub fn run() {
|
||||
app_memory_mb,
|
||||
app_memory_tree_mb,
|
||||
app_memory_breakdown,
|
||||
img_thumbs
|
||||
img_thumbs,
|
||||
fetch_image_b64,
|
||||
fetch_image_to,
|
||||
cancel_fetch
|
||||
])
|
||||
.setup(|app| {
|
||||
if cfg!(debug_assertions) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.184",
|
||||
"version": "3.26.249",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
+4
-1
@@ -123,6 +123,9 @@
|
||||
return out
|
||||
}
|
||||
|
||||
// 等当前归档队列排空(整批补漏前调用:避免最后一张的索引还在写就被误判成「未归档」)
|
||||
function whenIdle () { return queue.chain }
|
||||
|
||||
// 这条结果是否已经逐张归档过(整轮归档据此跳过,避免同一张图入两次库)
|
||||
function wasArchived (entry) {
|
||||
return !!(archived && entry && typeof entry === 'object' && archived.has(entry))
|
||||
@@ -247,7 +250,7 @@
|
||||
return ''
|
||||
}
|
||||
|
||||
return { archiveEntryNow, wasArchived, notifyChanged, localCopySrcOf, prepareInsert, gridSpots, nodeImageOf, thumbFor, thumbStats }
|
||||
return { archiveEntryNow, whenIdle, wasArchived, notifyChanged, localCopySrcOf, prepareInsert, gridSpots, nodeImageOf, thumbFor, thumbStats }
|
||||
}
|
||||
|
||||
let attached = null
|
||||
|
||||
@@ -184,9 +184,35 @@
|
||||
return groups.map((g, gi) => ({ sourceNodeId: n.id + '#b' + gi, ownerNodeId: n.id, title: String((n.data && n.data.title) || '').trim(), text: albumText, refNodes: g, diagnostics: diag }))
|
||||
}
|
||||
if (children.length) {
|
||||
return selfRefs.length
|
||||
? children.map((t) => ({ ...t, ownerNodeId: n.id, refNodes: dedupeTaskRefs((t.refNodes || []).concat(selfRefs)) }))
|
||||
: children.map((t) => ({ ...t, ownerNodeId: n.id }))
|
||||
// 2026-12-03:插件文本节点接了上游(例如给「提示词模板」接一张参考图)时,
|
||||
// 这里原来直接返回 children,把节点自己的 data.text 丢成空串 ⇒ 发出去只有图没有提示词,
|
||||
// 生图服务商报 400 INVALID_ARGUMENT。口径与上面的 prompt 分支一致:自己的文本优先,参考图取并集。
|
||||
const ownTitle = String((n.data && n.data.title) || '').trim()
|
||||
// 2026-12-03(用户):上游是「纯图片」或「图片 + 至多一段文本」时,合并成**一个**任务
|
||||
// (图1+图2 一起带,文本用节点自己的 > 上游那段);两段以上文本、相册/批量等多值源保持一子一任务。
|
||||
const refChildren = []
|
||||
const otherChildren = []
|
||||
for (const t of children) {
|
||||
const sn = graph.byId.get(t.sourceNodeId)
|
||||
if (sn && sn.type === 'ref') refChildren.push(t)
|
||||
else otherChildren.push(t)
|
||||
}
|
||||
const mergedRefs = dedupeTaskRefs(refChildren.flatMap((t) => t.refNodes || []))
|
||||
const mergedDiag = { cycles: children.flatMap((t) => (t.diagnostics && t.diagnostics.cycles) || []), disabledSources: [] }
|
||||
let base = children
|
||||
if (refChildren.length && !otherChildren.length) {
|
||||
base = [{ sourceNodeId: n.id, ownerNodeId: n.id, title: ownTitle, text: '', refNodes: mergedRefs, diagnostics: mergedDiag }]
|
||||
} else if (refChildren.length && otherChildren.length === 1) {
|
||||
const tc = otherChildren[0]
|
||||
base = [{ ...tc, sourceNodeId: own ? n.id : (tc.sourceNodeId || n.id), ownerNodeId: n.id, title: ownTitle || tc.title || '', text: String(tc.text || ''), refNodes: dedupeTaskRefs((tc.refNodes || []).concat(mergedRefs)), diagnostics: tc.diagnostics || mergedDiag }]
|
||||
}
|
||||
return base.map((t) => ({
|
||||
...t,
|
||||
ownerNodeId: n.id,
|
||||
title: ownTitle || t.title || '',
|
||||
text: own || t.text,
|
||||
refNodes: dedupeTaskRefs((t.refNodes || []).concat(selfRefs)),
|
||||
}))
|
||||
}
|
||||
return [{ sourceNodeId: n.id, ownerNodeId: n.id, text: own, refNodes: selfRefs, diagnostics: { cycles: [], disabledSources: [] } }]
|
||||
}
|
||||
|
||||
@@ -59,10 +59,17 @@
|
||||
// ① 优先路径:字节 → bitmap → 缩放 → WebP Blob → objectURL
|
||||
const runBitmap = async (key, v) => {
|
||||
try { window.IWBPerf && window.IWBPerf.tag('thumb') } catch (e) { /* ignore */ }
|
||||
if (typeof fetch !== 'function' || typeof createImageBitmap !== 'function') return false
|
||||
const resp = await fetch(v)
|
||||
if (!resp || !resp.ok) return false
|
||||
const blob = await resp.blob()
|
||||
if (typeof createImageBitmap !== 'function') return false
|
||||
// 2026-12-04(审计 P1):优先宿主注入的 Rust 取字节(远程图不再受 CORS 限制);失败再回退 fetch
|
||||
// 2026-12-04:只有远程地址才走 Rust;data:/blob: 直接走本地 fetch,避免每次多一次注定失败的 IPC。
|
||||
let blob = (typeof o.fetchBlob === 'function' && /^https?:\/\//i.test(String(v))) ? await o.fetchBlob(v) : null
|
||||
if (!blob || !blob.size) {
|
||||
if (typeof fetch !== 'function') return false
|
||||
const resp = await fetch(v)
|
||||
if (!resp || !resp.ok) return false
|
||||
blob = await resp.blob()
|
||||
}
|
||||
if (!blob || !blob.size) return false
|
||||
// v3.26.121(参考 Chromium 的 ImageDecodeCache 与 tldraw 的取图方式):
|
||||
// 先解码再缩放 = 整个原图(2016×2688 ≈ 21MB)先落地一次;改成在解码阶段就按目标宽度降采样,
|
||||
// 峰值内存与 CPU 都随 max 走,不随原图走。只给 resizeWidth(等比),纵向超出的再补一次 canvas 缩放。
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/* image-ingest-store.js —— 落地队列的持久化 + 状态视图(2026-12-02)
|
||||
*
|
||||
* 两个职责,都很薄:
|
||||
* 1) store:把 ingest 的记录存在 localStorage(只存元数据与引用,不存字节;字节在 blob 引用存储里)
|
||||
* —— 断点恢复靠它;上限 500 条,超出按最旧淘汰(pinned 不动)
|
||||
* 2) view:url → 状态的内存索引,供结果图组件按 url 查「下载中 / 失败 / 已就绪」
|
||||
* —— 组件订阅 notify 后重渲染,不需要把状态灌进画布节点数据
|
||||
*
|
||||
* 与 image-ingest.js 的分工:那边是执行器(下载/重试),这边只管「记账」和「给 UI 看」。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
|
||||
const KEY = 'iwb_ingest_idx'
|
||||
const MAX = 500
|
||||
|
||||
function createStore (deps) {
|
||||
const d = deps || {}
|
||||
const lsGet = typeof d.get === 'function' ? d.get : () => null
|
||||
const lsSet = typeof d.set === 'function' ? d.set : () => {}
|
||||
// 2026-12-03:上限由宿主配置注入(默认 500,范围 100~5000);插件只读/改配置。
|
||||
const maxOf = () => {
|
||||
let n = 500
|
||||
try { n = typeof d.max === 'function' ? d.max() : (Number(d.max) || 500) } catch (e) { n = 500 }
|
||||
n = Math.round(Number(n) || 500)
|
||||
return Math.max(1, Math.min(5000, n))
|
||||
}
|
||||
let cache = null
|
||||
|
||||
function load () {
|
||||
if (cache) return cache
|
||||
let arr = null
|
||||
try { arr = lsGet(KEY) } catch (e) { arr = null }
|
||||
cache = Array.isArray(arr) ? arr.filter((x) => x && x.id && x.url) : []
|
||||
return cache
|
||||
}
|
||||
function save (entry) {
|
||||
if (!entry || !entry.id) return
|
||||
const arr = load()
|
||||
const at = arr.findIndex((x) => x.id === entry.id)
|
||||
if (at >= 0) arr[at] = entry
|
||||
else arr.push(entry)
|
||||
const max = maxOf()
|
||||
if (arr.length > max) {
|
||||
// 淘汰最旧的非 pinned 记录(pinned = 被画布/图库引用)
|
||||
const isActive = (x) => !!(x && (x.status === 'queued' || x.status === 'downloading'))
|
||||
const drop = arr.filter((x) => !x.pinned && !isActive(x) && x.id !== entry.id).sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0))
|
||||
while (arr.length > max && drop.length) {
|
||||
const victim = drop.shift()
|
||||
const i = arr.indexOf(victim)
|
||||
if (i >= 0) arr.splice(i, 1)
|
||||
}
|
||||
}
|
||||
try { lsSet(KEY, arr) } catch (e) { /* 配额满:保留内存态,下次启动丢,不影响当前会话 */ }
|
||||
}
|
||||
function remove (id) {
|
||||
const arr = load()
|
||||
const i = arr.findIndex((x) => x.id === id)
|
||||
if (i >= 0) arr.splice(i, 1)
|
||||
try { lsSet(KEY, arr) } catch (e) { /* ignore */ }
|
||||
}
|
||||
function list () { return load().slice() }
|
||||
// 立即按当前上限裁剪(改设置后调用;只删记录,不删图片)
|
||||
function trim () {
|
||||
const arr = load()
|
||||
const max = maxOf()
|
||||
if (arr.length <= max) return 0
|
||||
const isActive = (x) => !!(x && (x.status === 'queued' || x.status === 'downloading'))
|
||||
const drop = arr.filter((x) => !x.pinned && !isActive(x)).sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0))
|
||||
let removed = 0
|
||||
while (arr.length > max && drop.length) {
|
||||
const victim = drop.shift()
|
||||
const i = arr.indexOf(victim)
|
||||
if (i >= 0) { arr.splice(i, 1); removed++ }
|
||||
}
|
||||
if (removed) { try { lsSet(KEY, arr) } catch (e) { /* ignore */ } }
|
||||
return removed
|
||||
}
|
||||
function clear () { cache = []; try { lsSet(KEY, []) } catch (e) { /* ignore */ } }
|
||||
return { load, save, remove, list, trim, clear, KEY, MAX }
|
||||
}
|
||||
|
||||
// 视图:url → { status, localUrl, bytes, error };订阅者用于 React 重渲染
|
||||
function createView () {
|
||||
const byUrl = new Map()
|
||||
const subs = new Set()
|
||||
function set (entry) {
|
||||
if (!entry || !entry.url) return
|
||||
const prev = byUrl.get(entry.url) || {}
|
||||
byUrl.set(entry.url, {
|
||||
id: entry.id,
|
||||
status: entry.status,
|
||||
ref: entry.ref || prev.ref || null,
|
||||
displayRef: entry.displayRef || prev.displayRef || null,
|
||||
localUrl: entry.localUrl || prev.localUrl || '',
|
||||
bytes: entry.bytes || 0,
|
||||
progress: entry.progress || 0,
|
||||
receivedBytes: entry.receivedBytes || 0,
|
||||
totalBytes: entry.totalBytes || 0,
|
||||
error: entry.lastError || '',
|
||||
})
|
||||
}
|
||||
function byUrlOf (url) { return byUrl.get(String(url || '')) || null }
|
||||
function hydrate (entries) { for (const e of (entries || [])) set(e) }
|
||||
function subscribe (fn) { if (typeof fn === 'function') { subs.add(fn); return () => subs.delete(fn) } return () => {} }
|
||||
function notify () { for (const fn of [...subs]) { try { fn() } catch (e) { /* ignore */ } } }
|
||||
return { set, get: byUrlOf, hydrate, subscribe, notify }
|
||||
}
|
||||
|
||||
global.IWBImageIngestStore = { createStore, createView, KEY }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -0,0 +1,392 @@
|
||||
/* image-ingest.js —— 结果图片落地管线(2026-12-02)
|
||||
*
|
||||
* 解决什么:出图后输出节点直接用 <img src=远程CDN>,图库缩略图又各自去 fetch 一遍;
|
||||
* CDN 慢/断流时表现为「图片从上往下慢慢刷 / 卡住半张」,图库还晚一步才出现。
|
||||
* 这里把「远程结果 → 本地字节」收敛成一条队列:下载一次,节点/图库/队列页共用。
|
||||
*
|
||||
* 设计约束:
|
||||
* · 幂等:同一条记录重复 enqueue 不会重复下载(按 id 去重;id 缺省用 url 的稳定 hash)
|
||||
* · 不丢图:原始 url 永远保留在 entry 上;失败只改状态,不删记录
|
||||
* · 可恢复:状态由宿主持久化(deps.persist),启动时用 restore() 把 queued/downloading 重排
|
||||
* · 原子:先写字节再置 ready;写失败保持 failed,可重试
|
||||
* · 可关:宿主不接线就是不启用(本模块自身不读任何全局)
|
||||
*
|
||||
* 依赖全部注入(便于单测):
|
||||
* fetchBytes(url) -> Promise<{ ok, dataUrl?, bytes?, mime?, error? }>
|
||||
* writeRef(dataUrl)-> Promise<ref|null> // 走宿主的唯一引用化入口
|
||||
* persist(entry) -> void // 状态变化时持久化
|
||||
* onEvent(kind, entry) -> void // 进度节流事件(宿主用来刷新 UI)
|
||||
* now() -> number
|
||||
* sleep(ms) -> Promise // 测试可注入
|
||||
* concurrency -> number(默认 2)
|
||||
* retries -> number(默认 3)
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
|
||||
const STATE = { QUEUED: 'queued', DOWNLOADING: 'downloading', READY: 'ready', FAILED: 'failed', LINK_ONLY: 'link-only' }
|
||||
|
||||
function create (deps) {
|
||||
const d = deps || {}
|
||||
// 2026-12-03(用户裁定):默认 30 并发,设置页可调(1–64);getConcurrency 让改动立即生效。
|
||||
const concurrencyOf = () => {
|
||||
const v = (typeof d.getConcurrency === 'function') ? d.getConcurrency() : d.concurrency
|
||||
return Math.max(1, Math.min(64, Number(v) || 30))
|
||||
}
|
||||
const maxRetries = Math.max(0, Number(d.retries) || 3)
|
||||
const now = typeof d.now === 'function' ? d.now : () => Date.now()
|
||||
const sleep = typeof d.sleep === 'function' ? d.sleep : (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
const entries = new Map() // id -> entry
|
||||
const queue = [] // 待下载 id
|
||||
let active = 0
|
||||
let seq = 0
|
||||
|
||||
const uid = () => 'ing_' + now().toString(36) + '_' + (++seq)
|
||||
function hash (s) {
|
||||
let h = 5381
|
||||
const str = String(s || '')
|
||||
for (let i = 0; i < str.length; i++) h = ((h * 33) ^ str.charCodeAt(i)) >>> 0
|
||||
return h.toString(36)
|
||||
}
|
||||
const emit = (kind, e) => { try { if (typeof d.onEvent === 'function') d.onEvent(kind, e) } catch (err) { /* ignore */ } }
|
||||
const persist = (e) => { try { if (typeof d.persist === 'function') d.persist(e) } catch (err) { /* ignore */ } }
|
||||
|
||||
function publicView (e) {
|
||||
return {
|
||||
id: e.id, url: e.url, source: e.source, status: e.status,
|
||||
bytes: e.bytes || 0, mime: e.mime || '', w: e.w || 0, h: e.h || 0,
|
||||
progress: e.progress || 0, receivedBytes: e.receivedBytes || 0, totalBytes: e.totalBytes || 0,
|
||||
ref: e.ref || null, displayRef: e.displayRef || null, thumbRef: e.thumbRef || null,
|
||||
retries: e.retries || 0, lastError: e.lastError || '', requestId: e.requestId || '',
|
||||
createdAt: e.createdAt, updatedAt: e.updatedAt, meta: e.meta || {},
|
||||
}
|
||||
}
|
||||
|
||||
function get (id) { const e = entries.get(id); return e ? publicView(e) : null }
|
||||
function list () { return [...entries.values()].map(publicView) }
|
||||
function stats () {
|
||||
const out = { total: 0, queued: 0, downloading: 0, ready: 0, failed: 0, linkOnly: 0, active: 0 }
|
||||
for (const e of entries.values()) {
|
||||
out.total++
|
||||
if (e.status === STATE.QUEUED) out.queued++
|
||||
else if (e.status === STATE.DOWNLOADING) out.downloading++
|
||||
else if (e.status === STATE.READY) out.ready++
|
||||
else if (e.status === STATE.FAILED) out.failed++
|
||||
else if (e.status === STATE.LINK_ONLY) out.linkOnly++
|
||||
}
|
||||
out.active = active
|
||||
return out
|
||||
}
|
||||
|
||||
function setStatus (e, status, patch) {
|
||||
e.status = status
|
||||
e.updatedAt = now()
|
||||
if (patch) Object.assign(e, patch)
|
||||
persist(publicView(e))
|
||||
emit(status, publicView(e))
|
||||
}
|
||||
|
||||
async function runOne (e) {
|
||||
// active 由 pump 在「决定启动」时同步 +1(见 pump):放在这里会晚一个微任务,
|
||||
// pump 的 while 就会在 active 还是 0 时把整个队列一次性放出去(2026-12-03 实测并发限制从未生效)。
|
||||
// 2026-12-03:每次运行带「运行序号 + 取消控制器」—— 取消/重下时旧请求的结果必须作废,
|
||||
// 否则回包晚到会把 link-only 覆盖成 ready,或和新一轮同时写同一条记录。
|
||||
const mySeq = (e.runSeq || 0) + 1
|
||||
e.runSeq = mySeq
|
||||
const ctrl = (typeof AbortController === 'function') ? new AbortController() : null
|
||||
e.ctrl = ctrl
|
||||
const stale = () => (e.runSeq !== mySeq || e.status !== STATE.DOWNLOADING)
|
||||
const settle = () => { active--; try { delete e.ctrl } catch (e0) { /* ignore */ } pump() }
|
||||
setStatus(e, STATE.DOWNLOADING, { lastError: '', progress: 0, receivedBytes: 0, totalBytes: 0 })
|
||||
let lastErr = ''
|
||||
// 2026-12-02:下载进度(有 content-length 才算百分比;拿不到就退回「下载中」文案)。
|
||||
// 事件节流 250ms —— 每 chunk 都触发会让画布整树重渲染,反而拖慢下载。
|
||||
const onProgress = (received, total) => {
|
||||
const rcv = Math.max(0, Number(received) || 0)
|
||||
const tot = Math.max(0, Number(total) || 0)
|
||||
e.receivedBytes = rcv
|
||||
e.totalBytes = tot
|
||||
e.progress = tot > 0 ? Math.min(1, rcv / tot) : 0
|
||||
const t = now()
|
||||
e.updatedAt = t
|
||||
if (t - (e._progAt || 0) < 250 && !(tot > 0 && rcv >= tot)) return
|
||||
e._progAt = t
|
||||
emit('progress', publicView(e))
|
||||
}
|
||||
// 2026-12-04(文件版下载,默认关闭):宿主开启 IWB_RUST_FILE=1 时,优先让 Rust 流式写文件,
|
||||
// 再由存储层「接管文件」得到引用,全程不经过 base64(大图批量时内存峰值从数份拷贝降到 64KB 缓冲)。
|
||||
const fileMode = () => (typeof d.fetchFile === 'function' && (typeof d.useFile !== 'function' || d.useFile()))
|
||||
// 2026-12-04:文件版只尝试一轮;全部失败后回退 base64 **一次**(用 __baseFallback 重新入队),
|
||||
// 不在每次 attempt 里都下载两遍。
|
||||
const useFile = fileMode() && !e.__baseFallback
|
||||
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
if (useFile) {
|
||||
const f = await d.fetchFile(e.url, e.id)
|
||||
if (stale()) { settle(); return publicView(e) }
|
||||
if (f && f.path) {
|
||||
// key 按 URL 去重(同一 URL 重下不会产生新文件);bytes 进 key 避免同名覆盖不同内容
|
||||
const fk = 'imgblob_f' + hash(e.url) + '_' + (Number(f.bytes) || 0)
|
||||
const fileRef = await d.writeFileRef(Object.assign({}, f, { key: fk }))
|
||||
if (stale()) { settle(); return publicView(e) }
|
||||
if (fileRef) {
|
||||
active--
|
||||
setStatus(e, STATE.READY, {
|
||||
ref: fileRef,
|
||||
progress: 1,
|
||||
bytes: Number(f.bytes || 0),
|
||||
mime: String(f.mime || ''),
|
||||
w: Number(f.w || 0) || e.w || 0,
|
||||
h: Number(f.h || 0) || e.h || 0,
|
||||
retries: attempt,
|
||||
lastError: '',
|
||||
})
|
||||
pump()
|
||||
return publicView(e)
|
||||
}
|
||||
}
|
||||
throw new Error((f && f.error) || 'file-fetch-failed')
|
||||
}
|
||||
const got = typeof d.fetchBytes === 'function' ? await d.fetchBytes(e.url, onProgress, ctrl ? ctrl.signal : undefined) : { ok: false, error: 'no-fetcher' }
|
||||
if (stale()) { settle(); return publicView(e) }
|
||||
if (!got || !got.ok || !got.dataUrl) throw new Error((got && got.error) || 'fetch-failed')
|
||||
const ref = typeof d.writeRef === 'function' ? await d.writeRef(got.dataUrl) : null
|
||||
if (!ref) throw new Error('write-ref-failed')
|
||||
if (stale()) { settle(); return publicView(e) }
|
||||
active--
|
||||
setStatus(e, STATE.READY, {
|
||||
ref,
|
||||
progress: 1,
|
||||
bytes: Number(got.bytes || 0) || Math.round(String(got.dataUrl).length * 0.75),
|
||||
mime: String(got.mime || ''),
|
||||
w: Number(got.w || 0) || e.w || 0,
|
||||
h: Number(got.h || 0) || e.h || 0,
|
||||
retries: attempt,
|
||||
lastError: '',
|
||||
})
|
||||
pump()
|
||||
return publicView(e)
|
||||
} catch (err) {
|
||||
lastErr = (err && err.message) ? err.message : String(err)
|
||||
if (stale()) { settle(); return publicView(e) }
|
||||
if (attempt < maxRetries) {
|
||||
setStatus(e, STATE.DOWNLOADING, { retries: attempt + 1, lastError: lastErr })
|
||||
await sleep(Math.min(8000, 1000 * Math.pow(2, attempt)))
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stale()) { settle(); return publicView(e) }
|
||||
// 文件版彻底失败:回退 base64 再试一轮(只一次,避免反复双下载)
|
||||
if (fileMode() && !e.__baseFallback) {
|
||||
e.__baseFallback = true
|
||||
active--
|
||||
try { delete e.ctrl } catch (e1) { /* ignore */ }
|
||||
setStatus(e, STATE.QUEUED, { lastError: lastErr })
|
||||
queue.push(e.id)
|
||||
pump()
|
||||
return publicView(e)
|
||||
}
|
||||
active--
|
||||
try { delete e.ctrl } catch (e1) { /* ignore */ }
|
||||
setStatus(e, STATE.FAILED, { retries: maxRetries, lastError: lastErr })
|
||||
pump()
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
function pump () {
|
||||
while (active < concurrencyOf() && queue.length) {
|
||||
const id = queue.shift()
|
||||
const e = entries.get(id)
|
||||
if (!e || e.status !== STATE.QUEUED) continue
|
||||
active++
|
||||
Promise.resolve().then(() => runOne(e))
|
||||
}
|
||||
}
|
||||
|
||||
// 入队:同一 url 已存在(且未失败)则直接返回旧记录,避免重复下载
|
||||
function enqueue (input) {
|
||||
const src = input || {}
|
||||
const url = String(src.url || '')
|
||||
if (!url) return null
|
||||
const id = String(src.id || ('u_' + hash(url)))
|
||||
const exist = entries.get(id)
|
||||
if (exist) {
|
||||
if (exist.status === STATE.FAILED || exist.status === STATE.LINK_ONLY) return retry(id)
|
||||
return publicView(exist)
|
||||
}
|
||||
const e = {
|
||||
id,
|
||||
url,
|
||||
source: String(src.source || 'gen'),
|
||||
status: STATE.QUEUED,
|
||||
bytes: 0, mime: '', w: Number(src.w || 0), h: Number(src.h || 0),
|
||||
ref: null, displayRef: null, thumbRef: null,
|
||||
retries: 0, lastError: '', requestId: String(src.requestId || ''),
|
||||
createdAt: now(), updatedAt: now(), meta: src.meta || {},
|
||||
}
|
||||
entries.set(id, e)
|
||||
queue.push(id)
|
||||
persist(publicView(e))
|
||||
emit(STATE.QUEUED, publicView(e))
|
||||
pump()
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
// 重试:复位状态重新排队(失败记录不删,url 保留)
|
||||
function retry (id) {
|
||||
const e = entries.get(id)
|
||||
if (!e) return null
|
||||
e.runSeq = (e.runSeq || 0) + 1 // 旧运行作废(回包晚到不覆盖新状态)
|
||||
// 2026-12-04:用户主动重试时重新尝试文件版(否则一次失败后永远只走 base64)
|
||||
delete e.__baseFallback
|
||||
e.retries = 0
|
||||
setStatus(e, STATE.QUEUED, { lastError: '' })
|
||||
queue.push(id)
|
||||
pump()
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
// 取消:仅对排队中/下载中有效;字节未落地的记录回到 queued 之外的状态由宿主任意处理
|
||||
function cancel (id) {
|
||||
const e = entries.get(id)
|
||||
if (!e) return null
|
||||
e.runSeq = (e.runSeq || 0) + 1
|
||||
try { if (typeof d.cancelFile === 'function') d.cancelFile(e.id) } catch (eF) { /* ignore */ }
|
||||
try { if (e.ctrl && typeof e.ctrl.abort === 'function') e.ctrl.abort() } catch (eC) { /* ignore */ }
|
||||
try { delete e.ctrl } catch (eD) { /* ignore */ }
|
||||
const at = queue.indexOf(id)
|
||||
if (at >= 0) queue.splice(at, 1)
|
||||
if (e.status === STATE.QUEUED || e.status === STATE.DOWNLOADING) setStatus(e, STATE.LINK_ONLY, { lastError: 'cancelled' })
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
// 释放本地字节,保留记录与 url(「仅保留链接」)
|
||||
function release (id) {
|
||||
const e = entries.get(id)
|
||||
if (!e) return null
|
||||
setStatus(e, STATE.LINK_ONLY, { ref: null, displayRef: null, thumbRef: null })
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
// 清空已结束的记录(ready/failed/link-only);进行中的保留(正在下载/排队),避免清掉在飞任务。
|
||||
function clearFinished () {
|
||||
let n = 0
|
||||
for (const [id, e] of Array.from(entries.entries())) {
|
||||
if (e.status === STATE.READY || e.status === STATE.FAILED || e.status === STATE.LINK_ONLY) {
|
||||
entries.delete(id)
|
||||
try { if (typeof d.removeEntry === 'function') d.removeEntry(id) } catch (err) { /* ignore */ }
|
||||
n++
|
||||
}
|
||||
}
|
||||
if (n) emit('cleared', { count: n })
|
||||
return n
|
||||
}
|
||||
|
||||
function remove (id) {
|
||||
const at = queue.indexOf(id)
|
||||
if (at >= 0) queue.splice(at, 1)
|
||||
entries.delete(id)
|
||||
try { if (typeof d.removeEntry === 'function') d.removeEntry(id) } catch (e) { /* ignore */ }
|
||||
emit('removed', { id })
|
||||
return true
|
||||
}
|
||||
|
||||
// 启动恢复:queued / downloading 重新排队;ready 但宿主说字节不在了 → missing(keep url)
|
||||
function restore (saved) {
|
||||
const arr = Array.isArray(saved) ? saved : []
|
||||
for (const raw of arr) {
|
||||
if (!raw || !raw.id || !raw.url) continue
|
||||
const e = Object.assign({}, raw, { meta: raw.meta || {} })
|
||||
if (e.status === STATE.READY) e.status = STATE.READY
|
||||
else if (e.status === STATE.FAILED) e.status = STATE.FAILED
|
||||
else if (e.status === STATE.LINK_ONLY) e.status = STATE.LINK_ONLY
|
||||
else e.status = STATE.QUEUED
|
||||
entries.set(e.id, e)
|
||||
if (e.status === STATE.QUEUED) queue.push(e.id)
|
||||
}
|
||||
pump()
|
||||
return stats()
|
||||
}
|
||||
|
||||
// 宿主自检回调:索引是 ready 但字节读不出来 → 标 missing(仍保留 url,可 retry)
|
||||
function markMissing (id, reason) {
|
||||
const e = entries.get(id)
|
||||
if (!e) return null
|
||||
setStatus(e, STATE.FAILED, { lastError: String(reason || 'missing-bytes'), ref: null, displayRef: null })
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
return { enqueue, retry, cancel, release, remove, clearFinished, get, list, stats, restore, markMissing, STATE }
|
||||
}
|
||||
|
||||
// 带进度的取字节:流式读 body,按 content-length 报百分比;拿不到长度就只报已收字节。
|
||||
// 失败(CORS/非 2xx/无 body)抛错,交给宿主回退到既有 wBlobFromSrc。
|
||||
function blobToDataUrl (blob) {
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
const fr = new FileReader()
|
||||
fr.onload = () => resolve(String(fr.result || ''))
|
||||
fr.onerror = () => resolve('')
|
||||
fr.readAsDataURL(blob)
|
||||
} catch (e) { resolve('') }
|
||||
})
|
||||
}
|
||||
async function fetchWithProgress (url, onProgress, signal) {
|
||||
const res = await fetch(url, signal ? { signal: signal } : undefined)
|
||||
if (!res || !res.ok) throw new Error('http-' + String((res && res.status) || 'error'))
|
||||
const total = Number(res.headers && res.headers.get && res.headers.get('content-length')) || 0
|
||||
let blob = null
|
||||
if (res.body && typeof res.body.getReader === 'function') {
|
||||
const reader = res.body.getReader()
|
||||
const chunks = []
|
||||
let received = 0
|
||||
for (;;) {
|
||||
const step = await reader.read()
|
||||
if (!step || step.done) break
|
||||
if (step.value) { chunks.push(step.value); received += step.value.length || 0 }
|
||||
if (typeof onProgress === 'function') onProgress(received, total)
|
||||
}
|
||||
blob = new Blob(chunks, { type: String((res.headers && res.headers.get && res.headers.get('content-type')) || '') })
|
||||
} else {
|
||||
blob = await res.blob()
|
||||
if (typeof onProgress === 'function') onProgress(blob ? blob.size : 0, total)
|
||||
}
|
||||
const dataUrl = blob ? await blobToDataUrl(blob) : ''
|
||||
if (!dataUrl) return { ok: false, error: 'empty-bytes' }
|
||||
return { ok: true, dataUrl, mime: String((blob && blob.type) || ''), bytes: (blob && blob.size) || 0 }
|
||||
}
|
||||
|
||||
// 宿主取字节适配器:流式(带进度)→ 失败回退宿主既有 blob 取法;整体带超时。
|
||||
// 放进本模块是为了让 app.js 只留一行装配(Workbench 行数棘轮)。
|
||||
function createFetchBytes (deps) {
|
||||
const d = deps || {}
|
||||
const timeoutMs = Math.max(1000, Number(d.timeoutMs) || 300000)
|
||||
return async function fetchBytes (url, onProgress, signal) {
|
||||
// 2026-12-03(用户裁定):优先用系统网络栈(Rust reqwest)—— 不受 CORS/WebView 限制,
|
||||
// 图床/CDN 对 XHR 的限速、挂起、防盗链都不会再影响下载。拿不到再退回 WebView fetch。
|
||||
if (typeof d.rustFetch === 'function') {
|
||||
try {
|
||||
const r = await d.rustFetch(url)
|
||||
if (r && r.ok && r.b64) {
|
||||
const mime = String(r.mime || 'application/octet-stream')
|
||||
if (typeof onProgress === 'function') onProgress(Number(r.bytes) || 0, Number(r.bytes) || 0)
|
||||
return { ok: true, dataUrl: 'data:' + mime + ';base64,' + String(r.b64), mime: mime, bytes: Number(r.bytes) || 0 }
|
||||
}
|
||||
} catch (eR) { /* 非 Tauri / 命令缺失 → 回退 WebView fetch */ }
|
||||
}
|
||||
let timer = null
|
||||
const job = fetchWithProgress(url, onProgress, signal).catch(async () => {
|
||||
// 用户取消(abort)导致的失败:不要回退再抓一次,直接按中止返回。
|
||||
if (signal && signal.aborted) return { ok: false, error: 'aborted' }
|
||||
const blob = await d.blobFromSrc(url)
|
||||
const dataUrl = blob ? await d.blobToDataUrl(blob) : ''
|
||||
return dataUrl ? { ok: true, dataUrl, mime: String((blob && blob.type) || '') } : { ok: false, error: 'empty-bytes' }
|
||||
})
|
||||
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve({ ok: false, error: 'timeout' }), timeoutMs) })
|
||||
try { return await Promise.race([job, timeout]) } catch (e) { return { ok: false, error: String((e && e.message) || 'fetch-failed') } } finally { try { if (timer) clearTimeout(timer) } catch (e2) { /* ignore */ } }
|
||||
}
|
||||
}
|
||||
|
||||
global.IWBImageIngest = { create, STATE, fetchWithProgress, createFetchBytes }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -27,9 +27,13 @@
|
||||
try {
|
||||
const url = String((n.data && n.data.url) || '')
|
||||
if (!url) continue
|
||||
const resp = await fetch(url, { credentials: 'omit' })
|
||||
if (!resp || !resp.ok) continue
|
||||
const blob = await resp.blob()
|
||||
// 2026-12-04(审计 P1):优先用宿主注入的 Rust 取字节(不受 CORS/白名单限制)
|
||||
let blob = (typeof o.fetchBlob === 'function') ? await o.fetchBlob(url) : null
|
||||
if (!blob || !blob.size) {
|
||||
const resp = await fetch(url, { credentials: 'omit' })
|
||||
if (!resp || !resp.ok) continue
|
||||
blob = await resp.blob()
|
||||
}
|
||||
if (!blob || !blob.size) continue
|
||||
const dataUrl = await new Promise((res, rej) => {
|
||||
const rd = new FileReader()
|
||||
@@ -64,9 +68,13 @@
|
||||
if (!url) return
|
||||
;(async () => {
|
||||
try {
|
||||
const resp = await fetch(url, { credentials: 'omit' })
|
||||
if (!resp || !resp.ok) return
|
||||
const blob = await resp.blob()
|
||||
// 2026-12-04(审计 P1):优先 Rust 取字节;失败再回退 WebView fetch
|
||||
let blob = (typeof o.fetchBlob === 'function') ? await o.fetchBlob(url) : null
|
||||
if (!blob || !blob.size) {
|
||||
const resp = await fetch(url, { credentials: 'omit' })
|
||||
if (!resp || !resp.ok) return
|
||||
blob = await resp.blob()
|
||||
}
|
||||
if (!blob || !blob.size) return
|
||||
const dataUrl = await new Promise((res, rej) => {
|
||||
const rd = new FileReader()
|
||||
|
||||
@@ -63,10 +63,13 @@
|
||||
const res = (Q && typeof Q.queryOutputs === 'function')
|
||||
? Q.queryOutputs(list, { query: o.query || '', range: o.range || '', limit, width: 320, tile: 130 })
|
||||
: { filtered: list, visible: list.slice(0, limit), total: list.length }
|
||||
// 2026-12-02(方案 A:先落地再显示):只展示已落地(orig=ok)的图;
|
||||
// pending(下载中)/ missing(失败)一律静默隐藏 —— 用户要的是「图库出现时就是完整可用的」,
|
||||
// 不再先冒一张取不到缩略图的空卡。'off' 是旧版「不备份原图」的历史条目(有缩略图),保留可见。
|
||||
const items = (res.visible || []).map(function (f) {
|
||||
return { name: f.name, label: f.label || '', w: f.w || 0, h: f.h || 0, mtime: f.mtime || 0, orig: f.orig || (f.origIdb ? 'ok' : 'missing') }
|
||||
})
|
||||
return { items: items, total: res.total || items.length }
|
||||
}).filter(function (it) { return it.orig === 'ok' || it.orig === 'off' })
|
||||
return { items: items, total: items.length }
|
||||
}
|
||||
|
||||
global.IWBPluginGallery = { setImpl: setImpl, api: function () { return API }, query: query, emit: emit }
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* plugin-api-queue.js —— 宿主「任务队列」能力(2026-12-03)
|
||||
*
|
||||
* 插件只是一个视图:账本、下载、落地、定位、记录上限全部在宿主。
|
||||
* 与 gallery 能力同构:setImpl 由 Workbench 每次渲染注入,插件拿到稳定代理。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
|
||||
let impl = null
|
||||
const listeners = []
|
||||
|
||||
function setImpl (next) { impl = (next && typeof next === 'object') ? next : null }
|
||||
|
||||
function call (name) {
|
||||
return function () {
|
||||
const fn = impl && impl[name]
|
||||
if (typeof fn !== 'function') return Promise.reject(new Error('任务队列能力未就绪'))
|
||||
try { return Promise.resolve(fn.apply(null, arguments)) } catch (e) { return Promise.reject(e) }
|
||||
}
|
||||
}
|
||||
|
||||
function emit (reason) {
|
||||
for (const fn of listeners.slice()) {
|
||||
try { fn(reason || 'changed') } catch (e) { /* 插件回调异常不影响宿主 */ }
|
||||
}
|
||||
}
|
||||
|
||||
const API = {
|
||||
list: call('list'),
|
||||
retry: call('retry'),
|
||||
restart: call('restart'),
|
||||
land: call('land'),
|
||||
preview: call('preview'),
|
||||
copyLink: call('copyLink'),
|
||||
locate: call('locate'),
|
||||
stats: call('stats'),
|
||||
clear: call('clear'),
|
||||
getLimit: call('getLimit'),
|
||||
setLimit: call('setLimit'),
|
||||
onChanged: function (fn) {
|
||||
if (typeof fn !== 'function') return function () {}
|
||||
listeners.push(fn)
|
||||
return function () { const i = listeners.indexOf(fn); if (i >= 0) listeners.splice(i, 1) }
|
||||
},
|
||||
}
|
||||
|
||||
global.IWBPluginQueue = { setImpl, api: function () { return API }, emit }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
const API_VERSION = 1
|
||||
const ID_PATTERN = /^[a-z][a-z0-9-]{2,31}$/
|
||||
const REQUIRED_FIELDS = ['id', 'name', 'version', 'apiVersion', 'capabilities']
|
||||
const CAPABILITIES = ['panels', 'commands', 'nodeTypes', 'generationHooks', 'providers', 'canvas', 'canvasWrite', 'nodeActions', 'gallery', 'grouplib', 'promptlib', 'files', 'images']
|
||||
const CAPABILITY_API_KEYS = { panels: 'ui', commands: 'commands', nodeTypes: 'nodes', generationHooks: 'generation', providers: 'providers', canvas: 'canvas', canvasWrite: 'canvas', nodeActions: 'nodeActions', gallery: 'gallery', grouplib: 'grouplib', promptlib: 'promptlib', files: 'files', images: 'images' }
|
||||
const CAPABILITIES = ['panels', 'commands', 'nodeTypes', 'generationHooks', 'providers', 'canvas', 'canvasWrite', 'nodeActions', 'gallery', 'grouplib', 'promptlib', 'files', 'images', 'queue', 'pages']
|
||||
const CAPABILITY_API_KEYS = { panels: 'ui', commands: 'commands', nodeTypes: 'nodes', generationHooks: 'generation', providers: 'providers', canvas: 'canvas', canvasWrite: 'canvas', nodeActions: 'nodeActions', gallery: 'gallery', grouplib: 'grouplib', promptlib: 'promptlib', files: 'files', images: 'images', queue: 'queue', pages: 'ui' }
|
||||
|
||||
function createPluginHost(options) {
|
||||
const opt = options || {}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
const isOn = typeof d.isOn === 'function' ? d.isOn : function () { return false }
|
||||
const resolveSrc = typeof d.resolveSrc === 'function' ? d.resolveSrc : null
|
||||
const toBlob = typeof d.toBlob === 'function' ? d.toBlob : null
|
||||
// 2026-12-04(审计 P2-12):宿主可注入「系统网络栈取字节」(Rust),远程兜底不再受 CORS 限制
|
||||
const fetchBlob = typeof d.fetchBlob === 'function' ? d.fetchBlob : null
|
||||
const write = typeof d.write === 'function' ? d.write : null
|
||||
const toast = typeof d.toast === 'function' ? d.toast : function () {}
|
||||
|
||||
@@ -52,11 +54,13 @@
|
||||
// 本地原图(dataURL)直接解码成 Blob,不再 fetch(dataURL);远程 URL 才走 fetch
|
||||
let blob = null
|
||||
if (toBlob) { try { blob = await toBlob(src) } catch (e) { blob = null } }
|
||||
if (!blob) {
|
||||
if (!blob && fetchBlob) { try { blob = await fetchBlob(src) } catch (e2) { blob = null } }
|
||||
if (!blob || !blob.size) {
|
||||
const resp = await fetch(src)
|
||||
if (!resp || !resp.ok) { failed++; continue }
|
||||
blob = await resp.blob()
|
||||
}
|
||||
if (!blob || !blob.size) { failed++; continue }
|
||||
const name = genName()
|
||||
const ok = await write(getDir(), name, blob)
|
||||
if (ok) saved++
|
||||
@@ -91,5 +95,24 @@
|
||||
return direct
|
||||
}
|
||||
|
||||
g.IWBDownloadAuto = Object.freeze({ create, resolveLocalFirst })
|
||||
// 方案 A(2026-12-02):自动下载优先等落地队列的本地字节,避免为同一张图再抓一次远程。
|
||||
// 返回 dataURL;拿不到(无记录/失败/超时)返回 '',交给调用方走原有本地优先链路。
|
||||
async function waitIngestRef (url, deps) {
|
||||
const d = deps || {}
|
||||
if (!url || typeof d.get !== 'function') return ''
|
||||
const t0 = Date.now()
|
||||
const max = Math.max(0, Number(d.timeoutMs) || 20000)
|
||||
for (;;) {
|
||||
const v = d.get(url)
|
||||
if (v && v.ref) {
|
||||
const du = typeof d.refDataUrl === 'function' ? await d.refDataUrl(v.ref) : ''
|
||||
if (du) return du
|
||||
}
|
||||
if (!v || v.status === 'failed') return ''
|
||||
if (Date.now() - t0 >= max) return ''
|
||||
await new Promise((r) => setTimeout(r, 250))
|
||||
}
|
||||
}
|
||||
|
||||
g.IWBDownloadAuto = Object.freeze({ create, resolveLocalFirst, waitIngestRef })
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -0,0 +1,42 @@
|
||||
/* ref-upload.js —— 参考图节点「上传到图库」动作(2026-12-04)
|
||||
*
|
||||
* 从 app.js 的节点气泡里抽出:气泡是装配层,逻辑放模块里(app.js 行数棘轮)。
|
||||
* 依赖全部注入:fetchBlob(Rust 优先)/ blobToDataUrl / uploadRef / config / updateNode / notice。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
function create (deps) {
|
||||
const d = deps || {}
|
||||
const uploading = new Set()
|
||||
const run = async (node, opts) => {
|
||||
if (!node || node.type !== 'ref' || uploading.has(node.id)) return false
|
||||
const data = node.data || {}
|
||||
const hasLocal = !!(data.data || data.localRef)
|
||||
const hasUrl = typeof data.url === 'string' && data.url
|
||||
if (!hasLocal && !hasUrl) return false
|
||||
const o = opts || {}
|
||||
uploading.add(node.id)
|
||||
try {
|
||||
let payload = data.data || data.localRef || null
|
||||
if (!payload) {
|
||||
let blob = await d.fetchBlob(data.url)
|
||||
if (!blob || !blob.size) {
|
||||
try { const r = await d.fetch(data.url, { credentials: 'same-origin' }); if (r && r.ok) blob = await r.blob() } catch (e) { /* ignore */ }
|
||||
}
|
||||
if (!blob || !blob.size) throw new Error('图片下载失败')
|
||||
payload = await d.blobToDataUrl(blob)
|
||||
}
|
||||
if (typeof o.notice === 'function') o.notice('正在上传到图库…')
|
||||
const url = await d.uploadRef(payload, d.config(), data.name)
|
||||
if (typeof o.updateNode === 'function') o.updateNode(node.id, { url: url, data: null, localRef: null, localName: null, name: String(url).split('/').pop() || '在线图片' })
|
||||
if (typeof o.notice === 'function') o.notice('已上传到图库并填入链接')
|
||||
return true
|
||||
} catch (e) {
|
||||
if (typeof o.notice === 'function') o.notice('上传失败:' + String((e && e.message) || e), 'err')
|
||||
return false
|
||||
} finally { uploading.delete(node.id) }
|
||||
}
|
||||
return { run: run, isUploading: (id) => uploading.has(id) }
|
||||
}
|
||||
global.IWBRefUpload = { create: create }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -239,6 +239,23 @@
|
||||
const gn = baseNodes.find((n) => n.id === nodeId)
|
||||
const cur = gn && Array.isArray(gn.data.result) ? gn.data.result : []
|
||||
const nextResult = upsertGenerationEntry(cur, entry)
|
||||
// 2026-12-02:每张结果落地就入队(这里是「结果写进节点数据」的唯一入口,批量/恢复都经过它)
|
||||
// 2026-12-03:带 meta(画布/节点/提示词/模型/尺寸),任务队列页据此跨画布展示与定位。
|
||||
const _ws0 = (refs.workspaces || []).find((w) => w.id === runWorkspaceId)
|
||||
const _task0 = (node && node.data && Array.isArray(node.data.tasks) ? node.data.tasks : []).find((t) => String(t && t.id) === String(pid))
|
||||
const _promptText = String((_task0 && _task0.text) || (entry && entry.label) || '').slice(0, 80)
|
||||
const _meta = {
|
||||
boardId: runWorkspaceId,
|
||||
boardName: String((_ws0 && _ws0.name) || ''),
|
||||
nodeId,
|
||||
prompt: String((entry && (entry.taskTitle || entry.label)) || '').slice(0, 200),
|
||||
promptText: _promptText,
|
||||
variant: Number(vi) + 1,
|
||||
model: String((node && node.data && node.data.model) || ''),
|
||||
size: size || ((entry && entry.width && entry.height) ? (entry.width + 'x' + entry.height) : ''),
|
||||
at: Number(entry && entry.at) || Date.now(),
|
||||
}
|
||||
try { if (global.__iwbIngest && entry && entry.url) global.__iwbIngest.enqueue({ url: entry.url, source: 'gen', w: entry.width, h: entry.height, meta: _meta }) } catch (eI) { /* 落地失败不得影响出图 */ }
|
||||
genLatest = baseNodes.map((n) => (n.id === nodeId ? { ...n, data: { ...(n.data || {}), result: nextResult } } : n))
|
||||
genLatest = commitRunNodes(runWorkspaceId, genLatest)
|
||||
}
|
||||
@@ -436,7 +453,8 @@
|
||||
if (od && od.type === 'out' && (od.w || NODE_W) < 420) applyPatch(od.id, { w: 420 })
|
||||
}
|
||||
// 浏览器模式:图库索引/缩略图异步旁路写入,不阻塞生成结果和画布保存。
|
||||
const runResult = await archiveGenerationResults(groups, () => refreshOutputs())
|
||||
const _wsName = ((refs.workspaces || []).find((w) => w.id === runWorkspaceId) || {}).name || ''
|
||||
const runResult = await archiveGenerationResults(groups, () => refreshOutputs(), { boardId: runWorkspaceId, boardName: String(_wsName), nodeId })
|
||||
const failItems = []
|
||||
for (const g of groups) for (const x of (g.items || [])) if (!x.ok) failItems.push(x.error || '生成失败')
|
||||
if (failItems.length) {
|
||||
@@ -790,7 +808,7 @@
|
||||
}
|
||||
const entry = { promptId: 'layers', label: '图层(' + ok.length + ' 张)', items: ok.map((l) => ({ ...l, label: l.name })) }
|
||||
commitLayerResult(entry)
|
||||
await archiveGenerationResults([entry], () => refreshOutputs())
|
||||
await archiveGenerationResults([entry], () => refreshOutputs(), { boardId: activeWsId, boardName: String(((refs.workspaces || []).find((w) => w.id === activeWsId) || {}).name || ''), nodeId })
|
||||
setNotice({ type: 'ok', text: '已生成 ' + ok.length + ' 张图层 ≈ ¥' + (ok.length * layerPriceOf(szParam)).toFixed(2) })
|
||||
} catch (e) {
|
||||
setNotice({ type: 'err', text: apiErrorMessage(e) })
|
||||
|
||||
+200
-28
@@ -63,20 +63,36 @@
|
||||
iwb_web_groups: 'groups.json', // 节点组
|
||||
iwb_web_groupgroups: 'group-groups.json', // 节点组的分组树
|
||||
iwb_web_outputs: 'gallery/index.json', // 图库清单(图片字节仍在 images/gallery/,按 hash 引用)
|
||||
iwb_ingest_idx: 'task-queue/index.json', // 任务队列账本(全局生成记录;不随设置/画布一起写)
|
||||
}
|
||||
const libFileOf = (k) => LIB_FILES[k] || ''
|
||||
const dirtyWs = new Set()
|
||||
const removedWs = new Set()
|
||||
const schedule = () => {
|
||||
// 2026-12-04:库文件脏集合 + data.json 内容签名 —— 没有实际变化就不重写,
|
||||
// 避免「每次启动 wsWriteKeys 把每块画布都 setItem 一遍」导致所有画布文件被批量重写。
|
||||
const libDirty = new Set()
|
||||
let lastDataSig = ''
|
||||
const schedule = (delay) => {
|
||||
if (!enabled()) return
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = setTimeout(() => { timer = null; flush().catch(() => {}) }, 800)
|
||||
timer = setTimeout(() => { timer = null; flush().catch(() => {}) }, delay || 800)
|
||||
}
|
||||
// 2026-12-05:写盘失败不能「一次失败就永久丢」——失败键放回脏集合,限次重试(盘满/无权限时不空转)。
|
||||
let retryBudget = 0
|
||||
const scheduleRetry = () => {
|
||||
if (retryBudget >= 3) return
|
||||
retryBudget++
|
||||
schedule(3000)
|
||||
}
|
||||
const isSplitKey = (k) => isWsKey(k) || !!libFileOf(k)
|
||||
const snapshot = () => {
|
||||
const snapshotParts = () => {
|
||||
const keys = {}
|
||||
for (const k of Object.keys(mem)) if (!isSplitKey(k)) keys[k] = mem[k]
|
||||
return JSON.stringify({ v: SCHEMA, at: Date.now(), keys, assets, small })
|
||||
return { keys, assets, small }
|
||||
}
|
||||
const snapshot = () => {
|
||||
const parts = snapshotParts()
|
||||
return JSON.stringify({ v: SCHEMA, at: Date.now(), keys: parts.keys, assets: parts.assets, small: parts.small })
|
||||
}
|
||||
// 落盘:data.json(不含画布)+ 只重写「脏」画布文件;画布内容本身就是一段合法 JSON
|
||||
const flush = async () => {
|
||||
@@ -84,10 +100,17 @@
|
||||
if (writing) return writing
|
||||
const wsDirty = Array.from(dirtyWs)
|
||||
const wsGone = Array.from(removedWs)
|
||||
dirtyWs.clear(); removedWs.clear()
|
||||
const body = snapshot()
|
||||
const libKeys = Array.from(libDirty)
|
||||
const failedWs = [] // 写失败的键:放回脏集合限次重试(2026-12-05)
|
||||
dirtyWs.clear(); removedWs.clear(); libDirty.clear()
|
||||
const parts = snapshotParts()
|
||||
const dataSig = JSON.stringify(parts)
|
||||
const body = JSON.stringify(Object.assign({ v: SCHEMA, at: Date.now() }, parts))
|
||||
const target = await join(dir, DATA_FILE)
|
||||
writing = (async () => {
|
||||
// 2026-12-04:先赋值、再 await —— 若函数体没有 await(244 之后启动那次 flush 就是全同步:
|
||||
// 画布不脏、库不脏、data.json 签名相同),IIFE 会同步跑完把 writing 置回 null,随后赋值又写成
|
||||
// 一个已解决的 promise,此后所有 flush 都卡在「if (writing) return writing」⇒ 整个会话不再写盘。
|
||||
const p = (async () => {
|
||||
try {
|
||||
if (wsDirty.length) {
|
||||
const cdir = await join(dir, CANVAS_DIR)
|
||||
@@ -100,14 +123,14 @@
|
||||
const tmp = await join(cdir, k.slice(9) + '.json.tmp')
|
||||
await fs().writeTextFile(tmp, String(text))
|
||||
await fs().rename(tmp, abs)
|
||||
} catch (e) { try { await fs().writeTextFile(abs, String(text)) } catch (e2) { /* ignore */ } }
|
||||
} catch (e) { try { await fs().writeTextFile(abs, String(text)) } catch (e2) { failedWs.push(k) } }
|
||||
}
|
||||
}
|
||||
for (const k of wsGone) {
|
||||
try { await fs().remove(await join(dir, CANVAS_DIR, k.slice(WS_PREFIX.length) + '.json')) } catch (e) { /* 不存在就算了 */ }
|
||||
}
|
||||
// 资源库:整体重写分类文件(都很小,改动频繁,不做脏标记)
|
||||
const libKeys = Object.keys(mem).filter((k) => !!libFileOf(k))
|
||||
// 2026-12-04:资源库只写「内容真的变了」的键(原来每次 flush 整体重写)
|
||||
const failedLib = []
|
||||
if (libKeys.length) {
|
||||
const ldir = await join(dir, LIB_DIR)
|
||||
try { await fs().mkdir(ldir, { recursive: true }) } catch (e) { /* 已存在 */ }
|
||||
@@ -121,19 +144,33 @@
|
||||
await fs().writeTextFile(await join(ldir, rel), String(mem[k]))
|
||||
// 新位置写成功后才删旧布局文件,避免"删了但没写上"造成数据丢失
|
||||
if (rel === 'gallery/index.json') { try { await fs().remove(await join(ldir, 'gallery.json')) } catch (e2) { /* 不存在 */ } }
|
||||
} catch (e) { /* 单个失败不影响其它 */ }
|
||||
} catch (e) { failedLib.push(k) }
|
||||
}
|
||||
}
|
||||
const tmp2 = await join(dir, DATA_FILE + '.tmp')
|
||||
await fs().writeTextFile(tmp2, body)
|
||||
await fs().rename(tmp2, target)
|
||||
// 2026-12-04:data.json 用内容签名判重(不含 at),没变化就不写
|
||||
if (dataSig !== lastDataSig) {
|
||||
const tmp2 = await join(dir, DATA_FILE + '.tmp')
|
||||
await fs().writeTextFile(tmp2, body)
|
||||
await fs().rename(tmp2, target)
|
||||
lastDataSig = dataSig
|
||||
}
|
||||
// 失败的键放回脏集合,限次重试;成功则清零预算
|
||||
if (failedWs.length) for (const k of failedWs) dirtyWs.add(k)
|
||||
if (failedLib.length) for (const k of failedLib) libDirty.add(k)
|
||||
if (failedWs.length || failedLib.length) { scheduleRetry(); return false }
|
||||
retryBudget = 0
|
||||
return true
|
||||
} catch (e) {
|
||||
// 中途异常:本次所有键放回脏集合(重写同内容无害),限次重试
|
||||
for (const k of wsDirty) dirtyWs.add(k)
|
||||
for (const k of libKeys) libDirty.add(k)
|
||||
scheduleRetry()
|
||||
try { await fs().writeTextFile(target, body) } catch (e2) { /* ignore */ }
|
||||
return false
|
||||
} finally { writing = null }
|
||||
}
|
||||
})()
|
||||
return writing
|
||||
writing = p
|
||||
try { return await p } finally { if (writing === p) writing = null }
|
||||
}
|
||||
|
||||
// 图片:内容哈希(SHA-256 前 16 位)→ images/<hash>.<ext>,同图只存一份
|
||||
@@ -277,8 +314,12 @@
|
||||
getItem(k) { return Object.prototype.hasOwnProperty.call(mem, String(k)) ? mem[String(k)] : null },
|
||||
setItem(k, v) {
|
||||
const key = String(k)
|
||||
mem[key] = String(v)
|
||||
const s = String(v)
|
||||
if (mem[key] === s) return // 内容未变:不标脏、不触发重写(启动时的重复 setItem 全靠这条挡住)
|
||||
mem[key] = s
|
||||
retryBudget = 0
|
||||
if (isWsKey(key)) { removedWs.delete(key); dirtyWs.add(key) }
|
||||
if (libFileOf(key)) libDirty.add(key)
|
||||
schedule()
|
||||
},
|
||||
removeItem(k) {
|
||||
@@ -354,7 +395,7 @@
|
||||
n++
|
||||
} catch (e) { /* 单张失败忽略 */ }
|
||||
}
|
||||
if (n) { mem['iwb_web_outputs'] = JSON.stringify(items); await flush() }
|
||||
if (n) { storage.setItem('iwb_web_outputs', JSON.stringify(items)); await flush() }
|
||||
await fs().writeTextFile(marker, String(n))
|
||||
return n
|
||||
} catch (e) { return 0 }
|
||||
@@ -722,6 +763,8 @@
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
// 2026-12-04:id → 文件内容(判断 data.json 的旧副本是否真的需要迁移)
|
||||
const fileTexts = {}
|
||||
// 画布:一张画布一个文件(canvases/<id>.json,内容就是该键的原始 JSON)
|
||||
try {
|
||||
const cdir = await join(dir, CANVAS_DIR)
|
||||
@@ -733,7 +776,9 @@
|
||||
for (const e of wsFiles) {
|
||||
try {
|
||||
const text = await fs().readTextFile(await join(cdir, e.name))
|
||||
mem['iwb_ws_' + e.name.replace(/\.json$/, '')] = text
|
||||
const wid = e.name.replace(/\.json$/, '')
|
||||
mem['iwb_ws_' + wid] = text
|
||||
fileTexts[wid] = text
|
||||
} catch (e) { /* 单个画布读失败不影响其它 */ }
|
||||
wsRead++
|
||||
bpReport('canvases', wsRead, wsFiles.length)
|
||||
@@ -756,7 +801,20 @@
|
||||
}
|
||||
} catch (e) { /* 目录还没有 */ }
|
||||
// 旧格式:画布还压在 data.json 里 ⇒ 标脏,下一次 flush 拆成单文件
|
||||
if (fromDataJson) for (const k of Object.keys(parsed.keys || {})) if (isWsKey(k)) dirtyWs.add(k)
|
||||
// 2026-12-04:只有「文件缺失」或「data.json 里的旧副本与文件内容不同」才标脏;
|
||||
// 原来只要 data.json 残留 ws 键就全部标脏 ⇒ 每次启动重写所有画布(用户实测 mtime 全变)。
|
||||
if (fromDataJson) for (const k of Object.keys(parsed.keys || {})) {
|
||||
if (!isWsKey(k)) continue
|
||||
const wid = k.slice(WS_PREFIX.length)
|
||||
const oldText = fileTexts[wid]
|
||||
if (oldText === undefined || String(oldText) !== String(parsed.keys[k])) dirtyWs.add(k)
|
||||
}
|
||||
// 2026-12-04:记下当前内容签名 —— 启动后第一次 flush 若没实际变化,就不重写 data.json
|
||||
try {
|
||||
const keys0 = {}
|
||||
for (const k of Object.keys(mem)) if (!isSplitKey(k)) keys0[k] = mem[k]
|
||||
lastDataSig = JSON.stringify({ keys: keys0, assets, small })
|
||||
} catch (e) { lastDataSig = '' }
|
||||
return fromDataJson ? 'loaded' : 'migrated'
|
||||
}
|
||||
|
||||
@@ -990,7 +1048,7 @@
|
||||
it.thumbHash = String(a.f).split('/').pop().replace(/\.[^.]+$/, '')
|
||||
} catch (e) { /* 单张失败不影响其它 */ }
|
||||
}
|
||||
mem['iwb_web_outputs'] = JSON.stringify(items)
|
||||
storage.setItem('iwb_web_outputs', JSON.stringify(items))
|
||||
await flush()
|
||||
await blog('gallery:rebuilt ' + items.length)
|
||||
}
|
||||
@@ -1099,6 +1157,83 @@
|
||||
} catch (e) { return '' }
|
||||
}
|
||||
|
||||
// 2026-12-03:图库条目 → **本地原图**。桌面端原图在 images/gallery/<文件>,老记录没有 origIdb。
|
||||
// 预览用 galleryOriginalOf(原生按 max 解码,落 thumbs 缓存,可反复命中);下载用 galleryOriginalBlob(原始字节)。
|
||||
function galleryOrigAssetOf (f) {
|
||||
try {
|
||||
if (!enabled() || !dir || !f) return null
|
||||
const key = String(f.origIdb || ('out_orig_' + String(f.name || '')))
|
||||
const a = assets[key]
|
||||
return (a && a.f) ? a : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
// 2026-12-04(文件版下载,默认关闭):把 Rust 已下载好的临时文件**接管**进资产库。
|
||||
// 与 kv.put(Blob) 等价,但不经过 base64:同卷 rename,跨卷 copy+remove,然后登记 assets。
|
||||
// 2026-12-04:文件接管后按路径生成一张小缩略图(dataURL),供显示层 prime,避免首帧整幅解码原图。
|
||||
async function displayThumbDataUrlOfRef (ref, max) {
|
||||
try {
|
||||
const key = String(ref && ref.__blob ? ref.__blob : '')
|
||||
const a = key ? assets[key] : null
|
||||
if (!a || !a.f) return ''
|
||||
const m = Math.max(64, Number(max) || 320)
|
||||
const h16 = await sha16(new TextEncoder().encode('file:' + key))
|
||||
const r = await makeDisplayThumbFromPath(h16, await join(dir, a.f), m)
|
||||
if (!r) return ''
|
||||
return await readDisplayThumb(h16, m)
|
||||
} catch (e) { return '' }
|
||||
}
|
||||
|
||||
async function putFileFrom (srcPath, opt) {
|
||||
try {
|
||||
if (!enabled() || !dir) return null
|
||||
const o = opt || {}
|
||||
const key = String(o.key || '')
|
||||
const src = String(srcPath || '')
|
||||
if (!key || !src) return null
|
||||
const mime = String(o.mime || 'application/octet-stream')
|
||||
const cat = catOfKey(key)
|
||||
const h16 = await sha16(new TextEncoder().encode('file:' + key))
|
||||
const rel = IMG_DIR + '/' + cat + '/' + h16 + '.' + extOf(mime)
|
||||
const abs = await join(dir, rel)
|
||||
try { await fs().mkdir(await join(dir, IMG_DIR, cat), { recursive: true }) } catch (e) { /* ignore */ }
|
||||
let moved = false
|
||||
try { await fs().rename(src, abs); moved = true } catch (e) { moved = false }
|
||||
if (!moved) {
|
||||
const u8 = await fs().readFile(src)
|
||||
if (!u8 || !u8.length) { try { await fs().remove(src) } catch (e) { /* ignore */ } ; return null }
|
||||
await fs().writeFile(abs, u8)
|
||||
try { await fs().remove(src) } catch (e) { /* ignore */ }
|
||||
}
|
||||
assets[key] = { f: rel, k: 'blob', m: mime }
|
||||
schedule()
|
||||
await flush()
|
||||
return { __blob: key }
|
||||
} catch (e) {
|
||||
try { await fs().remove(String(srcPath || '')) } catch (e2) { /* ignore */ }
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function galleryOriginalOf (f, max) {
|
||||
try {
|
||||
const a = galleryOrigAssetOf(f)
|
||||
if (!a) return null
|
||||
const abs = await join(dir, a.f)
|
||||
const m = Math.max(256, Number(max) || 2048)
|
||||
const h16 = await sha16(new TextEncoder().encode('galorig:' + String(f.name || a.f)))
|
||||
const r = await makeDisplayThumbFromPath(h16, abs, m)
|
||||
return (r && r.url) ? { url: r.url, w: r.w || 0, h: r.h || 0 } : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
async function galleryOriginalBlob (f) {
|
||||
try {
|
||||
const a = galleryOrigAssetOf(f)
|
||||
if (!a) return null
|
||||
const abs = await join(dir, a.f)
|
||||
const u8 = await fs().readFile(abs)
|
||||
return (u8 && u8.length) ? new Blob([u8], { type: a.m || 'application/octet-stream' }) : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
// v3.26.131:宫格缩略图改发 **objectURL**(同一张只读一次盘、只建一次 URL)。
|
||||
// 原来每张都 base64 成 dataURL(20~40KB 字符串),164 张 ⇒ 每次开面板 3~6MB 字符串 + 164 次 IPC,
|
||||
// 这就是「能加载但很慢」的来源。objectURL 首帧即用,重复打开直接命中。
|
||||
@@ -1260,11 +1395,32 @@
|
||||
}
|
||||
|
||||
// v3.25.80:启动维护入口(缩略图封顶 + legacy 未引用清理),宿主只调这一个
|
||||
// 2026-12-04:文件版下载的临时目录清理(失败/崩溃会留下 .bin;保留 24h 内,其余删)
|
||||
async function cleanupCacheTmp () {
|
||||
try {
|
||||
if (!enabled() || !dir) return 0
|
||||
const tdir = await join(dir, 'cache', 'tmp')
|
||||
if (!(await fs().exists(tdir))) return 0
|
||||
const ents = await fs().readDir(tdir)
|
||||
const cutoff = Date.now() - 24 * 3600e3
|
||||
let n = 0
|
||||
for (const e of ents) {
|
||||
if (!e || e.isDirectory) continue
|
||||
try {
|
||||
const st = await fs().stat(await join(tdir, e.name))
|
||||
if (!st || Number(st.mtimeMs || 0) < cutoff) { await fs().remove(await join(tdir, e.name)); n++ }
|
||||
} catch (err) { /* ignore */ }
|
||||
}
|
||||
return n
|
||||
} catch (e) { return 0 }
|
||||
}
|
||||
|
||||
async function maintain (opts) {
|
||||
const o = opts || {}
|
||||
const a = await pruneThumbs(o.maxMB).catch(() => 0)
|
||||
const b = await cleanupLegacy(o.keep).catch(() => 0)
|
||||
return { thumbs: a, legacy: b }
|
||||
const c = await cleanupCacheTmp().catch(() => 0)
|
||||
return { thumbs: a, legacy: b, tmp: c }
|
||||
}
|
||||
|
||||
// v3.26.123:原生缩略图。有就返回,没有就让 Rust 按目标尺寸解码/缩放/编码后写盘,再读成 objectURL。
|
||||
@@ -1442,7 +1598,7 @@
|
||||
if (!it || !it.data) continue
|
||||
if (it.thumbHash && map[String(it.thumbHash)]) { it.data = ''; n++ }
|
||||
}
|
||||
if (n) { mem['iwb_web_outputs'] = JSON.stringify(items); await flush() }
|
||||
if (n) { storage.setItem('iwb_web_outputs', JSON.stringify(items)); await flush() }
|
||||
await fs().writeTextFile(marker, String(n))
|
||||
return n
|
||||
} catch (e) { return 0 }
|
||||
@@ -1479,6 +1635,10 @@
|
||||
// 子目录也要扫:images/{canvas,gallery,thumbs,legacy}/ 里的孤儿同样占空间
|
||||
const subs = ['', 'canvas', 'gallery', 'thumbs', 'legacy']
|
||||
const orphans = []
|
||||
// 2026-12-03:thumbs/<hash>_<max>.<ext> 是**显示缓存**(320/512/768/2048),不进 assets、可再生。
|
||||
// 之前把它们算成「未引用图片」并搬进 trash ⇒ 每次清理都搬一遍新缓存,数字也被夸大。默认不动。
|
||||
const THUMB_CACHE_RE = /_\d+\.(jpg|jpeg|webp|png)$/i
|
||||
let thumbCaches = 0
|
||||
for (const sub of subs) {
|
||||
const abs = sub ? await join(imgAbs, sub) : imgAbs
|
||||
let entries = []
|
||||
@@ -1486,25 +1646,37 @@
|
||||
for (const e of entries) {
|
||||
if (!e || e.isDirectory) continue
|
||||
const rel = IMG_DIR + '/' + (sub ? sub + '/' : '') + e.name
|
||||
if (!used.has(rel)) orphans.push({ sub: sub, name: e.name, rel: rel })
|
||||
if (used.has(rel)) continue
|
||||
if (sub === 'thumbs' && THUMB_CACHE_RE.test(String(e.name))) { thumbCaches++; continue }
|
||||
orphans.push({ sub: sub, name: e.name, rel: rel })
|
||||
}
|
||||
}
|
||||
// 断链:画布引用了、但登记表里没有的 key —— 这类节点的图**已经显示不出来**,
|
||||
// GC 不会动它们(文件根本不在),但值得在确认弹窗里报数,让用户知道数据已经缺了。
|
||||
const dangling = Array.from(canvasKeys).filter((k) => !assets[k]).length
|
||||
const keptByCanvas = referenced.size
|
||||
if (dryRun || !orphans.length) return { ok: true, orphans: orphans.length, moved: 0, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas }
|
||||
if (dryRun || !orphans.length) return { ok: true, orphans: orphans.length, moved: 0, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas, thumbCaches: thumbCaches }
|
||||
const trashAbs = await join(dir, 'trash')
|
||||
let moved = 0
|
||||
for (const item of orphans) {
|
||||
try {
|
||||
const targetDir = item.sub ? await join(trashAbs, item.sub) : trashAbs
|
||||
await fs().mkdir(targetDir, { recursive: true })
|
||||
await fs().rename(await join(imgAbs, item.sub, item.name), await join(targetDir, item.name))
|
||||
let target = await join(targetDir, item.name)
|
||||
try {
|
||||
await fs().rename(await join(imgAbs, item.sub, item.name), target)
|
||||
} catch (eR) {
|
||||
// 同名已在 trash 里(上次清理过):加时间戳,别让整条静默失败
|
||||
const dot = String(item.name).lastIndexOf('.')
|
||||
const sfx = '-' + Date.now()
|
||||
const alt = dot > 0 ? String(item.name).slice(0, dot) + sfx + String(item.name).slice(dot) : String(item.name) + sfx
|
||||
target = await join(targetDir, alt)
|
||||
await fs().rename(await join(imgAbs, item.sub, item.name), target)
|
||||
}
|
||||
moved++
|
||||
} catch (e) { /* 单条失败忽略 */ }
|
||||
}
|
||||
return { ok: true, orphans: orphans.length, moved: moved, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas }
|
||||
return { ok: true, orphans: orphans.length, moved: moved, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas, thumbCaches: thumbCaches }
|
||||
} catch (e) { return { ok: false, error: String((e && e.message) || e) } }
|
||||
}
|
||||
|
||||
@@ -1612,7 +1784,7 @@
|
||||
enabled, ready: init, flush,
|
||||
// 供其它模块把诊断写进 _boot.log(v3.26.109)
|
||||
logLine: (m) => blog(m),
|
||||
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, galleryThumbOfEntry, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
|
||||
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, galleryThumbOfEntry, galleryOriginalOf, galleryOriginalBlob, putFileFrom, displayThumbDataUrlOfRef, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
|
||||
plugins: { manifest: pluginManifest, read: pluginRead, write: pluginWrite, remove: pluginRemove, dir: pluginDir, listLocal: pluginListLocal, listDirs: pluginListDirs, readFile: pluginReadFile, writeFile: pluginWriteFile, writeBinary: pluginWriteBinary, mkdir: pluginMkdir, removeDir: pluginRemoveDir, renameDir: pluginRenameDir, existsDir: pluginExistsDir },
|
||||
pluginData: { read: pluginDataRead, write: pluginDataWrite, remove: pluginDataRemove, list: pluginDataList },
|
||||
pluginFiles: { put: pluginFilePut, get: pluginFileGet, list: pluginFileList, remove: pluginFileRemove, stat: pluginFileStat, dir: pluginFilesDir, readBytes: pluginFileReadBytes, listAll: pluginFilesListAll },
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
const added = []
|
||||
for (const item of items || []) if (item && item.url) {
|
||||
const name = item.name || ('gen_' + Date.now() + '_' + Math.floor(Math.random() * 1e6) + '.png')
|
||||
index.push({ name, url: item.url, size: item.size || 0, mtime: item.mtime || Date.now(), w: item.width || item.w || 0, h: item.height || item.h || 0, label: item.label || '' })
|
||||
// 2026-12-03:保留 orig 状态 —— 之前重建行时丢掉它,行若在 markOk 之后创建就永远显示「未落地」。
|
||||
index.push({ name, url: item.url, size: item.size || 0, mtime: item.mtime || Date.now(), w: item.width || item.w || 0, h: item.height || item.h || 0, label: item.label || '', orig: item.orig || 'pending' })
|
||||
added.push(name)
|
||||
}
|
||||
const opts = options || {}
|
||||
|
||||
+18
-2
@@ -20,7 +20,7 @@
|
||||
const useCallback = React.useCallback
|
||||
const useLayoutEffect = React.useLayoutEffect
|
||||
|
||||
let ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl
|
||||
let ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, wOutNameOf, nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl
|
||||
|
||||
function inject (d) {
|
||||
if (!d) throw new Error('[iwb][IWBUICanvasView] 依赖未注入')
|
||||
@@ -29,6 +29,7 @@
|
||||
computeEdgePath = d.computeEdgePath
|
||||
copyImageToClipboard = d.copyImageToClipboard
|
||||
downloadUrl = d.downloadUrl
|
||||
wOutNameOf = d.wOutNameOf
|
||||
nodeTypeColor = d.nodeTypeColor
|
||||
nodeTypeH = d.nodeTypeH
|
||||
nodeWidth = d.nodeWidth
|
||||
@@ -339,6 +340,15 @@ function ImagePreview(props) {
|
||||
if (!e || typeof e === 'string' || !e.__gallery) return Promise.resolve(placeholderOf(e))
|
||||
const key = 'orig:' + entryKeyOf(e)
|
||||
const hit = cachedOf(key); if (hit) return Promise.resolve(hit)
|
||||
// 2026-12-03(用户裁定「本地优先」):没有 origIdb 的老记录,直接按行名读 images/gallery 原图(原生解码),
|
||||
// 不再退回 320 缩略图、也不直连远程;返回的是宿主持有的 objectURL,不进本组件的回收表。
|
||||
const SF = (typeof window !== 'undefined') ? window.IWBStorageFile : null
|
||||
if (!e.origIdb && e.name && SF && typeof SF.galleryOriginalOf === 'function') {
|
||||
return Promise.resolve(SF.galleryOriginalOf({ name: e.name, origIdb: e.origIdb }, 2048))
|
||||
.then((g) => (g && g.url) || '')
|
||||
.catch(() => '')
|
||||
.then((u) => u || urlOfFallback(e.url || placeholderOf(e), key, 'orig'))
|
||||
}
|
||||
const idbKey = e.origIdb || e.idb
|
||||
if (!idbKey) return urlOfFallback(e.url || placeholderOf(e), key, 'orig')
|
||||
const p = (typeof IDB.getBlob === 'function') ? IDB.getBlob(idbKey) : IDB.get(idbKey)
|
||||
@@ -363,6 +373,10 @@ function ImagePreview(props) {
|
||||
return wBlobFromDataUrl(str)
|
||||
}
|
||||
const fallbackStr = e.url || placeholderOf(e)
|
||||
const SF2 = (typeof window !== 'undefined') ? window.IWBStorageFile : null
|
||||
if (!e.origIdb && e.name && SF2 && typeof SF2.galleryOriginalBlob === 'function') {
|
||||
return Promise.resolve(SF2.galleryOriginalBlob({ name: e.name, origIdb: e.origIdb })).then((b) => b || null).catch(() => null)
|
||||
}
|
||||
const idbKey = e.origIdb || e.idb
|
||||
if (!idbKey) return Promise.resolve(asBlobOf(fallbackStr)).then((b) => ((b && b.size) ? b : null)).catch(() => null)
|
||||
const p = (typeof IDB.getBlob === 'function') ? IDB.getBlob(idbKey) : IDB.get(idbKey)
|
||||
@@ -533,7 +547,9 @@ function ImagePreview(props) {
|
||||
// downloadUrl 只吃 URL:把字节登记成**可取回**的 objectURL(wBlobRefGet 能反查),否则下载链路取不到 Blob
|
||||
const blob = await loadOriginalBlob(entry).catch(() => null)
|
||||
const blobUrl = (blob && typeof wRegisterBlobUrl === 'function') ? wRegisterBlobUrl(blob) : ''
|
||||
downloadUrl(blobUrl || src, 'image.png')
|
||||
// 2026-12-03:预览下载同样走图库行名(图库条目直接用行名,其余按 url 查),未落地才回退 image.png
|
||||
const dlName = (entry && entry.__gallery && entry.name) ? String(entry.name) : ((typeof wOutNameOf === 'function' && wOutNameOf(entry && entry.url)) || 'image.png')
|
||||
downloadUrl(blobUrl || src, dlName)
|
||||
},
|
||||
}, I('download'), ' 下载'),
|
||||
),
|
||||
|
||||
+14
-8
@@ -5,8 +5,11 @@
|
||||
const el = React.createElement
|
||||
function ResultImg(props) {
|
||||
const useState = React.useState
|
||||
const useEffect = React.useEffect
|
||||
const [hover, setHover] = useState(false)
|
||||
const item = props.item || {}
|
||||
// 2026-12-02:落地状态展示改在输出节点体(ui-node-bodies);本组件全仓无调用点,保持纯展示
|
||||
|
||||
const doCopyRef = () => { props.onCopyRef && props.onCopyRef(item.url) }
|
||||
const doCopyLink = () => {
|
||||
// 统一走 IWBClipboardCopy(2026-11-24)
|
||||
@@ -25,27 +28,30 @@
|
||||
) : null,
|
||||
)
|
||||
}
|
||||
// 共享「下载浮层」:底部渐变 + 下载(可选复制),hover/focus 才出现。
|
||||
// 图库插件是原生 DOM,用同一组 token 在插件 CSS 里复刻;宿主这里只需一个 React 组件。
|
||||
// pointer-events:浮层条本身不吃事件(否则会挡住图片点击/双击),只有悬停后按钮才可点。
|
||||
// 共享「下载浮层」:右下角圆形图标(可选复制),hover/focus 才出现。
|
||||
// 2026-12-03(用户裁定):只改输出节点这一处呈现 —— 底部横条会压住矮图的中心,改成只占右下角。
|
||||
// 约束(上一次改造踩过的坑):① 容器 pointer-events:none、只有按钮 auto;② 不改任何类名之外的 DOM 结构;
|
||||
// ③ 不动 z-index 层级表、不动 token 体系;旧的 .iwb-dl-bar 样式保留在 CSS 里可随时回退。
|
||||
function ResultDownloadOverlay (props) {
|
||||
const p = props || {}
|
||||
const stopDown = (e) => { try { e.stopPropagation() } catch (err) { /* ignore */ } }
|
||||
return el('div', { className: 'iwb-dl-ov' },
|
||||
p.children,
|
||||
el('div', { className: 'iwb-dl-bar' },
|
||||
el('div', { className: 'iwb-dl-corner' },
|
||||
p.onCopyRef ? el('button', {
|
||||
className: 'iwb-dl-btn iwb-dl-btn-ghost',
|
||||
className: 'iwb-dl-round',
|
||||
title: p.copyTitle || '插入为参考图节点',
|
||||
'aria-label': p.copyLabel || '复制',
|
||||
onPointerDown: stopDown,
|
||||
onClick: (e) => { e.stopPropagation(); p.onCopyRef() },
|
||||
}, p.copyIcon || null, el('span', { className: 'iwb-dl-txt' }, p.copyLabel || '复制')) : null,
|
||||
}, p.copyIcon || '⧉') : null,
|
||||
el('button', {
|
||||
className: 'iwb-dl-btn',
|
||||
className: 'iwb-dl-round iwb-dl-round-primary',
|
||||
title: p.downloadTitle || '下载原图',
|
||||
'aria-label': p.label || '下载',
|
||||
onPointerDown: stopDown,
|
||||
onClick: (e) => { e.stopPropagation(); if (p.onDownload) p.onDownload() },
|
||||
}, p.icon || null, el('span', { className: 'iwb-dl-txt' }, p.label || '下载')),
|
||||
}, p.icon || '↓'),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
['拖拽 / 框选', '拖动画布空白 = 框选节点(Shift 追加、Alt 反选);拖动节点 = 移动;Ctrl/Cmd + 点击 = 多选'],
|
||||
['空格 / 鼠标中键', '按住拖动平移画布;抓手工具(H)等效,V 切回选择'],
|
||||
['滚轮', '缩放画布;节点右下角可拖拽改尺寸'],
|
||||
['双击节点标题', '居中放大该节点;重命名走气泡铅笔 / 右键菜单 / F2'],
|
||||
['双击节点标题', '双击标题文字改名;双击标题栏其它处居中放大;也可右键菜单或 F2'],
|
||||
['右键', '自定义菜单:添加节点 / 复制选中 / 导出节点组 / 收藏 / 删除 / 该节点操作'],
|
||||
['连线', '从出端口拖到目标区域自动连接(绿框可连、红框不可连);点选连线 Delete 断开,双击直接断开'],
|
||||
['Alt + 拖到连线', '插入:节点吸附到连线中间并拆成两条;链中间单入单出的节点 Alt 拖出 = 脱离'],
|
||||
|
||||
@@ -77,6 +77,9 @@
|
||||
const onHome = props.onHome
|
||||
const onCanvas = props.onCanvas
|
||||
const onPlugins = props.onPlugins
|
||||
const pages = Array.isArray(props.pages) ? props.pages : []
|
||||
const activePage = String(props.activePage || '')
|
||||
const onPage = props.onPage
|
||||
const onHelp = props.onHelp
|
||||
const onHotkeys = props.onHotkeys
|
||||
const onSkin = props.onSkin
|
||||
@@ -195,6 +198,7 @@
|
||||
item('home', 'home', '首页(画布库)', view === 'home', onHome),
|
||||
item('canvas', 'layer', '列表(画布工作区)', view === 'canvas', onCanvas),
|
||||
item('plugins', 'box', '插件', view === 'plugins', onPlugins),
|
||||
pages.map((p) => item('pg:' + p.pluginId + ':' + p.id, p.icon || 'queue', p.title, activePage === (p.pluginId + ':' + p.id), () => { if (typeof onPage === 'function') onPage(p.pluginId, p.id) })),
|
||||
),
|
||||
el('div', { className: 'iwb-navrail-spacer' }),
|
||||
el('div', { className: 'iwb-navrail-group' },
|
||||
|
||||
+155
-50
@@ -11,11 +11,17 @@
|
||||
// · ctx = { onUpdate, busy, progress, h, stop, refMini },由调用方 renderBodyInner 组装。
|
||||
|
||||
// ── 注入依赖(app.js 在首次渲染时调用 inject 注入)─────────────────────────
|
||||
let I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, isImageProducer, nodePreviewRefsV2, nodeInheritOf, orderedUniqueRefNodes, outProgUI, outThumbCache, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg, wThumbSrc, el, wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder, GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName, ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds
|
||||
// 输出节点缩略图补取去重(每个 url 本会话只触发一次)
|
||||
const outThumbPending = new Set()
|
||||
let ingestView, I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, wOutNameOf, wPreviewEntryOf, wOutThumbEnsure, wRustFetchBlob, isImageProducer, nodePreviewRefsV2, nodeInheritOf, orderedUniqueRefNodes, outProgUI, outThumbCache, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg, wThumbSrc, el, wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder, GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName, ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, wThumbBump
|
||||
// 2026-12-03:输出格「NEW」标记 —— 只认本次启动之后生成的图;已确认的 key 记在内存里,不写画布存档。
|
||||
const OUT_NEW_SINCE = Date.now()
|
||||
const outNewSeen = new Set()
|
||||
function inject(d) {
|
||||
const D = d || {}
|
||||
I = D.I
|
||||
wPluginNodeVariants = D.wPluginNodeVariants
|
||||
ingestView = D.ingestView // 2026-12-02:落地状态视图由宿主注入(不直接读 window 全局)
|
||||
wPluginVariantMeta = D.wPluginVariantMeta
|
||||
isBatchSrc = D.isBatchSrc
|
||||
batchSrcText = D.batchSrcText
|
||||
@@ -25,6 +31,10 @@
|
||||
combineSourcePairs = D.combineSourcePairs
|
||||
downloadUrl = D.downloadUrl
|
||||
wResolveOutSrc = D.wResolveOutputSrc
|
||||
wOutNameOf = D.wOutNameOf
|
||||
wPreviewEntryOf = D.wPreviewEntryOf
|
||||
wOutThumbEnsure = D.wOutThumbEnsure
|
||||
wRustFetchBlob = D.wRustFetchBlob
|
||||
isImageProducer = D.isImageProducer
|
||||
nodePreviewRefsV2 = D.nodePreviewRefsV2
|
||||
nodeInheritOf = D.nodeInheritOf
|
||||
@@ -54,6 +64,7 @@
|
||||
resOfSize = D.resOfSize
|
||||
taskStallEndMs = D.taskStallEndMs
|
||||
wDedupeTaskIds = D.wDedupeTaskIds
|
||||
wThumbBump = D.wThumbBump
|
||||
}
|
||||
|
||||
|
||||
@@ -680,13 +691,17 @@
|
||||
// 直接 String() 会变成 "[object Object]" ⇒ <img> 破图(2026-11-29 实测 45 个节点踩中)。
|
||||
const src = wResolveImg(d.localRef) || wResolveImg(d.data) || wResolveImg(d.url)
|
||||
const hasImg = !!src
|
||||
// 来源判定:url 是 http(s) 就是网络图(缓存出 localRef 也不改变来源);否则是本地图片。
|
||||
const remoteUrl = typeof d.url === 'string' && /^https?:\/\//i.test(d.url)
|
||||
const showUrlRow = remoteUrl || !(d.data || d.localRef || d.localName)
|
||||
const commitRefUrl = (event) => {
|
||||
const root = event && event.currentTarget && event.currentTarget.closest ? event.currentTarget.closest('.iwb-ref-body') : null
|
||||
const input = root && root.querySelector('.iwb-ref-url-input')
|
||||
const value = String((input && input.value) || '').trim()
|
||||
if (!value) return
|
||||
if (!/^https?:\/\//i.test(value)) return props.onNotice && props.onNotice('图片链接必须以 http:// 或 https:// 开头')
|
||||
onUpdate(node.id, { url: value, data: null, localName: null, name: value.split('/').pop().split('?')[0] || '远程图片' })
|
||||
// 2026-12-05:换 URL 要一并清掉旧网络图的本地缓存引用,否则仍显示上一张。
|
||||
onUpdate(node.id, { url: value, data: null, localRef: null, ref: null, localName: null, name: value.split('/').pop().split('?')[0] || '远程图片' })
|
||||
}
|
||||
// 序号徽标:全画布参考图节点按坐标排序中的位置(x 从左到右,同 x 按 y)
|
||||
const allRefs = (props.nodes || []).filter((n) => n.type === 'ref' && !(n.data && n.data.enabled === false))
|
||||
@@ -745,54 +760,17 @@
|
||||
el('span', { className: 'iwb-ref-broken-t' }, '图片源已失效'),
|
||||
el('span', { className: 'iwb-ref-broken-s' }, '双击重新导入'),
|
||||
),
|
||||
(typeof d.url === 'string' && d.url) ? el('div', { className: 'iwb-ref-url-current', title: d.url }, 'URL 图片') : null,
|
||||
)
|
||||
: el('div', { className: 'iwb-ref-emptybox', title: '单击选中 · 双击上传图片', onDoubleClick: (e) => { e.stopPropagation(); if (refFileInput) refFileInput.click() } },
|
||||
el('span', { className: 'iwb-ref-upload' }, '点击上传参考图'),
|
||||
fileInput,
|
||||
),
|
||||
el('div', { className: 'iwb-ref-url-row' },
|
||||
// 「上传到图库」:本地图片直接上传;只有 URL 的节点先取字节再上传(2026-11-01 用户要求常驻)
|
||||
(d.data || (typeof d.url === 'string' && d.url)) ? el('button', {
|
||||
className: 'iwb-btn iwb-btn-sm iwb-ref-upload-link',
|
||||
disabled: props.uploadingRefId === node.id,
|
||||
title: props.uploadingRefId === node.id ? '正在上传…' : '上传到图库:把这张图传到图库并填入链接',
|
||||
'aria-label': '上传到图库',
|
||||
onClick: async (e) => {
|
||||
stop(e)
|
||||
if (props.uploadingRefId === node.id) return
|
||||
props.setUploadingRefId && props.setUploadingRefId(node.id)
|
||||
try {
|
||||
let payload = d.data
|
||||
// 只有 URL 时:先取回字节(同源/允许 CORS 才能成功)
|
||||
if (!payload) {
|
||||
const res = await fetch(d.url, { credentials: 'same-origin' })
|
||||
if (!res || !res.ok) throw new Error('图片下载失败(HTTP ' + (res && res.status) + ')')
|
||||
const blob = await res.blob()
|
||||
payload = await new Promise((done, fail) => {
|
||||
const fr = new FileReader()
|
||||
fr.onload = () => done(String(fr.result || ''))
|
||||
fr.onerror = () => fail(new Error('读取图片失败'))
|
||||
fr.readAsDataURL(blob)
|
||||
})
|
||||
}
|
||||
const url = await uploadRefToImageHost(payload, wRawCfg(), d.name)
|
||||
onUpdate(node.id, { url, data: null, localName: null, name: url.split('/').pop() || '在线图片' })
|
||||
props.onNotice && props.onNotice('已上传到图库并填入链接')
|
||||
} catch (err) {
|
||||
props.onNotice && props.onNotice('上传失败:' + String((err && err.message) || err))
|
||||
} finally {
|
||||
props.setUploadingRefId && props.setUploadingRefId(null)
|
||||
}
|
||||
},
|
||||
onPointerDown: stop,
|
||||
}, el('svg', { viewBox: '0 0 24 24', width: 15, height: 15, 'aria-hidden': 'true' },
|
||||
el('path', { d: 'M12 16V4m0 0L8 8m4-4 4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2', fill: 'none', stroke: 'currentColor', 'stroke-width': 1.8, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' }),
|
||||
)) : null,
|
||||
// 使用链接改为**按回车**(原来右侧还有一个 ✎ 按钮,用户要求去掉)
|
||||
el('input', { className: 'iwb-input iwb-ref-url-input', defaultValue: (typeof d.url === 'string' && !d.data) ? d.url : '', placeholder: '输入图片 URL(回车使用)', onKeyDown: (e) => { if (e.key === 'Enter') commitRefUrl(e) }, onPointerDown: stop }),
|
||||
),
|
||||
|
||||
// 2026-12-05(用户):URL 输入行保留给「网络图」与「空节点」;本地图片不渲染。
|
||||
// 网络图被后台缓存成 localRef 之后仍要能改链接(原来一看 localRef 就藏起来,用户找不到输入框)。
|
||||
// 「上传到图库」在选中气泡里,行内只有输入框。
|
||||
showUrlRow ? el('div', { className: 'iwb-ref-url-row' },
|
||||
el('input', { className: 'iwb-input iwb-ref-url-input', defaultValue: remoteUrl ? d.url : '', placeholder: '输入图片 URL(回车使用)', onKeyDown: (e) => { if (e.key === 'Enter') commitRefUrl(e) }, onPointerDown: stop }),
|
||||
) : null,
|
||||
el('div', { className: 'iwb-ref-foot' }, null),
|
||||
)
|
||||
}
|
||||
@@ -855,7 +833,18 @@
|
||||
for (const e of grp.entries) { const prev = keep.get(e.vi); if (!prev || e.at >= prev.at) keep.set(e.vi, e) }
|
||||
const items = []
|
||||
for (const e of Array.from(keep.values()).sort((a, b) => (a.vi - b.vi) || (a.at - b.at))) {
|
||||
for (const it of (Array.isArray(e.en.items) ? e.en.items : [])) if (it && it.ok && it.url) items.push(it)
|
||||
// 2026-12-02(方案 A):新图下载期间 entry.pending 存着上一张 —— 逐位配对成 _prev,
|
||||
// 渲染时按「新图本地字节是否就绪」决定显示新图还是旧图(见 renderOutBody)。
|
||||
const prevItems = (e.en.pending && Array.isArray(e.en.pending.items)) ? e.en.pending.items.filter((it) => it && it.ok && it.url) : []
|
||||
const its = (Array.isArray(e.en.items) ? e.en.items : []).filter((it) => it && it.ok && it.url)
|
||||
const genAt = numOr(e.en.at, 0)
|
||||
for (let k = 0; k < its.length; k++) {
|
||||
const prev = prevItems[k] || null
|
||||
// 始终复制:_genAt/_genKey 只给渲染用,绝不能挂到画布存档的 item 上。
|
||||
const extra = { _genAt: genAt, _genKey: String(grp.promptId) + '|' + String(e.vi) + '|' + String(genAt) }
|
||||
if (prev) extra._prev = prev
|
||||
items.push(Object.assign({}, its[k], extra))
|
||||
}
|
||||
}
|
||||
return { genId: grp.genId, promptId: grp.promptId, taskTitle: grp.taskTitle, taskTitleNow: grp.taskTitleNow, label: grp.label, at: grp.at, known: grp.known, items }
|
||||
})
|
||||
@@ -870,9 +859,29 @@
|
||||
.filter((n) => isImageProducer(n) && !(n.data && n.data.enabled === false))
|
||||
// 顺序以任务卡为准:metaOf 读的正是任务卡渲染用的同一份任务列表(同一个缓存),顺序必然一致
|
||||
const merged = outGroupsOf(srcGens, (g) => cachedGenerationTasks(g, props.nodes || [], props.edges || []).map((t) => ({ id: t.id, title: t.title || '' })))
|
||||
// 2026-12-02(方案 A):新图本地字节就绪前先显示上一张(_prev),就绪后再换成新图。
|
||||
const ingView0 = (typeof ingestView === 'function') ? ingestView() : null
|
||||
const localReady = (r) => {
|
||||
if (!r) return false
|
||||
if (r.idb && r.data) return true
|
||||
if (r.url && outThumbCache.get(r.url)) return true
|
||||
const v = (ingView0 && typeof ingView0.get === 'function') ? ingView0.get(r.url) : null
|
||||
return !!(v && v.localUrl)
|
||||
}
|
||||
for (const m of merged) m.items = m.items.map((r) => (r && r._prev && !localReady(r)) ? Object.assign({}, r._prev, { _awaitUrl: r.url }) : r)
|
||||
// 2026-12-03:NEW 标记自动消失时长(秒,0=不自动消失);设置 → 生成 →「新图标记」。
|
||||
const newBadgeMs = (() => {
|
||||
try {
|
||||
const c = (typeof wRawCfg === 'function') ? wRawCfg() : null
|
||||
const sec = Number(c && c.canvas && c.canvas.newBadgeSec)
|
||||
return Number.isFinite(sec) ? Math.max(0, Math.min(3600, sec)) * 1000 : 120000
|
||||
} catch (e) { return 120000 }
|
||||
})()
|
||||
const allOk = []
|
||||
for (const m of merged) for (const r of m.items) allOk.push(r)
|
||||
const openPreviewAt = (i) => { const u = allOk[i] && allOk[i].url; if (u) props.onPreview && props.onPreview(u, allOk.map((x) => x.url), i) }
|
||||
// 2026-12-03(用户):预览条目与图库同口径 —— 有图库行就给 __gallery(本地原图优先),不再一律喂远程 url。
|
||||
const previewEntryOf = (u) => (typeof wPreviewEntryOf === 'function' ? wPreviewEntryOf(u) : u)
|
||||
const openPreviewAt = (i) => { const u = allOk[i] && allOk[i].url; if (u) props.onPreview && props.onPreview(previewEntryOf(u), allOk.map((x) => previewEntryOf(x.url)), i) }
|
||||
// 生图节点中的 result 项不一定携带与自身匹配的缩略图;只有明确带 idb 引用时才使用 data,避免多张图共享旧缩略图。
|
||||
const thumbOf = (r) => (r && r.idb && r.data) ? r.data : ((r && r.url && outThumbCache.get(r.url)) || (r && r.url))
|
||||
let imgIndex = 0
|
||||
@@ -885,16 +894,112 @@
|
||||
let src = r.url
|
||||
// v3.25.18:从资料目录的本地归档取图(原图优先),远端 URL 只作兜底
|
||||
try { if (wResolveOutSrc) src = (await wResolveOutSrc(r, true)) || r.url } catch (e) { /* 回退远端 */ }
|
||||
downloadUrl(src, 'image.png')
|
||||
// 2026-12-03:文件名统一用图库行名(未落地才回退 image.png),与图库下载一致
|
||||
downloadUrl(src, (typeof wOutNameOf === 'function' && wOutNameOf(r.url)) || 'image.png')
|
||||
}
|
||||
const imgEl = el('img', { key: 'out-img-' + cur + '-' + String(r.url || '').slice(-48), className: 'iwb-out-cell-img', decoding: 'async', fetchPriority: 'low', referrerPolicy: 'no-referrer', src: wPreviewUrlOf((typeof wImgSrcForNode === 'function' ? wImgSrcForNode : wDisplayThumbOf)(thumbOf(r), Math.max(120, Math.min(360, (node && node.w ? node.w - 40 : 240))))), draggable: true, style: { aspectRatio: (r.width && r.height) ? String(r.width) + ' / ' + String(r.height) : undefined }, title: r.idb && r.data ? '单击选中 · 双击查看原图 · 拖到画布作参考图' : '单击选中 · 双击放大(可左右切换)· 拖到画布作参考图', onError: (e) => { if (e.currentTarget && e.currentTarget.src !== r.url) e.currentTarget.src = r.url }, onPointerDown: (e) => { e.stopPropagation(); props.onSelect && props.onSelect(node.id) }, onDragStart: (e) => { try { const u = r.url || ''; e.dataTransfer.setData('application/x-iwb-output-ref', u); e.dataTransfer.setData('text/plain', u); e.dataTransfer.effectAllowed = 'copy' } catch (err) { /* 浏览器拒写自定义 MIME 时仍保留 text/plain */ } }, onDoubleClick: (e) => { e.stopPropagation(); openPreviewAt(cur) } })
|
||||
// 生成中(2026-12-02,用户裁定「方案 1」):某一轮还在跑时,旧图压暗 + 角标「生成中」,
|
||||
// 但不改 data.result —— 失败时旧图原样保留,不会出现「图没了」。
|
||||
// 2026-12-02(方案 A):显示项可能是「上一张」(_prev),而下载状态属于「等待中的新 url」。
|
||||
const awaitUrl = r._awaitUrl || r.url
|
||||
const ingView = (typeof ingestView === 'function') ? ingestView() : null
|
||||
const ingSt = (ingView && typeof ingView.get === 'function') ? ingView.get(awaitUrl) : null
|
||||
// 2026-12-02(方案 A):这一格还没有任何本地源时,垫一层骨架 + 「下载中…」文字,
|
||||
// 避免大图区域纯空白(有缩略图时 LOD 已经会显示模糊可辨的画面,不需要这层)。
|
||||
// 2026-12-02 修 TDZ:_localSrc 必须先声明再用(上一版 phEl 读它时还没初始化,五态全崩)
|
||||
const _localSrc = (r && r.idb && r.data) ? r.data : ((r && r.url && outThumbCache.get(r.url)) || null)
|
||||
// 2026-12-04(用户):重开画布后老记录没有 data / 缓存是空的 → 按「本地优先」从磁盘补一张缩略图
|
||||
// (thumbHash → images/gallery 原图现生成 320),补到后 bump 重绘。每个 url 本会话只试一次。
|
||||
if (!_localSrc && r && r.url && typeof wOutThumbEnsure === 'function' && !outThumbPending.has(r.url)) {
|
||||
outThumbPending.add(r.url)
|
||||
Promise.resolve(wOutThumbEnsure(r.url)).then(function (u) {
|
||||
if (!u) return
|
||||
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e0) { /* ignore */ }
|
||||
}).catch(function () { /* ignore */ })
|
||||
}
|
||||
// 2026-12-02:骨架只在「连远程 url 都没有」时出现。有 url 就让 <img> 直接渐进渲染(203 的观感),
|
||||
// 不要用骨架盖住一张正在下载的图 —— 慢 CDN 上那会变成长时间空白。
|
||||
// 2026-12-02:骨架改为「垫在图片下面」的底层(不再只在没有 url 时出现)——
|
||||
// 图片未绘制前看到的是骨架,绘制完成(.is-loaded-cell)后骨架自动被隐藏,不会遮挡渐进渲染。
|
||||
// 显示上一张时绝不盖骨架(骨架是不透明垫层,会遮住旧图);骨架只服务「无任何可显示字节」的新格。
|
||||
const phEl = (!r._awaitUrl && !_localSrc && !(ingSt && ingSt.localUrl))
|
||||
? el('div', { className: 'iwb-out-cell-ph', key: 'ph' }, el('span', { className: 'iwb-out-cell-ph-txt' }, '下载中…'))
|
||||
: null
|
||||
const imgEl = el('img', { key: 'out-img-' + cur + '-' + String(r.url || '').slice(-48), className: 'iwb-out-cell-img', decoding: 'async', fetchPriority: 'low', referrerPolicy: 'no-referrer', onLoad: (e) => {
|
||||
// 2026-12-02:img 被包在下载浮层(.iwb-dl-ov)里,parentElement 不是单元格 —— 必须向上找 .iwb-out-cell
|
||||
try {
|
||||
const im = e && e.currentTarget
|
||||
if (!im) return
|
||||
im.classList.add('is-loaded')
|
||||
// 2026-12-02:加载成功后必须撤销失败态 —— 首帧本地 blob 失效会先打 is-broken,
|
||||
// 回退远程成功后若不撤销,「加载失败」与 25% 透明度会一直盖在正常图上。
|
||||
im.classList.remove('is-broken')
|
||||
const cell = (im.closest && im.closest('.iwb-out-cell')) || im.parentElement
|
||||
// 显示的是上一张(新图还在下)时不收角标,否则「下载中」会被旧图的 onLoad 立刻吃掉。
|
||||
if (cell && !r._awaitUrl) { cell.classList.add('is-loaded-cell'); cell.classList.remove('is-broken-cell') }
|
||||
} catch (e0) { /* ignore */ }
|
||||
}, src: (function () {
|
||||
var need = Math.max(120, Math.min(360, (node && node.w ? node.w - 40 : 240)))
|
||||
var pick = (typeof wImgSrcForNode === 'function') ? wImgSrcForNode : wDisplayThumbOf
|
||||
// 本地源(已落库/已入缩略图缓存)才走 LOD —— 避免 thumbOf 回落到远程后又整幅解码原图
|
||||
var localSrc = (r && r.idb && r.data) ? r.data : ((r && r.url && outThumbCache.get(r.url)) || null)
|
||||
if (localSrc) { try { var u = wPreviewUrlOf(pick(localSrc, need)); if (u) return u } catch (eL) { /* ignore */ } }
|
||||
if (ingSt && ingSt.localUrl) return ingSt.localUrl // 缩略图还没好:先用本地原图,别等远程
|
||||
if (r._awaitUrl) return r.url
|
||||
// 2026-12-03(用户):只有「没有落地记录」的旧数据才允许直连远程。
|
||||
// 已 ready 但本地 URL 还没解析出来的那一小段时间里空着等本地(缩略图已在上面返回),
|
||||
// 不要退回远程 —— 否则新图会「从上往下」渐进重下一遍,看起来像没取原图。
|
||||
if (!ingSt) return r.url
|
||||
return undefined // 未落地/本地 URL 待解析:不设 src(React 省略属性),避免空 src 触发伪请求
|
||||
})(), draggable: true, style: { aspectRatio: (r.width && r.height) ? String(r.width) + ' / ' + String(r.height) : undefined }, title: r.idb && r.data ? '单击选中 · 双击查看原图 · 拖到画布作参考图' : '单击选中 · 双击放大(可左右切换)· 拖到画布作参考图', onError: (e) => {
|
||||
// 2026-12-02:多级回退 —— 本地 blob 失效 → 远程 url;远程也失败才标 is-broken
|
||||
try {
|
||||
const im = e && e.currentTarget
|
||||
if (!im) return
|
||||
// 空 src(未落地/等待本地字节)不算失败,别把它当成「本地失效」去回退远程
|
||||
if (!im.getAttribute || !im.getAttribute('src')) return
|
||||
if (im.dataset && im.dataset.fb !== 'remote' && r && r.url) { im.dataset.fb = 'remote'; im.src = r.url; return }
|
||||
if (im.dataset) im.dataset.fb = 'broken'
|
||||
im.classList.add('is-broken')
|
||||
const cellB = (im.closest && im.closest('.iwb-out-cell')) || im.parentElement
|
||||
if (cellB && !r._awaitUrl) cellB.classList.add('is-broken-cell')
|
||||
} catch (e1) { /* ignore */ }
|
||||
}, onPointerDown: (e) => { ackNew(); e.stopPropagation(); props.onSelect && props.onSelect(node.id) }, onDragStart: (e) => { try { const u = r.url || ''; e.dataTransfer.setData('application/x-iwb-output-ref', u); e.dataTransfer.setData('text/plain', u); e.dataTransfer.effectAllowed = 'copy' } catch (err) { /* 浏览器拒写自定义 MIME 时仍保留 text/plain */ } }, onDoubleClick: (e) => { ackNew(); e.stopPropagation(); openPreviewAt(cur) } })
|
||||
// 下载浮层:与图库共用同一组 hover token;组件缺失时退回旧的双小按钮(单文件/旧加载顺序)
|
||||
const DlOv = (typeof global !== 'undefined' && global.IWBResultDownloadOverlay) || null
|
||||
const actions = DlOv ? null : el('div', { className: 'iwb-out-cell-actions' },
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', title: '下载', onClick: doDownload, onPointerDown: stop }, I('download')),
|
||||
)
|
||||
return el('div', { key: String(r.url || '') + '|' + ri, className: 'iwb-out-cell' },
|
||||
// 2026-12-02(用户要求恢复):角标不再只依赖视图命中 —— 只要这一格还没有本地源、
|
||||
// 而结果又是远程 url,就说明还在从网络取图,直接标「下载中」,保证一定有可见反馈。
|
||||
const _remoteOnly = !_localSrc && !(ingSt && ingSt.localUrl) && /^https?:/i.test(String((r && r.url) || ''))
|
||||
// 2026-12-02 修:先取安全状态再判 —— 之前或运算与三元混用,条件为真时仍解引用 ingSt.status,
|
||||
// 视图没命中(ingSt=null)会抛 TypeError。优先级:未落地 > 排队中/下载中。
|
||||
// 2026-12-02(第四次收敛):角标**默认渲染**,靠 CSS 在图片 onLoad(.is-loaded-cell)后收起。
|
||||
// 之前按「有没有本地源」决定是否渲染 —— 本地缓存失效但图片还在等远程时就没有任何提示(白板)。
|
||||
// NEW:本次启动后生成、新图已就绪(不是旧图占位)、未确认、且未超过显示时长。
|
||||
const ingFailed = !!(ingSt && ingSt.status === 'failed')
|
||||
const isNew = !!(r && r._genAt && r._genAt > OUT_NEW_SINCE && !outNewSeen.has(r._genKey) && !r._awaitUrl && !ingFailed && (newBadgeMs === 0 || (Date.now() - r._genAt) < newBadgeMs))
|
||||
const ackNew = () => {
|
||||
try {
|
||||
if (!r || !r._genKey) return
|
||||
outNewSeen.add(r._genKey)
|
||||
if (typeof wThumbBump === 'function') wThumbBump()
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
const newBadge = (isNew && r._genKey) ? el('span', { className: 'iwb-out-cell-new', key: 'new', style: newBadgeMs > 0 ? { animationDuration: (newBadgeMs / 1000) + 's' } : { animation: 'none' } }, 'NEW') : null
|
||||
const ingStatus = ingSt ? ingSt.status : null
|
||||
const ingPct = (ingSt && ingSt.progress) ? Math.round(ingSt.progress * 100) : 0
|
||||
const retryIng = (e) => { try { e.stopPropagation(); if (window.__iwbIngest && ingSt) window.__iwbIngest.retry(ingSt.id) } catch (e1) { /* ignore */ } }
|
||||
const ingBadge = (ingStatus === 'failed')
|
||||
? el('span', { className: 'iwb-out-cell-flag iwb-out-cell-flag-err', key: 'ing-flag', title: '点击重试下载', onClick: retryIng }, '未落地')
|
||||
: el('span', { className: 'iwb-out-cell-flag', key: 'ing-flag' }, ingStatus === 'queued' ? '排队中' : (ingPct ? '下载中 ' + ingPct + '%' : '下载中'))
|
||||
return el('div', { key: String(r.url || '') + '|' + String(awaitUrl) + '|' + ri, className: 'iwb-out-cell' },
|
||||
phEl,
|
||||
el('span', { className: 'iwb-out-cell-err', key: 'err' }, '加载失败'),
|
||||
ingBadge,
|
||||
DlOv ? el(DlOv, { key: 'ov', onDownload: doDownload, icon: I('download'), label: '下载' }, imgEl) : imgEl,
|
||||
// NEW 放在图片浮层之后:同为 positioned 元素时靠 DOM 顺序压在上面,不必新增 z-index 声明。
|
||||
newBadge,
|
||||
el('div', { className: 'iwb-out-cell-meta' }, (r.width || '?') + '×' + (r.height || '?')),
|
||||
actions,
|
||||
)
|
||||
|
||||
@@ -631,9 +631,10 @@ function GSetGroup (props) {
|
||||
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 + ' 处画布引用已经找不到图片(之前丢的,本次不影响它们)。')
|
||||
const lines = ['发现 ' + rDry.orphans + ' 个图片文件没有被画布/图库引用。']
|
||||
if (rDry.thumbCaches) lines.push('另有 ' + rDry.thumbCaches + ' 个缩略图缓存(可再生,本次不动)。')
|
||||
if (rDry.keptByCanvas) lines.push(rDry.keptByCanvas + ' 个文件画布/图库同时在用 → 自动保留。')
|
||||
if (rDry.dangling) lines.push('另有 ' + rDry.dangling + ' 处画布引用的图片已经缺失(登记表里没有,无法恢复,本次不受影响)。')
|
||||
lines.push('移动到 trash/(不直接删除,可在回收站找回)?')
|
||||
if (!(await window.IWBUIConfirm.askOrNative(lines.join('\n'), { title: '清理未引用图片', okText: '移动' }))) return
|
||||
const rGo = await F.gcImages({ dryRun: false })
|
||||
@@ -733,6 +734,22 @@ function GSetGroup (props) {
|
||||
el('div', null, '可在不误触的前提下提前结束该任务,不影响同批其他任务。'),
|
||||
),
|
||||
),
|
||||
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: 0, max: 3600, step: 10, value: Number.isFinite(Number(draft.canvas.newBadgeSec)) ? Number(draft.canvas.newBadgeSec) : 120, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, newBadgeSec: Math.max(0, Math.min(3600, Number(e.target.value) || 0)) } })) }),
|
||||
el('span', { className: 'iwb-hint' }, '秒'),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-gset-hint' }, '输出节点新图左上角「NEW」的显示时长;0 表示不自动消失(点一下图才消失)。'),
|
||||
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: 64, step: 1, value: Number(draft.canvas.downloadConcurrency) || 30, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, downloadConcurrency: Math.max(1, Math.min(64, Number(e.target.value) || 30)) } })) }),
|
||||
el('span', { className: 'iwb-hint' }, '张(1–64,默认 30)'),
|
||||
),
|
||||
),
|
||||
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' },
|
||||
@@ -1433,7 +1450,7 @@ function GSetGroup (props) {
|
||||
security: { password: draft.sec.clear ? '__CLEAR__' : ((draft.sec.password && draft.sec.password.trim()) || (draft.sec.hasPassword ? '__KEEP__' : '')) },
|
||||
// autoSaveImages 已废弃(v3.25.33):保留归一化只为老配置兼容,不再驱动任何下载;
|
||||
// 「出图自动保存」见 设置 → 图片导出目录 → 自动下载。
|
||||
canvas: { hotkeys: Object.assign({}, HOTKEY_DEFAULTS, draft.canvas.hotkeys || {}), appearance: (function () { const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null; return A ? A.normalize(draft) : ((draft.canvas && draft.canvas.appearance) || {}) })(), sizePresets: Array.isArray(draft.canvas.sizePresets) && draft.canvas.sizePresets.length ? draft.canvas.sizePresets : RATIOS, generationConcurrency: Math.max(GEN_CONCURRENCY_MIN, Math.min(GEN_CONCURRENCY_MAX, Number(draft.canvas.generationConcurrency) || GEN_CONCURRENCY_DEFAULT)), taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, Number(draft.canvas.taskStallEndMs) || 300000)), autoSaveImages: draft.canvas.autoSaveImages !== false, backupOriginals: true, lodLowZoom: draft.canvas.lodLowZoom !== false },
|
||||
canvas: { hotkeys: Object.assign({}, HOTKEY_DEFAULTS, draft.canvas.hotkeys || {}), appearance: (function () { const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null; return A ? A.normalize(draft) : ((draft.canvas && draft.canvas.appearance) || {}) })(), sizePresets: Array.isArray(draft.canvas.sizePresets) && draft.canvas.sizePresets.length ? draft.canvas.sizePresets : RATIOS, generationConcurrency: Math.max(GEN_CONCURRENCY_MIN, Math.min(GEN_CONCURRENCY_MAX, Number(draft.canvas.generationConcurrency) || GEN_CONCURRENCY_DEFAULT)), taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, Number(draft.canvas.taskStallEndMs) || 300000)), autoSaveImages: draft.canvas.autoSaveImages !== false, backupOriginals: true, lodLowZoom: draft.canvas.lodLowZoom !== false, newBadgeSec: Number.isFinite(Number(draft.canvas.newBadgeSec)) ? Math.max(0, Math.min(3600, Number(draft.canvas.newBadgeSec))) : 120, downloadConcurrency: Math.max(1, Math.min(64, Number(draft.canvas.downloadConcurrency) || 30)), rustFileDownload: draft.canvas.rustFileDownload === true },
|
||||
webhook: { enabled: !!draft.webhook.enabled, url: (draft.webhook.url || '').trim() },
|
||||
})
|
||||
setSaving(false)
|
||||
|
||||
@@ -334,6 +334,13 @@ button { font-family: inherit; }
|
||||
.iwb-history-actions { position: absolute; left: 0; right: 0; bottom: 2px; display: flex; gap: var(--iwb-space-4); justify-content: center; opacity: 0; transition: opacity .15s; }
|
||||
.iwb-history-item:hover .iwb-history-actions { opacity: 1; }
|
||||
.iwb-history-actions .iwb-btn { font-size: var(--iwb-font-2xs); padding: 1px 5px; background: var(--iwb-panel); text-decoration: none; } /*iwb:raw-until=3.28.0*/
|
||||
/* 2026-12-03:图库卡片的下载按钮与输出节点统一为「右下角圆形图标」。
|
||||
旧宿主规则 .iwb-history-actions 是「整条铺满 + 居中」,插件产物沿用了这个类名 ⇒ 按钮被居中。
|
||||
这里用 body .iwb-history-embedded 提高优先级覆盖,只作用于图库面板,不动旧历史面板。 */
|
||||
body .iwb-history-embedded .iwb-history-actions { left: auto; right: var(--iwb-space-8); bottom: var(--iwb-space-8); justify-content: flex-end; padding: 0; background-image: none; gap: var(--iwb-space-4); }
|
||||
body .iwb-history-embedded .iwb-history-actions .iwb-gal-dl { width: 26px; height: 26px; border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border2); background: var(--iwb-panel); color: var(--iwb-brand-text, var(--iwb-text)); display: grid; place-items: center; padding: 0; font-size: var(--iwb-font-base); line-height: 1; cursor: pointer; }
|
||||
body .iwb-history-embedded .iwb-history-actions .iwb-gal-dl:hover { background: var(--iwb-hover); }
|
||||
|
||||
.iwb-modal-sm { width: 460px; }
|
||||
.iwb-pickrow { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; cursor: pointer; font-size: 12px; }
|
||||
.iwb-picktext { color: var(--iwb-text); line-height: 1.4; word-break: break-all; }
|
||||
@@ -342,10 +349,7 @@ button { font-family: inherit; }
|
||||
.iwb-ref-upload:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); }
|
||||
.iwb-ref-emptybox { flex: 1 1 auto; min-height: 110px; display: flex; flex-direction: column; gap: var(--iwb-space-6); }
|
||||
.iwb-ref-url-row { display: flex; gap: var(--iwb-space-4); align-items: center; }
|
||||
.iwb-ref-url-row .iwb-ref-upload-link { background: var(--iwb-field); border-color: var(--iwb-border); color: var(--iwb-text2); }
|
||||
.iwb-ref-upload-link:hover { background: color-mix(in srgb, var(--iwb-brand) 10%, var(--iwb-field)); border-color: var(--iwb-border2); color: var(--iwb-text); }
|
||||
.iwb-ref-url-input { min-width: 0; flex: 1 1 auto; font-size: var(--iwb-font-xs); }
|
||||
.iwb-ref-url-current { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--iwb-text2); font-size: var(--iwb-font-2xs); }
|
||||
.iwb-ref-show { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
|
||||
/* v3.26.111:图片源失效的明确占位(破图图标会被误认为渲染 bug) */
|
||||
.iwb-ref-broken { display: none; flex-direction: column; align-items: center; justify-content: center; gap: var(--iwb-space-4); width: 100%; min-height: 120px; border: 1px dashed var(--iwb-border); border-radius: var(--iwb-radius-chip); background: var(--iwb-field); color: var(--iwb-text2); }
|
||||
@@ -957,6 +961,15 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
|
||||
.iwb-dl-btn-ghost { background: color-mix(in srgb, var(--iwb-panel) 18%, transparent); color: var(--iwb-on-brand); border-color: color-mix(in srgb, var(--iwb-on-brand) 26%, transparent); }
|
||||
.iwb-dl-btn .iwb-ic { width: var(--iwb-icon-sm); height: var(--iwb-icon-sm); }
|
||||
.iwb-dl-txt { white-space: nowrap; }
|
||||
/* 2026-12-03:输出节点下载浮层改右下角圆形图标(只占一个角,矮图不再被横条挡住中心)。
|
||||
容器不吃事件、只有按钮吃;不引入 z-index(DOM 顺序已保证在图片之上)。旧 .iwb-dl-bar 保留可回退。 */
|
||||
.iwb-dl-corner { position: absolute; right: var(--iwb-space-8); bottom: var(--iwb-space-8); display: flex; gap: var(--iwb-space-4); opacity: 0; pointer-events: none; transition: opacity var(--iwb-motion-hover) var(--iwb-ease-hover); }
|
||||
.iwb-dl-ov:hover .iwb-dl-corner, .iwb-dl-ov:focus-within .iwb-dl-corner { opacity: 1; }
|
||||
.iwb-dl-round { pointer-events: auto; width: 26px; height: 26px; border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border2); background: var(--iwb-panel); color: var(--iwb-text); display: grid; place-items: center; padding: 0; cursor: pointer; font-size: var(--iwb-font-xs); line-height: 1; }
|
||||
.iwb-dl-round:hover { background: var(--iwb-hover); }
|
||||
.iwb-dl-round-primary { color: var(--iwb-brand-text, var(--iwb-text)); }
|
||||
.iwb-dl-round .iwb-ic { width: var(--iwb-icon-sm); height: var(--iwb-icon-sm); }
|
||||
@media (prefers-reduced-motion: reduce) { .iwb-dl-corner { transition: none; } }
|
||||
@media (prefers-reduced-motion: reduce) { .iwb-out-cell-img, .iwb-dl-bar { transition: none; } .iwb-out-cell:hover .iwb-out-cell-img { transform: none; } }
|
||||
.iwb-out-cell-meta { font-size: var(--iwb-font-2xs); color: var(--iwb-text2); text-align: center; margin-top: var(--iwb-space-2); }
|
||||
.iwb-out-cell-actions { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; display: flex; align-items: center; justify-content: center; gap: var(--iwb-space-10); opacity: 0; transition: opacity .15s; border-radius: 0 0 8px 8px; background: rgba(0,0,0,0.45); } /*iwb:raw-until=3.28.0*/
|
||||
@@ -1242,7 +1255,7 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
|
||||
.iwb-canvas-meta .iwb-status-err { color: var(--iwb-err); }
|
||||
.iwb-canvas-topbar .iwb-top-nav-icon { width: 30px; height: 30px; }
|
||||
/* S12:顶部标签条(浏览器式多画布标签)——UX_SPEC §4 单框扁平 token(容器透明、active 品牌色扁平高亮、只用 CSS 变量) */
|
||||
.iwb-tabstrip { position: absolute; left: 0; right: 0; top: 0; height: var(--iwb-chrome-h); z-index: 36; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--iwb-chrome); box-sizing: border-box; border-bottom: 1px solid var(--iwb-border); overflow-x: auto; scrollbar-width: none; pointer-events: none; }
|
||||
.iwb-tabstrip { position: fixed; left: 0; right: 0; top: 0; height: var(--iwb-chrome-h); z-index: calc(var(--iwb-z-curtain) + 1); display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--iwb-chrome); box-sizing: border-box; border-bottom: 1px solid var(--iwb-border); overflow-x: auto; scrollbar-width: none; pointer-events: none; }
|
||||
.iwb-tabstrip .iwb-tab { pointer-events: auto; }
|
||||
.iwb-tabstrip::-webkit-scrollbar { display: none; }
|
||||
/* 标签:**全项目只有这一套**(v3.27.1 收敛)。高度/圆角/字号/内距走 token,改一档全局一致。
|
||||
@@ -2266,9 +2279,10 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
|
||||
/* 用「整屏 + 内边距」而不是 top:36/left:52:
|
||||
标签条高度或导航宽度以后若有变化,页头也不会被压在标签条下面(v3.25.60 修重叠) */
|
||||
.iwb-plugin-page {
|
||||
position: absolute; inset: 0; z-index: 25; box-sizing: border-box;
|
||||
position: fixed; inset: 0; z-index: 25; box-sizing: border-box;
|
||||
padding: 42px 0 0 52px;
|
||||
display: flex; flex-direction: column; background: var(--iwb-bg);
|
||||
overflow: hidden; /* 2026-12-03:整页锁滚,只有 body 滚;避免标签条/页头被一起滚走 */
|
||||
}
|
||||
.iwb-plugin-page-head {
|
||||
flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
|
||||
@@ -2276,7 +2290,7 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
|
||||
}
|
||||
.iwb-plugin-page-title { font-weight: 800; font-size: 16px; color: var(--iwb-text); }
|
||||
.iwb-plugin-page-sub { font-size: 12px; color: var(--iwb-text2); }
|
||||
.iwb-plugin-page-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 22px 40px; }
|
||||
.iwb-plugin-page-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 22px 40px; }
|
||||
|
||||
/* ── 快捷键弹窗(v3.25.59 分区罗列)──────────────────────────────────── */
|
||||
.iwb-hotkey-help { display: flex; flex-direction: column; gap: 12px; }
|
||||
@@ -2564,3 +2578,41 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
|
||||
|
||||
/* 升级中:左侧导航的升级箭头自己也转(菜单里那个已经在转,这里补"外面这个")*/
|
||||
.iwb-nav-more-upgrading .iwb-nav-up-spin { animation: iwb-nav-spin 0.9s linear infinite; }
|
||||
|
||||
/* 结果图落地状态(2026-12-02):出图后先排队/下载,就绪再换本地 objectURL */
|
||||
.iwb-rimg { position: relative; }
|
||||
.iwb-rimg-pending .iwb-result-thumb { opacity: .55; filter: saturate(.8); }
|
||||
.iwb-rimg-flag { position: absolute; left: var(--iwb-space-4); top: var(--iwb-space-4); padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-xs); line-height: 16px; color: var(--iwb-text); background: var(--iwb-panel); border: 1px solid var(--iwb-border2); opacity: .92; }
|
||||
.iwb-rimg-flag-err { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
|
||||
|
||||
/* 输出节点体的落地角标(2026-12-02) */
|
||||
.iwb-out-cell { position: relative; }
|
||||
.iwb-out-cell-flag { position: absolute; left: var(--iwb-space-4); top: var(--iwb-space-4); padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-xs); line-height: 16px; color: var(--iwb-text); background: var(--iwb-panel); border: 1px solid var(--iwb-border2); opacity: .92; }
|
||||
.iwb-out-cell-flag-err { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
|
||||
/* 2026-12-03:输出格「NEW」新图标记(会话内新生成;点击即消,或按设置时长自动淡出)。 */
|
||||
.iwb-out-cell-new { position: absolute; left: var(--iwb-space-4); top: var(--iwb-space-4); padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-2xs); line-height: 16px; letter-spacing: .04em; color: var(--iwb-on-brand); background: var(--iwb-brand); border: 1px solid var(--iwb-brand); pointer-events: none; animation-name: iwb-out-new-expire; animation-timing-function: linear; animation-fill-mode: forwards; }
|
||||
@keyframes iwb-out-new-expire { 0%, 90% { opacity: 1; visibility: visible; } 100% { opacity: 0; visibility: hidden; } }
|
||||
|
||||
|
||||
/* 生成中:旧图压暗 + 「生成中」角标(不动 data,失败即恢复) */
|
||||
.iwb-out-cell-busy .iwb-out-cell-img { opacity: .5; filter: saturate(.75); }
|
||||
.iwb-out-cell-flag-busy { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
|
||||
|
||||
/* 2026-12-02:输出单元格「下载中」骨架(无本地源时垫底,避免大图区域纯空白) */
|
||||
/* 2026-12-02:骨架改成「撑高」而不是绝对定位 —— 之前单元格没有高度,出图前会塌成一条线 */
|
||||
.iwb-out-cell-ph { position: absolute; inset: 0; display: grid; place-items: center; border-radius: var(--iwb-radius-card); background: var(--iwb-layer2); color: var(--iwb-text2); font-size: var(--iwb-font-xs); }
|
||||
.iwb-out-cell-img { position: relative; }
|
||||
.iwb-out-cell-ph-txt { opacity: .85; }
|
||||
|
||||
/* 2026-12-02:图片真正加载完成(is-loaded)后才收起骨架与角标 —— 之前以「本地源就绪」为准,
|
||||
会出现「角标没了、图还没出来」的空窗。用 :has 做纯 CSS 联动,不需要重渲染。 */
|
||||
/* 2026-12-02:改用「父容器打类」,不依赖 :has()(老 WebView2 会整条丢弃选择器) */
|
||||
.iwb-out-cell.is-loaded-cell .iwb-out-cell-ph,
|
||||
.iwb-out-cell.is-loaded-cell .iwb-out-cell-flag { display: none; }
|
||||
/* 破图:收起骨架与角标,改为明确的「加载失败」文案 */
|
||||
.iwb-out-cell.is-broken-cell .iwb-out-cell-ph,
|
||||
.iwb-out-cell.is-broken-cell .iwb-out-cell-flag { display: none; }
|
||||
.iwb-out-cell-err { display: none; position: absolute; inset: 0; place-items: center; color: var(--iwb-err); font-size: var(--iwb-font-xs); }
|
||||
.iwb-out-cell.is-broken-cell .iwb-out-cell-err { display: grid; }
|
||||
/* 两级回退都失败:明确显示失败态,而不是留一张破图 */
|
||||
.iwb-out-cell-img.is-broken { opacity: .25; }
|
||||
@@ -0,0 +1,44 @@
|
||||
/* canvas-save-settle-test.js —— 「落定窗口」内的编辑不得被静默丢弃(v3.26.249)
|
||||
*
|
||||
* 背景(2026-12-04,work 实机验收 247 时发现):
|
||||
* 启动后(loaded=false)或切换画布/同步后的 1.2s 内(refs.syncing=true)做的第一次编辑,
|
||||
* 保存 effect 走的是 else 分支,而 refs.savePending 只在 saveDebounced 内部置位 ——
|
||||
* 第一次编辑前它是 false ⇒ 既不排保存、cleanup 还会清掉定时器;skipInitialPersistence
|
||||
* 又把载入后那一次保存跳过 ⇒ 改动彻底丢失(界面已改、文件 mtime 不变)。
|
||||
*
|
||||
* 修法三处(缺一不可):
|
||||
* ① commitCanvas 在未落定时打标 refs.dirtyBeforeSettle;
|
||||
* ② 保存 effect 在 loaded && !syncing 时把标记补成一次 saveDebounced;
|
||||
* ③ 切画布/同步的 1.2s 定时器结束时同样补一次(syncing 非响应式,不会重跑 effect)。
|
||||
*
|
||||
* 这是源码契约断言(时序行为需要完整宿主才能驱动,jsdom 下不稳定);
|
||||
* 目录钉点总数远低于棘轮上限,不涉及上调。
|
||||
*/
|
||||
'use strict'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const assert = require('assert')
|
||||
|
||||
const app = fs.readFileSync(path.join(__dirname, '..', 'app.js'), 'utf8')
|
||||
const read = (rel) => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8')
|
||||
|
||||
assert.ok(/dirtyBeforeSettle: false/.test(app), '① refs 必须有 dirtyBeforeSettle 初值')
|
||||
|
||||
const commitBlock = app.slice(app.indexOf('const commitCanvas = '), app.indexOf('const saveDebounced = '))
|
||||
assert.ok(commitBlock.indexOf('if (!(loaded && !refs.syncing)) refs.dirtyBeforeSettle = true') >= 0,
|
||||
'① commitCanvas(画布唯一变更入口)在未落定时必须打标')
|
||||
|
||||
const gate = app.slice(app.indexOf('if (loaded && !(refs.syncing)) {'), app.indexOf('}, [nodes, edges, groups, loaded])'))
|
||||
assert.ok(/if \(refs\.dirtyBeforeSettle\) \{ refs\.dirtyBeforeSettle = false; saveDebounced\(\) \}/.test(gate),
|
||||
'② 保存 effect 落定后必须补一次保存并清标记')
|
||||
|
||||
assert.ok(/setTimeout\(\(\) => \{[\s\S]{0,400}refs\.syncing = false[\s\S]{0,400}dirtyBeforeSettle[\s\S]{0,200}saveDebounced\(\)/.test(app),
|
||||
'③ 切换画布/同步的 1.2s 定时器结束时也必须补存(syncing 非响应式)')
|
||||
|
||||
assert.ok(/dirtyBeforeSettle = false; saveDebounced\(\)/.test(app), '补存时必须先清标记,避免每次渲染重复排保存')
|
||||
|
||||
assert.ok(/refs\.savePending \|\| refs\.saving \|\| refs\.dirtyBeforeSettle/.test(app), '④ 关窗/隐藏兜底 flush 必须认 dirtyBeforeSettle(否则落定前编辑后立刻关窗仍会丢)')
|
||||
assert.ok(/if \(ok\) refs\.dirtyBeforeSettle = false/.test(app), '④ 兜底 flush 写成功后要清标记,避免重复落盘')
|
||||
|
||||
console.log('canvas-save-settle: 7 通过 / 0 失败')
|
||||
|
||||
+4
@@ -34,6 +34,8 @@
|
||||
"IWBImageCompress",
|
||||
"IWBImageDisplayThumb",
|
||||
"IWBImageFileRef",
|
||||
"IWBImageIngest",
|
||||
"IWBImageIngestStore",
|
||||
"IWBImageRemoteCache",
|
||||
"IWBImageThumbPick",
|
||||
"IWBImageWriteback",
|
||||
@@ -49,8 +51,10 @@
|
||||
"IWBPluginGroupLib",
|
||||
"IWBPluginHost",
|
||||
"IWBPluginPromptLib",
|
||||
"IWBPluginQueue",
|
||||
"IWBPromptCover",
|
||||
"IWBProviderPing",
|
||||
"IWBRefUpload",
|
||||
"IWBResultImg",
|
||||
"IWBRuntimeBoundary",
|
||||
"IWBRuntimeChannel",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"storage-outputs.js",
|
||||
"storage-backup.js",
|
||||
"storage-zip.js",
|
||||
"runtime-ref-upload.js",
|
||||
"plugin-promptlib-backup.js",
|
||||
"runtime-constants.js",
|
||||
"canvas-store.js",
|
||||
@@ -56,6 +57,7 @@
|
||||
"ui-components.js",
|
||||
"plugin-data.js",
|
||||
"plugin-api-gallery.js",
|
||||
"plugin-api-queue.js",
|
||||
"plugin-api-grouplib.js",
|
||||
"plugin-api-promptlib.js",
|
||||
"plugin-host.js",
|
||||
@@ -80,6 +82,8 @@
|
||||
"image-display-thumb.js",
|
||||
"image-cache-migrate.js",
|
||||
"image-writeback.js",
|
||||
"image-ingest.js",
|
||||
"image-ingest-store.js",
|
||||
"runtime-frame-probe.js",
|
||||
"image-remote-cache.js",
|
||||
"gallery-sync.js",
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
/* 图片读取/下载口径守卫(2026-12-03)
|
||||
*
|
||||
* 规则来源:docs/standards/image-read-and-download.md
|
||||
* ① 下载命名一律用图库行名(wOutNameOf),写死的 image.png 只允许做未落地兜底;
|
||||
* ② 预览只读本地:任务队列 preview 不得直连远程,也不得把 320 缩略图当原图;
|
||||
* ③ 老记录原图必须能从 images/gallery 读(storage-file 暴露 galleryOriginalOf/Blob)。
|
||||
*/
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const read = (p) => fs.readFileSync(path.join(root, p), 'utf8')
|
||||
const body = read('src/ui-node-bodies.js')
|
||||
let fail = 0
|
||||
const ok = (cond, msg) => { if (cond) console.log(' PASS ' + msg); else { fail++; console.error(' FAIL ' + msg) } }
|
||||
|
||||
const doc = read('docs/standards/image-read-and-download.md')
|
||||
ok(/取源顺序/.test(doc) && /wOutNameOf/.test(doc), '规范文档存在且写了取源顺序与命名')
|
||||
|
||||
const sf = read('src/storage-file.js')
|
||||
ok(/galleryOriginalOf/.test(sf) && /galleryOriginalBlob/.test(sf), 'storage-file 暴露本地原图读取(预览/下载)')
|
||||
|
||||
const app = read('app.js')
|
||||
ok(/function wOutNameOf \(url\)/.test(app), '宿主提供 wOutNameOf(按 url 查图库行名)')
|
||||
ok(/downloadUrl\(u, wOutNameOf\(u\)/.test(app), '批量下载用图库行名')
|
||||
ok(/galleryOriginalBlob\(item\)/.test(app), '下载取源(wResolveOutputSrc)本地优先')
|
||||
|
||||
const qBlock = app.slice(app.indexOf('preview: async (id) => {'), app.indexOf('copyLink: (id) => {'))
|
||||
ok(qBlock.length > 0 && !/\^https\?:/.test(qBlock), '任务队列预览不直连远程')
|
||||
ok(!/IDB\.get\(row\.idb\)/.test(qBlock), '任务队列预览不把 320 缩略图当原图')
|
||||
ok(/not-local/.test(qBlock), '任务队列预览在本地无图时给出「未下载」提示')
|
||||
|
||||
ok(!/wTauri\.http\.fetch/.test(app), '图片取字节不再走 http 插件(受域名白名单限制),统一用 fetch_image_b64')
|
||||
ok(/mime0\.indexOf\('image\/'\) !== 0/.test(app), 'wRustFetchBlob 校验 Content-Type(拒绝把 HTML 错误页当图片)')
|
||||
ok(read('src/image-display-thumb.js').indexOf('^https?:') >= 0 && read('src/image-display-thumb.js').indexOf('fetchBlob') >= 0, '显示缩略图只对远程地址走 Rust(data:/blob: 不浪费 IPC)')
|
||||
ok(/上传到图库(转成在线链接)/.test(app) && /IWBRefUpload/.test(app), 'ref 气泡提供「上传到图库」')
|
||||
ok(/aria-label': '替换'[\s\S]{0,200}I\('ref'\)/.test(app) && /aria-label': '上传到图库'[\s\S]{0,400}I\('upload'\)/.test(app), '气泡图标已对调:替换=ref(图片+号)、上传图库=upload(箭头)')
|
||||
ok(!/'aria-label': '改名'/.test(app), '气泡不再显示改名按钮(F2/双击标题/右键仍可改名)')
|
||||
ok(body.indexOf("const showUrlRow = remoteUrl || !(d.data || d.localRef || d.localName)") >= 0, '网络图即使已被缓存成 localRef 也保留 URL 输入行;本地图不渲染')
|
||||
ok(body.indexOf("showUrlRow ? el('div', { className: 'iwb-ref-url-row' }") >= 0, 'URL 输入行由 showUrlRow 决定(不再是「有本地数据就藏」)')
|
||||
ok(body.indexOf("/^https?:\\/\\//i.test(d.url)") >= 0, '来源判定:url 以 http(s) 开头即网络图')
|
||||
ok(/runtime-ref-upload\.js/.test(read('scripts/build.js')), 'ref-upload 模块已进构建清单')
|
||||
ok(/async function wRustFetchBlob \(url\)/.test(app), '宿主提供统一 Rust 取字节入口 wRustFetchBlob')
|
||||
ok(/wRustFetchBlob\(fkEarly\)/.test(app) && /wRustFetchBlob\(su\)/.test(app), 'storeOutputThumb / downloadUrl 走系统网络栈兜底')
|
||||
ok(/desktopFetch: async \(u\) => \{ const b = await wRustFetchBlob/.test(app), 'gallery-sync desktopFetch 走 Rust(不再用白名单 http.fetch)')
|
||||
ok(/path-outside-base/.test(read('src-tauri/src/lib.rs')) && /tokio::fs/.test(read('src-tauri/src/lib.rs')), 'fetch_image_to 限制在资料目录内 + tokio 异步写盘')
|
||||
ok(/cancel_fetch/.test(read('src-tauri/src/lib.rs')) && /__baseFallback/.test(read('src/image-ingest.js')), '文件版支持取消 + 一次性 base64 回退')
|
||||
ok(/imgblob_f/.test(read('src/image-ingest.js')), '文件版引用 key 按 URL 去重')
|
||||
ok(/displayThumbDataUrlOfRef/.test(read('src/storage-file.js')) && /cleanupCacheTmp/.test(read('src/storage-file.js')), '文件接管后有缩略图预热,临时目录有清理')
|
||||
ok(/rustFileDownload: draft\.canvas\.rustFileDownload === true/.test(read('src/ui-settings-sections.js')), '设置保存保留 rustFileDownload 开关')
|
||||
ok(/fetch_image_to/.test(read('src-tauri/src/lib.rs')), 'Rust 提供 fetch_image_to(流式写文件)')
|
||||
ok(/putFileFrom/.test(read('src/storage-file.js')), '存储层支持接管已下载文件(不经过 base64)')
|
||||
ok(/fetchFile\s*:/.test(app) && /writeFileRef\s*:/.test(app), 'ingest 接线文件版通道(默认关闭)')
|
||||
ok(/IWB_RUST_FILE/.test(app), '文件版下载有显式开关(默认关)')
|
||||
ok(/cacheUiRef\.current\.loaded && cacheUiRef\.current\.shellView === 'canvas'/.test(app), '远程参考图缓存用 ref 读当前视图(修首帧闭包导致 enabled 恒 false)')
|
||||
ok(/fetchBlob/.test(read('src/image-remote-cache.js')) && /fetchBlob/.test(read('src/image-display-thumb.js')) && /fetchBlob/.test(read('src/runtime-download-auto.js')), '三个模块支持注入 Rust 取字节')
|
||||
ok(/async function wOutThumbEnsure \(url\)/.test(app), '输出节点缩略图兜底:按图库同一套本地取源补缩略图')
|
||||
ok(/wOutThumbEnsure\(r\.url\)/.test(read('src/ui-node-bodies.js')), '输出节点在无本地缩略图时补取(thumbHash → 磁盘原图 320)')
|
||||
ok(/function wPreviewEntryOf \(url\)/.test(app), '输出节点预览按 url 查图库行(__gallery 条目)')
|
||||
ok(/previewEntryOf\(x\.url\)/.test(read('src/ui-node-bodies.js')) && /wPreviewEntryOf/.test(read('src/ui-node-bodies.js')), '输出节点双击预览使用图库条目(本地原图优先)')
|
||||
const bodies = read('src/ui-node-bodies.js')
|
||||
ok(/downloadUrl\(src, \(typeof wOutNameOf/.test(bodies), '输出节点下载用图库行名')
|
||||
|
||||
const view = read('src/ui-canvas-view.js')
|
||||
ok(/wOutNameOf\(entry && entry\.url\)/.test(view), '预览下载用图库行名')
|
||||
ok(/galleryOriginalOf/.test(view) && /galleryOriginalBlob/.test(view), '预览按行名读本地原图(不退回缩略图/远程)')
|
||||
|
||||
if (fail) { console.error('image-download contract: ' + fail + ' 项不符(见 docs/standards/image-read-and-download.md)'); process.exit(1) }
|
||||
console.log('image-download contract checks passed(取源本地优先 / 命名统一图库行名 / 预览不直连远程)')
|
||||
@@ -0,0 +1,356 @@
|
||||
// 结果落地管线(src/image-ingest.js)契约测试 —— 2026-12-02
|
||||
// 钉住的都是「会真丢图 / 会真重复下载」的点:幂等、重试、失败保留 url、恢复、释放。
|
||||
'use strict'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const src = fs.readFileSync(path.join(__dirname, '..', 'src', 'image-ingest.js'), 'utf8')
|
||||
const box = {}
|
||||
new Function('window', 'globalThis', src)(box, box)
|
||||
|
||||
let pass = 0, fail = 0
|
||||
const ok = (name, cond, extra) => {
|
||||
if (cond) { pass++; console.log(' ✅ ' + name) } else { fail++; console.log(' ❌ ' + name + (extra !== undefined ? ' → ' + JSON.stringify(extra) : '')) }
|
||||
}
|
||||
const tick = () => new Promise((r) => setTimeout(r, 5))
|
||||
async function until (fn, ms) {
|
||||
const end = Date.now() + (ms || 1000)
|
||||
while (Date.now() < end) { if (fn()) return true; await tick() }
|
||||
return false
|
||||
}
|
||||
|
||||
function make (opts) {
|
||||
const o = opts || {}
|
||||
const st = { fetched: [], written: [], persisted: [], events: [], maxActive: 0, active: 0 }
|
||||
let attempt = 0
|
||||
const ingest = box.IWBImageIngest.create({
|
||||
concurrency: o.concurrency || 2,
|
||||
retries: o.retries === undefined ? 3 : o.retries,
|
||||
sleep: async () => {}, // 测试里不真等退避
|
||||
now: () => 1000,
|
||||
fetchBytes: async (url) => {
|
||||
st.fetched.push(url)
|
||||
st.active++
|
||||
st.maxActive = Math.max(st.maxActive, st.active)
|
||||
try {
|
||||
if (o.failTimes && st.fetched.length <= o.failTimes) return { ok: false, error: 'net-' + st.fetched.length }
|
||||
if (o.alwaysFail) return { ok: false, error: 'net-down' }
|
||||
return { ok: true, dataUrl: 'data:image/png;base64,AAAA', bytes: 1234, mime: 'image/png' }
|
||||
} finally { st.active-- }
|
||||
},
|
||||
writeRef: async (dataUrl) => { st.written.push(dataUrl); return { __blob: 'b' + st.written.length } },
|
||||
persist: (e) => st.persisted.push(e.id + ':' + e.status),
|
||||
onEvent: (k) => st.events.push(k),
|
||||
removeEntry: () => {},
|
||||
})
|
||||
return { ingest, st }
|
||||
}
|
||||
|
||||
async function main () {
|
||||
// ① 正常落地
|
||||
{
|
||||
const { ingest, st } = make()
|
||||
const e = ingest.enqueue({ url: 'https://cdn/x.png', source: 'gen', w: 1024, h: 1024 })
|
||||
ok('①-1 入队立刻可见(queued)', !!ingest.get(e.id) && ingest.get(e.id).status === 'queued')
|
||||
await until(() => ingest.get(e.id).status === 'ready')
|
||||
const r = ingest.get(e.id)
|
||||
ok('①-2 落地后 ready + ref + bytes', r.status === 'ready' && !!r.ref && r.bytes === 1234, r)
|
||||
ok('①-3 只下载一次、只写一次引用', st.fetched.length === 1 && st.written.length === 1, { f: st.fetched.length, w: st.written.length })
|
||||
ok('①-4 状态变化被持久化', st.persisted.indexOf(e.id + ':ready') >= 0, st.persisted)
|
||||
}
|
||||
|
||||
// ② 幂等:同 url 再入队不重复下载
|
||||
{
|
||||
const { ingest, st } = make()
|
||||
const a = ingest.enqueue({ url: 'https://cdn/y.png' })
|
||||
await until(() => ingest.get(a.id).status === 'ready')
|
||||
const b = ingest.enqueue({ url: 'https://cdn/y.png' })
|
||||
await tick()
|
||||
ok('②-1 同 url 复用同一条记录', a.id === b.id)
|
||||
ok('②-2 没有第二次下载', st.fetched.length === 1, st.fetched.length)
|
||||
ok('②-3 重复 enqueue 不会把 ready 打回 queued', ingest.get(a.id).status === 'ready')
|
||||
}
|
||||
|
||||
// ③ 重试:失败两次后成功
|
||||
{
|
||||
const { ingest } = make({ failTimes: 2 })
|
||||
const e = ingest.enqueue({ url: 'https://cdn/retry.png' })
|
||||
await until(() => ingest.get(e.id).status === 'ready')
|
||||
const r = ingest.get(e.id)
|
||||
ok('③-1 第 3 次成功后 ready', r.status === 'ready', r.status)
|
||||
ok('③-2 重试次数如实记录', r.retries === 2, r.retries)
|
||||
ok('③-3 成功后清空 lastError', r.lastError === '', r.lastError)
|
||||
}
|
||||
|
||||
// ④ 彻底失败:保留 url、可重试
|
||||
{
|
||||
const { ingest } = make({ alwaysFail: true, retries: 2 })
|
||||
const e = ingest.enqueue({ url: 'https://cdn/bad.png' })
|
||||
await until(() => ingest.get(e.id).status === 'failed', 2000)
|
||||
const r = ingest.get(e.id)
|
||||
ok('④-1 重试用尽后 failed', r.status === 'failed', r.status)
|
||||
ok('④-2 原始 url 原样保留(不丢图)', r.url === 'https://cdn/bad.png')
|
||||
ok('④-3 带可读错误', /net-down/.test(r.lastError), r.lastError)
|
||||
ok('④-4 记录仍在列表里', ingest.list().length === 1)
|
||||
}
|
||||
|
||||
// ⑤ 失败后手动 retry 能恢复
|
||||
{
|
||||
const { ingest } = make({ alwaysFail: true, retries: 1 })
|
||||
const e = ingest.enqueue({ url: 'https://cdn/later.png' })
|
||||
await until(() => ingest.get(e.id).status === 'failed', 2000)
|
||||
const again = ingest.retry(e.id)
|
||||
ok('⑤-1 retry 复位为 queued', !!again && again.retries === 0)
|
||||
}
|
||||
|
||||
// ⑥ 释放字节(仅保留链接)
|
||||
{
|
||||
const { ingest } = make()
|
||||
const e = ingest.enqueue({ url: 'https://cdn/rel.png' })
|
||||
await until(() => ingest.get(e.id).status === 'ready')
|
||||
const r = ingest.release(e.id)
|
||||
ok('⑥-1 变为 link-only', r.status === 'link-only')
|
||||
ok('⑥-2 引用被清空但 url 保留', r.ref === null && r.url === 'https://cdn/rel.png')
|
||||
// 任务队列「下载」会再次 enqueue 同 url:link-only 必须回到 queued(否则永远不下)
|
||||
const again = ingest.enqueue({ url: 'https://cdn/rel.png' })
|
||||
ok('⑥-3 link-only 再次 enqueue → queued', again && again.status === 'queued', again && again.status)
|
||||
await until(() => ingest.get(e.id).status === 'ready', 2000)
|
||||
}
|
||||
|
||||
// ⑦ 启动恢复:downloading/queued 重排,ready 保持
|
||||
{
|
||||
const { ingest, st } = make()
|
||||
ingest.restore([
|
||||
{ id: 'a', url: 'https://cdn/a.png', status: 'downloading', createdAt: 1, updatedAt: 1 },
|
||||
{ id: 'b', url: 'https://cdn/b.png', status: 'queued', createdAt: 1, updatedAt: 1 },
|
||||
{ id: 'c', url: 'https://cdn/c.png', status: 'ready', ref: { __blob: 'x' }, createdAt: 1, updatedAt: 1 },
|
||||
{ id: 'd', url: 'https://cdn/d.png', status: 'failed', lastError: 'net', createdAt: 1, updatedAt: 1 },
|
||||
])
|
||||
ok('⑦-1 failed 不被自动重排', ingest.get('d').status === 'failed')
|
||||
ok('⑦-2 ready 保持 ready', ingest.get('c').status === 'ready')
|
||||
await until(() => ingest.get('a').status === 'ready' && ingest.get('b').status === 'ready')
|
||||
ok('⑦-3 downloading/queued 恢复后自动跑完', ingest.get('a').status === 'ready' && ingest.get('b').status === 'ready')
|
||||
}
|
||||
|
||||
// ⑧ 取消排队中的
|
||||
{
|
||||
const { ingest } = make({ concurrency: 1 })
|
||||
ingest.enqueue({ url: 'https://cdn/busy.png' })
|
||||
const q = ingest.enqueue({ url: 'https://cdn/wait.png' })
|
||||
ingest.cancel(q.id)
|
||||
ok('⑧-1 排队中被取消 → link-only', ingest.get(q.id).status === 'link-only', ingest.get(q.id).status)
|
||||
}
|
||||
|
||||
// ⑨ 并发上限
|
||||
{
|
||||
const { ingest, st } = make({ concurrency: 2 })
|
||||
for (let i = 0; i < 6; i++) ingest.enqueue({ url: 'https://cdn/c' + i + '.png' })
|
||||
await until(() => ingest.stats().ready === 6, 3000)
|
||||
ok('⑨-1 6 条全部落地', ingest.stats().ready === 6, ingest.stats())
|
||||
ok('⑨-2 同时下载不超过 2 路', st.maxActive <= 2, st.maxActive)
|
||||
}
|
||||
|
||||
// ⑩ 统计
|
||||
{
|
||||
const { ingest } = make()
|
||||
const a = ingest.enqueue({ url: 'https://cdn/s1.png' })
|
||||
await until(() => ingest.get(a.id).status === 'ready')
|
||||
ingest.enqueue({ url: 'https://cdn/s2.png' })
|
||||
await tick()
|
||||
const s = ingest.stats()
|
||||
ok('⑩-1 total/ready/queued 计数正确', s.total === 2 && s.ready >= 1, s)
|
||||
}
|
||||
|
||||
// ⑪ 下载优先走系统网络栈(Rust);失败/不可用才回退 WebView fetch
|
||||
{
|
||||
let rustCalls = 0
|
||||
const fb = box.IWBImageIngest.createFetchBytes({
|
||||
rustFetch: async () => { rustCalls++; return { ok: true, mime: 'image/png', bytes: 3, b64: 'AAA' } },
|
||||
blobFromSrc: async () => null,
|
||||
blobToDataUrl: async () => '',
|
||||
})
|
||||
const r = await fb('https://cdn/rust.png', () => {})
|
||||
ok('⑪-1 rustFetch 成功 → dataUrl + bytes', r.ok && r.dataUrl === 'data:image/png;base64,AAA' && r.bytes === 3 && rustCalls === 1, r)
|
||||
const fb2 = box.IWBImageIngest.createFetchBytes({
|
||||
rustFetch: async () => ({ ok: false, error: 'http-403' }),
|
||||
blobFromSrc: async () => ({ size: 1 }),
|
||||
blobToDataUrl: async () => 'data:image/png;base64,BB',
|
||||
})
|
||||
const r2 = await fb2('https://cdn/fallback.png', () => {})
|
||||
ok('⑪-2 rustFetch 失败 → 回退宿主取字节', r2.ok && r2.dataUrl === 'data:image/png;base64,BB', r2)
|
||||
}
|
||||
|
||||
// ⑪b 用户取消(abort)不回退再抓一次
|
||||
{
|
||||
let blobCalls = 0
|
||||
const ac = new AbortController()
|
||||
ac.abort()
|
||||
const fb = box.IWBImageIngest.createFetchBytes({
|
||||
rustFetch: async () => { throw new Error('no-rust') },
|
||||
blobFromSrc: async () => { blobCalls++; return null },
|
||||
blobToDataUrl: async () => '',
|
||||
})
|
||||
const r = await fb('https://cdn/abort.png', () => {}, ac.signal)
|
||||
ok('⑪b 已 abort 时直接返回失败、不回退抓取', r.ok === false && blobCalls === 0, { r, blobCalls })
|
||||
}
|
||||
|
||||
// ⑫ 并发数走 getConcurrency(默认 30,设置页可调)
|
||||
{
|
||||
let release = null
|
||||
const gate = new Promise((r) => { release = r })
|
||||
let active = 0, maxActive = 0
|
||||
const ing = box.IWBImageIngest.create({
|
||||
getConcurrency: () => 3,
|
||||
retries: 0,
|
||||
sleep: async () => {},
|
||||
now: () => 1000,
|
||||
fetchBytes: async () => {
|
||||
active++; maxActive = Math.max(maxActive, active)
|
||||
await gate
|
||||
active--
|
||||
return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1, mime: 'image/png' }
|
||||
},
|
||||
writeRef: async () => ({ __blob: 'b' }),
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
for (let i = 0; i < 5; i++) ing.enqueue({ url: 'https://cdn/g' + i + '.png' })
|
||||
await until(() => maxActive === 3, 500)
|
||||
ok('⑫-1 同时下载按 getConcurrency 生效(3 路)', maxActive === 3, maxActive)
|
||||
release()
|
||||
await until(() => ing.stats().ready === 5, 1500)
|
||||
ok('⑫-2 释放后 5 条全部完成', ing.stats().ready === 5, ing.stats())
|
||||
}
|
||||
|
||||
// ⑬ 取消:在飞结果作废(不写引用、不把 link-only 覆盖成 ready)
|
||||
{
|
||||
let release = null
|
||||
const gate = new Promise((r) => { release = r })
|
||||
let calls = 0, written = 0
|
||||
const ing = box.IWBImageIngest.create({
|
||||
retries: 2, sleep: async () => {}, now: () => 1000,
|
||||
fetchBytes: async () => { calls++; await gate; return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1, mime: 'image/png' } },
|
||||
writeRef: async () => { written++; return { __blob: 'b' } },
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
const e = ing.enqueue({ url: 'https://cdn/cancel.png' })
|
||||
await until(() => ing.get(e.id).status === 'downloading', 500)
|
||||
ing.cancel(e.id)
|
||||
release()
|
||||
await tick(); await tick(); await tick()
|
||||
ok('⑬-1 取消后状态是 link-only', ing.get(e.id).status === 'link-only', ing.get(e.id).status)
|
||||
ok('⑬-2 取消后在飞结果不写引用', written === 0, written)
|
||||
ok('⑬-3 取消后不会重试', calls === 1, calls)
|
||||
}
|
||||
|
||||
// ⑭ 取消后重试:新请求正常落地,旧请求的结果被丢弃
|
||||
{
|
||||
let release = null
|
||||
const gate = new Promise((r) => { release = r })
|
||||
let calls = 0, written = 0
|
||||
const ing = box.IWBImageIngest.create({
|
||||
retries: 0, sleep: async () => {}, now: () => 1000,
|
||||
fetchBytes: async () => {
|
||||
calls++
|
||||
if (calls === 1) await gate
|
||||
return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1, mime: 'image/png' }
|
||||
},
|
||||
writeRef: async () => { written++; return { __blob: 'b' } },
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
const e = ing.enqueue({ url: 'https://cdn/retry.png' })
|
||||
await until(() => ing.get(e.id).status === 'downloading', 500)
|
||||
ing.cancel(e.id)
|
||||
ing.retry(e.id)
|
||||
release()
|
||||
await until(() => ing.get(e.id).status === 'ready', 1000)
|
||||
await tick()
|
||||
ok('⑭-1 重试后落地 ready', ing.get(e.id).status === 'ready', ing.get(e.id).status)
|
||||
ok('⑭-2 只写一次引用(旧结果被丢弃)', written === 1, written)
|
||||
}
|
||||
|
||||
// ⑮ 文件版下载(IWB_RUST_FILE=1):走 fetchFile → writeFileRef,不经过 base64
|
||||
{
|
||||
let fetched = 0, wrote = 0
|
||||
const ing = box.IWBImageIngest.create({
|
||||
useFile: () => true,
|
||||
retries: 0, now: () => 1000,
|
||||
fetchFile: async () => ({ path: '/tmp/rf.bin', bytes: 4, mime: 'image/png' }),
|
||||
writeFileRef: async (f) => { wrote++; ok('⑮-1 writeFileRef 收到文件元数据', f && f.path === '/tmp/rf.bin' && f.bytes === 4); ok('⑮-1b key 按 URL 去重', String(f.key || '').indexOf('imgblob_f') === 0); return { __blob: 'kf' } },
|
||||
fetchBytes: async () => { fetched++; return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1 } },
|
||||
writeRef: async () => ({ __blob: 'kb' }),
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
const e = ing.enqueue({ url: 'https://cdn/file.png' })
|
||||
await until(() => ing.get(e.id).status === 'ready', 1000)
|
||||
const r = ing.get(e.id)
|
||||
ok('⑮-2 文件版落地 ready + ref', r.status === 'ready' && r.ref && r.ref.__blob === 'kf', r)
|
||||
ok('⑮-3 文件版不调用 fetchBytes(不走 base64)', fetched === 0 && wrote === 1, { fetched, wrote })
|
||||
}
|
||||
|
||||
// ⑯ 文件版失败 → 回退 base64 只一次(不在同一 attempt 里双下载)
|
||||
{
|
||||
let fileCalls = 0, baseCalls = 0
|
||||
const ing = box.IWBImageIngest.create({
|
||||
useFile: () => true,
|
||||
retries: 1, sleep: async () => {}, now: () => 1000,
|
||||
fetchFile: async () => { fileCalls++; return null },
|
||||
writeFileRef: async () => null,
|
||||
fetchBytes: async () => { baseCalls++; return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1 } },
|
||||
writeRef: async () => ({ __blob: 'kb' }),
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
const e = ing.enqueue({ url: 'https://cdn/fb.png' })
|
||||
await until(() => ing.get(e.id).status === 'ready', 1500)
|
||||
ok('⑯-1 文件版失败后 base64 回退落地', ing.get(e.id).status === 'ready' && ing.get(e.id).ref.__blob === 'kb')
|
||||
ok('⑯-2 只回退一次(文件重试 2 次 + base64 1 次)', fileCalls === 2 && baseCalls === 1, { fileCalls, baseCalls })
|
||||
}
|
||||
|
||||
// ⑰ 取消会通知 Rust 中断文件下载
|
||||
{
|
||||
let cancelled = null
|
||||
const ing = box.IWBImageIngest.create({
|
||||
useFile: () => true,
|
||||
retries: 0, now: () => 1000,
|
||||
fetchFile: async () => { await new Promise((r) => setTimeout(r, 50)); return { path: '/tmp/x', bytes: 1, mime: 'image/png' } },
|
||||
writeFileRef: async () => ({ __blob: 'k' }),
|
||||
cancelFile: (id) => { cancelled = id },
|
||||
fetchBytes: async () => ({ ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1 }),
|
||||
writeRef: async () => ({ __blob: 'kb' }),
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
const e = ing.enqueue({ url: 'https://cdn/cancel-file.png' })
|
||||
await until(() => ing.get(e.id).status === 'downloading', 500)
|
||||
ing.cancel(e.id)
|
||||
ok('⑰-1 取消调用 cancelFile(id)', cancelled === e.id, cancelled)
|
||||
await until(() => ing.get(e.id).status === 'link-only', 1000)
|
||||
ok('⑰-2 取消后保持 link-only(不被晚到结果覆盖)', ing.get(e.id).status === 'link-only')
|
||||
}
|
||||
|
||||
// ⑱ 手动重试会重新尝试文件版(__baseFallback 被重置)
|
||||
{
|
||||
let fileCalls = 0, baseCalls = 0
|
||||
const ing = box.IWBImageIngest.create({
|
||||
useFile: () => true,
|
||||
retries: 1, sleep: async () => {}, now: () => 1000,
|
||||
fetchFile: async () => { fileCalls++; return null },
|
||||
writeFileRef: async () => null,
|
||||
fetchBytes: async () => { baseCalls++; return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1 } },
|
||||
writeRef: async () => ({ __blob: 'kb' }),
|
||||
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
|
||||
})
|
||||
const e = ing.enqueue({ url: 'https://cdn/retry-file.png' })
|
||||
await until(() => ing.get(e.id).status === 'ready', 2000)
|
||||
const fileBefore = fileCalls
|
||||
ing.retry(e.id)
|
||||
await until(() => fileCalls > fileBefore, 1500)
|
||||
ok('⑱-1 重试后重新尝试文件版', fileCalls > fileBefore, { fileBefore, fileCalls })
|
||||
await until(() => ing.get(e.id).status === 'ready', 2000)
|
||||
ok('⑱-2 重试后仍能回退 base64 落地', ing.get(e.id).status === 'ready')
|
||||
}
|
||||
|
||||
console.log('')
|
||||
console.log(pass + ' passed, ' + fail + ' failed')
|
||||
if (fail) process.exit(1)
|
||||
}
|
||||
|
||||
main().catch((e) => { console.error(e); process.exit(1) })
|
||||
@@ -219,7 +219,8 @@ test('3. 预览复制 PNG 源 → 剪贴板为 image/png', async ({ page }) => {
|
||||
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)))
|
||||
const urls = await makeDataUrls(page)
|
||||
await seed(page, [
|
||||
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8 },
|
||||
// 2026-12-03:图库自 v3.26.226 只显示 orig='ok'(已落地)的条目,夹具必须带 orig,否则面板 0 条
|
||||
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8, orig: 'ok' },
|
||||
])
|
||||
const clip = await copyFromGalleryPreview(page, 'png_src.png')
|
||||
expect(clip.types, JSON.stringify(clip)).toContain('image/png')
|
||||
@@ -235,8 +236,8 @@ test('4. 预览复制 JPEG 源 → 也必须成功且为 image/png', async ({ pa
|
||||
const urls = await makeDataUrls(page)
|
||||
expect(urls.jpeg.indexOf('data:image/jpeg') === 0, 'JPEG 夹具应是 image/jpeg').toBe(true)
|
||||
await seed(page, [
|
||||
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8 },
|
||||
{ name: 'jpeg_src.jpg', url: urls.jpeg, data: urls.jpeg, size: 900, mtime: Date.now() - 2000, w: 8, h: 8 },
|
||||
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8, orig: 'ok' },
|
||||
{ name: 'jpeg_src.jpg', url: urls.jpeg, data: urls.jpeg, size: 900, mtime: Date.now() - 2000, w: 8, h: 8, orig: 'ok' },
|
||||
])
|
||||
const clip = await copyFromGalleryPreview(page, 'jpeg_src.jpg')
|
||||
expect(clip.types, JSON.stringify(clip)).toContain('image/png')
|
||||
|
||||
@@ -118,4 +118,16 @@ const urls = (groups) => Array.from(groups, (g) => Array.from(g.items, (r) => St
|
||||
assert.strictEqual(B.outGroupsOf([gi2], () => [{ id: 't1', title: '当前标题' }])[0].taskTitle, '快照标题', '⑨ 结果快照优先于当前标题')
|
||||
}
|
||||
|
||||
// ── 10. NEW 标记元数据:渲染项必须带 _genAt/_genKey,且是副本(不能挂到存档对象上)──
|
||||
{
|
||||
const src = item('new0')
|
||||
const gi = gen('g1', 0, 0, [{ promptId: 't1', vi: 0, at: 1796230000000, items: [src] }])
|
||||
const groups = B.outGroupsOf([gi], () => [{ id: 't1' }])
|
||||
const it = groups[0].items[0]
|
||||
assert.strictEqual(it._genAt, 1796230000000, '⑩ _genAt 来自条目 at')
|
||||
assert.strictEqual(it._genKey, 't1|0|1796230000000', '⑩ _genKey = 任务|变体|时间')
|
||||
assert.notStrictEqual(it, src, '⑩ 渲染项必须是副本,不能把 _genAt 挂到画布存档对象上')
|
||||
assert.strictEqual(src._genAt, undefined, '⑩ 原始 item 不得被污染')
|
||||
}
|
||||
|
||||
console.log('out-groups-order: 全部通过')
|
||||
@@ -13,7 +13,7 @@ vm.runInNewContext(source, sandbox)
|
||||
const host0 = sandbox.IWBPluginHost
|
||||
assert.ok(Number.isInteger(host0.apiVersion) && host0.apiVersion >= 1, 'apiVersion 必须是正整数')
|
||||
assert.ok(Array.isArray(host0.capabilities) && host0.capabilities.length >= 7, '能力清单应非空')
|
||||
assert.strictEqual(host0.capabilities.slice().sort().join(','), 'canvas,canvasWrite,commands,files,gallery,generationHooks,grouplib,images,nodeActions,nodeTypes,panels,promptlib,providers')
|
||||
assert.strictEqual(host0.capabilities.slice().sort().join(','), 'canvas,canvasWrite,commands,files,gallery,generationHooks,grouplib,images,nodeActions,nodeTypes,pages,panels,promptlib,providers,queue')
|
||||
|
||||
const manifest = (over) => Object.assign({ id: 'demo-plugin', name: 'Demo', version: '1.0.0', apiVersion: 1, capabilities: [] }, over)
|
||||
const stateOf = (ids) => {
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
'use strict'
|
||||
/* 插件文本节点 + 上游参考图:任务文本不能被丢空(2026-12-03)
|
||||
*
|
||||
* 守的是什么:
|
||||
* · 一图一任务:相册 N 张 → N 个任务,每个只带自己那张图
|
||||
* · 批量模式:按 ALBUM_BATCH_MAX(12) 分批 → ⌈N/12⌉ 个任务,每批多张参考图
|
||||
* · 组合扇出:相册接在组合前面时必须变成 N 个任务(否则会被压成 1 个任务 + N 张图)
|
||||
* · 零回归:没有相册时,ref/组合/中继的任务数逐字不变
|
||||
*
|
||||
* 用真实模块 + 最小注入实现(不切片 app.js):依赖全是纯函数,本文件里各写一份等价实现。
|
||||
*/
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const vm = require('vm')
|
||||
|
||||
const src = fs.readFileSync(path.join(__dirname, '..', 'src', 'generation-task-graph.js'), 'utf8')
|
||||
const box = { console }
|
||||
vm.runInNewContext(src, box)
|
||||
const TG = box.IWBWTaskGraph
|
||||
assert.ok(TG && typeof TG.create === 'function', '模块应导出 IWBWTaskGraph.create')
|
||||
|
||||
// ── 最小注入依赖(语义与 app.js 一致,但实现从简)──
|
||||
const byPos = (a, b) => (Number(a.x) - Number(b.x)) || (Number(a.y) - Number(b.y)) || String(a.id).localeCompare(String(b.id))
|
||||
const dedupeTaskRefs = (list) => { const seen = new Set(), out = []; for (const r of (list || [])) { if (!r || seen.has(r.id)) continue; seen.add(r.id); out.push(r) } return out }
|
||||
const refArgsOf = (rn) => { const d = (rn && rn.data) || {}; if (d.localName) return [{ type: 'local', name: d.localName }]; if (d.data) return [{ type: 'data', value: d.data, name: d.name || 'ref.png' }]; if (typeof d.url === 'string') return d.url.trim() ? [{ type: 'url', value: d.url.trim() }] : []; if (d.url) return [{ type: 'data', value: d.url, name: d.name || 'ref.png' }]; return [] }
|
||||
const isBatchSrc = (n) => !!n && (n.type === 'prompt' || n.type === 'textout' || n.type === 'combine' || n.type === 'batch' || (n.data && n.data.outKind === 'prompt'))
|
||||
const batchJoinedText = (data, base) => String((data && data.combined) || base || '')
|
||||
const batchSrcText = (n) => String((n && n.data && (n.data.combined || n.data.text)) || '')
|
||||
const wDedupeTaskIds = (list) => { const seen = new Set(), out = []; for (const t of (list || [])) { if (!t || seen.has(t.id)) continue; seen.add(t.id); out.push(t) } return out }
|
||||
|
||||
|
||||
const tg = TG.create({
|
||||
sortByPosition: (arr) => arr.slice().sort(byPos),
|
||||
compareCanvasImageOrder: byPos,
|
||||
compareCanvasTextOrder: byPos,
|
||||
dedupeTaskRefs,
|
||||
isBatchSrc,
|
||||
batchJoinedText,
|
||||
wDedupeTaskIds,
|
||||
refArgsOf,
|
||||
batchSrcText,
|
||||
standardSizeOf: (n) => ({ w: 1024, h: 1024 }),
|
||||
})
|
||||
|
||||
let failed = 0
|
||||
const ok = (name, cond, extra) => { if (!cond) failed++; console.log((cond ? '✓ ' : '✗ ') + name + (cond || !extra ? '' : ' · ' + extra)) }
|
||||
|
||||
const ref = { id: 'r1', type: 'ref', x: 0, y: 0, data: { url: 'data:image/png;base64,AAA' } }
|
||||
const tpl = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '我要画一只猫', outKind: 'prompt' } }
|
||||
const gen = { id: 'g1', type: 'gen', x: 200, y: 0, data: { model: 'm' } }
|
||||
const e1 = { id: 'e1', from: 'r1', to: 't1' }
|
||||
const e2 = { id: 'e2', from: 't1', to: 'g1' }
|
||||
|
||||
// 1) 插件文本节点接了参考图:文本必须保留,图也要带上
|
||||
let tasks = tg.buildGenerationTasksV2(gen, [ref, tpl, gen], [e1, e2])
|
||||
ok('插件文本节点 + 上游参考图:任务文本保留', tasks.length === 1 && tasks[0].text === '我要画一只猫', JSON.stringify(tasks.map((t) => t.text)))
|
||||
ok('插件文本节点 + 上游参考图:参考图带上', tasks.length === 1 && tasks[0].refs.length === 1)
|
||||
|
||||
// 2) 没有上游参考图:行为不变
|
||||
tasks = tg.buildGenerationTasksV2(gen, [tpl, gen], [e2])
|
||||
ok('无上游参考图:文本仍是自己的', tasks.length === 1 && tasks[0].text === '我要画一只猫' && tasks[0].refs.length === 0)
|
||||
|
||||
// 3) 插件节点自己没有文本、只带上游图:仍然允许「纯图任务」(不新增文本)
|
||||
const tplEmpty = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
|
||||
tasks = tg.buildGenerationTasksV2(gen, [ref, tplEmpty, gen], [e1, e2])
|
||||
ok('空文本 + 上游图:任务仍成立且文本为空', tasks.length === 1 && tasks[0].text === '' && tasks[0].refs.length === 1)
|
||||
|
||||
// 4) 上游是文本节点(非 ref):自己的文本仍然优先
|
||||
const textNode = { id: 'x1', type: 'textout', x: -50, y: 0, data: { text: '上游文本' } }
|
||||
const ex = { id: 'ex', from: 'x1', to: 't1' }
|
||||
tasks = tg.buildGenerationTasksV2(gen, [textNode, tpl, gen], [ex, e2])
|
||||
ok('上游文本 + 自己文本:自己的优先', tasks.length === 1 && tasks[0].text === '我要画一只猫', JSON.stringify(tasks.map((t) => t.text)))
|
||||
|
||||
// 5) 对照:内置 prompt 节点行为不变
|
||||
const promptNode = { id: 'p1', type: 'prompt', x: 100, y: 0, data: { text: '内置提示词' } }
|
||||
const ep = { id: 'ep', from: 'p1', to: 'g1' }
|
||||
tasks = tg.buildGenerationTasksV2(gen, [ref, promptNode, gen], [{ id: 'er', from: 'r1', to: 'p1' }, ep])
|
||||
ok('内置 prompt 节点 + 上游图:文本保留', tasks.length === 1 && tasks[0].text === '内置提示词' && tasks[0].refs.length === 1)
|
||||
|
||||
// 6) 两张参考图 → 插件文本节点:必须合并成 1 个任务(图1+图2 一起带)
|
||||
{
|
||||
const r2 = { id: 'r2', type: 'ref', x: 0, y: 100, data: { url: 'data:image/png;base64,BBB' } }
|
||||
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'e1b', from: 'r2', to: 't1' }, e2]
|
||||
const ts = tg.buildGenerationTasksV2(gen, [ref, r2, tpl, gen], edges2)
|
||||
ok('两张参考图 → 1 个任务', ts.length === 1, JSON.stringify(ts.map((t) => t.refs.length)))
|
||||
ok('两张参考图 → refs=2 且文本保留', ts.length === 1 && ts[0].refs.length === 2 && ts[0].text === '我要画一只猫')
|
||||
}
|
||||
|
||||
// 7) 两张参考图 + 空文本的插件节点:仍是 1 个任务(纯图任务)
|
||||
{
|
||||
const r2 = { id: 'r2', type: 'ref', x: 0, y: 100, data: { url: 'data:image/png;base64,BBB' } }
|
||||
const tplEmpty2 = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
|
||||
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'e1b', from: 'r2', to: 't1' }, e2]
|
||||
const ts = tg.buildGenerationTasksV2(gen, [ref, r2, tplEmpty2, gen], edges2)
|
||||
ok('两张参考图 + 空文本 → 1 个任务、refs=2', ts.length === 1 && ts[0].text === '' && ts[0].refs.length === 2, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
|
||||
}
|
||||
|
||||
// 7b) 一张图 + 一段文本 → 插件文本节点:合并成 1 个任务(不能多生成一张没图的)
|
||||
{
|
||||
const txtNode = { id: 'x9', type: 'textout', x: -50, y: 20, data: { text: '上游文案' } }
|
||||
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'ex9', from: 'x9', to: 't1' }, e2]
|
||||
const ts = tg.buildGenerationTasksV2(gen, [ref, txtNode, tpl, gen], edges2)
|
||||
ok('图 + 文本 → 1 个任务', ts.length === 1, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
|
||||
ok('图 + 文本 → 自己的文本优先、refs=1', ts.length === 1 && ts[0].text === '我要画一只猫' && ts[0].refs.length === 1)
|
||||
}
|
||||
|
||||
// 7c) 图 + 文本(节点自己没文本)→ 用上游文本、refs=1
|
||||
{
|
||||
const txtNode = { id: 'x9', type: 'textout', x: -50, y: 20, data: { text: '上游文案' } }
|
||||
const tplEmpty3 = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
|
||||
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'ex9', from: 'x9', to: 't1' }, e2]
|
||||
const ts = tg.buildGenerationTasksV2(gen, [ref, txtNode, tplEmpty3, gen], edges2)
|
||||
ok('图 + 文本(节点无文本)→ 1 个任务、用上游文本', ts.length === 1 && ts[0].text === '上游文案' && ts[0].refs.length === 1, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
|
||||
}
|
||||
|
||||
// 8) 回归:相册(2 张) → 插件文本节点 → 仍是一图一任务(不能被压平)
|
||||
{
|
||||
const album = { id: 'a1', type: 'plugin:album:album', x: 0, y: 0, data: { outKind: 'images', items: [{ src: 'data:image/png;base64,AAA' }, { src: 'data:image/png;base64,BBB' }] } }
|
||||
const ea = { id: 'ea', from: 'a1', to: 't1' }
|
||||
const ts = tg.buildGenerationTasksV2(gen, [album, tpl, gen], [ea, e2])
|
||||
ok('相册(2 张) → 插件文本节点:仍 2 个任务、各带 1 张', ts.length === 2 && ts.every((t) => t.refs.length === 1), JSON.stringify(ts.map((t) => t.refs.length)))
|
||||
ok('相册 → 插件文本节点:每个任务都带自己的文本', ts.every((t) => t.text === '我要画一只猫'))
|
||||
}
|
||||
|
||||
// 9) 回归:两个文本上游 → 插件节点:仍是 2 个任务
|
||||
{
|
||||
const x1 = { id: 'x1', type: 'textout', x: -100, y: 0, data: { text: '上游A' } }
|
||||
const x2 = { id: 'x2', type: 'textout', x: -100, y: 100, data: { text: '上游B' } }
|
||||
const ex1 = { id: 'ex1', from: 'x1', to: 't1' }
|
||||
const ex2 = { id: 'ex2', from: 'x2', to: 't1' }
|
||||
const ts = tg.buildGenerationTasksV2(gen, [x1, x2, tpl, gen], [ex1, ex2, e2])
|
||||
ok('两个文本上游 → 仍 2 个任务', ts.length === 2, JSON.stringify(ts.map((t) => t.text)))
|
||||
}
|
||||
|
||||
if (failed) { console.error('plugin-text-node-refs: ' + failed + ' 项失败'); process.exit(1) }
|
||||
console.log('plugin-text-node-refs checks passed')
|
||||
@@ -14,6 +14,8 @@ const React = {
|
||||
return { type, props: Object.assign({}, props || {}, { children }) }
|
||||
},
|
||||
useState(init) { return [init, function () {}] },
|
||||
// 183 起 ResultImg 用 useEffect 订阅落地状态;假 React 必须提供(既有失败,与本次回滚无关)
|
||||
useEffect(fn) { try { const c = fn && fn(); if (typeof c === 'function') c() } catch (e) { /* ignore */ } },
|
||||
}
|
||||
const sandbox = { React }
|
||||
vm.runInNewContext(fs.readFileSync(path.join(root, 'src', 'ui-components.js'), 'utf8'), sandbox)
|
||||
@@ -48,10 +50,14 @@ const ov = sandbox.IWBResultDownloadOverlay({
|
||||
onCopyRef: () => { copied++ },
|
||||
children: { type: 'img', props: {} },
|
||||
})
|
||||
const bar = ov.props.children.find((c) => c && c.props && c.props.className === 'iwb-dl-bar')
|
||||
assert.ok(bar, '浮层必须渲染底部条')
|
||||
const btns = bar.props.children.filter(Boolean)
|
||||
// 2026-12-03:下载浮层从底部横条改成右下角圆形图标(只占一个角)
|
||||
const corner = ov.props.children.find((c) => c && c.props && c.props.className === 'iwb-dl-corner')
|
||||
assert.ok(corner, '浮层必须渲染右下角操作区')
|
||||
const btns = corner.props.children.filter(Boolean)
|
||||
assert.strictEqual(btns.length, 2, '浮层应有复制 + 下载两个按钮')
|
||||
assert.ok(String(btns[0].props.className).indexOf('iwb-dl-round') >= 0, '复制按钮必须是圆钮')
|
||||
assert.ok(String(btns[1].props.className).indexOf('iwb-dl-round-primary') >= 0, '下载按钮必须是主圆钮')
|
||||
assert.strictEqual(btns[1].props['aria-label'], '下载', '图标按钮必须有 aria-label(可发现性)')
|
||||
btns[0].props.onClick({ stopPropagation() {} })
|
||||
btns[1].props.onClick({ stopPropagation() {} })
|
||||
btns[1].props.onPointerDown({ stopPropagation() { stopped++ } })
|
||||
|
||||
@@ -130,7 +130,7 @@ const MAX_SRC_COMPONENT_LINES = 531 // 2026-12-02 纳入记账基线(此前
|
||||
// −1(122→121)2026-12-02:插件画布桥新增 IWBPluginCanvasBridge(+1),同时删掉两个从未被引用的工厂导出
|
||||
// IWBStorageRuntimeFactory / IWBRuntimeMetricsFactory(−2,实例导出 IWBStorageRuntime / IWBRuntimeMetrics 仍在用)。
|
||||
// 新增模块请先看能不能挂到已有命名空间;确需新增则同批下调基线。
|
||||
const MAX_SRC_GLOBALS = 121
|
||||
const MAX_SRC_GLOBALS = 125 // 2026-12-04 +1(124→125):新增 IWBRefUpload(参考图上传到图库动作,从 app.js 气泡抽出)。2026-12-03 +1:IWBPluginQueue。之后只减不增。
|
||||
// ── app.js 总行数 & Workbench 行数棘轮(只减不增)────────────────────────────
|
||||
// 动机(2026-10-29 用户提问"以后新功能会不会还往 app.js 里加"):
|
||||
// 上面的 MAX_APP_COMPONENT_LINES **明确跳过 Workbench**,而且此前**没有** app.js 总行数守卫
|
||||
@@ -175,7 +175,7 @@ const MAX_SRC_GLOBALS = 121
|
||||
// · 图标解析统一(右键菜单 + 设置页走同一解析器,2 行) +2
|
||||
// 通用件(pick/grant/stat/readDataUrl/readBlob/参数校验)全部在 src/image-file-ref.js
|
||||
// 与 src/plugin-api-images.js,app.js 只做装配。
|
||||
const MAX_APP_JS_LINES = 8860 // −51(8,911→8,860)2026-12-02:插件画布桥(含图片写回装配)迁到 src/plugin-canvas-bridge.js,app.js 只留依赖装配。之后只减不增。
|
||||
const MAX_APP_JS_LINES = 9529 // +76(9,453→9,529)2026-12-04:ref 气泡「上传到图库」(含守卫 Set)+ 移除气泡改名。之前 +49 文件版加固;+42 文件版;+36 文件版;+6 缓存闭包;+4 mime;+56 原生审计;+19 缩略图兜底;+11 预览;+3 并发;+9 命名;+199 队列装配。之后只减不增。
|
||||
const MAX_APP_JS_SHARE = 0.40
|
||||
|
||||
// ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────
|
||||
@@ -218,7 +218,7 @@ const MAX_APP_JS_SHARE = 0.40
|
||||
// 需要实时读 .iwb-world 变换 + 按同类型实测高度校正视觉中心;属装配层的 DOM 读取,
|
||||
// 放 src 会引入新的全局读取与边界快照改动,权衡后留在 app.js // +10(2026-11-01):背景色「悬停预览」的 DOM 补丁助手(纯 DOM,不写数据/不进撤销栈);
|
||||
// 属装配层最小的 DOM 操作,放 src 会引入新的全局读取与边界快照改动,权衡后留在 app.js
|
||||
const MAX_WORKBENCH_LINES = 2454 // −51(2,505→2,454)2026-12-02:同上(画布桥迁出 Workbench())。之后只减不增。
|
||||
const MAX_WORKBENCH_LINES = 2710 // +4(2,706→2,710)2026-12-05:保存落定窗口补存(commitCanvas 打标 / 保存 effect 与 1.2s 同步定时器补一次 saveDebounced / 关窗兜底 flush 也认这个标记),时序逻辑依赖 Workbench 内的 loaded/syncing,抽不走。之前 +10 ref 气泡上传/去改名;+5 文件版接线;+4 文件版;+6 缓存闭包;+3 网络栈/并发;+1 队列预览;+153 队列装配。之后只减不增。
|
||||
// 2026-11-18 v3.25.21:模态层指针守卫(2 行)
|
||||
// 实测 3090 → 2998(省 92):① 生成取消族 cancelRunsFor/cancelRun/cancelTaskJobs
|
||||
// → src/runtime-workbench-logic.js 的 createCancelActions(−53);② 工作区列表写回族
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/* storage-flush-persist-test.js —— 「没变化就不写」之后,编辑必须仍然落盘(v3.26.247)
|
||||
*
|
||||
* 背景(2026-12-04 回归):244 引入「内容未变不写盘」后,启动那次 flush 变全同步
|
||||
* (画布不脏 / 库不脏 / data.json 签名相同)。原实现是
|
||||
* writing = (async () => { ... finally { writing = null } })()
|
||||
* 函数体没有 await 时 IIFE 同步跑完,finally 先把 writing 置 null,随后赋值又把 writing 写成
|
||||
* 一个已解决且永不清理的 promise ⇒ 此后每次 flush 都在 if (writing) return writing 处直接返回,
|
||||
* 整个会话不再写盘(用户实测:画布改动重启后消失)。
|
||||
*
|
||||
* 本用例跑真实 src/storage-file.js + 假 Tauri fs(真实临时目录),断言行为:
|
||||
* ① 启动后编辑画布 → flush → 磁盘文件变化 → 重载(新实例)仍在
|
||||
* ② 启动(无改动)后连续 flush 两次不把写盘通道卡死
|
||||
* ③ 非分板键写进 data.json
|
||||
* ④ 资源库键写进 library/<文件>(含 gallery 新布局)
|
||||
* ⑤ 一次性维护路径也经由 storage.setItem 标脏(不直写 mem)
|
||||
*/
|
||||
'use strict'
|
||||
const fs = require('node:fs')
|
||||
const os = require('node:os')
|
||||
const path = require('node:path')
|
||||
const assert = require('node:assert')
|
||||
|
||||
const SRC = fs.readFileSync(path.join(__dirname, '..', 'src', 'storage-file.js'), 'utf8')
|
||||
const ROOT = fs.mkdtempSync(path.join(os.tmpdir(), 'iwb-flush-persist-'))
|
||||
|
||||
const writeSeed = (rel, text) => {
|
||||
const abs = path.join(ROOT, rel)
|
||||
fs.mkdirSync(path.dirname(abs), { recursive: true })
|
||||
fs.writeFileSync(abs, text)
|
||||
}
|
||||
const readFile = (rel) => fs.readFileSync(path.join(ROOT, rel), 'utf8')
|
||||
|
||||
let failRe = null // 注入写失败:匹配到的路径抛错(验证「失败键回填 + 限次重试」)
|
||||
const makeFs = () => ({
|
||||
readTextFile: async (p) => fs.readFileSync(p, 'utf8'),
|
||||
writeTextFile: async (p, t, o) => {
|
||||
if (failRe && failRe.test(p)) throw new Error('EIO: injected')
|
||||
fs.mkdirSync(path.dirname(p), { recursive: true })
|
||||
if (o && o.append) fs.appendFileSync(p, t); else fs.writeFileSync(p, t)
|
||||
},
|
||||
writeFile: async (p, u8) => { fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, Buffer.from(u8)) },
|
||||
readFile: async (p) => new Uint8Array(fs.readFileSync(p)),
|
||||
rename: async (a, b) => { fs.mkdirSync(path.dirname(b), { recursive: true }); fs.renameSync(a, b) },
|
||||
remove: async (p) => { try { fs.rmSync(p, { recursive: true, force: true }) } catch (e) { /* 不存在 */ } },
|
||||
mkdir: async (p) => { fs.mkdirSync(p, { recursive: true }) },
|
||||
exists: async (p) => fs.existsSync(p),
|
||||
readDir: async (p) => {
|
||||
if (!fs.existsSync(p)) throw new Error('ENOENT')
|
||||
return fs.readdirSync(p, { withFileTypes: true }).map((d) => ({ name: d.name, isDirectory: d.isDirectory(), isFile: d.isFile() }))
|
||||
},
|
||||
stat: async (p) => fs.statSync(p),
|
||||
})
|
||||
|
||||
// 每个「进程」一个独立 global:模拟重启
|
||||
const boot = async () => {
|
||||
const ls = new Map([['iwb.dataDir', ROOT]])
|
||||
const g = {
|
||||
__TAURI__: {
|
||||
core: { invoke: async () => true },
|
||||
path: { join: async (...p) => path.join(...p.map(String)), documentDir: async () => ROOT },
|
||||
fs: makeFs(),
|
||||
},
|
||||
localStorage: {
|
||||
getItem: (k) => (ls.has(k) ? ls.get(k) : null),
|
||||
setItem: (k, v) => ls.set(k, String(v)),
|
||||
removeItem: (k) => ls.delete(k),
|
||||
key: (i) => Array.from(ls.keys())[i] || null,
|
||||
get length() { return ls.size },
|
||||
},
|
||||
addEventListener() {},
|
||||
document: { addEventListener() {}, visibilityState: 'visible' },
|
||||
setTimeout, clearTimeout, crypto: globalThis.crypto, atob, btoa, console,
|
||||
}
|
||||
const load = new Function('window', 'globalThis', SRC + '\nreturn window.IWBStorageFile')
|
||||
const F = load(g, g)
|
||||
const ok = await F.ready({ dir: ROOT })
|
||||
assert.ok(ok, '存储底座应能初始化')
|
||||
return F
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
const WS1 = '{"id":"ws1","name":"c1","nodes":[{"id":"n1","type":"text","data":{"text":"hello"}}],"edges":[],"groups":[]}'
|
||||
writeSeed('canvases/ws1.json', WS1)
|
||||
writeSeed('data.json', JSON.stringify({ v: 1, keys: {}, assets: {}, small: {} }))
|
||||
|
||||
const F1 = await boot()
|
||||
assert.strictEqual(F1.storage().getItem('iwb_ws_ws1'), WS1, '① 启动应把画布文件读进内存表')
|
||||
|
||||
// ② 启动那次 flush 是全同步路径:连续两次不能让写盘通道卡死
|
||||
await F1.flush()
|
||||
await F1.flush()
|
||||
|
||||
const WS2 = WS1.replace('hello', 'hello-edited')
|
||||
F1.storage().setItem('iwb_ws_ws1', WS2)
|
||||
await F1.flush()
|
||||
assert.ok(readFile('canvases/ws1.json').includes('hello-edited'), '① 画布编辑必须立刻落盘(会被 writing 卡死吞掉)')
|
||||
|
||||
F1.storage().setItem('iwb_web_config', '{"x":1}')
|
||||
await F1.flush()
|
||||
const data = JSON.parse(readFile('data.json'))
|
||||
assert.strictEqual(data.keys.iwb_web_config, '{"x":1}', '③ 非分板键应写进 data.json')
|
||||
|
||||
writeSeed('library/gallery.json', '[]')
|
||||
F1.storage().setItem('iwb_web_outputs', '[{"name":"a.png"}]')
|
||||
await F1.flush()
|
||||
assert.ok(readFile('library/gallery/index.json').includes('a.png'), '④ 图库清单应写到 library/gallery/index.json')
|
||||
assert.ok(!fs.existsSync(path.join(ROOT, 'library/gallery.json')), '④ 新布局写成功后应删掉旧的平铺文件')
|
||||
|
||||
const F2 = await boot()
|
||||
assert.ok(String(F2.storage().getItem('iwb_ws_ws1')).includes('hello-edited'), '① 重启后编辑仍在(用户实测的回归点)')
|
||||
assert.strictEqual(F2.storage().getItem('iwb_web_config'), '{"x":1}', '③ 重启后非分板键仍在')
|
||||
assert.ok(String(F2.storage().getItem('iwb_web_outputs')).includes('a.png'), '④ 重启后图库清单仍在')
|
||||
|
||||
assert.ok(!/mem\['iwb_web_outputs'\]\s*=\s*JSON\.stringify/.test(SRC), '⑤ 维护路径应经 storage.setItem 标脏,不能直写 mem 后 flush')
|
||||
|
||||
// ⑤ 写失败:失败的键必须回填脏集合并限次重试(不能一次失败就永久丢)
|
||||
failRe = /canvases\//
|
||||
const WS3 = WS2.replace('hello-edited', 'hello-retry')
|
||||
F2.storage().setItem('iwb_ws_ws1', WS3)
|
||||
const failed = await F2.flush()
|
||||
assert.strictEqual(failed, false, '⑤ 写失败时 flush 应返回 false')
|
||||
assert.ok(!readFile('canvases/ws1.json').includes('hello-retry'), '⑤ 写失败时磁盘内容不应变化')
|
||||
failRe = null
|
||||
await new Promise((r) => setTimeout(r, 4600))
|
||||
assert.ok(readFile('canvases/ws1.json').includes('hello-retry'), '⑤ 失败键应在重试后落盘(否则等于一次失败永久丢)')
|
||||
|
||||
fs.rmSync(ROOT, { recursive: true, force: true })
|
||||
console.log('storage-flush-persist: 10 通过 / 0 失败')
|
||||
})().catch((e) => { console.error('storage-flush-persist FAILED:', e && (e.stack || e.message)); process.exit(1) })
|
||||
|
||||
@@ -36,4 +36,13 @@ for (let i = 1; i < putRegions.length; i++) {
|
||||
}
|
||||
assert.ok(flushed >= 2, '图片登记后必须立刻 await flush()(当前 ' + flushed + '/2 处)')
|
||||
|
||||
console.log('storage-gc-canvas-refs: 8 通过 / 0 失败')
|
||||
// ④ 显示缩略图缓存(thumbs/<hash>_<max>.<ext>)是再生缓存,不得被当作未引用图片搬走
|
||||
assert.ok(/THUMB_CACHE_RE/.test(gcBody) && /thumbCaches/.test(gcBody), '④ gcImages 必须跳过 thumbs 下的显示缓存并单独计数')
|
||||
assert.ok(/sub === 'thumbs' && THUMB_CACHE_RE/.test(gcBody), '④ 只对 thumbs 目录应用缓存判据')
|
||||
|
||||
// ⑤ 确认弹窗文案必须与实现一致:assets 缺键时拿不到文件名,并不存在「自动保留」的兜底
|
||||
const UI = fs.readFileSync(path.join(__dirname, '..', 'src', 'ui-settings-sections.js'), 'utf8')
|
||||
assert.ok(!/登记表里没有,但画布仍在引用/.test(UI), '⑤ 弹窗不得声称「登记表里没有但画布仍在引用 → 自动保留」')
|
||||
assert.ok(/缩略图缓存/.test(UI), '⑤ 弹窗应说明跳过的缩略图缓存数量')
|
||||
|
||||
console.log('storage-gc-canvas-refs: 12 通过 / 0 失败')
|
||||
@@ -98,5 +98,13 @@ function loadStore(opts) {
|
||||
assert.strictEqual(r7.ok, true, '没有 navigator.locks 时仍要能工作(降级)')
|
||||
assert.deepStrictEqual(values.get(KEY).map((x) => x.name), ['z.png', 'y.png'], '降级路径也要真的写进去')
|
||||
|
||||
console.log('storage outputs mutate checks passed(跨标签锁接线 / 放弃写入 / 非法返回 / 抛错 / 串行顺序 / 无锁降级)')
|
||||
// ── 8. add 必须保留 orig 状态(2026-12-03)────────────────────────────────
|
||||
// 之前 doAdd 重建行时只保留 name/url/...,丢掉 orig;行若在 markOk 之后才创建,
|
||||
// 就会一直是「未落地」状态 → 图库按规则隐藏它,直到下次启动对账(用户实测的「丢图」)。
|
||||
values.set(KEY, [])
|
||||
const r8 = await store.add([{ name: 'g1.png', url: 'https://cdn.test/1.png', orig: 'pending' }])
|
||||
assert.strictEqual(r8.ok, true, 'add 应成功')
|
||||
assert.strictEqual(values.get(KEY)[0].orig, 'pending', 'add 必须保留 orig(否则行永远显示未落地)')
|
||||
|
||||
console.log('storage outputs mutate checks passed(跨标签锁接线 / 放弃写入 / 非法返回 / 抛错 / 串行顺序 / 无锁降级 / orig 保留)')
|
||||
})().catch((e) => { console.error(e); process.exit(1) })
|
||||
Vendored
+1
@@ -31,6 +31,7 @@ interface Window {
|
||||
IWBStorageMigrations?: any
|
||||
IWBStorageIndexedDb?: any
|
||||
IWBStorageFile?: any
|
||||
__iwbIngest?: any
|
||||
__TAURI__?: any
|
||||
__IWB_UPDATE__?: any
|
||||
IWBUIConfirm?: any
|
||||
|
||||
Reference in new issue
Block a user