Files
image-workbench-desktop/docs/archive/history/SYNC-NOTES.md
T

45 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
> **⚠️ 历史·过程留档(已归档,2026-10-16)**:本文为**当时**记录,**不代表现状**;现状以 `docs/standards/architecture-current-state.md` 为准,规则见 `docs/standards/`。
# Image Workbench Web 版 维护备忘
> ⚠️ **历史/时效说明(2026-10-15 复核)**:本文件主体是历史同步备忘,**其中「图片剥离」与「部署」两段已按现行流程就地更正**(见文中 `2026-10-15 更正` 标注)。当前事实以 [`docs/standards/architecture-current-state.md`](../../standards/architecture-current-state.md) 为准。
> 已过期点:① 图片剥离主通道写 `ref_*`(现行主通道为 IDB Blob `{__blob}`/`imgblob_*`);② `wCleanIdb` 回收前缀清单不全;③ 部署命令 `wrangler pages deploy .`(现行为 `npm run deploy`,上传 `dist/`);④ 线上版本号写死 `v3.0.0-o158`。
> 完整维护记录在本地仓库 `image-workbench-app/PROJECT-NOTES.md`;本文件记录 Web 版同步要点。
## 同步流程(以本地为基底重建)
1. `cp 本地 public/app.js → 本目录 app.js`
2. 替换 API 区为 Web 数据层块(lsGet/wApi/IndexedDB + `function api(name,args){return wApi(name,args)}`)
3. 应用 Web 组件适配:IS_BROWSER_MODE 状态栏、`wAddOutputs`(生成后写图库)、图库 `f.url`、`config?full=1`(wApi 返回完整配置)、项目链接 `image-workbench-web`、服务信息区「数据保存:本浏览器」
- ⚠️ 同步后必须核查:图库 img `src: (f.data || f.url) || ''`(o155 起优先 IndexedDB 缩略图,非 `/outputs/`)、生成回调含 `wAddOutputs(...)`、无 `pullModels` 残留
- Web 备份用本地 BackupModal(wApi 支持)
4. `cp 本地 style.css → 本目录`;index.html 版本号同步
5. Web 测试脚本回归(`tests/iwb-v32-web-test.js`;**2026-10-15 现值:门禁基线为 663 通过 / 0 新增失败 / 5 已知,e2e 102 条**;文中旧值 323/4 已过期)后提交部署
## ⚠️ 特殊规则
- **永不启用「模型拉取」**(本地版保留)。同步后核查 `pullModels`/「拉取模型」为 0 残留(模型管理区已有标记注释)。
- **rev 机制(o156 起 Web 自建)**:`wApi('workspaces')` 保存分支递增 `rev` 存 localStorage;读取 `{ light: true }` 跳过 hydrate 供轮询比对;`bcNotify()` 广播 BroadcastChannel 即时同步。**Web 与本地 server 的 rev 含义不同,勿混用**。
- **图片剥离(o155 起全量)**:`wSanitizeWs` 对 ref 节点 `data`/`url` 两字段的 dataURL(>3000 字符)剥离进 IndexedDB,确定性 key —— **2026-10-15 更正**:新写入主通道为 **IDB Blob `{__blob}` / key `imgblob_<hash>_<len>`**(`app.js:2143`),Cache Storage `{__cache}` 为兜底;`ref_<id>_<hash>` 属 **legacy 形态**(存量可读、不迁移)。`stripBigDataUrlsSync(list, true)` 仍用于 beforeunload **同步**兜底(先深拷贝 nodes 再剥离,勿污染 refs)——**该同步路径有意仍写 `{__cache}`,不要"顺手统一"成异步**。
- **粘贴新建的图片节点 base64 放在 `url` 字段**(`data` 为 null);剥离与 hydrate 两字段都要处理。
- **历史出图**:`wAddOutputs` 存 `label` + 异步 `storeOutputThumb` 缩略图进 IDB(`out_` 前缀,≤1024px);输出删除只删索引不删图床原图;`wCleanIdb` 回收 `ref_`/`out_`/`out_orig_`/`imgblob_` 孤儿(**2026-10-15 更正**:GC 前缀须覆盖这四类,见规范 §13.34)。
- **生成中断**:`refs.genRuns` + `iwb_web_running`(每张完成更新);刷新后 `resumeRuns` 续跑(跳过已有成功结果);删除/停用节点 `cancelRunsFor(nodeId)` abort 其请求(`wFetch` 支持外部 signal)。
- **Alt 交互**:连线插入与脱离都需按住 Alt(普通拖动不吸附);插入=拖到连线中点,脱离=拖出链中间节点。
## 部署
**2026-10-15 更正**:以下为**过时**写法(会把仓库根目录当产物上传;本机 wrangler 为 OAuth 登录,设 `CI=true` 会失败):
```
unset CLOUDFLARE_API_TOKEN CLOUDFLARE_ACCOUNT_ID
wrangler pages deploy . --project-name image-workbench-web --branch main
```
**现行做法**(内含全量 `verify`,不得绕过):
```bash
npm run deploy # 正式站(--branch main)
npm run deploy:test # 测试站(--branch test)
```
生产域名 https://iwb.maqiart.eu.org(部署后强制刷新 Ctrl+Shift+R 破缓存)。**线上版本以 `https://iwb.maqiart.eu.org/version.json` 为准**(2026-10-15 为 `v3.1.1+682554d`);完整变更记录见 `../../CHANGELOG.md`(`CHANGES-O152-O158.md` 为早期记录)。