Compare commits

..
183 Commits
Author SHA1 Message Date
qiqi 48a68a7e8a chore: v3.26.238(图片读取/下载本地优先 + 命名统一图库行名) 2026-12-03 11:55:28 +08:00
qiqi ec9ca02a82 site: 插件页同步 taskqueue 1.0.3(含 gallery 1.9.12 等已上线版本)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-03 11:35:30 +08:00
qiqi c3b76ec444 docs: 锚点同步 v3.26.237
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 24s
2026-12-03 11:35:02 +08:00
qiqi dc5c1a6b0a chore: v3.26.237(任务队列页头固定 / 老记录预览取原图,taskqueue 1.0.3) 2026-12-03 11:34:53 +08:00
qiqi a8b9296558 docs: 锚点同步 v3.26.236
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 43s
2026-12-03 11:02:34 +08:00
qiqi ab8579dcef chore: v3.26.236(测试版:标签条 portal 固定) 2026-12-03 11:02:24 +08:00
qiqi 9cbd5fa673 docs: 锚点同步 v3.26.235
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m3s
2026-12-03 10:46:38 +08:00
qiqi ac6a0062c3 chore: v3.26.235(测试版:任务队列修复) 2026-12-03 10:46:33 +08:00
qiqi 2e62769421 docs: 锚点同步 v3.26.234
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 45s
2026-12-03 10:22:55 +08:00
qiqi 42033a54ab chore: v3.26.234(测试版:任务队列体验修正) 2026-12-03 10:22:37 +08:00
qiqi 48232bec5c fix(queue): 选中态/缩略图复用/提示词标题/画布归属/状态与下载语义 2026-12-03 10:20:05 +08:00
qiqi 7b2bb0d58e docs: 锚点同步 v3.26.233
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-03 09:55:08 +08:00
qiqi 1c7cbd9726 chore: v3.26.233(测试版:任务队列左栏整页插件) 2026-12-03 09:54:59 +08:00
qiqi 630949eac7 fix(queue): 定位回画布 / 已在图库判定 / 上限保护 / 缩略图与兜底 2026-12-03 09:51:38 +08:00
qiqi 9edc635ed8 fix(queue): link-only 再次下载回到 queued + 执行计划状态 2026-12-03 09:45:08 +08:00
qiqi a0f86bf09c fix(queue): 账本上限/进行中保留 + 任务队列页工具区与状态修正 2026-12-03 09:44:35 +08:00
qiqi f5859b7596 feat(queue): 任务队列左栏整页插件 + 宿主 queue/pages 能力 2026-12-03 09:39:48 +08:00
qiqi 3cc53eec4b docs(plan): 任务队列左栏整页插件执行计划 2026-12-03 09:30:11 +08:00
qiqi 380d39146d docs(mockup): 任务队列缩略图支持点击预览(cursor/提示) 2026-12-03 09:23:13 +08:00
qiqi 81e73bd89b docs(mockup): 任务队列页 UI 原型(token 化、浅/深色截图) 2026-12-03 09:20:59 +08:00
qiqi 4cf0947e76 docs: 锚点同步 v3.26.232
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 40s
2026-12-03 08:15:34 +08:00
qiqi ba2918ff95 chore: v3.26.232(测试版:NEW 标记层叠修正) 2026-12-03 08:15:30 +08:00
qiqi bb9e7f487f docs: 锚点同步 v3.26.231
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 37s
2026-12-03 07:28:43 +08:00
qiqi 6102b7358a chore: v3.26.231(测试版:NEW 标记排除未落地) 2026-12-03 07:28:36 +08:00
qiqi 287da25a24 docs: 锚点同步 v3.26.230
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-03 07:17:58 +08:00
qiqi 14457c04f2 chore: v3.26.230(测试版:新图 NEW 标记) 2026-12-03 07:17:45 +08:00
qiqi e996975bf9 plugins: gallery 1.9.12(卡片下载钮对齐输出面板:SVG 图标 / 26px / 无阴影) 2026-12-03 07:10:51 +08:00
qiqi d81c085972 docs: 锚点同步 v3.26.229
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
2026-12-03 01:08:48 +08:00
qiqi aeba3d3785 chore: v3.26.229(测试版:图库下载圆钮对齐输出面板) 2026-12-03 01:08:41 +08:00
qiqi 6d9842ecd3 docs: 锚点同步 v3.26.228
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m2s
2026-12-03 00:40:31 +08:00
qiqi f948a45fcc chore: v3.26.228(测试版:输出节点下载圆钮) 2026-12-03 00:40:26 +08:00
qiqi c3bbe1a75a docs: 锚点同步 v3.26.227
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 51s
2026-12-03 00:25:56 +08:00
qiqi 0b9d7d4cfc chore: v3.26.227(测试版:图库一致性快修) 2026-12-03 00:25:50 +08:00
qiqi 7d106d2f2c fix(types): 补 window.__iwbIngest 声明(typecheck)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-02 23:38:56 +08:00
qiqi a95e38d2f7 docs: 锚点同步 v3.26.226 2026-12-02 23:38:39 +08:00
qiqi f0ccaf79d3 chore: v3.26.226(测试版:先落地再显示 / 单次下载) 2026-12-02 23:38:27 +08:00
qiqi ae6549354d docs: 锚点同步 v3.26.225
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m40s
2026-12-02 22:49:40 +08:00
qiqi 32e2c037ff chore: v3.26.225(测试版:撤销失败态) 2026-12-02 22:49:40 +08:00
qiqi 8c115c6f7d fix(out): onLoad 时撤销 is-broken / is-broken-cell(修「加载失败」盖在正常图上) 2026-12-02 22:49:40 +08:00
qiqi 308324a749 docs(workflow): 明确交付节奏 —— 报问题后先分析,经用户确认再改代码/构建 2026-12-02 22:46:24 +08:00
qiqi 8bac6bc701 docs: 锚点同步 v3.26.224
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m24s
2026-12-02 22:43:16 +08:00
qiqi c7f7d54db8 chore: v3.26.224(测试版:白板期可见) 2026-12-02 22:43:16 +08:00
qiqi 9463db2538 fix(out): 角标默认显示(onLoad 后由 CSS 收起);骨架垫在图片下方,白板期也能看到 2026-12-02 22:43:16 +08:00
qiqi 5246a1ef85 docs: 锚点同步 v3.26.223
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 55s
2026-12-02 22:40:37 +08:00
qiqi f8d547353f chore: v3.26.223(测试版:去重 + 续传) 2026-12-02 22:40:37 +08:00
qiqi 61dbbb83d3 feat(gallery): 启动按 url 去重(修 220 遗留的重复条目);超时失败在窗口聚焦时自动续传 2026-12-02 22:40:37 +08:00
qiqi fd5f7c7a17 chore(ratchet): app.js 9049→9053、Workbench→2552(归档补漏修正 +8 行)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m29s
2026-12-02 22:31:17 +08:00
qiqi 61c31b3203 docs: 锚点同步 v3.26.222
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 7s
2026-12-02 22:31:07 +08:00
qiqi 75e81ebc29 chore: v3.26.222(测试版:归档补漏修正) 2026-12-02 22:31:07 +08:00
qiqi aa9a54cdc2 fix(gallery): 归档补漏改按 item 级 url 判定(条目本身没有 url,原判定恒为待补 → 重复入库) 2026-12-02 22:31:07 +08:00
qiqi 7caa564ea1 docs: 锚点同步 v3.26.221
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m51s
2026-12-02 22:08:50 +08:00
qiqi f62ec18b0f chore: v3.26.221(测试版:渐进渲染回归) 2026-12-02 22:08:49 +08:00
qiqi 4e8f3215a5 fix(out): 有远程 url 时不做骨架遮挡(回到渐进渲染);落地超时改 5 分钟安全阀 2026-12-02 22:08:49 +08:00
qiqi ee09343011 docs: 锚点同步 v3.26.220
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m45s
2026-12-02 22:06:28 +08:00
qiqi 2b2eb263cd chore: v3.26.220(测试版:少一张 + 超时) 2026-12-02 22:06:28 +08:00
qiqi 25335ddd3d fix(gallery): 已归档但索引缺失的条目仍补入库;落地超时 25s→60s 2026-12-02 22:06:27 +08:00
qiqi 2c1a7e01e9 docs: 锚点同步 v3.26.219
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m19s
2026-12-02 21:54:53 +08:00
qiqi d86031bd76 chore: v3.26.219(诊断版:入库计数) 2026-12-02 21:54:53 +08:00
qiqi 6fe52f0ece diag(gallery): 记录 add-outputs / archive 的张数与跳过原因(定位「总少一张」) 2026-12-02 21:54:53 +08:00
qiqi 2ffe95f0aa docs: 锚点同步 v3.26.218
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m54s
2026-12-02 21:25:53 +08:00
qiqi f4ab497c73 chore: v3.26.218(测试版:下载超时) 2026-12-02 21:25:53 +08:00
qiqi 2f79d12c54 fix(ingest): 下载加 25s 超时(fetch 挂住会让状态永久停在下载中) 2026-12-02 21:25:52 +08:00
qiqi 95b6f45bfd docs: 锚点同步 v3.26.217
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m38s
2026-12-02 21:13:51 +08:00
qiqi b59120beb4 chore: v3.26.217(测试版:打类目标修正 + 骨架撑高) 2026-12-02 21:13:51 +08:00
qiqi 49d11744a6 fix(out): 加载/失败类打到最近的 .iwb-out-cell(img 被浮层包裹,parentElement 不是单元格) 2026-12-02 21:13:51 +08:00
qiqi 420e87628e docs: 锚点同步 v3.26.216
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 1m9s
2026-12-02 21:12:41 +08:00
qiqi ebde29c9d7 chore: v3.26.216(测试版:骨架撑高) 2026-12-02 21:12:41 +08:00
qiqi 15b3352f8f fix(out): 骨架改为撑高(min-height 140px),出图前不再塌成一条线 2026-12-02 21:12:40 +08:00
qiqi 8fdcf3b3dc docs: 锚点同步 v3.26.215
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m34s
2026-12-02 21:05:17 +08:00
qiqi fa0b97bdf6 chore: v3.26.215(测试版:失败态) 2026-12-02 21:05:17 +08:00
qiqi 37fe86c88c fix(out): 加载/失败态改用父容器打类(去 :has 依赖);破图显示「加载失败」 2026-12-02 21:05:17 +08:00
qiqi c20834b623 docs: 锚点同步 v3.26.214
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 58s
2026-12-02 20:59:09 +08:00
qiqi 10ad8618d7 chore: v3.26.214(测试版:加载态与回退) 2026-12-02 20:59:09 +08:00
qiqi fd1a9c636b feat(out): 骨架/角标改以图片 onLoad 为准(CSS :has 联动);onError 两级回退并标失败态 2026-12-02 20:59:09 +08:00
qiqi 8398a389fe docs: 锚点同步 v3.26.213
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 57s
2026-12-02 20:36:29 +08:00
qiqi 8487ef2c91 chore: v3.26.213(测试版:骨架 TDZ 修复) 2026-12-02 20:36:29 +08:00
qiqi 9f88b3a71c fix(out): 修骨架 TDZ(_localSrc 先声明),骨架仅对远程 url 生效 2026-12-02 20:36:29 +08:00
qiqi f0c39fb1c4 fix(style): 骨架用已定义 token(layer2/text2),修「引用未定义变量 +2」
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 53s
2026-12-02 20:30:45 +08:00
qiqi 5fe41ffad4 docs: 锚点同步 v3.26.212
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 14s
2026-12-02 20:30:30 +08:00
qiqi 7f38d31ac2 chore: v3.26.212(测试版:下载骨架) 2026-12-02 20:30:30 +08:00
qiqi 301669a148 feat(out): 无本地源时显示「下载中…」骨架(方案 A),有缩略图时仍走 LOD(方案 B) 2026-12-02 20:30:30 +08:00
qiqi d36bbe3b91 docs: 锚点同步 v3.26.211
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 58s
2026-12-02 20:09:54 +08:00
qiqi 768d01360d chore: v3.26.211(测试版:角标空指针修复) 2026-12-02 20:09:54 +08:00
qiqi fce4fedad6 fix(out): 角标空指针(视图未命中时 ingSt 为 null)+ 未落地优先于下载中 2026-12-02 20:09:54 +08:00
qiqi a6d4f5cc63 docs: 锚点同步 v3.26.210
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m25s
2026-12-02 20:01:01 +08:00
qiqi dde8e861e8 chore: v3.26.210(测试版:恢复下载中角标 + 分层修正) 2026-12-02 20:01:01 +08:00
qiqi e8894d6864 feat(out): 恢复「下载中」角标(按「无本地源且为远程 url」判定,不依赖视图命中) 2026-12-02 20:01:01 +08:00
qiqi 3a70e16ead refactor(boundary): 落地状态视图改为注入(src 不再直接读 window 全局);ResultImg 回到纯展示
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m20s
2026-12-02 19:31:53 +08:00
qiqi c346256115 docs: 锚点同步 v3.26.209
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-02 19:21:22 +08:00
qiqi 2d3aba2ed2 chore: v3.26.209(测试版:对账去轮询) 2026-12-02 19:21:22 +08:00
qiqi 9893d1121d perf(ingest): 对账改为「启动一次 + 窗口聚焦时」,去掉 30s 常驻轮询(用户要求空闲零开销) 2026-12-02 19:21:22 +08:00
qiqi 1b36960e4f docs(changelog): 补 v3.26.208 条目 2026-12-02 19:19:25 +08:00
qiqi 0bc96494e9 docs: 锚点同步 v3.26.208
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m26s
2026-12-02 19:19:18 +08:00
qiqi dd24679c3a chore: v3.26.208(测试版:ingest 日志 + 对账) 2026-12-02 19:19:18 +08:00
qiqi 9c8867fdae feat(ingest): 补进队/失败/就绪日志;新增索引对账(启动 3s 后 + 每 30s,幂等) 2026-12-02 19:19:17 +08:00
qiqi c0e4efc06e docs(changelog): 补 v3.26.207 与历史缺失的 v3.24.86 条目(release-records 守卫) 2026-12-02 18:35:43 +08:00
qiqi 9222144d22 docs: 锚点同步 v3.26.207
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-02 18:29:21 +08:00
qiqi ac4446d4a0 chore: v3.26.207(测试版:落地重试 + 留痕) 2026-12-02 18:29:20 +08:00
qiqi 1606e0cd7c fix(gallery): 落地 ready 未命中索引时延迟重试(1s/3s)并留痕(修批量静默不落库) 2026-12-02 18:29:20 +08:00
qiqi 17a8681897 docs(changelog): 补 v3.26.206 条目(183 起无记录,release-records 守卫需要) 2026-12-02 18:15:57 +08:00
qiqi c34cadc7d9 fix(style): 恢复 .iwb-pop-anchor 的 z-index(下拉弹层被压在节点下面,打不开)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 47s
2026-12-02 18:14:51 +08:00
qiqi a4d0f8ab79 fix(style): 去掉角标规则里的 z-index 声明(计数棘轮 +2;DOM 顺序已足够)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-02 18:08:13 +08:00
qiqi a56ad1829b chore(plugins): 回滚后重新同步插件产物(gallery 1.9.11) 2026-12-02 18:07:59 +08:00
qiqi bbd1e090b5 docs: 锚点同步 v3.26.206 2026-12-02 18:07:44 +08:00
qiqi fd76c76589 chore: v3.26.206(测试版:回滚到 203 行为) 2026-12-02 18:07:44 +08:00
qiqi 71cd7bc41e test: 补 useEffect 桩(183 起既有失败,与本轮无关) 2026-12-02 18:07:44 +08:00
qiqi af9d261636 revert(ui): 整树回滚到 v3.26.203 行为(下载钮/浮层/token 改造导致图库加载异常,先恢复功能) 2026-12-02 18:07:36 +08:00
qiqi 7c20ca90ee docs: 锚点同步 v3.26.205
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 40s
2026-12-02 17:48:28 +08:00
qiqi 8755e7327c chore: v3.26.205(测试版:图库圆钮位置/尺寸修正) 2026-12-02 17:48:27 +08:00
qiqi dc311ec0a9 fix(ui): 图库下载钮回右下角(覆盖宿主旧规则)、尺寸 28→26、与输出节点同款 2026-12-02 17:48:27 +08:00
qiqi eddd635846 fix(ui): 圆钮容器 pointer-events:none(空白时不挡图);修 result-img 单测(useEffect 桩 + 新结构断言)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 25s
2026-12-02 17:47:59 +08:00
qiqi c22d28320e chore(plugins): gallery 1.9.11 产物(修圆钮掉出卡片)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 33s
2026-12-02 17:45:49 +08:00
qiqi c6e3488aed docs: 锚点同步 v3.26.204
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 28s
2026-12-02 17:37:17 +08:00
qiqi e1c4501f00 chore: v3.26.204(测试版:宿主下载按钮圆形 + token 化;诊断读数修正) 2026-12-02 17:37:16 +08:00
qiqi 42304bc88f chore(tokens): 收紧 token 计数基线(deadTokens 31 / hex 78 / fontSize 119 / radius 69 / spacing 351 / radiusDistinct 12)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 29s
2026-12-02 17:33:44 +08:00
qiqi f83ed2e08a feat(tokens): 下载按钮尺寸提升为正式 token(--iwb-dl-size/radius/inset/gap),宿主与 gallery 共用
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 31s
2026-12-02 17:31:17 +08:00
qiqi 559945281f chore(plugins): gallery 1.9.10 产物(卡片下载改圆形图标、选中只留外框)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
2026-12-02 17:24:29 +08:00
qiqi fcbeab6cb1 feat(ui): 下载浮层改右下角圆形图标;图库选中只留外框(不显示角标)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 32s
2026-12-02 17:18:14 +08:00
qiqi 499f16a2df fix(diag): 私有内存读数做防守(Windows 出现 private>工作集 的错误值时不展示)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-02 16:58:15 +08:00
qiqi 1677f86129 docs: 锚点同步 v3.26.203
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 35s
2026-12-02 16:32:08 +08:00
qiqi 8872c2fa47 chore: v3.26.203(测试版:节点 LOD 优先) 2026-12-02 16:32:08 +08:00
qiqi 56b39b9829 perf(out): 节点取图回到 LOD 优先(本地源才走缩略图),并用本地字节预热 512/768 2026-12-02 16:32:08 +08:00
qiqi 711822092e fix(gallery): mutate 返回 {ok:false} 也按失败处理(避免误记 ok 并白刷一次)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-02 16:19:16 +08:00
qiqi c330d3ecf8 docs: 锚点同步 v3.26.202
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 32s
2026-12-02 16:08:58 +08:00
qiqi 65ea7dff9d chore: v3.26.202(测试版:orig 写对数据源) 2026-12-02 16:08:58 +08:00
qiqi 409233670c fix(gallery): orig 状态改写 ModularOutputStore(插件读的那份),不再只改 KV 索引 2026-12-02 16:08:58 +08:00
qiqi a9f36c26e7 docs: 锚点同步 v3.26.201
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 59s
2026-12-02 15:56:33 +08:00
qiqi 8b539ca03e chore: v3.26.201(测试版:图库刷新修复) 2026-12-02 15:56:33 +08:00
qiqi 4315072394 fix(gallery): 原图回填后让宿主重读 outputs(修「数据已 ok、界面不刷新」) 2026-12-02 15:56:33 +08:00
qiqi 8742bbd256 docs: 锚点同步 v3.26.200
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-02 15:35:19 +08:00
qiqi b674aae1bc chore: v3.26.200(诊断版修正) 2026-12-02 15:35:19 +08:00
qiqi 3563e54bd0 fix(diag): wIngestLog 自递归改为 wLog(上一版把 helper 内的调用也替换了) 2026-12-02 15:35:19 +08:00
qiqi d5787ca44a docs: 锚点同步 v3.26.199
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 43s
2026-12-02 15:26:36 +08:00
qiqi c411fbe851 chore: v3.26.199(诊断版:日志进 _boot.log) 2026-12-02 15:26:36 +08:00
qiqi bda61026ff diag(gallery): gallery-orig 双写 _boot.log(wLog 不进 _boot.log) 2026-12-02 15:26:36 +08:00
qiqi 3ab39fd522 docs: 锚点同步 v3.26.198
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-02 15:21:29 +08:00
qiqi 3993673ee6 chore: v3.26.198(诊断版:gallery-orig 日志) 2026-12-02 15:21:29 +08:00
qiqi c962859837 diag(gallery): 原图回填加 gallery-orig 日志(取证:为什么不命中) 2026-12-02 15:21:29 +08:00
qiqi 0276efd813 docs: 锚点同步 v3.26.197
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 35s
2026-12-02 15:11:22 +08:00
qiqi 68480551c6 chore: v3.26.197(测试版:原图回填补跑) 2026-12-02 15:11:22 +08:00
qiqi 434cf0d92d fix(gallery): 原图回填抽成公共函数,并在 wAddOutputs 之后补跑(修「下载比索引先完成」的时序竞争) 2026-12-02 15:11:22 +08:00
qiqi eb19811c8f docs: 锚点同步 v3.26.196
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-02 14:31:41 +08:00
qiqi 7228436b6f chore: v3.26.196(测试版:修图库原图状态) 2026-12-02 14:31:41 +08:00
qiqi a5b8b8b693 fix(gallery): 落地写原图后同步索引 orig=ok(修「仅缩略图」不消失) 2026-12-02 14:31:41 +08:00
qiqi 9f4abdbf44 docs: 锚点同步 v3.26.195
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m36s
2026-12-02 14:13:40 +08:00
qiqi 39294cec38 chore: v3.26.195(测试版:落地即存原图) 2026-12-02 14:13:40 +08:00
qiqi 1862d55563 feat(gallery): 落地成功即写原图到 images/gallery(out_orig_)并把索引 orig 置 ok 2026-12-02 14:13:40 +08:00
qiqi b756ae0ce7 docs: 锚点同步 v3.26.194
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m12s
2026-12-02 13:44:21 +08:00
qiqi 71d4a34197 chore: v3.26.194(测试版:图库读本地副本) 2026-12-02 13:44:21 +08:00
qiqi 5df4f626ee feat(gallery): 图库缩略图优先用落地本地副本;摘掉「生成中」样式 2026-12-02 13:44:21 +08:00
qiqi ff6e8ec883 docs: 锚点同步 v3.26.193
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m34s
2026-12-02 13:33:47 +08:00
qiqi fe94d89a46 chore: v3.26.193(测试版:生成中改 id 无关判定) 2026-12-02 13:33:47 +08:00
qiqi d3ef0f3940 fix(out): 生成中改为「存在任一 out 运行」判定,不再依赖具体节点 id 2026-12-02 13:33:47 +08:00
qiqi ae41246f5a docs: 锚点同步 v3.26.192
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m5s
2026-12-02 13:22:59 +08:00
qiqi 1fed4d4df3 chore: v3.26.192(测试版:生成中按宿主 busy 信号) 2026-12-02 13:22:59 +08:00
qiqi 73936ae076 fix(out): 生成中改读 busy[out::out](宿主运行态写入点,确定信号) 2026-12-02 13:22:59 +08:00
qiqi 67a379a0cf docs: 锚点同步 v3.26.191
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s
2026-12-02 13:16:32 +08:00
qiqi 48829aea5d chore: v3.26.191(测试版:生成中看源节点进度) 2026-12-02 13:16:32 +08:00
qiqi 61b6df94c5 fix(out): 生成中同时看源节点进度(等上游时表头取的是 sourceProgOut) 2026-12-02 13:16:32 +08:00
qiqi 02ccb87ec7 docs: 锚点同步 v3.26.190
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m4s
2026-12-02 13:01:44 +08:00
qiqi 5137f38b7f chore: v3.26.190(测试版:生成中角标按进度信号) 2026-12-02 13:01:44 +08:00
qiqi 2c46b0b756 feat(out): 生成中角标改用 progress[node::out](与表头进度同源,无 TDZ) 2026-12-02 13:01:44 +08:00
qiqi b4d8a7ba6a docs: 锚点同步 v3.26.189
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 43s
2026-12-02 13:00:59 +08:00
qiqi a594efc64a chore: v3.26.189(测试版:摘掉生成中角标,保留落地角标) 2026-12-02 13:00:59 +08:00
qiqi a4928d472c revert(out): 先摘掉「生成中」角标(忙碌信号取不到,不能带着猜实现;下载角标保留) 2026-12-02 13:00:59 +08:00
qiqi a8b0999a1b docs: 锚点同步 v3.26.188
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 37s
2026-12-02 12:56:49 +08:00
qiqi ce8a837923 chore: v3.26.188(测试版:修输出节点渲染崩溃) 2026-12-02 12:56:49 +08:00
qiqi 5947e0c18b fix(out): 生成中判定改用 busy 标记(修 TDZ 崩溃 Cannot access before initialization) 2026-12-02 12:56:49 +08:00
qiqi a204298fee docs: 锚点同步 v3.26.187
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
2026-12-02 12:51:18 +08:00
qiqi 955423eac6 chore: v3.26.187(测试版:生成中角标) 2026-12-02 12:51:17 +08:00
qiqi 7ff3dd57f4 docs: 事实快照同步(srcLines) 2026-12-02 12:51:17 +08:00
qiqi 2cadad7ea7 feat(out): 生成中给旧图压暗 + 「生成中」角标(不动 data,失败即恢复)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 9s
2026-12-02 12:51:08 +08:00
qiqi 6ff6ab6a9f docs: 基线锚点同步到 v3.26.186(a1ac3dff)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 36s
2026-12-02 12:40:15 +08:00
qiqi a1ac3dffe1 chore: v3.26.186(测试版:输出节点落地角标 + 本地优先) 2026-12-02 12:40:15 +08:00
qiqi 4b7dc6ee40 fix(ingest): 入队改到「结果写进节点数据」处,输出节点体本地优先 + 角标
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 6s
上一版把角标加在了 ResultImg,而它全仓没有调用点(输出节点用的是
ui-node-bodies 的 iwb-out-cell-img),所以用户看不到任何变化。

- runtime-workbench-logic.liveUpsert:每张结果写入节点数据时 enqueue(批量/恢复都走这里)
- ui-node-bodies:输出单元格优先用 ingest 的 localUrl,另加「排队中/下载中/未落地」角标
- app.js onEvent 里补 wThumbBump(),让命令式渲染的节点体跟着重绘
- 棘轮:app 8,895→8,896、Workbench 2,487→2,488
2026-12-02 12:40:06 +08:00
qiqi a409fa6206 docs: 基线锚点同步到 v3.26.185(b2a01354)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 30s
2026-12-02 12:28:33 +08:00
qiqi b2a0135467 chore: v3.26.185(测试版:出图结果接落地队列,仅 win 测试用) 2026-12-02 12:28:33 +08:00
qiqi c6e259a2b0 fix(ingest): ready 后异步补一次本地 URL(首次 objectURL 未就绪时也能切到本地)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 13s
2026-12-02 12:28:17 +08:00
qiqi a8c2cd9d97 feat(ingest): 出图结果接落地队列(节点先显示远程,就绪后换本地)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 29s
- src/image-ingest-store.js:localStorage 索引(500 条上限、pinned 不淘汰)+ url→状态视图(供组件订阅)
- app.js:装配 ingest(fetchBytes = wBlobFromSrc → dataURL → wImgRefWrite;persist 走 store)
  启动时 restore,出图后立即 enqueue(不等下载完)
- ui-components ResultImg:读视图状态,排队/下载中显示角标并压暗,失败显示「未落地」,
  就绪后 src 换成本地 objectURL(不再直连 CDN)
- style.css:角标样式全部走 token(z-anchor / radius-full / font-xs / err 语义色)
- 棘轮:app.js 8,860→8,891、Workbench 2,454→2,483、global 122→123(均按 B3 记账)

验证:image-ingest 24 条 + writeback 23 条单测、e2e 冒烟 33/33、lint/typecheck/facts/ratchet/token-lint 全绿。
图库侧仍走原缩略图链路,下一步接同一份本地引用。
2026-12-02 12:27:47 +08:00
qiqi bca71e53b9 feat(ingest): 结果图片落地管线基座(src/image-ingest.js + 24 条契约单测)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 58s
背景:出图后输出节点直接用 <img src=远程CDN>、图库缩略图再各自 fetch 一次,
CDN 慢/断流时就是「从上往下慢慢刷 / 卡住半张」,图库还晚一步。
先把「远程结果 → 本地字节」收敛成一条队列,本次只落基座,不接线(零行为变化)。

- src/image-ingest.js:状态机 queued/downloading/ready/failed/link-only;
  幂等(同 url 复用记录)、重试 1s/2s/4s×3、并发 ≤2、失败保留 url、
  释放字节(link-only)、启动恢复(queued/downloading 重排)、markMissing 自检入口。
  依赖全注入(fetchBytes/writeRef/persist/onEvent/sleep),不读任何全局,便于单测。
- tests/image-ingest-test.js:24 条断言(正常落地/幂等/重试成功/彻底失败/manual retry/
  释放/恢复/取消/并发上限/统计),已进 test:unit。
- 注册:build.js 顺序 + 模块顺序快照 + 耦合面快照;global 写入口 121→122(单列命名空间)。

下一步(未做):接线到出图结果与图库、节点改吃本地副本、失败/进度 UI —— 需与显示层一起上。
2026-12-02 12:19:30 +08:00
qiqi 200c1d35b1 docs(design): 任务队列页面方案 + 交互样式图(mockup HTML / 浅色·深色截图) 2026-12-02 12:11:37 +08:00
qiqi fae497289d docs(site): v3.26.184 发布登记(三平台齐平)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 43s
- releases.json:3.26.184 / darwin-aarch64(10,145,011 B)、darwin-x86_64(10,601,813 B)、windows-x86_64(5,589,965 B)
- 首页 / 下载页 / 插件页重新生成并上传(显示 v3.26.184)
- latest.json 三平台齐平(windows 条目来自 latest-windows.json 的 184)
2026-12-02 11:49:26 +08:00
qiqi 0cf7af230f docs: 基线锚点同步到 v3.26.184(08367fc7)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-02 11:36:12 +08:00
60 changed files with 3146 additions and 139 deletions

No files matched your search

+179
View File
@@ -16,6 +16,185 @@
> 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.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),原因已写在常量注释。
## 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% 的主因)。
+3 -3
View File
@@ -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 141 个单测文件(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,345**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,686** |
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
+530 -36
View File
@@ -83,7 +83,8 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
? window.IWBDownloadAuto.create({
getDir: wDownloadDir,
isOn: wAutoDownload,
resolveSrc: (item) => window.IWBDownloadAuto.resolveLocalFirst(item, { resolveDirect: (x) => wResolveOutputSrc(x, true), listFiles: () => (ModularOutputStore ? ModularOutputStore.list({ metaOnly: true }).then((r) => (r && r.ok && r.value && r.value.files) || []).catch(() => []) : lsGet(OUT_KEY, [])), readIdb: (k) => IDB.get(k).catch(() => null) }),
// 2026-12-02(方案 A):等落地队列的本地字节(最多 20s),拿不到才回落原有本地优先链路
resolveSrc: async (item) => { try { const du = await window.IWBDownloadAuto.waitIngestRef(item && item.url, { get: (u) => (window.IWBImageIngestView && typeof window.IWBImageIngestView.get === 'function') ? window.IWBImageIngestView.get(u) : null, refDataUrl: wImgRefDataUrl }); if (du) return du } catch (eIng) { /* ignore */ } return window.IWBDownloadAuto.resolveLocalFirst(item, { resolveDirect: (x) => wResolveOutputSrc(x, true), listFiles: () => (ModularOutputStore ? ModularOutputStore.list({ metaOnly: true }).then((r) => (r && r.ok && r.value && r.value.files) || []).catch(() => []) : lsGet(OUT_KEY, [])), readIdb: (k) => IDB.get(k).catch(() => null) }) },
// dataURL 直接解码成 Blob(不再 fetch(dataURL));远程 URL 返回 null 让调用方走 fetch
toBlob: (src) => (String(src || '').indexOf('data:') === 0 ? wBlobFromDataUrl(src) : null),
write: wWriteBlobToDir,
@@ -236,6 +237,8 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// 与 wPluginNodeVariants(菜单/运行用,仅"已激活"变体)分开,故不影响启停语义。
const wPluginVariantMeta = new Map()
const wPluginPanels = []
const wPluginPages = [] // 插件整页(pages 能力):{id,title,icon,mount,pluginId}
const wQueueThumbCache = new Map() // 任务队列缩略图缓存:url -> 320 dataURL
const wPluginGenHooks = []
const wPluginProviders = []
let wPluginCanvasBridge = null
@@ -416,7 +419,7 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// autoSaveImages 已废弃(v3.25.33):保留字段只为老配置兼容,**不再驱动任何下载行为**。
// 「出图自动保存」由 设置 → 图片导出目录 → 自动下载(iwb.autoDownload + wAutoSaver)负责。
// lodLowZoom(v3.25.71):15% 以下是否切轻量节点体(用户可关)
const W_DEF_CANVAS = { generationConcurrency: 4, taskStallEndMs: 300000, autoSaveImages: true, backupOriginals: true, lodLowZoom: true, appearance: W_DEF_APPEARANCE }
const W_DEF_CANVAS = { generationConcurrency: 4, taskStallEndMs: 300000, autoSaveImages: true, backupOriginals: true, lodLowZoom: true, newBadgeSec: 120, taskQueueMax: 500, appearance: W_DEF_APPEARANCE }
// 任务条「结束」按钮出现的阈值:默认 5 分钟。判据是「该任务距上一次进展的时长」,
// 而不是任务总时长 —— 多个变体(如 3 张)正常跑 6 分钟也不会误报"卡住"。
const TASK_STALL_END_MIN = 60000
@@ -1923,6 +1926,168 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// v3.87.33:抓取失败的输出(多为图床 CORS/403)记入"不再重试",否则每次生成都会把
// 全部失败图重新抓取+整尺寸解码(配合并发 5 → 单次 500~900MB 尖峰,实测 d720/d898)。
const wThumbFail = new Set()
// 2026-12-02(197):把「落地队列拿到的本地字节」写成图库原图(out_orig_)并同步索引。
// 幂等:已 ok / 已有 origIdb / 取不到字节都直接跳过。onEvent(ready) 与 wAddOutputs 之后各调一次,
// 覆盖「下载比索引先完成」的时序竞争(196 就是只挂在前者,才出现「有些正常有些一直仅缩略图」)。
// 诊断专用:既写 wLog(IDB/data.json),也写 _boot.log(用户最容易取到的那条通道)
function wIngestLog(msg) {
try { wLog('gallery-orig', msg) } catch (e1) { /* ignore */ }
try { const SF = window.IWBStorageFile; if (SF && typeof SF.logLine === 'function') SF.logLine('gallery-orig ' + msg) } catch (e2) { /* ignore */ }
}
// 索引条目 → 用落地队列已拿到的本地字节写原图 + 缩略图(不再抓第二次远程)。返回是否已写。
function wFillOutputFromIngest(item) {
try {
const view = (typeof window !== 'undefined') ? window.IWBImageIngestView : null
const v = (view && typeof view.get === 'function') ? view.get(item && item.url) : null
if (v && v.ref) return wIngestOrigFromRef(item.name, item.url, v.ref)
} catch (e) { /* ignore */ }
return null
}
function wIngestOrigFromRef(name, url, ref) {
if (!name || !ref) return Promise.resolve(false)
return Promise.resolve(wImgRefDataUrl(ref)).then((du) => {
if (!du) return false
// 同时预热节点显示用的 512/768 缩略图(ref key),让画布不必再解原图或抓远程
try { if (typeof wPrimeDisplayThumbForRef === 'function') wPrimeDisplayThumbForRef(ref, du) } catch (e5) { /* ignore */ }
// 先等原图 + 320 缩略图**真的写完**,再把索引标 ok 并通知图库 ——
// 否则插件先看到 ok 却取不到缩略图,就是用户看到的「图库显示缩略图加载失败」。
return Promise.resolve(storeOutputThumb({ name: name, url: url, data: du }, true)).catch(() => null).then((written) => {
// 2026-12-03:原图没真正落盘就不许标 ok —— 否则会出现「图库有卡片、images/gallery 没文件」。
if (!written) { try { wIngestLog('orig-write-fail name=' + name) } catch (eW) { /* ignore */ } return false }
// 202:必须写进 **ModularOutputStore**(图库/插件读的是它),只改 KV 索引不会生效。
const markOk = (list) => (Array.isArray(list) ? list.map((f) => (f && f.name === name)
? Object.assign({}, f, { orig: 'ok', origIdb: IDB_ORIG_PREFIX + name })
: f) : list)
const after = () => {
try { if (typeof wGalleryChanged === 'function') wGalleryChanged('output') } catch (eG) { /* ignore */ }
try { if (typeof window !== 'undefined' && typeof window.__iwbRefreshOutputs === 'function') window.__iwbRefreshOutputs() } catch (eR) { /* ignore */ }
try { wIngestLog('ok name=' + name) } catch (eL) { /* ignore */ }
}
try {
if (ModularOutputStore && typeof ModularOutputStore.mutate === 'function') {
Promise.resolve(ModularOutputStore.mutate(markOk)).then((r) => {
// storage-outputs 的失败约定是「返回 {ok:false}」而不是 reject(2026-12-02 构建机指出)。
// 不判这一下,写失败也会记 ok、还会白刷一次图库,下一轮诊断会被误导。
if (r && r.ok === false) { try { wIngestLog('index-write-fail ' + name + ' err=' + String(r.error && (r.error.code || r.error.message) || r.error || '-')) } catch (eF1) { /* ignore */ } return }
after()
}).catch(() => { try { wIngestLog('index-write-fail ' + name) } catch (eF) { /* ignore */ } })
} else {
lsSet(OUT_KEY, markOk(lsGet(OUT_KEY, []) || []))
after()
}
} catch (e2) { wIngestLog('index-write-fail ' + name) }
return true
})
}).catch(() => false)
}
// 按结果列表回填:给每条还没 ok 的条目找落地队列里的本地引用
// 2026-12-02(207 之后):对账兜底 —— 只靠 ready 时刻匹配会漏(索引写得更慢 / 进程被杀)。
// 这里扫一遍索引:orig 未 ok 且落地队列已有本地引用的,直接补写;幂等,可反复跑。
// 2026-12-02:图库索引去重 —— 220 那次「补漏」读错字段导致同一 url 被写入多条。
// 这里按 url 分组,同 url 只保留一条(优先保留已落地原图的那条),幂等,可反复跑。
// 按 url 去重(同一张图只留一行,优先保留已落地的)。写回走 ModularOutputStore.mutate(同一把锁),
// 不再直接 lsSet —— 直写会绕过锁,与归档并发时互相覆盖。
async function wDedupeOutputs() {
try {
const compute = (list) => {
const idx = Array.isArray(list) ? list : []
if (idx.length < 2) return { kept: idx, removed: 0 }
const best = new Map()
let removed = 0
for (const f of idx) {
const u = String((f && f.url) || '')
if (!u) continue
const prev = best.get(u)
if (!prev) { best.set(u, f); continue }
const score = (x) => ((x && x.orig === 'ok') ? 2 : 0) + ((x && x.origIdb) ? 1 : 0)
if (score(f) > score(prev)) best.set(u, f)
removed++
}
if (!removed) return { kept: idx, removed: 0 }
const kept = []
const seen = new Set()
for (const f of idx) {
const u = String((f && f.url) || '')
if (!u) { kept.push(f); continue }
if (seen.has(u)) continue
seen.add(u)
kept.push(best.get(u))
}
return { kept, removed }
}
let removed = 0, left = 0
if (ModularOutputStore && typeof ModularOutputStore.mutate === 'function') {
const r = await ModularOutputStore.mutate((list) => { const out = compute(list); removed = out.removed; left = out.kept.length; return out.removed ? out.kept : null })
if (r && r.ok === false) return 0
} else {
const out = compute(lsGet(OUT_KEY, []) || [])
removed = out.removed; left = out.kept.length
if (removed) lsSet(OUT_KEY, out.kept)
}
if (!removed) return 0
try { wIngestLog('dedupe removed=' + removed + ' left=' + left) } catch (e1) { /* ignore */ }
try { if (typeof wGalleryChanged === 'function') wGalleryChanged('output') } catch (e2) { /* ignore */ }
try { if (typeof window !== 'undefined' && typeof window.__iwbRefreshOutputs === 'function') window.__iwbRefreshOutputs() } catch (e3) { /* ignore */ }
return removed
} catch (e4) { return 0 }
}
function wIngestReconcile(repairOnly) {
try {
const idx = lsGet(OUT_KEY, []) || []
const view = (typeof window !== 'undefined') ? window.IWBImageIngestView : null
if (!view || typeof view.get !== 'function') return 0
let n = 0
for (const f of idx) {
if (!f || !f.url || f.orig === 'ok' || f.origIdb) continue
const v = view.get(f.url)
if (v && v.ref) { try { wIngestOrigFromRef(f.name, f.url, v.ref); n++ } catch (e1) { /* ignore */ } }
}
if (n) { try { wIngestLog('reconcile fixed=' + n) } catch (e2) { /* ignore */ } }
// 2026-12-02:超时失败不判死 —— 下次窗口聚焦时放回队列重试(慢 CDN 超过 5 分钟也能续上)
if (!repairOnly) try {
const ing = (typeof window !== 'undefined') ? window.__iwbIngest : null
if (ing && typeof ing.retry === 'function') {
let re = 0
for (const f of idx) {
if (!f || !f.url || f.orig === 'ok' || f.origIdb) continue
const v = view.get(f.url)
if (v && v.status === 'failed' && /timeout/i.test(String(v.error || ''))) { try { ing.retry(v.id); re++ } catch (e5) { /* ignore */ } }
}
if (re) { try { wIngestLog('reconcile retry-timeout=' + re) } catch (e6) { /* ignore */ } }
}
} catch (e7) { /* ignore */ }
return n
} catch (e3) { return 0 }
}
// 图库面板打开/刷新时的轻量自愈(节流 1.5s):去重 + 把「有落地字节但索引没标 ok」的行补上。
// 运行期出现状态漂移时,打开图库就能立刻修好,不必重启。
let wLastGalleryRepairAt = 0
function wGalleryRepair() {
try {
const now = Date.now()
if (now - wLastGalleryRepairAt < 1500) return
wLastGalleryRepairAt = now
try { wDedupeOutputs() } catch (e1) { /* ignore */ }
try { wIngestReconcile(true) } catch (e2) { /* ignore */ }
} catch (e3) { /* ignore */ }
}
function wIngestOrigBackfill(results) {
try {
const idx = lsGet(OUT_KEY, []) || []
const view = (typeof window !== 'undefined') ? window.IWBImageIngestView : null
for (const r of (results || [])) {
if (!r || !r.url) continue
const f = idx.find((x) => x && String(x.url || '') === String(r.url))
if (!f) { try { wIngestLog('backfill-no-index-entry url=' + String(r.url).slice(0, 60)) } catch (eL1) { /* ignore */ } continue }
if (f.orig === 'ok' || f.origIdb) continue
const v = view && typeof view.get === 'function' ? view.get(r.url) : null
if (!v) { try { wIngestLog('backfill-no-view name=' + f.name) } catch (eL2) { /* ignore */ } continue }
if (!v.ref) { try { wIngestLog('backfill-no-ref name=' + f.name + ' status=' + String(v.status)) } catch (eL3) { /* ignore */ } continue }
try { wIngestLog('backfill-hit name=' + f.name + ' orig=' + String(f.orig || '-')) } catch (eL4) { /* ignore */ }
try { wIngestOrigFromRef(f.name, r.url, v.ref) } catch (e3) { /* ignore */ }
}
} catch (e4) { /* ignore */ }
}
const wThumbProxyTried = new Set() // 经本站代理重试过(每个 URL 只试一次)
const wThumbFailKey = (item) => String((item && item.url) || (item && item.name) || '')
function storeOutputThumb(item, forceOrig) {
@@ -2054,10 +2219,33 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
const awaitArchive = !!(opts && opts.awaitArchive)
if (ModularOutputStore) {
const items = []
let _skNoOk = 0, _skNoUrl = 0, _skDup = 0
// 2026-12-03:幂等 —— 同一 url 只允许一行。已存在的复用(还没落地就用本地字节补),本批内重复只取第一条。
const _idx0 = lsGet(OUT_KEY, []) || []
const _byUrl = new Map()
for (const f of _idx0) { const u = String((f && f.url) || ''); if (u && !_byUrl.has(u)) _byUrl.set(u, f) }
const _seen = new Set()
const _reuse = []
for (const r of (results || [])) {
if (!r || !r.ok || !r.url) continue
if (!r || !r.ok) { _skNoOk++; continue }
if (!r.url) { _skNoUrl++; continue }
const _u = String(r.url)
if (_byUrl.has(_u) || _seen.has(_u)) {
_skDup++
const ex = _byUrl.get(_u)
if (ex && ex.orig !== 'ok' && !ex.origIdb) _reuse.push(ex)
continue
}
_seen.add(_u)
items.push({ name: 'gen_' + Date.now() + '_' + Math.floor(Math.random() * 1e6) + '.png', url: r.url, size: 0, mtime: Date.now(), width: r.width || 0, height: r.height || 0, label: r.label || '', snapshot: r.snapshot || null, orig: 'pending' })
}
try { wIngestLog('add-outputs in=' + (results || []).length + ' accepted=' + items.length + ' skipNoOk=' + _skNoOk + ' skipNoUrl=' + _skNoUrl + ' skipDup=' + _skDup) } catch (eL0) { /* ignore */ }
if (!items.length) {
// 没有新行要建;命中的旧行若还没落地,用本地字节补上(不新建行)
const _ing0 = !!(typeof window !== 'undefined' && window.IWBImageIngestView)
for (const item of _reuse) if (_ing0) { try { wFillOutputFromIngest(item) } catch (eR) { /* ignore */ } }
return []
}
const prevIdx = lsGet(OUT_KEY, [])
const modular = await ModularOutputStore.add(items, { retention: wRawCfg().outputsRetention })
if (modular && modular.ok) {
@@ -2073,17 +2261,15 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// v3.87.37:只处理**本次新增**的条目。之前每次生成都会把整库(实测 109 条)重扫 + 逐条 hydrate,
// 点「生成」后 480ms 内就 +720MB(探针实测),这是最大的内存尖峰来源。
const newNames = new Set(items.map((x) => x && x.name).filter(Boolean))
const needThumb = curFiles.filter((item) => item && newNames.has(item.name) && !item.idb && !wThumbFail.has(wThumbFailKey(item)))
if (needThumb.length) {
const thumbJob = runWithConcurrency(needThumb, 2, (item) => storeOutputThumb(item))
const onThumbFail = (e) => {
// 整批缩略图失败此前是**零反馈**:图库里看不到缩略图,用户不知道发生了什么。
// 现在:记录 + 提示一次(整批失败才提示,不逐张刷屏)。
try { if (CrashLog && typeof CrashLog.record === 'function') CrashLog.record('thumb-batch-failed', { scope: 'output-store', message: '缩略图批量生成失败(' + needThumb.length + ' 张):' + String((e && e.message) || e), version: APP_VERSION }) } catch (err) { /* ignore */ }
wLogNotice('部分图片的缩略图生成失败(' + needThumb.length + ' 张),图库中可能显示为空白。', 'err')
}
if (awaitArchive) { try { await thumbJob } catch (e) { onThumbFail(e) } } else thumbJob.catch(onThumbFail)
// 2026-12-02(方案 A):不再为同一张图抓第二次远程 —— 缩略图/原图统一用落地队列的本地字节。
// 已落地(ready)的立刻写;未落地的等 onEvent(ready) 回填(已有 1s/3s 重试)。
const ingOn = !!(typeof window !== 'undefined' && window.IWBImageIngestView)
const fills = []
for (const item of curFiles) if (item && newNames.has(item.name) && !item.idb) {
const p = ingOn ? wFillOutputFromIngest(item) : storeOutputThumb(item)
if (awaitArchive && p && typeof p.then === 'function') fills.push(p)
}
if (fills.length) { try { await Promise.all(fills) } catch (eF) { /* ignore */ } }
for (const item of curFiles) {
if (item && newNames.has(item.name) && imageFolderApi) imageFolderApi.save(item, item.data).catch(() => {})
}
@@ -2092,8 +2278,12 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
}
const idx = lsGet(OUT_KEY, [])
const added = []
const _seen2 = new Set(idx.map((f) => String((f && f.url) || '')).filter(Boolean))
for (const r of (results || [])) {
if (!r || !r.ok || !r.url) continue
const _u2 = String(r.url)
if (_seen2.has(_u2)) continue
_seen2.add(_u2)
const name = 'gen_' + Date.now() + '_' + Math.floor(Math.random() * 1e6) + '.png'
idx.push({ name, url: r.url, size: 0, mtime: Date.now(), w: r.width || 0, h: r.height || 0, label: r.label || '', snapshot: r.snapshot || null, orig: 'pending' })
added.push(name)
@@ -2111,16 +2301,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// 保留策略剪掉的条目:连同缩略图+原图一并移除(Plan A 整体删除,不留孤儿原图)
const removedNames = idx.filter((f) => !keptNames.has(f.name)).map((f) => f.name)
if (removedNames.length) wPruneOutputIdb(removedNames)
const needThumb2 = idx.filter((f) => keptNames.has(f.name) && !f.idb)
if (needThumb2.length) {
const thumbJob2 = runWithConcurrency(needThumb2, 5, (f) => storeOutputThumb(f))
const onThumbFail2 = (e) => {
// 同上:整批失败原先零反馈(用户只看到图库空白,不知道原因)
try { if (CrashLog && typeof CrashLog.record === 'function') CrashLog.record('thumb-batch-failed', { scope: 'output-store', message: '缩略图批量生成失败(' + needThumb2.length + ' 张):' + String((e && e.message) || e), version: APP_VERSION }) } catch (err) { /* ignore */ }
wLogNotice('部分图片的缩略图生成失败(' + needThumb2.length + ' 张),图库中可能显示为空白。', 'err')
}
if (awaitArchive) { try { await thumbJob2 } catch (e) { onThumbFail2(e) } } else thumbJob2.catch(onThumbFail2)
}
// 同上:只补本次新增、且还没有缩略图的;有落地队列时一律从本地字节生成(不重复抓远程)
const ingOn2 = !!(typeof window !== 'undefined' && window.IWBImageIngestView)
for (const f of idx) if (keptNames.has(f.name) && !f.idb && added.indexOf(f.name) >= 0) { if (ingOn2) wFillOutputFromIngest(f); else storeOutputThumb(f).catch(() => {}) }
for (const f of idx) {
if (keptNames.has(f.name) && imageFolderApi) imageFolderApi.save(f, f.data).catch(() => {})
}
@@ -2282,6 +2465,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
async function wResolveOutputSrc(item, localFirst) {
if (!item) return ''
if (item.origIdb) { const v = await IDB.get(item.origIdb).catch(() => null); if (v) return v }
// 2026-12-03(用户裁定「统一本地优先」):老记录原图在 images/gallery 文件里,先读本地字节,再谈远程。
const FL = wStoreMod()
if (FL && typeof FL.galleryOriginalBlob === 'function') { try { const b = await FL.galleryOriginalBlob(item); if (b && b.size) return wRegisterBlobUrl(b) } catch (e) { /* ignore */ } }
// C3 第2步:物品的 data 可能是引用形态({__cache}/{__blob}/{__idb})——调用方要的是能直接用的字节/dataURL,
// 这里按需解析(不写回物品、不留驻);远程 URL 仍只作最后回退。
const localData = (item.data && typeof item.data === 'object') ? await wImgRefDataUrl(item.data) : item.data
@@ -2292,6 +2478,11 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
if (item.idb) { const v = await IDB.get(item.idb).catch(() => null); if (v) return v }
return ''
}
// 2026-12-03(下载命名规范):同一张图,不论从输出节点、预览还是图库下载,都用图库行名。
// 未落地的图没有行名,调用方回退自己的默认名。
function wOutNameOf (url) {
try { const u = String(url || ''); if (!u) return ''; const row = (lsGet(OUT_KEY, []) || []).find((f) => f && String(f.url) === u); return (row && row.name) ? String(row.name) : '' } catch (e) { return '' }
}
// 图库条目 → 可直接交给 <img>/下载/剪贴板的 src:命中「有界 objectURL 缓存」即复用,
// 避免每次点击都把 2MB+ base64 重新读进堆(驱逐时统一 revoke)。
async function wOutputSrcForUse(item, cacheKey, localFirst) {
@@ -3520,6 +3711,7 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
settings: '<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',
help: '<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',
download: '<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"/>',
queue: '<path d="M8 6h13M8 12h13M8 18h13"/><circle cx="3.5" cy="6" r="1"/><circle cx="3.5" cy="12" r="1"/><circle cx="3.5" cy="18" r="1"/>',
upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',
save: '<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/>',
github: '<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/>',
@@ -3831,8 +4023,13 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
function upsertGenerationEntry(entries, entry) {
const list = Array.isArray(entries) ? entries : []
if (!entry) return list.slice()
const prev = list.find((x) => x && x.promptId === entry.promptId && x.vi === entry.vi)
const keep = list.filter((x) => !(x && x.promptId === entry.promptId && x.vi === entry.vi))
return keep.concat([entry])
// 2026-12-02(方案 A:先落地再显示):新图下载期间保留上一张作为 pending,
// 输出格先继续显示旧图,等新图本地字节就绪再整体替换 —— 中间不再出现白板。
const prevItems = prev && Array.isArray(prev.items) ? prev.items.filter((it) => it && it.ok && it.url) : []
const next = prevItems.length ? Object.assign({}, entry, { pending: { items: prevItems, at: Number(prev.at) || 0 } }) : entry
return keep.concat([next])
}
// 将任务条目展平为图库结果:统一标签,不修改输入数据。
@@ -3847,22 +4044,43 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// 生成归档边界:图库索引/缩略图属于旁路缓存,不能阻塞生成结果和画布保存。
// v3.26.61:每张结果在生成过程中已由 wArchiveEntryNow 逐张入库(图库要「出图即见」),
// 这里只补剩下没归档的(失败条目/兜底路径),不再整批重写一遍 —— 否则同一张图会入两次库。
async function archiveGenerationResults(entries, refresh) {
async function archiveGenerationResults(entries, refresh, meta) {
const all = Array.isArray(entries) ? entries : []
const results = flattenGenerationEntries(all)
// 先入落地队列(不等下载完):节点先显示远程,就绪后换成 localUrl;失败保留 url 可重试
// meta:兜底入队(分层/非 liveUpsert 路径)也要带画布/节点,否则任务队列显示「未知画布」、无法定位。
try { if (window.__iwbIngest) for (const r of results) if (r && r.ok && r.url) window.__iwbIngest.enqueue({ url: r.url, source: 'gen', w: r.width, h: r.height, meta: Object.assign({}, meta || {}, { prompt: String((r && r.label) || (meta && meta.prompt) || '') }) }) } catch (eI) { /* 落地失败不得影响出图 */ }
iwbDebugCounter('archiveGenerationResults', { entries: results.length })
const pendingEntries = all.filter((e) => !(wGallerySync && wGallerySync.wasArchived(e)))
for (const hook of wPluginGenHooks) {
if (typeof hook.afterResult !== 'function') continue
try { hook.afterResult(results) } catch (e) { /* 插件钩子异常不得影响结果归档 */ }
}
// 归档 → 刷新 → 自动下载串行:自动下载必须等本批原图写进图库(out_orig_)后再跑,才谈得上「从本地字节复制」。
Promise.resolve().then(async () => {
// 2026-12-03:先把单张归档队列排空,再判断补漏 —— 否则最后一张的索引还在写,会被误判成
// 「未归档」再 add 一次,同一 url 出现两行(图库重复卡 + Gallery 重复文件)。
try { if (wGallerySync && typeof wGallerySync.whenIdle === 'function') await wGallerySync.whenIdle() } catch (eW) { /* ignore */ }
// 2026-12-02:wasArchived 是按「条目对象」记的,单张归档路径标记后,批量归档会整批跳过 ——
// 于是「一次出 2 张,图库只进 1 张」。这里加一道校验:已标记归档但图库索引里查不到该 url 的,仍然补。
const _idxNow = lsGet(OUT_KEY, []) || []
const _urlInIdx = new Set(_idxNow.map((f) => String((f && f.url) || '')))
const pendingEntries = all.filter((e) => {
const archived = !!(wGallerySync && wGallerySync.wasArchived(e))
if (!archived) return true
// 条目形状是 {promptId,vi,label,items:[{ok,url}]},**没有 e.url** —— 必须下沉到 item 级取 url。
// 只要有任一 item 的 url 不在图库索引里才补;全都在索引里就跳过(否则会重复入库)。
const urls = flattenGenerationEntries([e]).map((i) => String((i && i.url) || '')).filter(Boolean)
if (!urls.length) return false
return urls.some((u) => !_urlInIdx.has(u))
})
try { wIngestLog('archive entries=' + all.length + ' pending=' + pendingEntries.length) } catch (eL1) { /* ignore */ }
// 只有「自动下载」开启时才等归档完成:它要从本地原图复制,必须等 out_orig_ 落盘;
// 没开就保持后台异步归档,避免出图到图库可点开的时间被拖长。
const needArchiveWait = !!(wAutoSaver && typeof wAutoSaver.enabled === 'function' && wAutoSaver.enabled())
const rest = flattenGenerationEntries(pendingEntries)
if (rest.length) { try { await wAddOutputs(rest, { awaitArchive: needArchiveWait }) } catch (e) { /* 图库缓存失败不影响画布结果 */ } }
try { wIngestOrigBackfill(rest) } catch (eBk) { /* 回填不影响出图 */ }
try { wDedupeOutputs() } catch (eDd) { /* 去重失败不影响出图 */ }
try { if (typeof refresh === 'function') await refresh() } catch (e) { /* ignore */ }
try { wGalleryChanged('output') } catch (e) { /* ignore */ }
try { if (wAutoSaver) await wAutoSaver.saveResults(results) } catch (e) { /* 自动下载失败不影响生图 */ }
@@ -5507,10 +5725,11 @@ const tbCenterSeed = (type, refs) => {
try {
IWNodeBodies.inject({ el, I, LocalTextField, autoGrow, nodePreviewRefsV2, nodeInheritOf, combineSourcePairs, isPluginTypeId,
orderedUniqueRefNodes, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg,
wThumbSrc, downloadUrl, wResolveOutputSrc, isImageProducer, outProgUI, outThumbCache,
wThumbSrc, downloadUrl, wResolveOutputSrc, wOutNameOf, isImageProducer, outProgUI, outThumbCache,
ingestView: () => window.IWBImageIngestView,
wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder,
GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName,
ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, React, ReactDOM })
ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, React, ReactDOM, wThumbBump: () => { try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e) { /* ignore */ } } })
IWNodeBodies.__iwbInjected = true
} catch (e) { /* 注入失败:继续用内置分支 */ }
}
@@ -5910,12 +6129,28 @@ const tbCenterSeed = (type, refs) => {
// 快捷键弹窗内容(分区罗列 + 折叠说明)
const HotkeyHelp = (typeof window !== 'undefined' && window.IWBUIHotkeyHelp) ? window.IWBUIHotkeyHelp.HotkeyHelp : null
// 插件整页(复用设置里的插件管理块;页面壳在 src/ui-plugin-page.js)
// 插件整页容器(pages 能力):把 host DOM 交给插件 mount,离开/禁用时清理。
const PluginPageHost = (props) => {
const page = props && props.page
const hostRef = React.useRef(null)
React.useEffect(() => {
const host = hostRef.current
if (!host || !page || typeof page.mount !== 'function') return undefined
let cleanup = null
try { cleanup = page.mount(host) } catch (e) { try { host.textContent = '插件页面加载失败:' + String((e && e.message) || e) } catch (e2) { /* ignore */ } }
return () => { try { if (typeof cleanup === 'function') cleanup(); else host.innerHTML = '' } catch (e) { /* ignore */ } }
}, [page])
return el('div', { className: 'iwb-plugin-page iwb-plugin-page-custom' },
el('div', { className: 'iwb-plugin-page-head' }, el('span', { className: 'iwb-plugin-page-title' }, (page && page.title) || '任务队列')),
el('div', { className: 'iwb-plugin-page-body', ref: hostRef }),
)
}
const PluginsPage = (typeof window !== 'undefined') ? window.IWBUIPluginPage : null
// 依赖注入点:放在 Workbench 之前 —— 此处 ICONS / computeEdgePath / downloadUrl / IDB 等全部已定义。
_mod.inject({
ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl,
ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, wOutNameOf,
nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl,
})
@@ -6120,6 +6355,12 @@ const tbCenterSeed = (type, refs) => {
if (!PluginHost || typeof PluginHost.on !== 'function') return undefined
return PluginHost.on(() => setPluginRev((v) => v + 1))
}, [])
React.useEffect(() => {
// 201:把「重读 outputs」暴露给模块级的落地回填(它改完索引后要让图库状态刷新,
// storage 事件在本文档不触发、BroadcastChannel 也不回送自己,只能走这个回调)
try { if (typeof window !== 'undefined') window.__iwbRefreshOutputs = () => { try { refreshOutputs(100) } catch (e) { /* ignore */ } } } catch (e0) { /* ignore */ }
return () => { try { if (typeof window !== 'undefined') window.__iwbRefreshOutputs = null } catch (e1) { /* ignore */ } }
}, [])
React.useEffect(() => {
// 插件画布桥 + 图片写回收口(v3.26.183 收口,2026-12-02 拆到 src/plugin-canvas-bridge.js)
// 这里只装配依赖:引用化统一走 wImportImage(keepOriginal),阈值共用 IMPORT_INLINE_MAX。
@@ -6161,6 +6402,72 @@ const tbCenterSeed = (type, refs) => {
wImageWriteback = built ? built.writeback : null
return () => { wPluginCanvasBridge = null; wImageWriteback = null }
}, [])
// 结果落地队列(2026-12-02):出图后后台把远程图下到本地,节点/图库不再直连 CDN。
React.useEffect(() => {
if (!window.IWBImageIngest || !window.IWBImageIngestStore) return undefined
const store = window.IWBImageIngestStore.createStore({ get: (k) => lsGet(k, null), set: (k, v) => lsSet(k, v), max: () => { try { return Number(wRawCfg().canvas.taskQueueMax) || 500 } catch (e) { return 500 } } })
window.__iwbIngestStore = store
const view = window.IWBImageIngestStore.createView()
window.IWBImageIngestView = view
const ing = window.IWBImageIngest.create({
// 2026-12-02(方案 A):取字节 = 流式下载(带百分比)+ 超时 + 回退既有 wBlobFromSrc;实现在 src/image-ingest.js
fetchBytes: window.IWBImageIngest.createFetchBytes({ blobFromSrc: wBlobFromSrc, blobToDataUrl: wImgBlobToDataUrl }),
writeRef: (dataUrl) => wImgRefWrite(dataUrl),
persist: (e) => store.save(e),
removeEntry: (id) => store.remove(id),
onEvent: (kind, e) => {
const patch = Object.assign({}, e)
try { if (window.IWBPluginQueue) window.IWBPluginQueue.emit(kind) } catch (eQ) { /* ignore */ }
if (e && e.ref) {
try { patch.localUrl = wResolveImg(e.ref) || '' } catch (err) { patch.localUrl = '' }
// 首次 ready 时 objectURL 可能还没建好:异步解析完成后再补一次视图,确保节点真的切到本地
try { Promise.resolve(wResolveImgAsync(e.ref)).then((u) => { if (u) { view.set(Object.assign({}, e, { localUrl: u })); view.notify(); try { if (typeof wThumbBump === 'function') wThumbBump() } catch (eB2) { /* ignore */ } } }).catch(() => {}) } catch (err2) { /* ignore */ }
}
try {
if (kind === 'queued') wIngestLog('enqueue id=' + e.id + ' url=' + String(e.url || '').slice(0, 60))
else if (kind === 'failed') wIngestLog('failed id=' + e.id + ' err=' + String(e.lastError || '-') + ' retries=' + (e.retries || 0) + ' url=' + String(e.url || '').slice(0, 60))
else if (kind === 'ready') wIngestLog('ready id=' + e.id + ' ref=' + (e.ref ? 'Y' : 'N'))
} catch (eL0) { /* ignore */ }
view.set(patch); view.notify()
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (eB) { /* 触发画布节点体重绘 */ }
// 195:落地成功就把**原图**写进图库(images/gallery/,key=out_orig_<name>)并把索引 orig 置 ok。
// 用本机已有字节,不再二次抓 CDN;失败保持 pending,由原来的抓取路径兜底。
try {
if (kind === 'ready' && e && e.ref) {
// 207:原来是「索引没命中就静默 return」—— 落地变快后 ready 常早于索引写入,
// 于是整批图静默不落库(用户实测 4/16 张)。改成:未命中延迟重试 1s / 3s,并留痕。
const tryOnce = (attempt) => {
const idx = lsGet(OUT_KEY, []) || []
const hit = idx.find((f) => f && String(f.url || '') === String(e.url || ''))
if (hit) {
if (hit.orig !== 'ok' && !hit.origIdb && typeof storeOutputThumb === 'function') {
try { wIngestOrigFromRef(hit.name, hit.url, e.ref) } catch (e5) { /* ignore */ }
}
return true
}
try { wIngestLog('orig-defer url=' + String(e.url || '').slice(0, 60) + ' attempt=' + attempt) } catch (e6) { /* ignore */ }
return false
}
if (!tryOnce(1)) {
setTimeout(() => { if (!tryOnce(2)) setTimeout(() => { tryOnce(3) }, 3000) }, 1000)
}
}
} catch (eG) { /* 图库写入不得影响出图 */ }
},
})
window.__iwbIngest = ing
const saved = store.load()
view.hydrate(saved)
ing.restore(saved)
try { store.trim() } catch (eTrim) { /* 上限收紧后启动即裁剪 */ }
// 启动先对一次账,之后每 30s 一次(幂等;不阻塞启动)
try { setTimeout(() => { try { wDedupeOutputs() } catch (eD0) { /* ignore */ } try { wIngestReconcile() } catch (eR0) { /* ignore */ } }, 3000) } catch (eR1) { /* ignore */ }
// 2026-12-02:不做常驻轮询(用户要求不占空闲 CPU)。改成「窗口重新获得焦点时」跑一次:
// 用户切回来通常就是「图该出来了」的时刻,成本与操作频率同阶,闲置时零开销。
const onFocusReconcile = () => { try { wIngestReconcile() } catch (eR2) { /* ignore */ } }
try { window.addEventListener('focus', onFocusReconcile) } catch (eR3) { /* ignore */ }
return () => { window.__iwbIngest = null; window.__iwbIngestStore = null; try { window.removeEventListener('focus', onFocusReconcile) } catch (eR4) { /* ignore */ } }
}, [])
const [layoutLocked, setLayoutLocked] = useState(false)
const [wsMoreOpen, setWsMoreOpen] = useState(false) // 顶部 ⋯ 三点菜单(展开态)
const [wsMorePos, setWsMorePos] = useState({ top: 0, left: 0 }) // 三点菜单 fixed 定位
@@ -6287,6 +6594,13 @@ const tbCenterSeed = (type, refs) => {
return () => { try { delete window.__IWB_E2E_HISTORY__; delete window.__IWB_E2E_CANVAS__; delete window.__IWB_E2E_SETREF__; delete window.__IWB_E2E_PUSH_HISTORY__ } catch (e) { /* ignore */ } }
}, [])
const [shellView, setShellView] = useState(() => { try { return lsRawGet('iwb_shell_view', null) === 'canvas' ? 'canvas' : 'home' } catch (e) { return 'home' } }) // landing=首页说明,home=我的画布,canvas=无限画布;刷新时恢复上次所在的视图
const [pluginPage, setPluginPage] = useState(null) // 插件整页:{pluginId,pageId};仅 pages 能力注册的页面
// 插件被禁用/页面被移除时,若正停在该页,回到画布(避免空白页)
React.useEffect(() => {
if (!pluginPage) return
const ok = wPluginPages.some((p) => p.pluginId === pluginPage.pluginId && p.id === pluginPage.pageId)
if (!ok) { setPluginPage(null); setShellView('canvas') }
}, [pluginRev, pluginPage])
// 记住当前视图;刷新后在画布编辑器则恢复到画布编辑器(画布库则仍回画布库)
useEffect(() => { try { lsRawSet('iwb_shell_view', shellView) } catch (e) { /* ignore */ } }, [shellView])
const [homeSelectedWs, setHomeSelectedWs] = useState([])
@@ -7871,7 +8185,7 @@ const tbCenterSeed = (type, refs) => {
setWsMorePos,
setWsMoreOpen,
})
: (shellView === 'plugins' ? null : el(ProductNav, { shellView, setShellView, setSettingOpen: openSettings, setHelpOpen, toggleTheme, theme }))
: ((shellView === 'plugins' || shellView === 'page') ? null : el(ProductNav, { shellView, setShellView, setSettingOpen: openSettings, setHelpOpen, toggleTheme, theme }))
// 底栏工具栏:稳定动作(useCallback 读 refs/selRef) + 派生状态(拖拽时不变化) → React.memo 跳过重渲,缩小拖拽 re-render 范围
// 工具栏编组/取消编组按钮已移除;多选节点组气泡的禁用态直接用 sel / groupOf 判定,故不再需要派生 canGroup/canUngroup。
const tbOnAdd = React.useCallback((t) => addNode(t, null, null, tbCenterSeed(t, refs)), [])
@@ -7937,10 +8251,20 @@ const tbCenterSeed = (type, refs) => {
})
}
if (window.IWBPluginGallery) window.IWBPluginGallery.setImpl({
list: (o) => window.IWBPluginGallery.query(outputs, o),
list: (o) => { try { wGalleryRepair() } catch (eRp) { /* ignore */ } return window.IWBPluginGallery.query(outputs, o) },
// v3.26.61:缩略图取源顺序(清单 data → images/thumbs → 本地原图 → 远程)在 gallery-sync 里,
// 原因是「生图后图库不显示」有一半出在这里 —— 新图 data 还没 hydrate 就只剩远程 url 可退。
thumb: (name) => (wGallerySync ? wGallerySync.thumbFor(name, { outputs, displayThumbOf: wDisplayThumbOf, galleryThumb: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumb === 'function') ? F.galleryThumb(h) : Promise.resolve('') }, galleryThumbUrl: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbUrl === 'function') ? F.galleryThumbUrl(h) : Promise.resolve('') }, galleryThumbOf: (f, max) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbOfEntry === 'function') ? F.galleryThumbOfEntry(f, max) : Promise.resolve('') } }) : ''),
thumb: (name) => (wGallerySync ? wGallerySync.thumbFor(name, { outputs, displayThumbOf: wDisplayThumbOf, galleryThumb: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumb === 'function') ? F.galleryThumb(h) : Promise.resolve('') }, galleryThumbUrl: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbUrl === 'function') ? F.galleryThumbUrl(h) : Promise.resolve('') }, galleryThumbOf: (f, max) => {
// 2026-12-02:图库缩略图优先用落地队列拿到的**本地副本**,别再为同一张图去 fetch 远程。
// 未落地(无 localUrl)时行为不变,回落原来的 f.url。
let ff = f
try {
const v = window.IWBImageIngestView && typeof window.IWBImageIngestView.get === 'function' ? window.IWBImageIngestView.get(f && f.url) : null
if (v && v.localUrl) ff = Object.assign({}, f, { url: v.localUrl })
} catch (eIng) { /* ignore */ }
const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null
return (F && typeof F.galleryThumbOfEntry === 'function') ? F.galleryThumbOfEntry(ff, max) : Promise.resolve('')
} }) : ''),
preview: (name) => setPreview({ list: outputs.map((x) => ({ __gallery: true, name: x.name, origIdb: x.origIdb, idb: x.idb, url: x.url, thumb: x.data || null })), idx: Math.max(0, outputs.findIndex((x) => x.name === name)) }),
download: async (names) => {
const failed = []
@@ -7959,6 +8283,143 @@ const tbCenterSeed = (type, refs) => {
insert: async (names, o) => ({ ok: true, inserted: await insertOutputsToCanvas((outputs || []).filter((f) => names.indexOf(f.name) >= 0), (o && o.insertK) || '1k') }),
remove: async (names) => { const n = await deleteOutputs(names); return { ok: n > 0, removed: n } }, openFolder: () => window.IWBDesktopHelpers.openGalleryDir(), backfill: (names) => { const want = Array.isArray(names) ? names : []; const hits = (outputs || []).filter((f) => want.indexOf(f.name) >= 0); return Promise.all(hits.map((f) => storeOutputThumb(f, true))).then((rs) => ({ ok: rs.filter(Boolean).length, count: rs.filter(Boolean).length, failed: hits.filter((f, i) => !rs[i]).map((f) => f.name) })) },
})
// 任务队列插件(queue):账本/下载/落地/定位/上限全部在宿主,插件只做视图。
if (window.IWBPluginQueue) {
const qList = () => { try { return window.__iwbIngest ? window.__iwbIngest.list() : [] } catch (e) { return [] } }
const qEntry = (id) => qList().find((x) => x.id === id) || null
const qView = (url) => { try { return (window.IWBImageIngestView && typeof window.IWBImageIngestView.get === 'function') ? window.IWBImageIngestView.get(url) : null } catch (e) { return null } }
const qMapStatus = (s) => s === 'ready' ? 'ok' : (s === 'failed' ? 'fail' : ((s === 'queued' || s === 'downloading') ? 'down' : 'only'))
window.IWBPluginQueue.setImpl({
list: async (o) => {
const opt = o || {}
const want = String(opt.status || '')
const limit = Math.max(1, Math.min(5000, Number(opt.limit) || 500))
const q = String(opt.query || '').toLowerCase()
const idxNow = lsGet(OUT_KEY, []) || []
let items = qList().map((e) => {
const v = qView(e.url)
const meta = e.meta || {}
return {
id: e.id, url: e.url, status: e.status, kind: qMapStatus(e.status),
progress: Number(e.progress) || 0, bytes: Number(e.bytes) || 0,
w: Number(e.w) || 0, h: Number(e.h) || 0, error: String(e.lastError || ''),
retries: Number(e.retries) || 0, createdAt: Number(e.createdAt) || 0, updatedAt: Number(e.updatedAt) || 0,
meta,
thumbUrl: (wQueueThumbCache.get(e.url) || outThumbCache.get(e.url) || ''),
localUrl: (v && v.localUrl) ? v.localUrl : '',
inGallery: (() => { const row = idxNow.find((f) => f && String(f.url) === String(e.url)); return !!(row && (row.orig === 'ok' || row.origIdb)) })(),
}
})
if (want && want !== 'all') items = items.filter((x) => x.kind === want)
if (q) items = items.filter((x) => (String(x.meta.prompt || '') + ' ' + String(x.meta.boardName || '') + ' ' + String(x.url || '')).toLowerCase().indexOf(q) >= 0)
items.sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0))
const page = items.slice(0, limit)
// 缩略图:图库里本来就有 320 缩略图(row.idb),这里按需读出来复用;最多 120 条/次,其余下次刷新再补。
const need = page.filter((x) => !x.thumbUrl && x.url).slice(0, 120)
if (need.length) {
await Promise.all(need.map(async (x) => {
const row = idxNow.find((f) => f && String(f.url) === String(x.url))
if (!row || !row.idb) { if (x.localUrl) x.thumbUrl = x.localUrl; return }
try {
const v = await IDB.get(row.idb)
const ok = (v && typeof v === 'string' && v.length > 20)
if (ok) {
x.thumbUrl = v
if (wQueueThumbCache.size > 500) { const k0 = wQueueThumbCache.keys().next().value; if (k0) wQueueThumbCache.delete(k0) }
wQueueThumbCache.set(x.url, v)
} else if (x.localUrl) x.thumbUrl = x.localUrl
} catch (e) { if (x.localUrl) x.thumbUrl = x.localUrl }
}))
}
return { items: page, total: items.length }
},
retry: (id) => { try { return window.__iwbIngest ? window.__iwbIngest.retry(id) : null } catch (e) { return null } },
restart: (id) => { try { if (!window.__iwbIngest) return null; try { window.__iwbIngest.cancel(id) } catch (e0) { /* ignore */ } return window.__iwbIngest.retry(id) } catch (e) { return null } },
land: async (id) => {
const e = qEntry(id)
if (!e) return { ok: false, error: 'record-missing' }
if (!/^https?:/i.test(String(e.url || ''))) return { ok: false, error: 'no-url' }
const idx = lsGet(OUT_KEY, []) || []
const row = idx.find((f) => f && String(f.url) === String(e.url))
if (row && (row.orig === 'ok' || row.origIdb)) return { ok: true, already: true }
if (!row) {
try { await wAddOutputs([{ ok: true, url: e.url, width: e.w, height: e.h, label: String((e.meta && e.meta.prompt) || '') }], {}) } catch (e1) { /* ignore */ }
}
try { window.__iwbIngest.enqueue({ url: e.url, source: 'task-queue', w: e.w, h: e.h, meta: e.meta }) } catch (e2) { /* ignore */ }
const hit = (lsGet(OUT_KEY, []) || []).find((f) => f && String(f.url) === String(e.url))
const v = qView(e.url)
if (hit && v && v.ref) { try { wIngestOrigFromRef(hit.name, e.url, v.ref) } catch (e3) { /* ignore */ } }
try { wIngestLog('queue-land url=' + String(e.url).slice(0, 60)) } catch (e4) { /* ignore */ }
return { ok: true }
},
preview: async (id) => {
const all = qList().filter((x) => x && x.url)
const idx = all.findIndex((x) => x.id === id)
if (idx < 0) return { ok: false, error: 'record-missing' }
const idxNow = lsGet(OUT_KEY, []) || []
const F = wStoreMod()
const rowOf = (x) => idxNow.find((f) => f && String(f.url) === String(x.url)) || null
// 2026-12-03(用户裁定):预览只读本地 —— origIdb → images/gallery 原图文件;都没有就提示未下载。
// 列表条目交给 ImagePreview 的 __gallery 解析(它按需读原图),这里不再直连远程、不再把 320 缩略图当原图。
const curRow = rowOf(all[idx])
let hasLocal = !!(curRow && curRow.origIdb)
if (!hasLocal && curRow && F && typeof F.galleryOriginalOf === 'function') { try { const g = await F.galleryOriginalOf(curRow, 2048); hasLocal = !!(g && g.url) } catch (e) { /* ignore */ } }
if (!hasLocal) { setNotice({ type: 'err', text: '这张图还没有下载到本地,先点「下载」' }); return { ok: false, error: 'not-local' } }
const list = all.map((x) => {
const row = rowOf(x)
const thumb = wQueueThumbCache.get(x.url) || ''
if (row && row.name) return { __gallery: true, name: row.name, origIdb: row.origIdb, idb: row.idb, url: '', thumb: thumb || row.data || null, w: Number(x.w) || 0, h: Number(x.h) || 0 }
return { url: '', thumb: thumb || undefined, w: Number(x.w) || 0, h: Number(x.h) || 0, name: String((x.meta && (x.meta.promptText || x.meta.prompt)) || '') }
})
setPreview({ list, idx })
return { ok: true }
},
copyLink: (id) => {
const e = qEntry(id)
if (!e || !e.url) return { ok: false, error: 'record-missing' }
const C = (typeof window !== 'undefined') ? window.IWBClipboardCopy : null
if (!C || typeof C.copyText !== 'function') return { ok: false, error: 'clipboard-unavailable' }
return C.copyText(String(e.url)).then((ok) => ok ? { ok: true } : { ok: false, error: 'copy-failed' })
},
locate: (id) => {
const e = qEntry(id)
const meta = (e && e.meta) || {}
const bid = String(meta.boardId || '')
const nid = String(meta.nodeId || '')
if (!bid || !nid) return Promise.resolve({ ok: false, error: 'missing-meta' })
const pick = (n) => new Promise((resolve) => {
const hit = (refs.nodes || []).find((x) => x.id === nid)
if (hit) { try { setSel([nid]) } catch (e1) { /* ignore */ } ; resolve({ ok: true }); return }
if (n < 10) { setTimeout(() => { pick(n + 1).then(resolve) }, 200); return }
resolve({ ok: false, error: 'node-missing' })
})
const target = (refs.workspaces || []).find((w) => w.id === bid)
if (!target) return Promise.resolve({ ok: false, error: 'board-missing' })
if (bid !== activeWsId) { try { switchWs(bid) } catch (e2) { /* ignore */ } }
else { try { setShellView('canvas') } catch (e3) { /* ignore */ } }
return pick(0)
},
stats: () => {
const out = { total: 0, ok: 0, down: 0, fail: 0, only: 0 }
for (const e of qList()) { out.total++; const k = qMapStatus(e.status); if (out[k] !== undefined) out[k]++ }
return out
},
clear: () => { try { return window.__iwbIngest ? window.__iwbIngest.clearFinished() : 0 } catch (e) { return 0 } },
getLimit: () => { try { return Math.max(100, Math.min(5000, Number(wRawCfg().canvas.taskQueueMax) || 500)) } catch (e) { return 500 } },
setLimit: (n) => {
const v = Math.max(100, Math.min(5000, Math.round(Number(n) || 500)))
try {
const stored = wRawStoredCfg()
const next = Object.assign({}, stored, { canvas: Object.assign({}, stored.canvas || {}, { taskQueueMax: v }) })
LocalStore.set(StorageContract.localKeys.config, next)
if (window.__iwbIngestStore && typeof window.__iwbIngestStore.trim === 'function') window.__iwbIngestStore.trim()
else { const S = window.IWBImageIngestStore; if (S) S.createStore({ get: (k) => lsGet(k, null), set: (k, x) => lsSet(k, x), max: () => v }).trim() }
} catch (e) { /* ignore */ }
try { if (window.IWBPluginQueue) window.IWBPluginQueue.emit('limit') } catch (e2) { /* ignore */ }
return { ok: true, limit: v }
},
})
}
// 节点组库插件(grouplib):数据仍由宿主持有,插件只拿读写/实例化能力
if (window.IWBPluginGroupLib) {
window.IWBPluginGroupLib.setImpl({
@@ -7990,7 +8451,7 @@ const tbCenterSeed = (type, refs) => {
const dockPanels = (typeof window !== 'undefined' && window.IWBUIDockPanels)
? window.IWBUIDockPanels.build(PluginHost, wPluginPanels)
: {}
return el('div', { className: 'iwb-overlay' + (shellView === 'landing' ? ' iwb-view-landing' : shellView === 'home' ? ' iwb-view-home' : (shellView === 'plugins' ? ' iwb-view-plugins' : ' iwb-view-canvas')) + (drawerOpen ? ' drawer-open' : '') + ((nodes.length && loaded) ? ' has-minimap' : '') },
return el('div', { className: 'iwb-overlay' + (shellView === 'landing' ? ' iwb-view-landing' : shellView === 'home' ? ' iwb-view-home' : ((shellView === 'plugins' || shellView === 'page') ? ' iwb-view-plugins' : ' iwb-view-canvas')) + (drawerOpen ? ' drawer-open' : '') + ((nodes.length && loaded) ? ' has-minimap' : '') },
// 页面加载动画(真实进度条:src/ui-splash.js + src/boot-progress.js,加载完成后淡出)
!splashDone && window.IWBUISplash ? el(window.IWBUISplash.Splash, { fade: loaded, icon: I('palette') }) : null,
shellView === 'home' ? el('div', { className: 'iwb-home-panel' },
@@ -8088,7 +8549,10 @@ const tbCenterSeed = (type, refs) => {
NavRail ? el(NavRail, {
I,
logoIcon: 'brand',
view: shellView === 'plugins' ? 'plugins' : (shellView === 'home' ? 'home' : 'canvas'),
view: shellView === 'page' ? 'page' : (shellView === 'plugins' ? 'plugins' : (shellView === 'home' ? 'home' : 'canvas')),
pages: wPluginPages.slice(),
activePage: (shellView === 'page' && pluginPage) ? (pluginPage.pluginId + ':' + pluginPage.pageId) : '',
onPage: (pid, id) => { setPluginPage({ pluginId: pid, pageId: id }); setShellView('page') },
skinIcon: theme === 'dark' ? 'sun' : 'moon',
onHome: () => { setShellView('home'); try { goHome() } catch (e) { /* ignore */ } },
onCanvas: () => setShellView('canvas'),
@@ -8104,7 +8568,11 @@ const tbCenterSeed = (type, refs) => {
shellView === 'plugins' ? (PluginsPage
? el(PluginsPage, { I, PluginHost, wRuntimePlugins, wEnsurePluginLoaded, Sections: window.IWBUISettingsSections, onBack: () => setShellView('canvas') })
: el('div', { className: 'iwb-plugin-page' }, el('div', { className: 'iwb-plugin-page-head' }, '插件页未就绪'))) : null,
tabstripEl, // S12:顶部标签条(在顶栏上方)
shellView === 'page' && pluginPage ? (() => {
const page = wPluginPages.find((p) => p.pluginId === pluginPage.pluginId && p.id === pluginPage.pageId)
return page ? el(PluginPageHost, { key: page.pluginId + ':' + page.id, page }) : null
})() : null,
ReactDOM.createPortal(tabstripEl, document.body), // S12:顶部标签条(portal 到 body,脱离 overlay 的滚动/层叠)
topbarEl,
el('div', {
className: 'iwb-canvas' + (shellView !== 'canvas' ? ' iwb-canvas-hidden' : '') + (connecting ? ' iwb-connecting' : '') + (refs.drag ? ' iwb-dragging' : '') + (tool === 'pan' ? ' iwb-tool-pan' : ''),
@@ -8262,7 +8730,7 @@ const tbCenterSeed = (type, refs) => {
el('button', { 'aria-label': '复制', 'data-tip': '复制', onClick: (e) => { e.stopPropagation(); duplicateNodes(sel) } }, I('copy')),
sn.type === 'ref' ? el('label', { 'aria-label': '替换', 'data-tip': '替换', onPointerDown: (e) => e.stopPropagation() }, I('upload'), el('input', { type: 'file', accept: 'image/*', style: { display: 'none' }, onChange: (e) => { const f = e.target.files && e.target.files[0]; if (!f) return; try { const rd = new FileReader(); rd.onload = () => wImportImage(rd.result, { onError: (msg) => setNotice({ type: 'err', text: msg }) }, (r) => { if (!r || !r.ok || !r.data) return; updateNode(sn.id, { data: r.data, name: f.name, localName: null, url: '' }) }); rd.onerror = () => setNotice({ type: 'err', text: '读取图片文件失败:' + String(f.name || '') }); rd.readAsDataURL(f) } catch (err) { console.error(err) } } }, null)) : null,
sn.type === 'ref' ? el('button', { 'aria-label': '粘贴', 'data-tip': '粘贴', onClick: (e) => { e.stopPropagation(); floatbarRefPaste(sn.id) }, onPointerDown: (e) => e.stopPropagation() }, I('paste')) : null,
sn.type === 'out' ? (() => { const uout = outResultUrls(sn.id); return el('button', { 'aria-label': '下载', 'data-tip': '下载', disabled: !uout.length, onClick: (e) => { e.stopPropagation(); uout.forEach((u, i) => setTimeout(() => downloadUrl(u, 'image-' + String(i + 1).padStart(3, '0') + '.png'), i * 350)) } }, I('download')) })() : null,
sn.type === 'out' ? (() => { const uout = outResultUrls(sn.id); return el('button', { 'aria-label': '下载', 'data-tip': '下载', disabled: !uout.length, onClick: (e) => { e.stopPropagation(); uout.forEach((u, i) => setTimeout(() => downloadUrl(u, wOutNameOf(u) || ('image-' + String(i + 1).padStart(3, '0') + '.png')), i * 350)) } }, I('download')) })() : null,
...pluginNodeActionItems.filter((a) => !a.appliesTo || a.appliesTo({ id: sn.id, type: sn.type, data: sn.data || {} })).map((a) => el('button', {
key: 'plug_' + a.id, className: 'iwb-node-floatbar-plugin', title: a.title, 'data-tip': a.title,
onPointerDown: (e) => e.stopPropagation(),
@@ -8627,6 +9095,7 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
log: () => { try { wLog.apply(null, arguments) } catch (e) { /* ignore */ } },
capabilities: {
gallery: () => ((typeof window !== 'undefined' && window.IWBPluginGallery) ? window.IWBPluginGallery.api() : {}),
queue: () => ((typeof window !== 'undefined' && window.IWBPluginQueue) ? window.IWBPluginQueue.api() : {}),
grouplib: () => ((typeof window !== 'undefined' && window.IWBPluginGroupLib) ? window.IWBPluginGroupLib.api() : {}),
promptlib: () => ((typeof window !== 'undefined' && window.IWBPluginPromptLib) ? window.IWBPluginPromptLib.api() : {}),
// 插件文件能力(v3.26.36):沙箱目录 plugin-data/<id>/files,供插件自持图片
@@ -8658,6 +9127,31 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
dir: () => need().dir(ctx.id),
}
},
pages: (ctx) => {
const owned = []
const changed = () => { try { if (PluginHost && typeof PluginHost.emit === 'function') PluginHost.emit('plugin-pages-changed') } catch (e) { /* ignore */ } }
return {
registerPage: (page) => {
if (!page || !page.id || !page.title || typeof page.mount !== 'function') return false
for (let i = wPluginPages.length - 1; i >= 0; i--) {
const e = wPluginPages[i]
if (e && e.pluginId === ctx.id && e.id === String(page.id)) wPluginPages.splice(i, 1)
}
const entry = { id: String(page.id), title: String(page.title), icon: pluginIconOf(ctx.id) || page.icon || 'queue', mount: page.mount, pluginId: ctx.id }
wPluginPages.push(entry)
owned.push(entry)
changed()
return true
},
dispose: () => {
for (const entry of owned.splice(0)) {
const i = wPluginPages.indexOf(entry)
if (i >= 0) wPluginPages.splice(i, 1)
}
changed()
},
}
},
commands: (ctx) => {
const owned = []
return {
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

+485
View File
@@ -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>
+163
View File
@@ -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>
+108
View File
@@ -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)。
+97
View File
@@ -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 节点画布下打开队列页,滚动不掉帧
+5 -5
View File
@@ -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 = dc5c1a6b`(线上 `v3.26.237+dc5c1a6b` —— 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-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,345 行**(**双层预算**:绝对上限 9,345 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,686 行**(上限 **2,686**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **128** 个模块 / 26,194 行,`sourceModules` 128 项;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` 不引用模块全局)。**128 个模块中 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 耦合面(**107** 项)与 `sourceModules` 顺序(**128** 项);命名例外由第 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 耦合面」(**107** 项)与 `sourceModules` 顺序(**128** 项);新增模块、新增耦合、新增 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 规则三的同一失败模式)。
+40
View File
@@ -0,0 +1,40 @@
# 图片读取与下载口径(2026-12-03)
> 目的:同一张图,不管从输出节点、图库、任务队列还是预览打开/下载,**取源顺序与文件名只有一套**。
> 新代码按本文写;`tests/image-download-contract-test.js` 会拦住已知的偏离写法。
## 1. 取源顺序(桌面端)
预览 / 下载统一按这个顺序取,**能拿到上一层就不再往下走**:
1. `origIdb` —— 图库行写入的原图字节(新记录)
2. `images/gallery/<文件>` —— 本地原图文件(老记录没有 `origIdb`;入口 `IWBStorageFile.galleryOriginalOf` / `galleryOriginalBlob`)
3. 会话本地副本 —— `IWBImageIngestView.localUrl`(任务队列专用,重启即失效)
4. 远程 URL —— **仅下载/插入**可兜底
5. 320 缩略图(`row.idb`)—— **只做列表/宫格/预览的占位底图,永远不当原图**
硬规则:
- **预览不许直连远程**。本地没有原图就提示「这张图还没有下载到本地」,不打开预览、不放大缩略图。
- 下载必须**本地优先**:`wResolveOutputSrc` 先 `origIdb` → 本地文件 → 数据 → 远程。
- 缩略图可以「先出画面」,但只作为 `ImagePreview` / 节点体的底图,原图解析到后必须换掉。
## 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` 只允许作为「还没落地的兜底」)。
## 3. 相关入口
- `src/storage-file.js`:`galleryOriginalOf(row, max)`(预览用,原生按尺寸解码)、`galleryOriginalBlob(row)`(下载用,原始字节)
- `app.js`:`wResolveOutputSrc`(下载取源)、`wOutNameOf`(命名)
- `src/ui-canvas-view.js`:`ImagePreview` 统一解析 `{__gallery, name, origIdb, idb}`
+2
View File
@@ -51,6 +51,8 @@
## 5. 与构建机(work)协作
> **交付节奏(2026-12-02 用户明确)**:用户报问题后,先只做分析与方案,**不要立即改代码、不要构建任何版本(含 Windows 测试包)**;等用户明确说「开始/可以做」再动手。构建前必须得到确认。
> **分工红线(2026-12-02 用户明确)**:**所有代码修改只在 mac 侧执行**(mac 上负责实施的 agent)。
> win 构建机只做「拉取指定 SHA → 构建/打包 → 回报路径/字节/sha256/FileVersion」这类流程性动作,
> **不具备也不承担改代码的能力**;遇到需要改源码/测试/文档的情况,一律回报给 mac 侧处理,不许在 win 侧就地改。
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "image-workbench-web",
"private": true,
"version": "3.26.184",
"version": "3.26.238",
"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/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/ui-minimap-fit-test.js && node tests/ui-workbeLine 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
View File
@@ -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 },
+3 -3
View File
@@ -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"
}
}
+16 -7
View File
@@ -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; }
+14 -3
View File
@@ -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"
}
},
{
@@ -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"
}
}
]
+11
View File
@@ -140,5 +140,16 @@
"批量",
"出图"
]
},
"taskqueue": {
"name": "任务队列",
"desc": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
"author": "official",
"icon": "⏳",
"color": "#eef6f6",
"tags": [
"工具",
"记录"
]
}
}
+249
View File
@@ -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)
+19
View File
@@ -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"
}
}
+40
View File
@@ -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; } }
+3
View File
@@ -84,6 +84,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 +109,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',
+1 -1
View File
@@ -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
View File
@@ -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.184-mx704yxj">
<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.184</a>
</div>
</div></nav>
<main>
+10 -6
View File
@@ -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.184 · 9.7 MB · .dmg<div class="hash">sha256 2358abf9f64ff17a…</div></div>
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.184_aarch64.dmg?h=2358abf9f64f">下载</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.184 · 10.1 MB · .dmg<div class="hash">sha256 24d1030ba3501699…</div></div>
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.184_x64.dmg?h=24d1030ba350">下载</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.184 · 5.3 MB · .exe<div class="hash">sha256 d26a90dda86df474…</div></div>
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.184_x64-setup.exe?h=d26a90dda86d">下载</a>
</div>
<h2>系统要求</h2>
@@ -97,6 +97,10 @@
</ol>
<h2>历史版本</h2>
<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>
+11 -11
View File
@@ -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.184-mx704yxj">
</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.184</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.184-mx704yxj" alt=""></div>
<div class="hero-veil"></div>
<div class="wrap">
<span class="kicker">v3.26.183 · macOS / Windows · 数据在本地</span>
<span class="kicker">v3.26.184 · 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.184</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.184_aarch64.dmg?h=2358abf9f64f"><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.184_x64.dmg?h=24d1030ba350"><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.184_x64-setup.exe?h=d26a90dda86d"><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>
+45 -11
View File
@@ -1,6 +1,6 @@
{
"version": 2,
"updatedAt": "2026-12-02T00:54:41.997Z",
"updatedAt": "2026-12-03T03:24:51.310Z",
"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
}
]
},
@@ -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
}
]
}
]
}
+12 -4
View File
@@ -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.184-mx704yxj">
</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.184</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>
@@ -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>
+29 -1
View File
@@ -1,8 +1,36 @@
{
"app": "Image Workbench",
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
"updatedAt": "2026-12-02T01:11:24.514Z",
"updatedAt": "2026-12-02T03:49:12.414Z",
"releases": [
{
"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",
+1 -1
View File
@@ -2014,7 +2014,7 @@ dependencies = [
[[package]]
name = "image-workbench"
version = "3.26.184"
version = "3.26.238"
dependencies = [
"arboard",
"base64 0.22.1",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "image-workbench"
version = "3.26.184"
version = "3.26.238"
description = "无限画布 · 生图工作台桌面版"
authors = ["malongan"]
license = ""
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "image-workbench",
"version": "3.26.184",
"version": "3.26.238",
"identifier": "com.malongan.imageworkbench",
"build": {
"frontendDist": "../dist",
+4 -1
View File
@@ -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
+111
View File
@@ -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)
+310
View File
@@ -0,0 +1,310 @@
/* 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 || {}
const concurrency = Math.max(1, Number(d.concurrency) || 2)
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++
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))
}
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
const got = typeof d.fetchBytes === 'function' ? await d.fetchBytes(e.url, onProgress) : { ok: false, error: 'no-fetcher' }
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')
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 (attempt < maxRetries) {
setStatus(e, STATE.DOWNLOADING, { retries: attempt + 1, lastError: lastErr })
await sleep(Math.min(8000, 1000 * Math.pow(2, attempt)))
continue
}
}
}
active--
setStatus(e, STATE.FAILED, { retries: maxRetries, lastError: lastErr })
pump()
return publicView(e)
}
function pump () {
while (active < concurrency && queue.length) {
const id = queue.shift()
const e = entries.get(id)
if (!e || e.status !== STATE.QUEUED) continue
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.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
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) {
const res = await fetch(url)
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) {
let timer = null
const job = fetchWithProgress(url, onProgress).catch(async () => {
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)
+5 -2
View File
@@ -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 }
+48
View File
@@ -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
View File
@@ -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 || {}
+20 -1
View File
@@ -91,5 +91,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)
+20 -2
View File
@@ -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) })
+32 -1
View File
@@ -63,6 +63,7 @@
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()
@@ -1099,6 +1100,36 @@
} 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 }
}
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 首帧即用,重复打开直接命中。
@@ -1612,7 +1643,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, 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 },
+2 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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 || '↓'),
),
)
}
+4
View File
@@ -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' },
+126 -5
View File
@@ -11,11 +11,15 @@
// · 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
let ingestView, I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, wOutNameOf, 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 +29,7 @@
combineSourcePairs = D.combineSourcePairs
downloadUrl = D.downloadUrl
wResolveOutSrc = D.wResolveOutputSrc
wOutNameOf = D.wOutNameOf
isImageProducer = D.isImageProducer
nodePreviewRefsV2 = D.nodePreviewRefsV2
nodeInheritOf = D.nodeInheritOf
@@ -54,6 +59,7 @@
resOfSize = D.resOfSize
taskStallEndMs = D.taskStallEndMs
wDedupeTaskIds = D.wDedupeTaskIds
wThumbBump = D.wThumbBump
}
@@ -855,7 +861,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,6 +887,24 @@
.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) }
@@ -885,16 +920,102 @@
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-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 // 缩略图还没好:先用本地原图,别等远程
// 方案 A:新图还在排队/下载/失败时**不直连远程**(否则浏览器再下一次,等于双份流量);
// 只有「没有落地记录」(旧数据)或「已 ready 但本地 URL 尚未解析」才允许远程兜底。
if (r._awaitUrl) return r.url
if (!ingSt || ingSt.status === 'ready') return r.url
return undefined // 未落地:不设 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,
)
+9 -1
View File
@@ -733,6 +733,14 @@ 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' },
@@ -1433,7 +1441,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 },
webhook: { enabled: !!draft.webhook.enabled, url: (draft.webhook.url || '').trim() },
})
setSaving(false)
+58 -3
View File
@@ -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; }
@@ -957,6 +964,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 +1258,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 +2282,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 +2293,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 +2581,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; }
+3
View File
@@ -34,6 +34,8 @@
"IWBImageCompress",
"IWBImageDisplayThumb",
"IWBImageFileRef",
"IWBImageIngest",
"IWBImageIngestStore",
"IWBImageRemoteCache",
"IWBImageThumbPick",
"IWBImageWriteback",
@@ -49,6 +51,7 @@
"IWBPluginGroupLib",
"IWBPluginHost",
"IWBPluginPromptLib",
"IWBPluginQueue",
"IWBPromptCover",
"IWBProviderPing",
"IWBResultImg",
+3
View File
@@ -56,6 +56,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 +81,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",
+41
View File
@@ -0,0 +1,41 @@
#!/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')
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), '任务队列预览在本地无图时给出「未下载」提示')
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(取源本地优先 / 命名统一图库行名 / 预览不直连远程)')
+169
View File
@@ -0,0 +1,169 @@
// 结果落地管线(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)
}
console.log('')
console.log(pass + ' passed, ' + fail + ' failed')
if (fail) process.exit(1)
}
main().catch((e) => { console.error(e); process.exit(1) })
+12
View File
@@ -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: 全部通过')
+1 -1
View File
@@ -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) => {
+9 -3
View File
@@ -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++ } })
+3 -3
View File
@@ -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 = 124 // 2026-12-03 +1(123→124):新增 IWBPluginQueue(任务队列能力桥,与 gallery 同构)。之后只减不增。
// ── 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 = 9354 // +9(9,345→9,354)2026-12-03:下载命名规范 wOutNameOf + 队列预览改「只读本地」(origIdb/图库磁盘原图,未落地提示下载)。之前 +199(9,146→9,345)任务队列装配。之后只减不增。
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 = 2687 // +1(2,686→2,687)2026-12-03:队列预览改「只读本地」(未落地提示下载)。之前 +153(2,533→2,686)任务队列装配。之后只减不增。
// 2026-11-18 v3.25.21:模态层指针守卫(2 行)
// 实测 3090 → 2998(省 92):① 生成取消族 cancelRunsFor/cancelRun/cancelTaskJobs
// → src/runtime-workbench-logic.js 的 createCancelActions(−53);② 工作区列表写回族
+9 -1
View File
@@ -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) })
+1
View File
@@ -31,6 +31,7 @@ interface Window {
IWBStorageMigrations?: any
IWBStorageIndexedDb?: any
IWBStorageFile?: any
__iwbIngest?: any
__TAURI__?: any
__IWB_UPDATE__?: any
IWBUIConfirm?: any