Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d72f28435e | ||
|
|
8c9121f00d | ||
|
|
1c3785e526 | ||
|
|
8e3325490f | ||
|
|
a9af0242d9 | ||
|
|
52a64521e7 | ||
|
|
b66f36d4f8 | ||
|
|
17c99fa829 | ||
|
|
d00efa1012 | ||
|
|
f3c16803a3 | ||
|
|
18eaeb96f2 | ||
|
|
9c27a8178b | ||
|
|
9745454094 | ||
|
|
7806722318 | ||
|
|
da840b8b07 | ||
|
|
909090648a | ||
|
|
32e1f24d2b | ||
|
|
e97ea75e73 | ||
|
|
e453b769fd | ||
|
|
d4815736ad | ||
|
|
9943e999c5 | ||
|
|
057e78ab71 | ||
|
|
61506cc39a | ||
|
|
24fdb0bca6 |
No files matched your search
@@ -61,3 +61,26 @@ jobs:
|
||||
key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
||||
- run: npx playwright install --with-deps chromium
|
||||
- run: npm run test:e2e
|
||||
|
||||
# 桌面端 Rust 门禁(2026-11-26 新增)。此前 25 个 tauri 命令、mac/Win32 双平台分支
|
||||
# 完全没有 CI,只能靠人工在 mac / win 上构建验证。
|
||||
# 选 macOS runner:Linux 编译 tauri 需要 webkit2gtk 等系统库,macOS 自带,成本也最低;
|
||||
# 且 src-tauri 的 #[cfg(target_os = "macos")] 分支只有 mac 能真正编译到。
|
||||
rust:
|
||||
name: rust (fmt · clippy · test)
|
||||
runs-on: macos-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: rustfmt, clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: src-tauri
|
||||
- name: fmt
|
||||
run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check
|
||||
- name: clippy
|
||||
run: cargo clippy --manifest-path src-tauri/Cargo.toml --all-targets -- -D warnings
|
||||
- name: test
|
||||
run: cargo test --manifest-path src-tauri/Cargo.toml
|
||||
@@ -26,3 +26,6 @@ market/
|
||||
# 临时截图/调试产物(不入库)
|
||||
_*.png
|
||||
_tray-preview/
|
||||
|
||||
# 本地工具输入截图(不入库,2026-11-26)
|
||||
.qoder-input-images/
|
||||
|
Before Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 242 KiB |
|
Before Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 178 KiB |
|
Before Width: | Height: | Size: 702 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 748 KiB |
|
Before Width: | Height: | Size: 542 KiB |
|
Before Width: | Height: | Size: 566 KiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 286 KiB |
|
Before Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 307 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 155 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 347 KiB |
|
Before Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 174 KiB |
|
Before Width: | Height: | Size: 393 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 3.9 MiB |
|
Before Width: | Height: | Size: 185 KiB |
|
Before Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 316 KiB |
|
Before Width: | Height: | Size: 863 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 32 KiB |
@@ -16,6 +16,73 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.26.106(2026-11-26)复制粘贴通道重写(mac ⌘C/⌘V 一条命令贴一切)+ mac 图标修复 + 便利贴空白行
|
||||
|
||||
**修「mac 上复制节点组时灵时不灵、⌘V 贴不上」**(用户多轮实测:复制节点组没有"已复制"提示;三种粘贴方式两处静默;焦点卡在输入框时只能看到"先点一下画布空白处")。
|
||||
根因是 mac 的 WKWebView **只在第一响应者可编辑时派发 paste 事件**,而 `Menu::default()` 的 Edit>Copy/Paste 绑的是 `copy:` / `paste:` 且 `setAutoenablesItems(false)` 永远 enabled —— 只要第一响应者认为"有东西可复制",AppKit 直接处理掉,keydown 根本到不了 JS。旧实现只有 keydown 一条复制入口,于是静默失败。
|
||||
|
||||
- **复制改由 DOM `copy` 事件驱动**(`src/clipboard-graph.js` 新增 `bindCopy`):在事件里用 `clipboardData.setData` **同步**写 `text/html`(带节点组标记)+ `text/plain`(人话摘要)。这是用户手势直接授权的通道,Chromium / WKWebView 都成,不再依赖 `navigator.clipboard.write` 那条异步链路(WKWebView 里它经常被拒,只能降级成"纯文本摘要 + 全等比对")。keydown 保留 80ms 兜底(个别不派发 `copy` 的 WebView),两者用时间戳去重;Workbench 卸载时显式摘监听,避免回首页后 ⌘C 拿已卸载的 refs 去复制旧画布。
|
||||
- **⌘V 改为 keydown 主动粘贴**(`src/clipboard-paste.js` 新增 `pasteFromKey`):指针在画布就接管,逐级降级 —— 系统剪贴板富读取(`navigator.clipboard.read`,能拿到 html 标记)→ 原生文本(Rust `clipboard_read_text`,靠 `matchPlain` 认出节点组)→ 原生图片(Rust `clipboard_read_image`)→ 应用内剪贴板。150ms 内若等到真实 `paste` 事件则让给事件通道(Windows / WebView2 行为不变),一次按键只贴一份。
|
||||
- **焦点在输入框里的三种情形分别处理**:指针在画布 → blur 并把节点组贴到指针处(原来这里只有一句"先点一下画布空白处",而点节点内的空白宿主会 `preventDefault`、焦点根本不会走);只有「N 个节点」摘要 → `preventDefault` 拦下(旧实现只提示不拦,摘要被原生粘贴打进输入框,是本次一并修掉的污染);剪贴板里带提示词全文 → 放行原生,照常把那段文字粘进输入框。
|
||||
- **节点组标记双写**:HTML 注释(Chromium 原样保留)+ `data-iwb-graph` 属性(WKWebView 写读剪贴板时会把注释整段洗掉,属性值能活)。`decode()` 两处都找,旧格式仍可读。
|
||||
- **提示可读**:未选中节点按 ⌘C 会明确说"没有可复制的节点";复制失败、粘贴失败都有指路文案;`notice` 的 err/info 5.2s 自动消失(旧实现只有 toast 会消失,错误提示会一直挂在状态栏)。
|
||||
- 门禁:`tests/clipboard-graph-test.js` 56 项(新增双标记、`writeToEvent`、`bindCopy`/`unbindCopy`),`tests/clipboard-paste-test.js` 100 项(新增 `pasteFromKey` 接管/去重、指针在画布改贴画布),`tests/clipboard-audit.spec.js` 的 TTL 用例补了"先清空系统剪贴板"前置(系统剪贴板按设计不设 TTL),第 19 条改为两种情形分别断言。
|
||||
|
||||
**修「mac 没有软件图标(Dock 空白方块)」**:v3.26.105 换图标时 `src-tauri/icons/icon.icns` 的文件头总长度字段写坏了 —— 声明 693,114 字节、实际 167,838 字节。`sips` 不做全量校验照样能解码(所以本地看图没问题),但 macOS IconServices 按声明长度解析直接失败,Dock / 访达 / 关于面板全部显示空白。用 `iconutil` 从 1024 主图重建(头部自洽,337,249 字节),并新增 `tests/icon-assets-test.js`:icns 头部长度 == 文件长度、chunk 链正好走完、必须有 1024 图块、png/ico 结构完好。**装新包后需要 `killall Dock`(或把 app 挪一次位置)让 LaunchServices 刷缓存。**
|
||||
|
||||
### 插件 sticky 1.0.8(市场单发,不改客户端包)
|
||||
|
||||
- **修「便利贴文字下面又多出一行空白」**(用户反馈:v1.0.4 修过又回来了)。`fitBody` 的高度缓存只比 `text/fontSize`,**宽度变化不重算** —— 宿主改卡片宽度的时机(拖宽节点、左右侧栏开合、首帧还没布局完 `clientWidth=0`)都会让它沿用旧行数的高度,文字少一行时正好空出一整行;`scrollHeight` 的整数取整误差(line-height 1.7×14=23.8)还会叠出半行。
|
||||
- 现在高度按「行高 × 整数行 + padding」对齐,并把 `clientWidth` 纳入缓存键;同时加 `ResizeObserver`(骨架被摘除时自我断开),宿主改宽度也能跟着重算。
|
||||
- 契约测试 `sticky/tools/harness.mjs` 新增两条断言:同一段文字宽度 160→420 高度必须变矮、高度必须落在整数行上(无半行残差);版本断言改为对齐 `package.json`,不再写死。
|
||||
|
||||
|
||||
|
||||
## v3.26.107(2026-11-26)双母图图标:macOS 消除系统底板,Windows 保留圆角
|
||||
|
||||
- **macOS 图标改用满幅不透明母图**(`icon.icns`):深色铺满 1024 画布、无透明边,由系统套 squircle 遮罩。A/B 对照实测:透明边母图在 Dock 渲染出 26.6% 浅色底板(左右各 13.3%),满幅母图为 0%。
|
||||
- **Windows 图标保留圆角母图**(`icon.ico` + 共用 PNG):圆角 tiles + 真实 alpha 羽化边缘,同时修复母图边缘被压平成不透明灰(RGB 164 / alpha 255)的问题——原边缘现为深色 RGB 45 的 alpha 渐变,256px 帧左边中点为全透明。
|
||||
- **两套母图分头产出**:`icon.icns` 来自满幅母图,`icon.ico` 与 `128x128` / `64x64` / `32x32` / `Square*Logo` / `StoreLogo` / `icon.png` 来自修好灰边的圆角母图;`src-tauri/icons/tray-template.png` 原样保留(`src-tauri/src/lib.rs` 编译期 `include_bytes!` 依赖)。
|
||||
- `icon.icns` 结构为 `is32`+`s8mk` / `il32`+`l8mk` + 8 个 PNG chunk,不含 classic `ARGB` 裸数据。
|
||||
|
||||
## v3.26.106(2026-11-26)复制粘贴通道重写 + mac 图标修复 + 便利贴 1.0.8
|
||||
|
||||
- **复制粘贴通道重写**:mac 上 ⌘C / ⌘V 改为一条命令贴一切 —— `copy` 事件作为主通道,`keydown` 主动触发粘贴,修复此前部分场景粘贴无响应。
|
||||
- **mac 应用图标修复**:重建 `src-tauri/icons/icon.icns`(旧文件头部长度字段与实际数据不一致,导致 Dock 显示空白方块);新增 `tests/icon-assets-test.js` 断言 icns/png/ico 结构(含 1024 主图切片、容器长度自洽)。
|
||||
- **便利贴 1.0.8**:便利贴宽度变化后不再把高度算高(修复文字下方多出一行空白)。
|
||||
- **相册 1.1.6**:插件页与索引同步。
|
||||
- 发布范围:macOS(arm64 / x86_64)与 Windows(x64)三平台产物均已构建、校验字节并由正式私钥签名发布;`latest.json` 三平台齐平,`latest-windows.json` 独立指向 Windows 包。
|
||||
|
||||
## v3.26.105(2026-11-26)新版全平台应用图标
|
||||
|
||||
- **全平台图标更新**:macOS / Windows 应用图标换新(深色圆角底 + 渐变 W 字标),`src-tauri/icons/` 17 个桌面图标整体替换(`icon.png` / `icon.icns` / `icon.ico` / `128x128` / `64x64` / `32x32` / `Square*Logo` / `StoreLogo`)。
|
||||
- **保留 `src-tauri/icons/tray-template.png`**:它是 `src-tauri/src/lib.rs` 用 `include_bytes!` 编译期读入的托盘图(`tauri icon` 不生成),图标替换只做逐文件覆盖、不删目录,mac 与 Windows 的 Rust 编译均不受影响。
|
||||
- **不追改已发布版本**:图标改动会改写安装包字节与签名,因此只在 v3.26.105 生效,v3.26.104 的安装包、`releases.json` / `latest.json` / `latest-windows.json` 三处登记保持原样。
|
||||
- Windows 与 mac 双架构包已同步发布,三平台更新清单齐平(`latest.json` 含 darwin-aarch64 / darwin-x86_64 / windows-x86_64,`latest-windows.json` 独立指向 Windows 包)。
|
||||
- 其余功能沿用 v3.26.104:移除 PWA 图标面、相册外部路径重启复授权、相册重选与缩略图自愈。
|
||||
|
||||
### 插件 album 1.1.6(2026-11-26,市场单发,不改客户端包)
|
||||
|
||||
- **修「相册有图却没有缩略图」**(用户报障:拖网络图 / 选本地图 / 添加文件夹都能加成功,格子是空的;切走画布再回来缩略图就出来了,再加一张又全空)。根因是 1.1.5 把「元素存活判断」提进公共 helper `applyThumb`,而命中**内存缓存**的分支在 `btn.appendChild(img)` **之前**就调用它 —— 那一刻 `img.isConnected` 必然 false ⇒ 直接 return,`src` 从不赋值。磁盘里的缩略图一直是好的,所以看缓存/看日志都会误判成「读图失败」。现在缓存命中直接赋 `src`,存活判断只留在异步回调里。
|
||||
- **修「透明图缩略图黑底」**:`toDataURL('image/jpeg')` 没有 alpha 通道,透明像素编码后是纯黑 `rgba(0,0,0,255)`。改为隔点采样 alpha —— 含透明走 PNG,照片仍走 JPEG 0.85。
|
||||
- 缓存名带版本代号 `t2-`(读时两种后缀都试、写成功再删旧缓存),否则升级后仍旧命中旧黑底 JPEG,修复等于没发。
|
||||
- 导入收尾不再强制整块重建(旧写法每次导入末尾把全部格子重建成一遍,500 张时肉眼可见卡顿,也正好掩盖了上面那个 bug)。
|
||||
- 门禁:新增 `tests/iwb-album-thumbs.spec.js`(首次导入 / 追加 / 切密度 / 翻页 / 换宿主五条路径逐一断言「每格都有 src」,并验证透明图缩略图 alpha 保留);门禁 spec 53 → 54。插件源码真源在 `iwb-plugins-desktop`(`album/src/index.js`,同步后 `plugins/album/*` 与 `plugins/index.json` 哈希一致)。
|
||||
|
||||
|
||||
## v3.26.104(2026-11-26)移除 PWA 图标面 + Windows 构建文档订正
|
||||
|
||||
- **构建修复**:根目录 `favicon.svg` / `icon-192.png` / `icon-512.png` / `apple-touch-icon.png` / `manifest.webmanifest` 已删除;`scripts/build.js` 不再拷贝/引用这些文件,避免 `beforeBuildCommand` 因 ENOENT 让 `app:build` 直接失败。
|
||||
- **保留 `sw.js`**:它不是纯 PWA 安装面,仍负责版本更新检测与 `/__iwb_cache__` 图片缓存直出;删了会破图/丢更新提示。
|
||||
- `scripts/check-dist.js` 新增断言:PWA 图标/manifest 不得进 dist、index.html 不得引用、sw.js 必须存在。
|
||||
- **Windows 文档订正**:`WIN_BUILD_SPEC.md §3` 改为无更新私钥时的正确构建命令(临时 `createUpdaterArtifacts:false` config,不再用会失败的 `npm run app:build`);Cargo 版本改用 PowerShell `Select-String`;win remote 统一为 `origin`;`AI-HANDOFF-WINDOWS.md` 更新为当前 `latest-windows.json` 更新源事实,并修正旧装机兼容说明与日志路径。
|
||||
|
||||
## v3.26.103(2026-11-26)相册重选文件夹与缩略图缓存自愈
|
||||
|
||||
- 相册插件 **1.1.5**:重选同一文件夹时按归一化路径**就地更新**,不再追加重复项(旧实现把坏格留在前面、重复项排到后面,看起来就是“重选也不出缩略图”);同时清 missing、删旧缩略图缓存并强制重读原图。
|
||||
- 缩略图 `<img onerror>` 增加一次绕过坏缓存的重读;重选后旧图可自愈。
|
||||
- Windows 3.26.103 同时包含 3.26.102 的 `{__file}` fs 授权持久化/启动复授权修复。
|
||||
|
||||
## v3.26.102(2026-11-26)相册外部路径重启复授权
|
||||
|
||||
- **修复 Windows 重启后相册旧图在组合节点变感叹号**:相册 `{__file}` 只存路径,Tauri fs scope 是运行时授权,重启后失效;缩略图有插件缓存还能显示,组合/参考图读原图失败,只有本次新导入的图正常。
|
||||
|
||||
@@ -40,7 +40,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 131 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test:unit 132 个单测文件(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)
|
||||
@@ -102,8 +102,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` | **9,190**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **3,046** |
|
||||
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **9,205**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **3,060** |
|
||||
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
|
||||
|
||||
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
|
||||
|
||||
@@ -6116,8 +6116,11 @@ const tbCenterSeed = (type, refs) => {
|
||||
toastTimer: null, saveTimer: null, typingTimer: null,
|
||||
// Ctrl+Shift+V 的按下时间窗:吞掉浏览器随后派发的 paste(Chrome 会以纯文本形式触发)
|
||||
pasteGroupUntil: 0,
|
||||
// Ctrl+V 探测标记(src/clipboard-paste.js probe):等到真实 paste 就清零,否则给「请用 Ctrl+Shift+V」提示
|
||||
pasteProbe: 0,
|
||||
// 粘贴通道时间戳(2026-11-26):pasteKeyAt = 本次 ⌘V 按下;pasteEventAt = 真收到 paste;
|
||||
// pasteSwallowUntil = 主动粘贴刚落地,吞掉重复事件。三条一起保证「一次按键只贴一份」。
|
||||
pasteKeyAt: 0, pasteEventAt: 0, pasteSwallowUntil: 0,
|
||||
// 本机系统剪贴板是否可信(复制时写成功=true / 写失败=false;失败后 ⌘V 只认应用内剪贴板)
|
||||
sysClipOk: null,
|
||||
// 内部剪贴板「复制过但已过期」(readClipboardGraph 维护):用于把静默失败变成一句提示
|
||||
clipExpired: false,
|
||||
// ── 多画布 Session(S1:结构落地;行为改造在 S5–S6;Pilot 2 第二片容器外置到 sessionsStore)──
|
||||
@@ -6448,6 +6451,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
const floatbarRefPaste = (...a) => wbCmd().floatbarRefPaste(...a)
|
||||
const outResultUrls = (...a) => wbCmd().outResultUrls(...a)
|
||||
const copyNodes = (...a) => wbCmd().copyNodes(...a)
|
||||
const stageClip = (...a) => wbCmd().stageClip(...a)
|
||||
const pasteGraph = (...a) => wbCmd().pasteGraph(...a)
|
||||
const readClipboardGraph = (...a) => wbCmd().readClipboardGraph(...a)
|
||||
const pasteCopiedNodes = (...a) => wbCmd().pasteCopiedNodes(...a)
|
||||
@@ -7456,10 +7460,15 @@ const tbCenterSeed = (type, refs) => {
|
||||
// 这里只把 Workbench 闭包依赖递过去(每次调用现取,避免陈旧闭包)。
|
||||
const pasteCtx = () => ({
|
||||
refs, ui: { settingOpen, drawerOpen, helpOpen, wsMoreOpen, ctxMenu, connMenu }, readClipboardGraph, pasteCopiedNodes, pasteGraph,
|
||||
// 复制侧(DOM copy 事件)要用:选中集合取实时镜像(渲染闭包的 sel 可能是框选前的空数组)
|
||||
stageClip, copyNodes, ids: () => selRef.current, clipboardOf: (list) => CanvasOps.clipboardOf(refs.nodes, refs.edges, refs.groups, list),
|
||||
hasTextSelection: (el) => !!((typeof window !== 'undefined' && window.IWBClipboardCopy) ? window.IWBClipboardCopy.hasTextSelection(el) : null),
|
||||
markSys: (ok) => { refs.sysClipOk = !!ok },
|
||||
wsId: activeWsIdRef.current || activeWsId, activeWsId: () => activeWsIdRef.current || activeWsId, nodes: () => refs.nodes,
|
||||
uid, findSpot, nodeW: (ty) => nodeWidth({ type: ty }), nodeH: (ty) => nodeTypeH(ty),
|
||||
pushHistory, commitCanvas, setSel, setNotice, showToast, importImage: wImportImage,
|
||||
readNativeImage: (typeof window !== 'undefined' && window.IWBDesktop && window.IWBDesktop.clipboardReadImage) ? () => window.IWBDesktop.clipboardReadImage() : null,
|
||||
readNativeText: (typeof window !== 'undefined' && window.IWBDesktop && window.IWBDesktop.clipboardReadText) ? () => window.IWBDesktop.clipboardReadText().then((r) => ((r && r.ok) ? r.text : '')).catch(() => '') : null,
|
||||
closeLibrary: () => { setDrawerOpen(false) },
|
||||
})
|
||||
const onKey = (e) => {
|
||||
@@ -7493,19 +7502,21 @@ const tbCenterSeed = (type, refs) => {
|
||||
if (hit('ungroup')) { e.preventDefault(); const g = sel.map((id) => groupOf(id)).find(Boolean); if (g) ungroup(g.id); return }
|
||||
if (hit('undo')) { e.preventDefault(); undo(); return }
|
||||
if (hit('redo')) { e.preventDefault(); redo(); return }
|
||||
if (hit('copy')) { if (sel.length && !(hasTxt && hasTxt(t)) && copyNodes(sel)) e.preventDefault(); return }
|
||||
// 复制不再在这里做:mac 上 ⌘C 常被原生菜单 Edit>Copy 接管,keydown 到不了 JS(静默失败)。
|
||||
// 现在统一由 DOM copy 事件处理(src/clipboard-graph.js 的 bindCopy,同步 clipboardData),
|
||||
// 这里只保留"不 preventDefault"——prevent 反而会取消原生复制动作、连 copy 事件都不派发。
|
||||
if (hit('copy')) return
|
||||
if (hit('cut')) { if (sel.length && !(hasTxt && hasTxt(t)) && cutNodes(sel)) e.preventDefault(); return }
|
||||
// Ctrl+Shift+V:永远粘贴内部节点组剪贴板(不受系统剪贴板内容影响)。
|
||||
// 必须先于 Ctrl+V 分支判断,让 Ctrl+Shift+V 不被 Ctrl+V 语义吃掉;
|
||||
// 同时设一个时间窗,吞掉浏览器为 Ctrl+Shift+V 派发的「纯文本 paste」(Chrome 行为)。
|
||||
if (hit('pasteGroup')) { e.preventDefault(); refs.pasteGroupUntil = Date.now() + 800; pasteCopiedNodes(); return }
|
||||
if (hit('paste')) {
|
||||
// v3.24.67:Ctrl+V 只认系统剪贴板,节点组一律 Ctrl+Shift+V(用户裁定的心智模型)。
|
||||
// 旧实现在这里挂 300ms 定时器回退贴节点组,且用递增 token 只让最后一次执行 ——
|
||||
// 「复制一份、80ms 内连按 3 次 Ctrl+V」因此只贴出 1 份。定时器已删除;
|
||||
// 现在只在一直没有 paste 事件时给一句说明(probe),不代替用户粘贴任何东西。
|
||||
// 2026-11-26:⌘V 不再只"探测 + 提示"。桌面端(mac)焦点不在输入框时根本不派发 paste
|
||||
// 事件,旧实现只能提示"请按 Ctrl+Shift+V"。现在这里直接**主动粘贴**(指针在画布才接管):
|
||||
// 先让原生走(有 paste 事件的平台照旧),150ms 内没等到事件才自己读剪贴板。
|
||||
const mod = (typeof window !== 'undefined' && window.IWBClipboardPaste) || null
|
||||
if (mod) mod.probe(pasteCtx())
|
||||
if (mod && mod.pasteFromKey) mod.pasteFromKey(pasteCtx())
|
||||
return
|
||||
}
|
||||
if (hit('duplicate')) { e.preventDefault(); duplicateNodes(sel); return }
|
||||
@@ -7545,15 +7556,16 @@ const tbCenterSeed = (type, refs) => {
|
||||
// 替换参考图只保留显式入口(节点头「粘贴图片替换」/ 气泡按钮 / 上传),且必须可撤销。
|
||||
const onPaste = (e) => {
|
||||
const t = e.target, editable = !!(t && t.tagName && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT' || t.isContentEditable))
|
||||
refs.pasteProbe = 0 // 收到真实 paste → 取消「系统剪贴板为空」的提示
|
||||
refs.pasteEventAt = Date.now() // 真收到 paste → 主动粘贴那条定时器不再重复读剪贴板
|
||||
const mod = (typeof window !== 'undefined' && window.IWBClipboardPaste) || null
|
||||
// pasteStamp 只在**真正被消费**时自增(桌面端 keydown 兜底靠它判断);无条件自增会让被忽略的 paste 也挡住兜底。
|
||||
// pasteStamp 只在**真正被消费**时自增(其它模块靠它判断这次 paste 有没有被处理)。
|
||||
if (mod && mod.handle(e, pasteCtx(), editable)) refs.pasteStamp = (refs.pasteStamp || 0) + 1
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
window.addEventListener('keyup', onKeyUp)
|
||||
const pasteModEarly = (typeof window !== 'undefined' && window.IWBClipboardPaste) || null
|
||||
if (pasteModEarly && pasteModEarly.bindHotkeyFallback) pasteModEarly.bindHotkeyFallback(pasteCtx)
|
||||
// 复制主通道(2026-11-26):DOM copy 事件 + keydown 兜底,见 src/clipboard-graph.js
|
||||
const copyMod = (typeof window !== 'undefined' && window.IWBClipboardGraph) || null
|
||||
if (copyMod && copyMod.bindCopy) copyMod.bindCopy(pasteCtx)
|
||||
window.addEventListener('paste', onPaste)
|
||||
window.addEventListener('blur', onBlur)
|
||||
return () => {
|
||||
@@ -7567,6 +7579,9 @@ const tbCenterSeed = (type, refs) => {
|
||||
window.removeEventListener('keyup', onKeyUp)
|
||||
window.removeEventListener('paste', onPaste)
|
||||
window.removeEventListener('blur', onBlur)
|
||||
// 复制通道绑在 window 上(不在 lifecycle 里):卸载时必须显式摘掉,否则回到首页后
|
||||
// ⌘C 仍会拿已卸载那份 refs 去复制旧画布的选中节点。
|
||||
if (copyMod && copyMod.unbindCopy) copyMod.unbindCopy()
|
||||
}
|
||||
}, [sel, selEdge, settingOpen, drawerOpen, drawerTab, wsMoreOpen, ctxMenu, connMenu, helpOpen])
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.8 KiB |
@@ -1,14 +1,14 @@
|
||||
# 给 Windows 端 AI 的协作说明(Image Workbench 桌面版)
|
||||
|
||||
> 这份文档是给 **Windows 构建端的 AI agent** 读的。读完你应理解:项目架构、为什么 Windows 之前开不了网页、发布链路、你的职责边界、这次踩过的坑。
|
||||
> 详细打包步骤见仓库 `docs/WIN_BUILD_SPEC.md`(gitea/main)。本文是「认知 + 边界」,那份是「操作清单」。
|
||||
> 详细打包步骤见仓库 `docs/WIN_BUILD_SPEC.md`(main;mac 的 remote 叫 `gitea`,win 叫 `origin`)。本文是「认知 + 边界」,那份是「操作清单」。
|
||||
|
||||
---
|
||||
|
||||
## 1. 项目是什么
|
||||
|
||||
- Image Workbench:Tauri v2 桌面应用(本地优先的 AI 生图无限画布)。
|
||||
- 仓库:`/Users/qiqi/open/github/image-workbench-desktop`(mac 端),git remote 名为 `gitea`。
|
||||
- 仓库:`/Users/qiqi/open/github/image-workbench-desktop`(mac 端),mac 的 git remote 名为 `gitea`;win 构建机的 remote **只有 `origin`**,命令别照抄 `gitea`。
|
||||
- 分发:自建 NAS,公网 `https://download.maqiart.eu.org`,根目录 `/vol8/web/iwb-download`。
|
||||
- 版本线:以 `package.json` 为准(当前 `3.26.x`);历史 `3.25.x` 仅示例。**注意**:仓库里最高的 git tag `v3.87.65` 是历史遗留线,semver 更大但**不是**最新——判断最新版看 `package.json` / `CHANGELOG.md` 顶条 / `tauri.conf.json`,永远别按最高 tag。
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
|
||||
```
|
||||
mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
→ win `git fetch gitea && git reset --hard gitea/main`
|
||||
→ win 构建 setup.exe(npm ci && npm run app:build)
|
||||
→ win `git fetch origin && git reset --hard origin/main`
|
||||
→ win 构建 setup.exe(npm ci + WIN_BUILD_SPEC.md §3 的临时 nosign config)
|
||||
→ win 自测矩阵通过
|
||||
→ win 把 setup.exe 放到 NAS `_inbox/`(权限700,公网403)
|
||||
→ 通知 mac:版本 + size + sha256
|
||||
@@ -54,9 +54,9 @@ mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
## 4. 你的职责边界(AI 必须遵守)
|
||||
|
||||
✅ 你该做:
|
||||
- `git reset --hard gitea\main` 到最新
|
||||
- `git reset --hard origin/main` 到最新
|
||||
- 核对三处版本一致(package.json / tauri.conf.json / Cargo.toml)+ 确认 lib.rs 里 6 个 `async fn canvas_webview_*` 都在
|
||||
- `npm ci && npm run app:build`
|
||||
- `npm ci`,再按 `WIN_BUILD_SPEC.md §3` 用临时 nosign config 构建(`npm run app:build` 会因缺少更新私钥失败)
|
||||
- 跑自测矩阵(尤其第 2 项:画布网页节点能打开、不卡死)
|
||||
- 把 `image-workbench_<version>_x64-setup.exe` 放 NAS `_inbox/`
|
||||
- 记录 size + SHA256,通知 mac 端
|
||||
@@ -65,7 +65,7 @@ mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
- **自己签名 / 生成 .sig** —— 更新私钥只在 mac(`~/.config/iwb-updater.key`),win 签出来的 key ID 与项目公钥 `17ae57d0ac9f15f1` 不配对,客户端会拒绝安装(这次 win 放上来的临时 .sig 就被 mac 忽略重签了)
|
||||
- 改 `src-tauri\src\lib.rs` / `Cargo.toml` / `tauri.conf.json` 等任何源码
|
||||
- 跑 `cargo fmt` 或让 IDE 保存即格式化
|
||||
- `git add -A` / `git push gitea main`(push 是 mac 端 `RELEASE=1` 的单独动作)
|
||||
- `git add -A` / `git push`(push 是 mac 端 `RELEASE=1` 的单独动作;win 不 push)
|
||||
- 把 `target\`、`node_modules\`、`.msi`、`.sig` 提交进 git
|
||||
|
||||
---
|
||||
@@ -73,8 +73,8 @@ mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
## 5. 这次踩过的坑(让你少走弯路)
|
||||
|
||||
1. **win 自签 .sig 无效**:win 端没有正式私钥,签出来的 sig keyid 对不上,白签。只交 setup.exe,签名交给 mac。
|
||||
2. **`latest.json` 平台解耦 bug**:项目想做 mac/win 独立更新清单(mac→`latest.json`,win→`latest-windows.json`),但**应用的 `tauri.conf.json` endpoints 只配了 `latest.json`**,且 mac 发布脚本 `publish-update.sh` 写清单时**只硬编码 darwin 两平台、丢弃 windows 条目**。结果:win 用户的应用拉 `latest.json` 找不到 `windows-x86_64` → 更新无结果。**临时修**:mac 端把 windows 条目合并回 `latest.json`。**已修(v3.25.32)**:`publish-update.sh` 现从 `latest-windows.json` 合并 windows 条目,且**仅当 win version == 本次 mac version(同批)才合并**,否则拒绝并警告(防"声明新版、实际旧包"导致 updater 反复提示同一旧包的死循环)。
|
||||
3. **v3.25.30 旧 win 包 updater 卡「正在检查…」**:那是旧包的 updater 行为/网络,不是发布错。诊断法:浏览器打开 `https://download.maqiart.eu.org/updates/latest.json`,能看到 `windows-x86_64` 即发布侧没问题;旧包用户**直接用网页下载 setup.exe 手动升级**最稳,装上 v3.25.31 后以后就能应用内更新。
|
||||
2. **更新源平台解耦(已修复,旧装机例外)**:早期 win 客户端编译时写死读 `latest.json`,而 mac 发布脚本曾只写 darwin 条目,导致 win 更新无结果。自 `856e34a`(2025-11-18)起,`src-tauri/tauri.windows.conf.json` 已把 updater endpoints 覆盖成 `latest-windows.json`;**新构建的 win 应用直接读 `latest-windows.json`**。mac 仍会把 windows 条目合并进 `latest.json`,只为兼容**旧装机**(它们编译时写死旧源)。升级到新包后,旧装机也会改读 `latest-windows.json`。
|
||||
3. **v3.25.30 旧 win 包 updater 卡「正在检查…」**:那是旧包的 updater 行为/网络,不是发布错。诊断法:新包看 `https://download.maqiart.eu.org/updates/latest-windows.json`,旧包看 `latest.json`;能看到 `windows-x86_64` 即发布侧没问题。旧包用户**直接用网页下载 setup.exe 手动升级**最稳,装上包含 `856e34a` 的版本后就会改读 `latest-windows.json`。
|
||||
4. **Windows 画布网页节点无圆角**:`cwv_round` 非 macOS 分支是空 stub,网页节点直角贴卡片。cosmetic,已知缺失,另排 backlog,不影响交付。
|
||||
|
||||
---
|
||||
@@ -84,14 +84,15 @@ mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
**结论**:win 客户端**支持在程序里「检查更新」自动升级**,机制和 mac 一样,但**依赖 mac 端配合签名 + 合并更新清单**,win 端自己做不到完整闭环。
|
||||
|
||||
**更新怎么触发**
|
||||
- win 客户端 `tauri.conf.json` 的更新源写死指向 `https://download.maqiart.eu.org/updates/latest.json`(和 mac 共用一个源,**不是** `latest-windows.json`)。
|
||||
- 点「检查更新」→ 读 `latest.json` → 找 **`windows-x86_64`** 条目 → 下载它指向的 `setup.exe` → 用项目公钥校验签名 → 通过则运行安装、重启。
|
||||
- 能否更新取决于两点:① `latest.json` 里有没有 `windows-x86_64` 条目;② 那个包是不是 mac 正式私钥签的。
|
||||
- 当前 win 构建(`src-tauri/tauri.windows.conf.json`,自 `856e34a`)的更新源是 `https://download.maqiart.eu.org/updates/latest-windows.json`;mac 的 `tauri.conf.json` 才是 `latest.json`。**不要再按旧文档说“win 只读 latest.json”**。
|
||||
- 点「检查更新」→ 读 `latest-windows.json` → 找 **`windows-x86_64`** 条目 → 下载它指向的 `setup.exe` → 用项目公钥校验签名 → 通过则运行安装、重启。
|
||||
- 能否更新取决于两点:① `latest-windows.json` 里有没有 `windows-x86_64` 条目;② 那个包是不是 mac 正式私钥签的。
|
||||
- **旧装机**仍可能读 `latest.json`(编译时写死);所以 mac 仍把 win 条目合并进 `latest.json` 作为兼容。新装机不需要这条也能更新。
|
||||
|
||||
**每次 win 发版的完整链路**
|
||||
1. win 端:拉最新 main → `npm ci && npm run app:build` → 得 `image-workbench_<版本>_x64-setup.exe` → 自测矩阵 → 放 NAS `_inbox/`(**只放 setup.exe,不放 .sig**)。
|
||||
1. win 端:拉最新 main → `npm ci` → 按 `WIN_BUILD_SPEC.md §3` 用临时 nosign config 构建(直接用 `npm run app:build` 会因没有更新私钥在签名阶段失败)→ 得 `image-workbench_<版本>_x64-setup.exe` → 自测矩阵 → 放 NAS `_inbox/`(**只放 setup.exe,不放 .sig**)。
|
||||
2. mac 端:`publish-windows-update.sh <setup.exe>`(正式私钥签名 + 上传 `updates/windows-x86_64/` + 写 `latest-windows.json`)。
|
||||
3. mac 端:重跑 `publish-update.sh`,把 win 条目合并进 `latest.json`(合并条件:win 版本 == mac 本次版本)。
|
||||
3. mac 端:重跑 `publish-update.sh`,把 win 条目合并进 `latest.json`(兼容旧装机;合并条件:win 版本 == mac 本次版本)。新装机读 `latest-windows.json`,不依赖这一步。
|
||||
4. 完成后 win 用户即可在程序里检查更新到新版。
|
||||
|
||||
**硬性前提 / 规则**
|
||||
@@ -107,13 +108,15 @@ mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
## 7. 验证发布是否到位(win 用户/你都能查)
|
||||
|
||||
```
|
||||
浏览器打开 https://download.maqiart.eu.org/updates/latest-windows.json
|
||||
→ version 应是目标版本,platforms 应含 windows-x86_64
|
||||
浏览器打开 https://download.maqiart.eu.org/updates/latest.json
|
||||
→ version 应是目标版本,platforms 应含 darwin-aarch64 / darwin-x86_64 / windows-x86_64
|
||||
→ mac 条目为目标版本;为兼容旧装机,也应含 windows-x86_64
|
||||
浏览器打开 https://download.maqiart.eu.org/
|
||||
→ 三平台都应是「下载」按钮,不是「暂未提供」
|
||||
```
|
||||
|
||||
`latest.json` 是 `cf-cache-status: DYNAMIC`(CF 不缓存),改完即时生效,不用等。
|
||||
`latest.json` / `latest-windows.json` 都是 `cf-cache-status: DYNAMIC`(CF 不缓存),改完即时生效,不用等。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
| 组件 | 位置 | 说明 |
|
||||
|---|---|---|
|
||||
| 更新插件 | `src-tauri/Cargo.toml` → `tauri-plugin-updater` | Rust 侧用 `UpdaterExt` |
|
||||
| 更新源 | `src-tauri/tauri.conf.json` → `plugins.updater.endpoints` | `https://download.maqiart.eu.org/updates/latest.json` |
|
||||
| 更新源(macOS) | `src-tauri/tauri.conf.json` → `plugins.updater.endpoints` | `https://download.maqiart.eu.org/updates/latest.json` |
|
||||
| 更新源(Windows) | `src-tauri/tauri.windows.conf.json` → `plugins.updater.endpoints` | `https://download.maqiart.eu.org/updates/latest-windows.json`(自 `856e34a`;旧装机仍可能读 latest.json) |
|
||||
| 签名公钥 | 同上 `plugins.updater.pubkey` | 私钥在 `~/.config/iwb-updater.key`(**务必备份**) |
|
||||
| 产物开关 | `bundle.createUpdaterArtifacts: true` | 构建 app 时额外产出 `.app.tar.gz` + `.sig` |
|
||||
| Rust 命令 | `check_update` / `install_update` | 前端通过 `__TAURI__.core.invoke` 调用 |
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
---
|
||||
name: iwb-win-build
|
||||
description: Windows 构建机执行 image-workbench-desktop 打包的本机实操补充。规范以 docs/WIN_BUILD_SPEC.md 与 docs/AI-HANDOFF-WINDOWS.md 为准,本文件只补规范没有的本机细节(本机 remote 名、node 双版本、cargo 代理、PowerShell 编码坑、Taildrop 交付通道、latest.json 合并缓存坑、图标替换要点);冲突时以规范为准。
|
||||
version: 3.0.1
|
||||
---
|
||||
|
||||
# Windows 打包 · 本机实操补充(非规范)
|
||||
|
||||
> **定位**:`docs/WIN_BUILD_SPEC.md`(操作清单)+ `docs/AI-HANDOFF-WINDOWS.md`(认知与边界)是**权威规范**。
|
||||
> 本文件只记录规范里没有、但在这台 Windows 机器上真实踩过的坑。任何冲突一律以规范为准。
|
||||
>
|
||||
> **v3.0.1 变更(2026-11-26,mac 端审阅后)**:
|
||||
> ① §8 把「`/updates/*` 强缓存」精确化为「**产物文件**强缓存」,并补规范 §7 的事实——**清单 JSON 是 DYNAMIC、即时生效**(mac 端 2026-11-26 实测:上传后公网 GET 立刻拿到新条目);
|
||||
> ② §7 补一句:规范 §6 的 `_inbox/` 仍是规范路径,Taildrop 是本机实测的等价替代,**二选一,不要同时放两份不同字节的包**;
|
||||
> ③ §10 补准确表述:四个根 PWA 图标**已随 v3.26.104 提交删除**,main 上已不存在,win 侧旧工作区看到的 `D` 是「未提交的删除」,不要 restore;
|
||||
> ④ 新增 §11「图标替换要点」(mac 端 v3.26.105 实操):`tray-template.png` 是编译期 `include_bytes!` 依赖,**逐文件覆盖、绝不删目录**。
|
||||
>
|
||||
> **v3.0.0 变更(2026-11-26,v3.26.104 发布后)**:v2.0.0 里「本机采用方案 A 但规范没写」「win 客户端只读 latest.json」「根目录 PWA 图标是构建输入」这三条**已被 mac 端修掉并写进规范**,相应条目改写为历史记录;新增 Taildrop 交付通道与 latest.json 合并的 CF 缓存坑。
|
||||
>
|
||||
> 本机:`DESKTOP-V53OQ19`(tailnet 名 `fulu-work`,`100.101.6.64`),用户 `ma`,仓库 `D:\GITHUB\image-workbench-desktop`,remote **`origin`**。
|
||||
|
||||
---
|
||||
|
||||
## 1. 版本号怎么判断
|
||||
|
||||
- **永远不要按最高的 git tag 判断最新版**:仓库有历史线 `v3.87.65`,semver 比现行 `3.26.x` 大但不是最新。
|
||||
- 现行线看三处且必须完全一致:`package.json` / `src-tauri/tauri.conf.json` / `src-tauri/Cargo.toml`。
|
||||
- 读取方式(Cargo.toml 是 TOML,**不能**用 `require()`,规范 §2.1 已改):
|
||||
|
||||
```powershell
|
||||
node -p "require('./package.json').version"
|
||||
node -p "require('./src-tauri/tauri.conf.json').version"
|
||||
(Select-String -Path src-tauri\Cargo.toml -Pattern '^version').Line
|
||||
```
|
||||
|
||||
- 死锁修复门禁(6 个 `async fn canvas_webview_*`)用 `Select-String` 匹配英文标识符可靠;乱码只影响中文注释的显示,别凭乱码行判断。
|
||||
|
||||
## 2. 取代码
|
||||
|
||||
规范 §2 已统一为 `origin`。本机习惯用 `git merge --ff-only origin/main` 代替 `reset --hard`(效果相同、不会丢未提交改动)。
|
||||
|
||||
- 拉取前 `git restore src-tauri/Cargo.lock`:`tauri build` 会让 cargo 改写其中版本号一行,否则 `--ff-only` 失败。
|
||||
- 到 `git.maqiart.eu.org` 偶发 `schannel: SSL/TLS handshake failed` / `curl 28` / `early EOF`。**失败 ≠ 没新版本**,fetch 失败时 `behind/ahead` 显示 `0 0` 是假象,绝不能报「已是最新」:
|
||||
|
||||
```powershell
|
||||
git -c http.lowSpeedLimit=1000 -c http.lowSpeedTime=30 fetch origin --prune
|
||||
```
|
||||
|
||||
- 拉 tag 时可能看到 `! [rejected] v3.26.101 -> v3.26.101 (would clobber existing tag)`:mac 端重打过 tag,**不影响构建**,别去 `--force` 覆盖。
|
||||
|
||||
## 3. 环境:两个 node 必须钉住 v22
|
||||
|
||||
- 系统 `C:\Program Files\nodejs\node.exe` = v26.13.1(PATH 默认命中);项目期望 v22。
|
||||
- 本机可用:`C:\Users\ma\.qwenworkcn\bin\node\node.exe` = **v22.19.0**(无 nvm/fnm/volta、无 `.nvmrc`)。
|
||||
|
||||
```powershell
|
||||
$env:PATH = "C:\Users\ma\.qwenworkcn\bin\node;" + $env:PATH
|
||||
node -v # 必须 v22.19.0
|
||||
```
|
||||
|
||||
`npm ci` 与构建必须用同一个 node。交付 `meta.txt` 里 `node=` 写构建时实际版本,不是系统 v26。
|
||||
|
||||
- **Rust 判定**:`rustc -V` 永不输出 host triple,所以 `scripts/windows-check.ps1` 里「当前工具链不是 MSVC」是**假阴性**,别据此停、也别改脚本。权威判定:
|
||||
|
||||
```powershell
|
||||
rustup show active-toolchain # stable-x86_64-pc-windows-msvc
|
||||
rustc -vV | Select-String '^host:' # host: x86_64-pc-windows-msvc
|
||||
```
|
||||
|
||||
- 该脚本还是 UTF-8 无 BOM,`powershell.exe` 5.1 按 GBK 码页读,含中文的行会乱码并报「字符串缺少终止符」的**假语法错误**。等价执行(不改仓库文件):
|
||||
|
||||
```powershell
|
||||
$code = Get-Content -Raw -Encoding UTF8 'scripts\windows-check.ps1'
|
||||
& ([ScriptBlock]::Create($code))
|
||||
```
|
||||
|
||||
- `src-tauri/src/lib.rs` 工作区是 **CRLF** 属正常:`core.autocrlf=true` 且 `.gitattributes` 没给 `*.rs` 声明 `eol=lf`,git 视为未改动。**不要**手动转行尾或格式化。
|
||||
|
||||
## 4. 网络:cargo 何时需要代理
|
||||
|
||||
crates.io 直连会 `transfer too slow: failed to transfer more than 10 bytes in 30s` 卡死(VS / rust-lang 直连反而正常):
|
||||
|
||||
```powershell
|
||||
$env:HTTP_PROXY='http://127.0.0.1:10808'; $env:HTTPS_PROXY='http://127.0.0.1:10808'
|
||||
```
|
||||
|
||||
判断要不要开:**看 `src-tauri/Cargo.lock` 除版本号外有没有依赖变化**。只有版本号一行变(如 3.26.101→3.26.104)= 依赖全缓存,不需要代理,实测增量构建 1m40s;新增 crate 或改 tauri features 才需要,约 5–8 分钟。
|
||||
|
||||
## 5. 构建:方案 A(现已写进规范 §3)
|
||||
|
||||
`tauri.conf.json` 是 `bundle.createUpdaterArtifacts: true`,win 无正式私钥,**直接 `npm run app:build` 会在签名阶段失败**。规范 §3 现在的正式写法:
|
||||
|
||||
```powershell
|
||||
$cfg = Join-Path $env:TEMP 'iwb-tauri-win-nosign.json'
|
||||
'{"bundle":{"createUpdaterArtifacts":false}}' | Set-Content -Encoding ascii $cfg
|
||||
.\node_modules\.bin\tauri.cmd build --config $cfg
|
||||
```
|
||||
|
||||
- **不能**用 `npm run app:build` 透传 `--config`(npm 不透传)。
|
||||
- 直接调本地 CLI **不绕过 lint**:`beforeBuildCommand` 由 tauri 执行,日志里照样出现 `Running beforeBuildCommand npm run lint && npm run build && node scripts/strip-plugins.js`。
|
||||
- 产物只有 `*-setup.exe`、**没有 `.sig`**,这是预期;签名由 mac 用正式私钥做。
|
||||
- `tauri.windows.conf.json` 已把 `targets` 锁成 `["nsis"]`,不会产 msi。
|
||||
|
||||
## 6. 产物核对
|
||||
|
||||
产物名必须 `image-workbench_<version>_x64-setup.exe`。核对「本次产了什么」要按 `LastWriteTime` 过滤——目录里会堆历史包(本机曾累积 19 个 exe + 3 个无效自签 `.sig`,2026-11-26 已清理,只留当前版与装机版)。`Get-ChildItem | Format-Table` 会把大数字截断成 `...882`,取精确字节用 `(Get-Item $p).Length`。
|
||||
|
||||
```powershell
|
||||
Get-ChildItem src-tauri\target\release\bundle -Recurse -File |
|
||||
Where-Object { $_.LastWriteTime -gt (Get-Date).AddMinutes(-20) } |
|
||||
Select-Object FullName, Length, LastWriteTime
|
||||
(Get-FileHash <setup.exe> -Algorithm SHA256).Hash.ToLower()
|
||||
```
|
||||
|
||||
顺手验一下版本已嵌进 PE:`(Get-Item <setup.exe>).VersionInfo.FileVersion`。
|
||||
|
||||
## 7. 交付:**Taildrop 是首选通道(不需要任何密钥)**
|
||||
|
||||
规范 §6 的路径是 scp 到 `[email protected]:/vol8/web/iwb-download/_inbox/`。**本机现状**:
|
||||
|
||||
- `~/.ssh/` 只有 `id_ed25519`,**没有**规范/`publish-windows-update.sh` 用的 `id_ed25519_fnos`;用 id_ed25519 会被拒:`Permission denied (publickey,password)`。要修就把本机公钥加到 NAS 的 `authorized_keys`。
|
||||
- **已验证可行的替代**:两台电脑在同一 Tailscale tailnet(mac = `qiqimac-mini` / `100.79.190.57`,NAS = `fnos01-1` / `100.71.19.58`,互联 6–7ms),直接推到 mac:
|
||||
|
||||
```powershell
|
||||
& "C:\Program Files\Tailscale\tailscale.exe" ping --c 3 qiqimac-mini
|
||||
& "C:\Program Files\Tailscale\tailscale.exe" file cp <setup.exe> "qiqimac-mini:"
|
||||
```
|
||||
|
||||
实测 5,116,258 B 一次落到 mac 的 `~/Downloads`,两端 `shasum -a 256` 一致。该版本 tailscale 的 `file` 只有 `cp` / `get` 子命令(没有 `ls`)。
|
||||
- ⚠️ **Taildrop 与 `_inbox/` 是二选一**:规范路径仍是 `_inbox/`(`_inbox/` 权限 700、公网 403)。若两条都放,**必须保证是同一份字节**(同一次构建产物),否则 mac 端可能取到错的那份、导致 sha256 与登记不符。
|
||||
- 最后的退路(规范兼容做法):落 `C:\Users\ma\Desktop\iwb-out\<version>\`,文件名**不改**,同目录放 `meta.txt`(`version` / `commit` / `arch=x64` / `built_at` ISO+08:00 / `node` / `rustc` / `notes`)与 `sha256.txt`;**不放 `.sig`**。
|
||||
- 报给 mac 的三要素固定是:**版本 + size + sha256**。
|
||||
|
||||
## 8. 更新清单现状(v2.0.0 那节已过期,重写)
|
||||
|
||||
两个清单**都活着**,别再把它们当单源:
|
||||
|
||||
| 清单 | 谁读它 | CF 缓存 |
|
||||
|---|---|---|
|
||||
| `updates/latest-windows.json` | **Windows 客户端**——`src-tauri/tauri.windows.conf.json` 自 v3.25.14(commit `856e34a`)起已覆盖 endpoints 指向它。v2.0.0 说「应用根本不读它」是错的,那是 v3.25.14 之前的事实 | DYNAMIC,**即时生效**(规范 §7) |
|
||||
| `updates/latest.json` | mac 客户端;同时为 v3.25.14 之前的老 win 装机保留 windows 条目 | DYNAMIC,**即时生效**(规范 §7) |
|
||||
|
||||
⚠️ **合并 windows 进 `latest.json` 时,不要重跑 `scripts/publish-update.sh`**。该脚本没有 skip-build 开关(第 47/50 行硬跑双架构 `npx tauri build --bundles app`),重跑会**重建并同名重传** `image-workbench_<V>_<arch>.app.tar.gz`。
|
||||
|
||||
这里要分清两类缓存(v3.0.1 修订,v2.0.0 表述过宽):
|
||||
|
||||
- **清单 JSON**(`latest.json` / `latest-windows.json`):`cf-cache-status: DYNAMIC`,改完**即时生效**,不需要等(规范 §7;mac 端 2026-11-26 实测:上传后立刻公网 GET 就拿到新条目)。
|
||||
- **产物文件**(`.dmg` / `.app.tar.gz` / `.exe`):Cloudflare 对 `/updates/*` 是 `max-age=14400` 的**强缓存**,同名文件重传后 4 小时内仍返回旧字节——`scripts/update-releases.js` 注释里记着 2026-11-18 的真实事故(「包已换、下载页 sha256 与实际不符」),`release.sh` 也写了同样的坑。
|
||||
|
||||
所以危险的不是「清单更新了」,而是「**清单指向的文件名没变、字节却变了**」:下载页链接带 `?h=<sha12>` 能强制回源,**但 latest.json 里的 updater URL 不带指纹** → mac 用户从 updater 拿到被缓存的旧字节配新 signature = 验签失败。
|
||||
|
||||
**正确做法(只注入、不重建)**:`curl` 备份线上 `latest.json` → 仅新增 `platforms["windows-x86_64"]`(signature/url 从 `latest-windows.json` 原样搬)→ `version` / `pub_date` / 两条 darwin 记录一字不动 → 写回。逻辑等价于 `publish-update.sh` 第 99–104 行的合并分支。只有在 mac 本身要发新版本(版本号变 ⇒ 文件名变 ⇒ URL 变)时才走完整脚本。
|
||||
|
||||
## 9. 自测边界(诚实原则)
|
||||
|
||||
- 可自动化:安装(NSIS 每用户、`/S` 无需 UAC)、进程存活、数据目录结构、单实例、`0.0.0.0:30092` 是否监听。
|
||||
- **必须人工点验**:规范 §5 的 5 项里第 2/3/4/5 项都涉及 GUI(画布网页节点加载不卡死、拖动缩放、子 webview 回收、独立窗口)。**不代打勾、不伪造结果**,如实标「待用户点验」。
|
||||
- 第 2 项不过 → 不交付,把 `%APPDATA%\com.malongan.imageworkbench\_cwv.log` 回传 mac 端(规范 §5 那个 `_%APPDATA%` 笔误已在 v3.26.104 修正)。
|
||||
- ⚠️ 安装前**不要强杀正在运行的实例**:多实例/异常退出会把 `data.json` 与 `canvases` 写成不一致状态,那是用户真实工作数据。请用户从**托盘右键退出**后再装。
|
||||
- 已知 cosmetic 缺失:Windows 画布网页节点无圆角(`cwv_round` 非 mac 分支是空 stub),伴随 `dead_code` 警告 `CWV_RADIUS` / `CWV_ROUND_CALLS` 与 `unused variable pid`,不阻断交付。
|
||||
|
||||
## 10. 已经不存在的老坑(别再照旧文档找)
|
||||
|
||||
- ~~根目录 `favicon.svg` / `icon-192.png` / `icon-512.png` / `apple-touch-icon.png` / `manifest.webmanifest` 是构建输入~~ → **v3.26.104 已整体移除**(`build.js` 不再拷贝/引用,`check-dist.js` 新增断言它们不得进 dist 且 `sw.js` 必须存在)。这四个图标是 PWA 遗留,删除是**有意为之**:mac 端 main 上已提交删除(`git ls-files` 查不到);win 侧若在旧工作区看到它们是 ` D`(未提交的删除),**不要 restore**。
|
||||
- `sw.js` 必须保留:它管版本更新检测与 `/__iwb_cache__` 图片缓存直出,不是纯 PWA 面。
|
||||
- 桌面包图标来自 `src-tauri/icons/`,与上面四个根图标无关。
|
||||
|
||||
## 11. 换图标(mac 端 v3.26.105 实操,win 侧只需知道后果)
|
||||
|
||||
- **换图标 = 换 PE 资源 = 安装包字节变 = sha256 与签名全变**。所以**绝不能回填已发布版本**(v3.26.104 的 `releases.json` / `latest.json` / `latest-windows.json` 三处登记的是 `63213fc5b2e0…` 那串字节与 mac 正式签名)。新图标必须**随下一个版本号**发布;win 侧相应地要**重新构建该版本的 setup.exe**,不能沿用旧包。
|
||||
- ⚠️ **`src-tauri/icons/tray-template.png` 必须保留**:它是 `src-tauri/src/lib.rs` 用 `include_bytes!("../icons/tray-template.png")` **编译期**读进去的托盘图(黑底 + IW 镂空),`tauri icon` 不生成它(所以新图标只有 17 个文件,而现用目录是 18 个)。若按「清空 icons 目录再拷」的方式替换,**mac 与 win 的 Rust 编译会同时失败**(`include_bytes` 找不到文件)——是**构建期**错,不是运行期问题。**逐文件覆盖,不删目录。**
|
||||
- 体积:mac 端交付的新图标做过 256 色量化(渐变 + 投影的 RGBA 原图 PNG 压不动,实测 `icon.icns` 693 KB → 168 KB、`icon.png` 105 KB → 29 KB、`icon.ico` 50 KB → 21 KB,肉眼无可见差异)。量化只影响图标文件体积,**不影响安装包功能**。
|
||||
|
||||
## 12. 红线复述
|
||||
|
||||
- ❌ 不签名、不生成/不交付 `.sig`
|
||||
- ❌ 不改 `src-tauri/**`、`app.js`、`src/**`、`style.css`、`scripts/build.js`、`scripts/gen-tokens.js`
|
||||
- ❌ 不跑 `cargo fmt`、不让 IDE 保存即格式化
|
||||
- ❌ 不 `git add -A`、不 commit、不 push、不打 tag
|
||||
- ❌ 不提交 `target\`、`node_modules\`、`.msi`、`.sig`
|
||||
- ❌ 不绕过 lint 门禁;报错就停下贴原文
|
||||
- ❌ 不删 / 不改 `src-tauri/icons/tray-template.png`(编译期依赖,删了直接构建失败)
|
||||
- 🔒 `%USERPROFILE%\Documents\ImageWorkbench\data.json` 明文存 API key:绝不整段读取/回显,只取需要的单字段
|
||||
|
||||
## 13. 实战记录
|
||||
|
||||
| 版本 | 日期 | 结果 |
|
||||
|---|---|---|
|
||||
| 3.26.101 | 2026-11-26 08:12 | 5,069,088 B / `fe49a49b…d715`;mac 已签名发布,三处清单一致 |
|
||||
| 3.26.104 | 2026-11-26 09:00 | 5,116,258 B / `63213fc5…3fd037`;增量 1m40s;Taildrop 送 mac → mac 验签发布 → `latest.json` 只注入合并(`e97ea75`) |
|
||||
| 3.26.105 | 2026-11-26 | **进行中**:mac 端已提交新图标 + 版本号 bump(win 侧待构建 setup.exe);旧包不可复用 |
|
||||
@@ -12,7 +12,7 @@ win 构建 setup.exe → win 自测通过 → 把 setup.exe 放到 NAS `_inbox/`
|
||||
## 0.1 版本与 CRLF(2026-11-24 教训,v3.26.54/55)
|
||||
|
||||
- **版本号只认 `package.json`**:`node -e "console.log(require('./package.json').version)"`;文档里写死的版本一律视为历史示例。
|
||||
- 拉取 `gitea/main` 后先跑 `npm run tokens:check`,再 `npm run app:build`。
|
||||
- 拉取 `origin/main` 后先跑 `npm run tokens:check`,再按 §3 的临时 nosign config 构建。
|
||||
- 若报 `src/design-tokens.css 与 derive() 不一致`:**先怀疑 Windows 检出把 CSS 转成了 CRLF**,不要直接 `tokens:write`。校验层(`gen-tokens.js` + `build.js`)自 v3.26.55 起已归一 `\r\n`;仍失败时把**第一处差异行**原样发回 mac 端。
|
||||
- `.gitattributes` 的 `eol=lf` 只影响**新检出**,不会自动 renormalize 已存在工作区——所以不能只靠它。
|
||||
- 不要改 `scripts/build.js` / `gen-tokens.js` 来绕过;构建脚本属于 mac 源码,改动先同步 mac 端。
|
||||
@@ -44,18 +44,20 @@ rustc -V # 期望 >= 1.90
|
||||
## 2. 取代码(必须是最新 main)
|
||||
|
||||
```powershell
|
||||
git fetch gitea
|
||||
git fetch origin
|
||||
git checkout main
|
||||
git reset --hard gitea\main
|
||||
git reset --hard origin/main
|
||||
```
|
||||
|
||||
> win 机器的 remote 只有 `origin`;`gitea` 是 mac 端 remote,不要混用。
|
||||
|
||||
**校验基线**(构建前必查,缺一不可):
|
||||
|
||||
```powershell
|
||||
# 2.1 三处版本号必须完全一致,且 = 目标版本(如 3.25.31)
|
||||
node -e "console.log(require('./package.json').version)"
|
||||
node -e "console.log(require('./src-tauri/tauri.conf.json').version)"
|
||||
node -e "console.log(require('./src-tauri/Cargo.toml').version)"
|
||||
(Select-String -Path .\src-tauri\Cargo.toml -Pattern '^version\s*=\s*"([^"]+)"' | Select-Object -First 1).Matches[0].Groups[1].Value
|
||||
|
||||
# 2.2 确认含 Windows 死锁修复(v3.25.31 的关键改动)
|
||||
# 这 6 个命令必须是 async fn,不是同步 fn
|
||||
@@ -75,10 +77,18 @@ findstr /C:"async fn canvas_webview_close_all" src-tauri\src\lib.rs
|
||||
|
||||
```powershell
|
||||
npm ci
|
||||
npm run app:build
|
||||
|
||||
# 关键:win 没有正式更新私钥,而 tauri.conf.json 是 createUpdaterArtifacts:true。
|
||||
# 直接 npm run app:build 会在签名阶段失败(Rust/NSIS 都白编)。
|
||||
# 把 createUpdaterArtifacts 关掉,写到临时目录再构建;不要改仓库文件、不要产 .sig。
|
||||
$cfg = Join-Path $env:TEMP 'iwb-tauri-win-nosign.json'
|
||||
'{"bundle":{"createUpdaterArtifacts":false}}' | Set-Content -Encoding ascii $cfg
|
||||
.\node_modules\.bin\tauri.cmd build --config $cfg
|
||||
```
|
||||
|
||||
- **不要用** `npm run app:build` 替代上面这条:npm 不会把 `--config` 透传给 tauri,且 win 端不该自己签名。
|
||||
- 首次会编译约 250 个 crate,2–5 分钟;之后增量很快。
|
||||
- 产物目录不变;因为关闭 updater artifacts,不会生成 `.sig`,这是预期的。mac 端会用自己的私钥重签。
|
||||
- 产物:
|
||||
- `src-tauri\target\release\bundle\nsis\image-workbench_<version>_x64-setup.exe` ← **交付这个**
|
||||
- `src-tauri\target\release\bundle\msi\*.msi`(可选,备用)
|
||||
@@ -120,7 +130,7 @@ certutil -hashfile src-tauri\target\release\bundle\nsis\image-workbench_3.25.31_
|
||||
| 4 | 节点 ✕ / 切工作区 / 退出应用 | cwv-* 子 webview 正常回收,不留残余进程 |
|
||||
| 5 | 独立浏览器窗口(插件「↗ 独立窗口」)| 能打开(这条本来就跨平台可用)|
|
||||
|
||||
第 2 项不过 → 别交付,把 `_%APPDATA%\com.malongan.imageworkbench\_cwv.log` 发回 mac 端排查。
|
||||
第 2 项不过 → 别交付,把 `%APPDATA%\com.malongan.imageworkbench\_cwv.log` 发回 mac 端排查。
|
||||
|
||||
已知缺失(不影响交付,但告知用户):Windows 画布网页节点**没有圆角**(直角贴卡片),属 cosmetic,另排 backlog。
|
||||
|
||||
@@ -148,7 +158,7 @@ mac 端收到通知后执行:
|
||||
2. `./scripts/publish-windows-update.sh <setup.exe>` —— 本机正式私钥签名 + 上传 `updates/windows-x86_64/` + 写 `latest-windows.json`
|
||||
3. `node scripts/update-releases.js --platform windows-x86_64 …` 登记网页下载
|
||||
4. `gen-release-page.js` + `gen-site.js` 重生成页面 + scp 元数据
|
||||
5. 合并 windows 条目进 `latest.json`(应用内更新源)
|
||||
5. 合并 windows 条目进 `latest.json`(兼容旧装机;新 win 构建读 `latest-windows.json`,见 `tauri.windows.conf.json`)
|
||||
6. commit + `RELEASE=1 git push gitea main`
|
||||
|
||||
---
|
||||
@@ -160,16 +170,16 @@ mac 端收到通知后执行:
|
||||
- ❌ 在 win 上跑 `cargo fmt` / IDE 保存即格式化(会引入整文件 diff,污染 mac 端同步)
|
||||
- ❌ 把 `target\`、`node_modules\`、`.cargo`、`.msi` 提交进 git
|
||||
- ❌ 用 `git add -A`(只精确提交需要入库的文件)
|
||||
- ❌ 直接 `git push gitea main`(push 需 mac 端 `RELEASE=1` 口令,win 端不 push)
|
||||
- ❌ 直接 `git push`(push 需 mac 端 `RELEASE=1` 口令,win 端不 push;win 的 remote 是 `origin`,不是 `gitea`)
|
||||
|
||||
---
|
||||
|
||||
## 9. 快速核对清单(交付前打勾)
|
||||
|
||||
- [ ] `git reset --hard gitea\main` 到最新
|
||||
- [ ] `git reset --hard origin/main` 到最新
|
||||
- [ ] package.json / tauri.conf / Cargo.toml 三处版本一致 = 目标版本
|
||||
- [ ] lib.rs 里 6 个 `async fn canvas_webview_*` 都在
|
||||
- [ ] `npm ci && npm run app:build` 成功
|
||||
- [ ] §3 的 `tauri build --config <临时 nosign.json>` 成功(不是 `npm run app:build`)
|
||||
- [ ] 产物名 = `image-workbench_<version>_x64-setup.exe`
|
||||
- [ ] 记下 size + SHA256
|
||||
- [ ] 自测矩阵 5 项全过(尤其第 2 项画布网页不卡死)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(桌面版)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = d604bb3`(线上 `v3.26.102+d604bb3` —— 2026-11-24 **图库:出图即入图库 + 插入落本地副本(能标注)**:每张生成完成即归档并通知插件(此前只在整轮结束写一次 ⇒ 生成中图库一直空)、插入取源改本地字节优先并引用化(抓不到才留原链接 + 提示)、`getNodeImage` 补 `data.localRef` 候选(远程缓存命中却仍判「不支持标注」的直接成因)、批量插入改 4 列栅格(旧实现同批全叠一处),逻辑落 `src/gallery-sync.js`,app.js 只装配;上一条 `v3.26.60+cf0e9a0` —— **浮层字号上调一档**:「模型设置」「图像设置」选择项 11→13px、高 22→28、左右内距 6→10、间距 4→6、标题 12→14、面板 328→360,改动全落在 `.iwb-pop` 的 6 个 token(两面板共用一套);上一条 `v3.26.59+e966b34` —— 备份新增 `plugin-files/` 通道,提示词封面换机不再丢;再上一条 2026-11-23 **节点正文文本区修复**:提示词/文本节点正文透明继承卡片底色(白卡片消失)、编辑态三层框(控件 border / 聚焦光晕 / D8 焦点环)全去掉,规范补表面角色三分法与 `node-scope-test` 第 5 条守卫,8 张基线重录;上一条 `v3.26.51+21554b0` —— **M6 延展验证**:插件面板两段六次叠加样式合并重写、133 行新增零裸值;补 `--iwb-font-base`(14px) 第 8 档与亮色状态色调深(对浅页面 2.13 → ≥4.6),对比度守卫 114→138 对;新增 ⑦⑧ 组件夹具基线共 16 张;`batch-export` 1.2.2 状态色走宿主 token、去掉纯蓝主按钮;棘轮基线首次下调。M1–M6 全部完成;上一条 `v3.26.50+cab473c` —— **M5 闸门**:新增 `scripts/token-lint.js`(只查 diff 新增行,CSS 与 JS 内联样式两套判据、四类白名单)+ `tests/design-token-ratchet-test.js`(13 项计数只降不升)+ `tests/theme-contrast-test.js`(亮/暗 × 文字 × 表面 114 对),三条各做一次打红验证后接进 `verify:ci`;顺手把首启动「选择资料目录」弹窗 token 化(全仓最后一个完全未 token 化的界面);上一条 `v3.26.49+1743453` —— **M4-B6 收尾**:`style.css` 剩余 16 处半像素字号全清零(守卫收紧为全文件断言)、`--iwb-control-h` 裁定不扩到全局控件(并排表单 vs 成组紧凑控件);插件主题契约重写,`ALLOW_FILES` 文件级豁免 **6 → 0** —— 改为「私有皮肤 manifest 自声明 `skin` + chroma 强调色判据 + 内容色行内标记」,声明私有皮肤的插件不得引用宿主颜色 token;同步 4 个插件版本,插件侧中性色写死归零;视觉基线 8 张因字号栅格化变化更新,A/B 回退确认非环境噪声;上一条 `v3.26.48+cb9cb9c` —— **M4-B5 节点**:节点卡内部表面统一 `--iwb-field` —— 端口底色从 `#161616`(暗色对卡片差 39 级,一颗黑洞)改 `#494949`(差 12 级),同病灶另 6 处(ref-img/ref-single/upload-link/refmini-empty/task-result-img/node-head:hover)一并改;浮条与任务卡 hover 改 `color-mix(text 10%)`(原来 panel 与 layer2 深色同色,hover 无反馈);字号 12/15/11/13 全归档位、圆角 8/6/5/14 归并、间距 52 处等值 + 13 处 1px 级微调;删 6 个死类名;新增 `tests/node-scope-test.js` 钉「节点内禁用面板表面色」;上一条 `v3.26.47+f5c8174` —— **M4-B4 设置/外观**:新增 `--iwb-control-h`(30px) 修「同行输入框 33px / 按钮 24px」的 9px 落差;设置页正文 14→13、标题 16→15,范围内半像素字号清零;删 21 条死规则(setcell/setgrid/set-row/appear-val 等);新增 `tests/settings-scope-test.js` 钉「控件等高 / 死类名不复现 / 引用的 token 必须存在」;上一条 `v3.26.46+9f29996` —— 2026-11-23 **M4-B3 首页/库**:删 30 条零生产者规则(25 个类名在产物里 0 次)+ 4 条被 specificity 覆盖的死声明,`style.css` 2391→2339 行;首页/库 106 条规则换 token,间距写死 91→5(只剩版心与导航让位的布局值)、字号写死清零,新增 `--iwb-font-display:24px` 第 7 档;验收改为「计算样式逐元素 diff + 12 张基线只首页 2 张变化」;上一条 `v3.26.45+968ff46` —— **M4-B2 浮层层级表 + 阴影四档**:14 档 `--iwb-z-*`(裸 z-index 取值种类 42→31)、`--iwb-elevation-1..4`(浮层 8 种阴影写法→4 档)、`.iwb-pop` 圆角 18→`radius-popover(14)`;修「弹窗里点保存看不到提示」—— 根因不是层级数字而是 `.iwb-overlay` 本身就是堆叠上下文,toast 改为 portal 到 `body`;新增 `tests/overlay-layer-test.js` 钉 9 条顺序约束;上一条 `v3.26.44+846a59b` —— **设计 token 体系重建**:D1–D9 色彩模型改为真正的深色(#12Line truncated
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = a9af024`(线上 `v3.26.107+a9af024` —— 2026-11-24 **图库:出图即入图库 + 插入落本地副本(能标注)**:每张生成完成即归档并通知插件(此前只在整轮结束写一次 ⇒ 生成中图库一直空)、插入取源改本地字节优先并引用化(抓不到才留原链接 + 提示)、`getNodeImage` 补 `data.localRef` 候选(远程缓存命中却仍判「不支持标注」的直接成因)、批量插入改 4 列栅格(旧实现同批全叠一处),逻辑落 `src/gallery-sync.js`,app.js 只装配;上一条 `v3.26.60+cf0e9a0` —— **浮层字号上调一档**:「模型设置」「图像设置」选择项 11→13px、高 22→28、左右内距 6→10、间距 4→6、标题 12→14、面板 328→360,改动全落在 `.iwb-pop` 的 6 个 token(两面板共用一套);上一条 `v3.26.59+e966b34` —— 备份新增 `plugin-files/` 通道,提示词封面换机不再丢;再上一条 2026-11-23 **节点正文文本区修复**:提示词/文本节点正文透明继承卡片底色(白卡片消失)、编辑态三层框(控件 border / 聚焦光晕 / D8 焦点环)全去掉,规范补表面角色三分法与 `node-scope-test` 第 5 条守卫,8 张基线重录;上一条 `v3.26.51+21554b0` —— **M6 延展验证**:插件面板两段六次叠加样式合并重写、133 行新增零裸值;补 `--iwb-font-base`(14px) 第 8 档与亮色状态色调深(对浅页面 2.13 → ≥4.6),对比度守卫 114→138 对;新增 ⑦⑧ 组件夹具基线共 16 张;`batch-export` 1.2.2 状态色走宿主 token、去掉纯蓝主按钮;棘轮基线首次下调。M1–M6 全部完成;上一条 `v3.26.50+cab473c` —— **M5 闸门**:新增 `scripts/token-lint.js`(只查 diff 新增行,CSS 与 JS 内联样式两套判据、四类白名单)+ `tests/design-token-ratchet-test.js`(13 项计数只降不升)+ `tests/theme-contrast-test.js`(亮/暗 × 文字 × 表面 114 对),三条各做一次打红验证后接进 `verify:ci`;顺手把首启动「选择资料目录」弹窗 token 化(全仓最后一个完全未 token 化的界面);上一条 `v3.26.49+1743453` —— **M4-B6 收尾**:`style.css` 剩余 16 处半像素字号全清零(守卫收紧为全文件断言)、`--iwb-control-h` 裁定不扩到全局控件(并排表单 vs 成组紧凑控件);插件主题契约重写,`ALLOW_FILES` 文件级豁免 **6 → 0** —— 改为「私有皮肤 manifest 自声明 `skin` + chroma 强调色判据 + 内容色行内标记」,声明私有皮肤的插件不得引用宿主颜色 token;同步 4 个插件版本,插件侧中性色写死归零;视觉基线 8 张因字号栅格化变化更新,A/B 回退确认非环境噪声;上一条 `v3.26.48+cb9cb9c` —— **M4-B5 节点**:节点卡内部表面统一 `--iwb-field` —— 端口底色从 `#161616`(暗色对卡片差 39 级,一颗黑洞)改 `#494949`(差 12 级),同病灶另 6 处(ref-img/ref-single/upload-link/refmini-empty/task-result-img/node-head:hover)一并改;浮条与任务卡 hover 改 `color-mix(text 10%)`(原来 panel 与 layer2 深色同色,hover 无反馈);字号 12/15/11/13 全归档位、圆角 8/6/5/14 归并、间距 52 处等值 + 13 处 1px 级微调;删 6 个死类名;新增 `tests/node-scope-test.js` 钉「节点内禁用面板表面色」;上一条 `v3.26.47+f5c8174` —— **M4-B4 设置/外观**:新增 `--iwb-control-h`(30px) 修「同行输入框 33px / 按钮 24px」的 9px 落差;设置页正文 14→13、标题 16→15,范围内半像素字号清零;删 21 条死规则(setcell/setgrid/set-row/appear-val 等);新增 `tests/settings-scope-test.js` 钉「控件等高 / 死类名不复现 / 引用的 token 必须存在」;上一条 `v3.26.46+9f29996` —— 2026-11-23 **M4-B3 首页/库**:删 30 条零生产者规则(25 个类名在产物里 0 次)+ 4 条被 specificity 覆盖的死声明,`style.css` 2391→2339 行;首页/库 106 条规则换 token,间距写死 91→5(只剩版心与导航让位的布局值)、字号写死清零,新增 `--iwb-font-display:24px` 第 7 档;验收改为「计算样式逐元素 diff + 12 张基线只首页 2 张变化」;上一条 `v3.26.45+968ff46` —— **M4-B2 浮层层级表 + 阴影四档**:14 档 `--iwb-z-*`(裸 z-index 取值种类 42→31)、`--iwb-elevation-1..4`(浮层 8 种阴影写法→4 档)、`.iwb-pop` 圆角 18→`radius-popover(14)`;修「弹窗里点保存看不到提示」—— 根因不是层级数字而是 `.iwb-overlay` 本身就是堆叠上下文,toast 改为 portal 到 `body`;新增 `tests/overlay-layer-test.js` 钉 9 条顺序约束;上一条 `v3.26.44+846a59b` —— **设计 token 体系重建**:D1–D9 色彩模型改为真正的深色(#12Line 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 **9,190 行**(**双层预算**:绝对上限 9,190 / 占总源码 ≤ 40%,现 **29.5%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **3,045 行**(上限 **3,046**,余量 1;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **112** 个模块 / 21,985 行,`sourceModules` 112 项;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,205 行**(**双层预算**:绝对上限 9,205 / 占总源码 ≤ 40%,现 **29.2%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **3,060 行**(上限 **3,060**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **112** 个模块 / 22,266 行,`sourceModules` 112 项;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`。
|
||||
|
||||
## 2. 门禁与环境现状
|
||||
@@ -31,7 +31,7 @@
|
||||
|---|---|---|
|
||||
| 单测基线 | **658 通过 / 0 新增失败 / 2 已知环境差异**(2026-11-12 v3.24.76 实测;660 −2 = 94-5~7 三条钉点换成一条消费方契约) | (A) `npm test` 实测(`tests/iwb-v32-web-test.js`) |
|
||||
| e2e | spec 文件 **58** 个(**52** 个进门禁 + 4 个 dev 探针 `_perf-baseline` / `_plugin-host-probe` / `_probe-drag` / `_probe-tab-switch`) | (A) `tests/` 计数 + `scripts/list-e2e-specs.js` |
|
||||
| e2e 用例数 | **200 条**(2026-11-16 实测:55 个进门禁 spec 内 `test()` 总数;v3.25.15 删除网页版部署面后为 **53** 个进门禁;v3.25.56 节点组库改插件 `grouplib`(宿主侧栏组件删除)后为 **52** 个进门禁 —— `iwb-csp-gate` / `iwb-functions-headers` 随 `_headers`、`functions/` 一起移除)(历史:115 → v3.24.18 **143** → v3.24.19 **147** → v3.24.21 **151** → F2 改名 1 条 **152** → 抓手工具 2 条 **154** → v3.24.44 输出顺序 2 条 **166** → v3.24.47 同步去重 `iwb-sync-dedupe` 1 条 **167** → v3.24.67 **179** → v3.24.68 **183** → v3.24.69 **184** → v3.24.70 **186** → v3.24.74 **187**(新增「拖入 PDF 给提示 + MIME 空 PNG 仍能导入」)→ v3.24.75 **188**(新增「同一张图连粘两次只建一个节点」)→ v3.24.76 **191**(新增 `iwb-tabs-release` 3 条:回首页不降级 / 关标签先保存再关 / 彻底删除连带关标签)→ v3.24.77 **194**(新增 `iwb-lod` 3 条:fit 大画布必须全 LOD / 放大后必须恢复 / 常规画布不 LOD)→ v3.24.78 **196**(`iwb-lod` 3 → 5 条:新增「lite 档必须画出代表图/首行文字」与「缩到 15% 以下才退成 plain」)→ v3.24.82 **197**(新增 `iwb-inherit-text` 1 条:提示词/文本节点显示上游继承文本、改字接管、恢复跟随)→ v3.24.83 **198**(新增 `iwb-plugin-node-coldstart` 1 条:插件脚本晚到 1.2s,存档里的插件节点必须自动切回插件节点体,且类型不被降级成 `plugin`)→ v3.24.79 **196 不变**(测速修复的守门落在 jsdom 单测 `provider-ping-test.js`,e2e 无新增)→ v3.24.85 **200**(新增 `iwb-multi-tab` 2 条:A 页 flush 落盘后 B 页必须靠 rev 轮询看到改动;B 页持锁期间 A 页图库归档必须挂起);早期 99 → 115 的逐版链条见 `docs/history/coverage-baseline-2026-10-27.md`) | (A) `tests/*.spec.js` 计数 + `scripts/list-e2e-specs.js` |
|
||||
| e2e 用例数 | **202 条**(2026-11-26 实测:**54** 个进门禁 spec 内 `test()` 总数(2026-11-16 时为 200 条 / 55 个 spec);v3.25.15 删除网页版部署面后为 **53** 个进门禁;v3.25.56 节点组库改插件 `grouplib`(宿主侧栏组件删除)后为 **52** 个进门禁 —— `iwb-csp-gate` / `iwb-functions-headers` 随 `_headers`、`functions/` 一起移除)(历史:115 → v3.24.18 **143** → v3.24.19 **147** → v3.24.21 **151** → F2 改名 1 条 **152** → 抓手工具 2 条 **154** → v3.24.44 输出顺序 2 条 **166** → v3.24.47 同步去重 `iwb-sync-dedupe` 1 条 **167** → v3.24.67 **179** → v3.24.68 **183** → v3.24.69 **184** → v3.24.70 **186** → v3.24.74 **187**(新增「拖入 PDF 给提示 + MIME 空 PNG 仍能导入」)→ v3.24.75 **188**(新增「同一张图连粘两次只建一个节点」)→ v3.24.76 **191**(新增 `iwb-tabs-release` 3 条:回首页不降级 / 关标签先保存再关 / 彻底删除连带关标签)→ v3.24.77 **194**(新增 `iwb-lod` 3 条:fit 大画布必须全 LOD / 放大后必须恢复 / 常规画布不 LOD)→ v3.24.78 **196**(`iwb-lod` 3 → 5 条:新增「lite 档必须画出代表图/首行文字」与「缩到 15% 以下才退成 plain」)→ v3.24.82 **197**(新增 `iwb-inherit-text` 1 条:提示词/文本节点显示上游继承文本、改字接管、恢复跟随)→ v3.24.83 **198**(新增 `iwb-plugin-node-coldstart` 1 条:插件脚本晚到 1.2s,存档里的插件节点必须自动切回插件节点体,且类型不被降级成 `plugin`)→ v3.24.79 **196 不变**(测速修复的守门落在 jsdom 单测 `provider-ping-test.js`,e2e 无新增)→ v3.24.85 **200**(新增 `iwb-multi-tab` 2 条:A 页 flush 落盘后 B 页必须靠 rev 轮询看到改动;B 页持锁期间 A 页图库归档必须挂起)→ v3.26.71 **201**(`iwb-default-gen-model` 1 条:通用 tab 新建配置节点默认模型)→ v3.26.106 **202**(`iwb-album-thumbs` 1 条:相册宫格重建后每格必须仍有缩略图 src,且透明图缩略图必须保留 alpha);早期 99 → 115 的逐版链条见 `docs/history/coverage-baseline-2026-10-27.md`) | (A) `tests/*.spec.js` 计数 + `scripts/list-e2e-specs.js` |
|
||||
| CI | `.github/workflows/verify.yml`:**push(main) + PR(→main) + 手动** 触发,两个 job(`gate` = `verify:ci`;`e2e` = `test:e2e`),只验证不部署 | (A) |
|
||||
| 发布(桌面) | mac:`bash scripts/publish-update.sh`;Windows:`publish-windows-update.sh` 后**重跑** mac 发布以合并 `latest.json` | `docs/WIN_BUILD_SPEC.md` §0.1 |
|
||||
| 发布环境 | 已无 Cloudflare Pages / wrangler / `deploy` 脚本;更新源为 NAS `https://download.maqiart.eu.org/updates/latest.json` | `PUBLISHING.md` |
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
6. **外部路径的 fs 授权不是持久的。**
|
||||
`{__file}` 只存路径;Tauri fs scope 重启即失效。`grant_paths` 必须落盘,启动时恢复;
|
||||
旧画布还要扫描已知 `{__file}` 再 grant 一次。否则“缩略图有缓存、组合节点全感叹号”,且只有新导入的图正常。
|
||||
重选文件夹也不要直接 append:按归一化路径就地更新,清 missing + 缩略图缓存 + forceThumbs,否则坏格留在前面、重复项排到后面/下一页。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -278,9 +278,10 @@ npm run verify
|
||||
dist/app.js = src/*.js(按 sourceModules 定序,逐文件 minify;自动发现的 src/plugin-*.js 追加于末尾)
|
||||
+ app.js(先注入 APP_VERSION,再 minify),纯文本拼接
|
||||
dist/style.css = style.css(minify)
|
||||
dist/ += favicon.svg / _headers / THIRD_PARTY_NOTICES.md
|
||||
/ vendor/react*.js ×2 / sw.js(注入 __IWB_VERSION__)
|
||||
dist/ += _headers / THIRD_PARTY_NOTICES.md
|
||||
/ vendor/react*.js ×2 / sw.js(注入 __IWB_VERSION__;保留更新检测 + 图片缓存,不是 PWA 安装面)
|
||||
/ index.html(内联生成)/ version.json
|
||||
(2026-11-26 起根目录 favicon/icon-*/apple-touch-icon/manifest 已删除)
|
||||
```
|
||||
|
||||
- **规则:`sourceModules` 的顺序即加载顺序,绝不排序、绝不改动**(各模块通过 `window.IWB*` 在运行时互相依赖)。
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<rect width="64" height="64" rx="14" fill="#2563eb"/>
|
||||
<path d="M16 18h32v8H16zM16 29h22v8H16zM16 40h32v8H16z" fill="#fff"/>
|
||||
<circle cx="47" cy="33" r="7" fill="#fbbf24"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "无限画布 Image Workbench",
|
||||
"short_name": "无限画布",
|
||||
"description": "本地优先的 AI 生图画布:节点式编排、提示词库、图库与画板管理",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"orientation": "any",
|
||||
"background_color": "#0f1115",
|
||||
"theme_color": "#2563eb",
|
||||
"lang": "zh-CN",
|
||||
"icons": [
|
||||
{ "src": "icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },
|
||||
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" },
|
||||
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" },
|
||||
{ "src": "favicon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any" }
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.102",
|
||||
"version": "3.26.107",
|
||||
"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/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine 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/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine 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",
|
||||
"plugins:gc": "node scripts/plugins-publish.mjs --gc",
|
||||
|
||||
@@ -66,10 +66,32 @@
|
||||
const isImagePath = (p) => IMG_EXT.indexOf(extOf(p)) >= 0
|
||||
const fileRefOf = (src) => (src && typeof src === 'object' && typeof src.__file === 'string') ? src.__file : ''
|
||||
const nameOf = (p) => String(p || '').replace(/^.*[\\/]/, '')
|
||||
// Windows 路径大小写不敏感;重选同一文件夹时 dialog 可能回不同大小写,必须按平台归一化后再去重
|
||||
const WIN = typeof navigator !== 'undefined' && /Windows/i.test(String(navigator.userAgent || ''))
|
||||
const normPath = (p) => { const s = String(p || '').replace(/\\/g, '/'); return WIN ? s.toLowerCase() : s }
|
||||
const str = (v) => (v == null ? '' : String(v))
|
||||
|
||||
// ── 缩略图(插件私有缓存,几十 KB/张,不碰画布存储)────────────
|
||||
const thumbNameOf = (key) => 't-' + hash32(key) + '.jpg'
|
||||
// 编码代号(1.1.6):
|
||||
// · 1.1.5 及以前一律 JPEG —— 而 JPEG 没有 alpha,canvas 的透明像素编码后是**纯黑**
|
||||
// (Chromium 实测 rgba(0,0,0,255))⇒ 抠图/透明 PNG 在相册里是一格格黑方块。
|
||||
// · 现在「含 alpha 走 PNG,否则 JPEG 0.85」;代号进文件名,旧黑底缓存自然不再命中。
|
||||
const THUMB_REV = '2'
|
||||
const thumbBase = (key) => 't' + THUMB_REV + '-' + hash32(key)
|
||||
// 宿主文件白名单只认 jpg/jpeg/png/webp,后缀必须与实际字节一致(读回时按文件头嗅探 mime)
|
||||
const thumbNameOf = (key, ext) => thumbBase(key) + '.' + (ext === 'png' ? 'png' : 'jpg')
|
||||
const thumbNames = (key) => [thumbNameOf(key, 'png'), thumbNameOf(key, 'jpg')]
|
||||
// 1.1.5 及以前的缓存名(永远是 JPEG),写新图时顺手清掉,别让黑底缩略图在磁盘里越积越多
|
||||
const oldThumbName = (key) => 't-' + hash32(key) + '.jpg'
|
||||
// keepExt:刚写成功的那一份不能删(png/jpg 只留一个),其余变体清掉
|
||||
function dropThumbFile (ctx, key, keepExt) {
|
||||
if (!ctx || !ctx.files || !key) return
|
||||
const keep = keepExt ? thumbNameOf(key, keepExt) : ''
|
||||
for (const n of thumbNames(key).concat([oldThumbName(key)])) {
|
||||
if (keep && n === keep) continue
|
||||
try { const p = ctx.files.remove(n); if (p && typeof p.catch === 'function') p.catch(() => {}) } catch (e) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
// 缩略图缓存键(1.1.0 修「串味」):旧实现是 `fileRefOf(src) || it.name`,一旦固化(src 变成
|
||||
// {__blob})或从别处导入,路径就没了 ⇒ 键退化成纯文件名 ⇒ 不同目录下的 1.png 共用同一张缩略图。
|
||||
@@ -90,6 +112,9 @@
|
||||
return 'n:' + str(n)
|
||||
}
|
||||
|
||||
// 返回 { url, ext };失败返回 null。
|
||||
// alpha 判定:缩放后隔 4 个像素采样 alpha 通道(256² 画布全读也就 256KB 一次性缓冲)。
|
||||
// 只有确实含透明像素才付 PNG 的体积代价 —— 照片仍走 JPEG,缓存总量不会膨胀。
|
||||
function makeThumb (dataUrl) {
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
@@ -103,12 +128,18 @@
|
||||
cv.width = w; cv.height = h
|
||||
const c2 = cv.getContext('2d')
|
||||
c2.drawImage(img, 0, 0, w, h)
|
||||
resolve(cv.toDataURL('image/jpeg', THUMB_Q))
|
||||
} catch (e) { resolve('') }
|
||||
let alpha = false
|
||||
try {
|
||||
const d = c2.getImageData(0, 0, w, h).data
|
||||
for (let i = 3; i < d.length; i += 16) { if (d[i] < 250) { alpha = true; break } }
|
||||
} catch (e) { /* 读不出像素就按不透明处理(IMG 被污染时 JPEG 也不会更糟) */ }
|
||||
if (alpha) resolve({ url: cv.toDataURL('image/png'), ext: 'png' })
|
||||
else resolve({ url: cv.toDataURL('image/jpeg', THUMB_Q), ext: 'jpg' })
|
||||
} catch (e) { resolve(null) }
|
||||
}
|
||||
img.onerror = () => resolve('')
|
||||
img.onerror = () => resolve(null)
|
||||
img.src = dataUrl
|
||||
} catch (e) { resolve('') }
|
||||
} catch (e) { resolve(null) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -143,6 +174,7 @@
|
||||
const st = {
|
||||
nodeId: node.id,
|
||||
thumbs: new Map(), // key → dataURL(内存缓存)
|
||||
forceThumbs: new Set(), // 需要绕过旧缩略图缓存、重新读原图的 key(重选文件夹/缩略图损坏)
|
||||
pending: new Map(), // key → Promise(并发去重:格子挂载和预生成会同时要同一张)
|
||||
missing: new Set(), // 失联文件的 key
|
||||
busy: '',
|
||||
@@ -354,11 +386,31 @@
|
||||
title: (it && it.name ? it.name : ('图 ' + (index + 1))) + (missing ? '(文件已不在原位置:点一下重新定位)' : ''),
|
||||
})
|
||||
const img = el('img', { alt: '', draggable: 'false' })
|
||||
// 缩略图缓存可能来自旧路径/旧版本,dataURL 本身坏了也会命中;onerror 时绕过缓存重读原图一次。
|
||||
let thumbRetried = false
|
||||
const applyThumb = (url) => {
|
||||
if (!url) return
|
||||
img.onerror = () => {
|
||||
if (thumbRetried) return
|
||||
thumbRetried = true
|
||||
st.thumbs.delete(key)
|
||||
if (st.forceThumbs) st.forceThumbs.add(key)
|
||||
dropThumbFile(ctx, key)
|
||||
loadThumb(ctx, st, it, key, true).then((next) => { if (next) applyThumb(next) })
|
||||
}
|
||||
img.src = url
|
||||
}
|
||||
const cached = st.thumbs.get(key)
|
||||
if (cached) img.src = cached
|
||||
// ⚠ 命中内存缓存时 img **还没** appendChild(本函数末尾才挂),所以这里不能判存活:
|
||||
// 1.1.5 把「存活判断」提进了 applyThumb,于是同步分支永远 isConnected === false ⇒ 直接 return,
|
||||
// 每次「导入 / 翻页 / 切密度 / 拖拽排序」引发宫格重建后,内存里已有的缩略图全都赋不上 src,
|
||||
// 格子一片空白(切走再切回来才正常 —— 那时内存缓存是空的,走异步分支)。
|
||||
// 存活判断只对异步回来的那一支有意义:那时格子可能已被下一次重建丢掉。
|
||||
if (cached) applyThumb(cached)
|
||||
// 不设 img.src = '':空字符串会向页面 URL 发一次请求(控制台 ERR_UNKNOWN_URL_SCHEME)。
|
||||
// 不设 src 属性时 <img> 什么都不做,缩略图到了再赋上即可。
|
||||
else loadThumb(ctx, st, it, key).then((url) => { if (url && img.isConnected !== false) img.src = url })
|
||||
// 异步分支才判存活(等图期间宫格可能已被下一次重建丢掉,旧 img 不该再赋值)
|
||||
else loadThumb(ctx, st, it, key).then((u) => { if (u && img.isConnected) applyThumb(u) })
|
||||
btn.appendChild(img)
|
||||
btn.appendChild(el('span', { className: 'iwb-album-idx' }, String(index + 1)))
|
||||
// 批次角标(右上角那个「1」)已删除:顶栏「N 张 → M 个任务」已经说清楚,角标是重复信息,
|
||||
@@ -442,21 +494,25 @@
|
||||
// ── 缩略图取用:内存 → 插件文件 → 现做 ───────────────────
|
||||
// 并发去重(1.1.0):格子一挂载就各自要缩略图,而 addPaths 又顺序预热一遍 ⇒ 同一张图会被读两次盘。
|
||||
// 用 pending 表把同 key 的请求合成一个 Promise(否则导入 30 张会解 60 次原图,内存直接翻倍)。
|
||||
async function loadThumb (ctx, st, it, key) {
|
||||
if (st.thumbs.has(key)) return st.thumbs.get(key)
|
||||
async function loadThumb (ctx, st, it, key, force) {
|
||||
const forced = !!force || !!(st.forceThumbs && st.forceThumbs.has(key))
|
||||
if (!forced && st.thumbs.has(key)) return st.thumbs.get(key)
|
||||
const flight = st.pending && st.pending.get(key)
|
||||
if (flight) return flight
|
||||
const p = loadThumbInner(ctx, st, it, key).finally(() => { if (st.pending) st.pending.delete(key) })
|
||||
if (flight && !forced) return flight
|
||||
const p = loadThumbInner(ctx, st, it, key, forced).finally(() => { if (st.pending) st.pending.delete(key) })
|
||||
if (st.pending) st.pending.set(key, p)
|
||||
return p
|
||||
}
|
||||
async function loadThumbInner (ctx, st, it, key) {
|
||||
if (st.thumbs.has(key)) return st.thumbs.get(key)
|
||||
const name = thumbNameOf(key)
|
||||
async function loadThumbInner (ctx, st, it, key, force) {
|
||||
if (!force && st.thumbs.has(key)) return st.thumbs.get(key)
|
||||
// 读缓存要试两个后缀:同一个 key 可能存成 png(含透明)或 jpg(照片)。
|
||||
// 先 png 不会误命中 —— 透明图只可能存 png,照片只可能存 jpg。
|
||||
try {
|
||||
if (ctx.files) {
|
||||
const got = await ctx.files.get(name)
|
||||
if (got && got.ok && got.url) { st.thumbs.set(key, got.url); return got.url }
|
||||
if (!force && ctx.files) {
|
||||
for (const name of thumbNames(key)) {
|
||||
const got = await ctx.files.get(name)
|
||||
if (got && got.ok && got.url) { st.thumbs.set(key, got.url); return got.url }
|
||||
}
|
||||
}
|
||||
} catch (e) { /* 没缓存就现做 */ }
|
||||
let dataUrl = ''
|
||||
@@ -467,12 +523,20 @@
|
||||
else dataUrl = await ctx.images.dataUrl(src)
|
||||
} catch (e) { dataUrl = '' }
|
||||
if (!dataUrl) return ''
|
||||
const thumb = await makeThumb(dataUrl)
|
||||
if (!thumb) return ''
|
||||
st.thumbs.set(key, thumb)
|
||||
const made = await makeThumb(dataUrl)
|
||||
if (!made || !made.url) return ''
|
||||
st.thumbs.set(key, made.url)
|
||||
if (st.forceThumbs) st.forceThumbs.delete(key)
|
||||
// 内存里已经有一张就够本会话用了;写盘失败(配额满)不影响显示
|
||||
try { if (ctx.files) await ctx.files.put(name, thumb) } catch (e) { /* ignore */ }
|
||||
return thumb
|
||||
try {
|
||||
if (ctx.files) {
|
||||
const put = await ctx.files.put(thumbNameOf(key, made.ext), made.url)
|
||||
// 写成功才清旧:换格式留下的另一份、以及 1.1.5 的黑底 JPEG。
|
||||
// 写失败(如 64MB 配额满)就先都留着,别把唯一一份也删了。
|
||||
if (!put || put.ok !== false) dropThumbFile(ctx, key, made.ext)
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
return made.url
|
||||
}
|
||||
|
||||
// ── 看大图:插件自带全屏查看器(1.1.2 起支持 ← → 切换)──────────
|
||||
@@ -645,7 +709,7 @@
|
||||
function clearAll (ctx, st) {
|
||||
const items = itemsOf(st.node)
|
||||
if (!items.length) return
|
||||
st.thumbs.clear(); st.pending.clear(); st.missing.clear()
|
||||
st.thumbs.clear(); st.pending.clear(); st.missing.clear(); if (st.forceThumbs) st.forceThumbs.clear()
|
||||
st.checkedMissing = false // 清空后再导入要重新做一次失联检测
|
||||
closeViewer(st) // 正在看大图时清空 ⇒ 先把浮层收掉(别留个没有数据的空查看器)
|
||||
update(st.props, st.node, { items: [], page: 0, pageRange: null }, true)
|
||||
@@ -696,7 +760,33 @@
|
||||
st.busy = '导入 ' + (i + 1) + '/' + list.length; st.sig = ''; sync(ctx, st, st.node, st.props)
|
||||
const ref = await ctx.images.reference(list[i])
|
||||
if (!ref || !ref.ok) continue
|
||||
items.push({ src: { __file: ref.item.path }, name: ref.item.name, size: ref.item.size, mtime: ref.item.mtime, on: true })
|
||||
const nextSrc = { __file: ref.item.path }
|
||||
// 重选同一文件夹:按归一化路径就地更新,不追加重复项(旧实现会让坏格一直留在前面,
|
||||
// 新加的重复项排到后面/下一页,看起来就是「重新选择也不出缩略图」)。
|
||||
let at = -1
|
||||
for (let k = 0; k < items.length; k++) {
|
||||
const p0 = fileRefOf(items[k] && items[k].src)
|
||||
if (p0 && normPath(p0) === normPath(ref.item.path)) { at = k; break }
|
||||
}
|
||||
if (at >= 0) {
|
||||
const old = items[at]
|
||||
const oldKey = thumbKeyOf(old)
|
||||
items[at] = Object.assign({}, old, { src: nextSrc, name: ref.item.name, size: ref.item.size, mtime: ref.item.mtime, on: true })
|
||||
st.missing.delete(fileRefOf(old && old.src))
|
||||
st.missing.delete(ref.item.path)
|
||||
st.thumbs.delete(oldKey)
|
||||
if (st.forceThumbs) st.forceThumbs.add(oldKey)
|
||||
dropThumbFile(ctx, oldKey)
|
||||
// 路径大小写/分隔符不同 ⇒ 新 key 也要清掉旧缓存并强制重读
|
||||
const newKey = thumbKeyOf(items[at])
|
||||
if (newKey !== oldKey) {
|
||||
st.thumbs.delete(newKey)
|
||||
if (st.forceThumbs) st.forceThumbs.add(newKey)
|
||||
dropThumbFile(ctx, newKey)
|
||||
}
|
||||
} else {
|
||||
items.push({ src: nextSrc, name: ref.item.name, size: ref.item.size, mtime: ref.item.mtime, on: true })
|
||||
}
|
||||
}
|
||||
st.busy = ''
|
||||
st.checkedMissing = false // 新图要重新做一次失联检测(否则清空后再导入,检测永远不再跑)
|
||||
@@ -716,8 +806,10 @@
|
||||
}
|
||||
st.busy = ''
|
||||
st.btnAdd.textContent = '+ 添加图片'
|
||||
st.sig = ''
|
||||
sync(ctx, st, st.node, st.props)
|
||||
// 预生成只是「提前把缩略图做进缓存」:格子自己的 loadThumb 早在上面那次 sync 里就发起了,
|
||||
// pending 表已把同一张合成一个 Promise。这里**不再**置空 sig 强制整块重建 ——
|
||||
// 1.1.5 每次导入末尾都会多建一遍全部格子(500 张导入 = 白建 500 个 DOM),是肉眼可见的卡顿;
|
||||
// 而它当年还掩盖了缩略图赋值的问题(重建恰好把所有格子都变成「命中缓存 → 空白」)。
|
||||
}
|
||||
|
||||
async function importDropped (ctx, st, files) {
|
||||
@@ -737,12 +829,12 @@
|
||||
if (!src) continue
|
||||
const name = f.name || ('图 ' + (items.length + 1))
|
||||
items.push({ src, name: name, size: f.size || 0, on: true })
|
||||
const thumb = await makeThumb(dataUrl)
|
||||
const made = await makeThumb(dataUrl)
|
||||
// 键必须和 cellOf / loadThumb 完全一致(thumbKeyOf),否则写进缓存也命中不到
|
||||
if (thumb) {
|
||||
if (made && made.url) {
|
||||
const key = thumbKeyOf(items[items.length - 1])
|
||||
st.thumbs.set(key, thumb)
|
||||
try { if (ctx.files) await ctx.files.put(thumbNameOf(key), thumb) } catch (e) { /* ignore */ }
|
||||
st.thumbs.set(key, made.url)
|
||||
try { if (ctx.files) await ctx.files.put(thumbNameOf(key, made.ext), made.url) } catch (e) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
st.busy = ''
|
||||
@@ -812,7 +904,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'album',
|
||||
name: '相册',
|
||||
version: '1.1.4',
|
||||
version: '1.1.6',
|
||||
apiVersion: 1,
|
||||
capabilities: ['nodeTypes', 'images', 'files'],
|
||||
settings: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "album",
|
||||
"name": "相册",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -14,7 +14,7 @@
|
||||
"出图"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "7e092c7b38842661fde9bd301306609b38f3927c7025d97f4ab29bfc04683914",
|
||||
"main.js": "c60ddff7a9200f8b74ff7519506be1748205b5172b104ed0e1ce84c747b4f650",
|
||||
"styles.css": "f8af2310bc5fe099f726f05b5234f928fe31a651f2143c96c88e474b9797fdf7"
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
"dir": "album",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"files": {
|
||||
"main.js": "7e092c7b38842661fde9bd301306609b38f3927c7025d97f4ab29bfc04683914",
|
||||
"main.js": "c60ddff7a9200f8b74ff7519506be1748205b5172b104ed0e1ce84c747b4f650",
|
||||
"styles.css": "f8af2310bc5fe099f726f05b5234f928fe31a651f2143c96c88e474b9797fdf7"
|
||||
}
|
||||
},
|
||||
@@ -75,9 +75,9 @@
|
||||
},
|
||||
{
|
||||
"id": "sticky",
|
||||
"file": "plugin-sticky.af8e7249f0c7.js",
|
||||
"version": "1.0.7",
|
||||
"integrity": "sha256-r45ySfDHwBDMFUTuWpOpq21cJcqlYtq5DnOKUtndSLI="
|
||||
"file": "plugin-sticky.f5f77ac81467.js",
|
||||
"version": "1.0.8",
|
||||
"integrity": "sha256-9fd6yBRnWxcDNDN1G+KywL9vp5JN9CaTMja4s5pK1As="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
@@ -280,19 +280,55 @@
|
||||
body.addEventListener('input', onInput)
|
||||
|
||||
st._listeners = { tools: onTool, pal: onPal, color: onColor, input: onInput, dblclick: onDblClick, setEditing: setEditing }
|
||||
|
||||
// 宽度变化 → 重新算行数(2026-11-26)。宿主改卡片宽度的时机都不经过 render:
|
||||
// 拖右下角改宽、左右侧栏开合、首帧布局落后于脚本。没有这条监听时,
|
||||
// 「先窄后宽」会让 textarea 一直按窄的时候的行数留高度 —— 文字下面就多出一行空白。
|
||||
if (typeof global.ResizeObserver === 'function') {
|
||||
try {
|
||||
st.ro = new global.ResizeObserver(function () {
|
||||
// 宿主销毁节点后 observer 会继续活着:发现骨架已摘除就自我断开
|
||||
if (st.root && st.root.isConnected === false) { try { st.ro.disconnect() } catch (e3) { /* noop */ } st.ro = null; return }
|
||||
var d = (st.node && st.node.data) || {}
|
||||
fitBody(st, d.text == null ? '' : String(d.text), normSize(d.fontSize == null ? DEFAULT_SIZE : d.fontSize))
|
||||
fitOuterBox(st, st.node)
|
||||
})
|
||||
st.ro.observe(body)
|
||||
} catch (e3) { st.ro = null }
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
// textarea 高度贴字:数据(文本/字号)变了才重算,避免每次 render 都 reflow。
|
||||
// textarea 高度贴字:文本 / 字号 / **宽度** 变了才重算,避免每次 render 都 reflow。
|
||||
// 设 auto → 读 scrollHeight → 写回,是 textarea 自适应的标准做法;浏览器里行数/自动换行都算准。
|
||||
//
|
||||
// 2026-11-26(用户反馈「文字下面又多出一行空白行」,v1.0.4 修过又回来了):
|
||||
// ① 旧实现只比 text/size ⇒ **宽度一变就沿用旧行数的高度**。宿主会在这些时候改卡片宽度:
|
||||
// 拖动改宽、左右侧栏开合、首帧还没布局完(clientWidth=0 时会算出很多行)。宽了以后
|
||||
// 文本少一行,高度却按多一行留着 —— 正好在文字下面空一整行。
|
||||
// ② scrollHeight 是整数像素,line-height 1.7×14=23.8 时每行都有取整误差,累加后同样表现为
|
||||
// 「多出半行到一行」。改成先按行数取整、再乘回去。
|
||||
function fitBody(st, text, size) {
|
||||
if (st.fitText === text && st.fitSize === size) return
|
||||
st.fitText = text; st.fitSize = size
|
||||
var b = st.body
|
||||
var w = b.clientWidth || 0
|
||||
if (st.fitText === text && st.fitSize === size && st.fitW === w) return
|
||||
st.fitText = text; st.fitSize = size; st.fitW = w
|
||||
var padY = 24
|
||||
var lineH = Math.round(size * 1.7) || 24
|
||||
try {
|
||||
var cs = global.getComputedStyle ? global.getComputedStyle(b) : null
|
||||
if (cs) {
|
||||
var pt = parseFloat(cs.paddingTop), pb = parseFloat(cs.paddingBottom)
|
||||
if (isFinite(pt) && isFinite(pb)) padY = pt + pb
|
||||
var lh = parseFloat(cs.lineHeight)
|
||||
if (isFinite(lh) && lh > 0) lineH = lh
|
||||
}
|
||||
} catch (e) { /* noop */ }
|
||||
var prev = b.style.height
|
||||
b.style.height = 'auto'
|
||||
var h = b.scrollHeight
|
||||
b.style.height = (h && h > 0 ? h : Math.max(1, text.split('\n').length) * Math.round(size * 1.7) + 24) + 'px'
|
||||
var raw = b.scrollHeight
|
||||
var lines = (raw > 0 && lineH > 0) ? Math.max(1, Math.round((raw - padY) / lineH)) : Math.max(1, String(text).split('\n').length)
|
||||
b.style.height = Math.round(lines * lineH + padY) + 'px'
|
||||
// 高度没变就不留空字符串(兼容 stub:style.height 是普通对象)
|
||||
if (!b.style.height && prev) b.style.height = prev
|
||||
}
|
||||
@@ -441,7 +477,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'sticky',
|
||||
name: '便利贴',
|
||||
version: '1.0.7',
|
||||
version: '1.0.8',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'nodeTypes', 'canvas'],
|
||||
}, function (ctx) {
|
||||
@@ -212,11 +212,8 @@ const minifiedCss = transformSync(cssRaw, {
|
||||
}).code
|
||||
fs.writeFileSync(path.join(dist, 'style.css'), minifiedCss)
|
||||
|
||||
fs.copyFileSync(path.join(root, 'favicon.svg'), path.join(dist, 'favicon.svg'))
|
||||
// PWA(2026-11-07):可安装 —— manifest + 图标(iOS 额外要 apple-touch-icon 的 PNG)
|
||||
for (const f of ['manifest.webmanifest', 'icon-192.png', 'icon-512.png', 'apple-touch-icon.png']) {
|
||||
fs.copyFileSync(path.join(root, f), path.join(dist, f))
|
||||
}
|
||||
// 2026-11-26:PWA 安装面已移除(根目录 favicon/icon-*/apple-touch-icon/manifest 已删)。
|
||||
// sw.js 保留:它不只服务 PWA,还负责版本更新检测和 /__iwb_cache__ 图片缓存直出,删了会破图。
|
||||
// 第三方许可随部署产物一起分发(MIT 要求随软件保留版权与许可声明)
|
||||
fs.copyFileSync(path.join(root, 'THIRD_PARTY_NOTICES.md'), path.join(dist, 'THIRD_PARTY_NOTICES.md'))
|
||||
fs.copyFileSync(path.join(root, 'vendor/react.production.min.js'), path.join(dist, 'vendor/react.production.min.js'))
|
||||
@@ -234,12 +231,7 @@ const html = `<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>无限画布</title>
|
||||
<link rel="icon" type="image/svg+xml" href="favicon.svg">
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<meta name="theme-color" content="#2563eb">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-title" content="无限画布">
|
||||
<link rel="stylesheet" href="style.css?v=${version}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -60,3 +60,12 @@ for (const key of ['version', 'packageVersion', 'commit']) {
|
||||
if (!meta[key] || String(meta[key]).length === 0) fail('dist/version.json.' + key + ' 为空')
|
||||
}
|
||||
pass('dist/version.json 的 version/packageVersion/commit 均非空')
|
||||
|
||||
// 6. PWA 安装面已移除(2026-11-26):根图标/manifest 不再进 dist,也不能再被 index.html 引用。
|
||||
// sw.js 必须保留:它负责更新检测和 /__iwb_cache__ 图片直出,不是纯 PWA 安装面。
|
||||
for (const f of ['favicon.svg', 'manifest.webmanifest', 'icon-192.png', 'icon-512.png', 'apple-touch-icon.png']) {
|
||||
if (fs.existsSync(path.join(dist, f))) fail('dist/' + f + ' 不应存在(PWA 安装面已移除)')
|
||||
if (html.includes(f)) fail('dist/index.html 仍引用已删除的 ' + f)
|
||||
}
|
||||
if (!fs.existsSync(path.join(dist, 'sw.js'))) fail('dist/sw.js 必须保留(更新检测 + 图片缓存)')
|
||||
pass('PWA 图标/manifest 未进 dist,index.html 无引用;sw.js 保留')
|
||||
@@ -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.102-mwwtwp33">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.107-mwx4ugck">
|
||||
<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.102</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.107</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
|
||||
@@ -57,18 +57,18 @@
|
||||
<h2>下载</h2>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Apple Silicon<div class="hint">M1 / M2 / M3 / M4</div></div>
|
||||
<div class="meta">版本 3.26.102 · 8.4 MB · .dmg<div class="hash">sha256 da83189ca8d192dd…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.102_aarch64.dmg?h=da83189ca8d1">下载</a>
|
||||
<div class="meta">版本 3.26.107 · 9.1 MB · .dmg<div class="hash">sha256 64793c8fb7bb7333…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.107_aarch64.dmg?h=64793c8fb7bb">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.26.102 · 8.8 MB · .dmg<div class="hash">sha256 bb1558f02f85158f…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.102_x64.dmg?h=bb1558f02f85">下载</a>
|
||||
<div class="meta">版本 3.26.107 · 9.5 MB · .dmg<div class="hash">sha256 1b2b869f242dbd72…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.107_x64.dmg?h=1b2b869f242d">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
<div class="meta"></div>
|
||||
<span class="muted">暂未提供</span>
|
||||
<div class="meta">版本 3.26.107 · 5.0 MB · .exe<div class="hash">sha256 bc4848bd4b071183…</div></div>
|
||||
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.107_x64-setup.exe?h=bc4848bd4b07">下载</a>
|
||||
</div>
|
||||
|
||||
<h2>系统要求</h2>
|
||||
@@ -97,6 +97,26 @@
|
||||
</ol>
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<div class="row">
|
||||
<div class="name">3.26.107<div class="hint">双母图图标:macOS 满幅消除系统底板,Windows 保留圆角并修复边缘不透明灰</div></div>
|
||||
<div class="meta">2026-11-26<div class="hint">Windows · x64 / macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.106<div class="hint">复制粘贴通道重写(mac ⌘C/⌘V 一条命令贴一切);mac 应用图标修复(Dock 不再空白方块);便利贴 1.0.8 宽度变化不算高度;相册 1.1.6</div></div>
|
||||
<div class="meta">2026-11-26<div class="hint">Windows · x64 / macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.105<div class="hint">新版应用图标(全平台);沿用 3.26.104 的相册外部路径重启复授权、重选与缩略图自愈</div></div>
|
||||
<div class="meta">2026-11-26<div class="hint">Windows · x64 / macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.104<div class="hint">移除 PWA 图标面;相册外部路径重启复授权;相册重选与缩略图自愈</div></div>
|
||||
<div class="meta">2026-11-26<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.103</div>
|
||||
<div class="meta">2026-11-26<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.102</div>
|
||||
<div class="meta">2026-11-26<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta name="description" content="本地优先的 AI 生图无限画布:节点式工作流、插件按需安装、数据全部留在本机。">
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.102-mwwtwp33">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.107-mwx4ugck">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
@@ -17,19 +17,19 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.102</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.107</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.102-mwwtwp33" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.107-mwx4ugck" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.26.102 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.26.107 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.102</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.107</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 13 个插件</a>
|
||||
</div>
|
||||
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="grid c3">
|
||||
<div class="pcard" data-name="相册 album 一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点 图片 批量 出图" data-tags="图片,批量,出图">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
|
||||
<div><div class="nm">相册</div><div class="ver">v1.1.4 · 官方</div></div></div>
|
||||
<div><div class="nm">相册</div><div class="ver">v1.1.6 · 官方</div></div></div>
|
||||
<div class="desc">一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点</div>
|
||||
<div class="tags"><span class="tag">图片</span><span class="tag">批量</span><span class="tag">出图</span></div>
|
||||
</div>
|
||||
@@ -96,9 +96,9 @@
|
||||
<section class="section"><div class="wrap">
|
||||
<h2>下载 Image Workbench</h2>
|
||||
<p class="lead">选你的平台。装过一次之后,以后在应用内「设置 → 通用 → 版本与更新」就能一键升级。</p>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.102_aarch64.dmg?h=da83189ca8d1"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 8.4 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.26.102_x64.dmg?h=bb1558f02f85"><div class="n">macOS · Intel</div><div class="s">x86_64 · 8.8 MB · .dmg</div></a>
|
||||
<div class="none"><div class="n">Windows · x64</div><div class="s">暂未提供</div></div></div>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.107_aarch64.dmg?h=64793c8fb7bb"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 9.1 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.26.107_x64.dmg?h=1b2b869f242d"><div class="n">macOS · Intel</div><div class="s">x86_64 · 9.5 MB · .dmg</div></a>
|
||||
<a href="/updates/windows-x86_64/image-workbench_3.26.107_x64-setup.exe?h=bc4848bd4b07"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.0 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>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"updatedAt": "2026-11-25T23:18:13.578Z",
|
||||
"updatedAt": "2026-11-26T04:51:02.845Z",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "album",
|
||||
@@ -14,21 +14,21 @@
|
||||
"批量",
|
||||
"出图"
|
||||
],
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/album-1.1.4.zip",
|
||||
"bundleSize": 59308,
|
||||
"bundleSha256": "f722811371af7f9b704c18a7d49ade8aa09790deda30b4d5abe120c8520fc850",
|
||||
"bundle": "plugins/album-1.1.6.zip",
|
||||
"bundleSize": 65652,
|
||||
"bundleSha256": "d80b65dd39bc3b76bc53e6870a0222086e14300fb056053ab10cf9a382966a45",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "ee785ced93da4d27656fe7a0c1c43004ccbd784d8292f5e4fd4c58c3930fbf18",
|
||||
"sha256": "8c5bbd41027fa975a959513180543dd2020d7f8fc8ffc3310ea17dd688a80f4e",
|
||||
"size": 593
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "7e092c7b38842661fde9bd301306609b38f3927c7025d97f4ab29bfc04683914",
|
||||
"size": 46716
|
||||
"sha256": "c60ddff7a9200f8b74ff7519506be1748205b5172b104ed0e1ce84c747b4f650",
|
||||
"size": 53060
|
||||
},
|
||||
{
|
||||
"path": "styles.css",
|
||||
@@ -315,27 +315,27 @@
|
||||
"标注",
|
||||
"便签"
|
||||
],
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"apiVersion": 1,
|
||||
"bundle": "plugins/sticky-1.0.7.zip",
|
||||
"bundleSize": 25425,
|
||||
"bundleSha256": "1087fc1a8f842145e75cfca909acb0caf839fbf7349de6a7eee1d112843df369",
|
||||
"bundle": "plugins/sticky-1.0.8.zip",
|
||||
"bundleSize": 27653,
|
||||
"bundleSha256": "4bbb4292be53548837aeae73f41ba0c79de942859fb75b584e40e12efd5c6331",
|
||||
"files": [
|
||||
{
|
||||
"path": "manifest.json",
|
||||
"sha256": "17e5bf6fb11cfe6d7748957d902f3e78585cdb7a1df44b387fd6dbdcae3a7958",
|
||||
"sha256": "b0b79e4eb1ffe076845d55c7c1ffda28893ce7c8d1849e91463867bb1f9f5e95",
|
||||
"size": 400
|
||||
},
|
||||
{
|
||||
"path": "main.js",
|
||||
"sha256": "af8e7249f0c7c010cc1544ee5a93a9ab6d5c25caa562dab90e738a52d9dd48b2",
|
||||
"size": 24811
|
||||
"sha256": "f5f77ac814675b17033433751be2b2c0bf6fa7924df426933236b8b39a4ad40b",
|
||||
"size": 27039
|
||||
}
|
||||
],
|
||||
"file": "plugins/plugin-sticky.af8e7249f0c7.js",
|
||||
"size": 24811,
|
||||
"sha256": "af8e7249f0c7c010cc1544ee5a93a9ab6d5c25caa562dab90e738a52d9dd48b2",
|
||||
"integrity": "sha256-r45ySfDHwBDMFUTuWpOpq21cJcqlYtq5DnOKUtndSLI="
|
||||
"file": "plugins/plugin-sticky.f5f77ac81467.js",
|
||||
"size": 27039,
|
||||
"sha256": "f5f77ac814675b17033433751be2b2c0bf6fa7924df426933236b8b39a4ad40b",
|
||||
"integrity": "sha256-9fd6yBRnWxcDNDN1G+KywL9vp5JN9CaTMja4s5pK1As="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<title>插件市场 · Image Workbench</title>
|
||||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.102-mwwtwp33">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.107-mwx4ugck">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.102</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.107</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
@@ -52,7 +52,7 @@
|
||||
<div class="grid c3" id="list">
|
||||
<div class="pcard" data-name="相册 album 一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点 图片 批量 出图" data-tags="图片,批量,出图">
|
||||
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
|
||||
<div><div class="nm">相册</div><div class="ver">v1.1.4 · 官方</div></div></div>
|
||||
<div><div class="nm">相册</div><div class="ver">v1.1.6 · 官方</div></div></div>
|
||||
<div class="desc">一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点</div>
|
||||
<div class="tags"><span class="tag">图片</span><span class="tag">批量</span><span class="tag">出图</span></div>
|
||||
</div>
|
||||
@@ -106,7 +106,7 @@
|
||||
</div>
|
||||
<div class="pcard" data-name="便利贴 sticky 画布便利贴:多行文本 + 字号/粗细调节 + 8 色背景,纯说明不连线 标注 便签" data-tags="标注,便签">
|
||||
<div class="head"><span class="av" style="background:#fdf3d0">📝</span>
|
||||
<div><div class="nm">便利贴</div><div class="ver">v1.0.7 · 官方</div></div></div>
|
||||
<div><div class="nm">便利贴</div><div class="ver">v1.0.8 · 官方</div></div></div>
|
||||
<div class="desc">画布便利贴:多行文本 + 字号/粗细调节 + 8 色背景,纯说明不连线</div>
|
||||
<div class="tags"><span class="tag">标注</span><span class="tag">便签</span></div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,141 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-11-26T00:43:16.757Z",
|
||||
"updatedAt": "2026-11-26T05:49:27.903Z",
|
||||
"releases": [
|
||||
{
|
||||
"version": "3.26.107",
|
||||
"date": "2026-11-26",
|
||||
"notes": "双母图图标:macOS 满幅消除系统底板,Windows 保留圆角并修复边缘不透明灰",
|
||||
"platforms": {
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.107_x64-setup.exe",
|
||||
"size": 5252408,
|
||||
"sha256": "bc4848bd4b0711838db578d31b7958ed5633e266d3fb5465ee2c5bab7c1dc3d4",
|
||||
"h": "bc4848bd4b07",
|
||||
"kind": "exe"
|
||||
},
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.107_aarch64.dmg",
|
||||
"size": 9514172,
|
||||
"sha256": "64793c8fb7bb73331c51dba5890e253add880bc3288610cb24d27774d2d90921",
|
||||
"h": "64793c8fb7bb",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.107_x64.dmg",
|
||||
"size": 9927853,
|
||||
"sha256": "1b2b869f242dbd7258891e8882a3df2aa0b5cff89d4a023a7573680d59a923ff",
|
||||
"h": "1b2b869f242d",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.106",
|
||||
"date": "2026-11-26",
|
||||
"notes": "复制粘贴通道重写(mac ⌘C/⌘V 一条命令贴一切);mac 应用图标修复(Dock 不再空白方块);便利贴 1.0.8 宽度变化不算高度;相册 1.1.6",
|
||||
"platforms": {
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.106_x64-setup.exe",
|
||||
"size": 5130099,
|
||||
"sha256": "1f16e0e13ed4471e0d56d336ed6f8ebc80bf55f3bc59eb31ae410b3a344bff55",
|
||||
"h": "1f16e0e13ed4",
|
||||
"kind": "exe"
|
||||
},
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.106_aarch64.dmg",
|
||||
"size": 9087129,
|
||||
"sha256": "12e8ee9e1f6b102faac67eb63be60b80cc9ded2acd0977ddf029ef927207526f",
|
||||
"h": "12e8ee9e1f6b",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.106_x64.dmg",
|
||||
"size": 9507225,
|
||||
"sha256": "b26ff4734d0a15261ebd83a11393b9483f712f69d57d0a289fe32a856508d465",
|
||||
"h": "b26ff4734d0a",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.105",
|
||||
"date": "2026-11-26",
|
||||
"notes": "新版应用图标(全平台);沿用 3.26.104 的相册外部路径重启复授权、重选与缩略图自愈",
|
||||
"platforms": {
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.105_x64-setup.exe",
|
||||
"size": 5129261,
|
||||
"sha256": "b127dbd7ab63a524a2ffb702b3d106a79a6153358ee421c6eb7b46411684d0bf",
|
||||
"h": "b127dbd7ab63",
|
||||
"kind": "exe"
|
||||
},
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.105_aarch64.dmg",
|
||||
"size": 8912251,
|
||||
"sha256": "0e108477525cb9303c850a2bef4dde198d1157af306a185f4be4337a5562b008",
|
||||
"h": "0e108477525c",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.105_x64.dmg",
|
||||
"size": 9333409,
|
||||
"sha256": "736441831110ccdff1959c3e3aec954574cbcbc51265cb27d4be17d0a3eca89c",
|
||||
"h": "736441831110",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.104",
|
||||
"date": "2026-11-26",
|
||||
"notes": "移除 PWA 图标面;相册外部路径重启复授权;相册重选与缩略图自愈",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.104_aarch64.dmg",
|
||||
"size": 8817895,
|
||||
"sha256": "dd043537e4f93e444c6266810d6daf8fbd1d79102977244316f2429481217e04",
|
||||
"h": "dd043537e4f9",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.104_x64.dmg",
|
||||
"size": 9233401,
|
||||
"sha256": "95a4b97f13f2bf396c37d9c455c1ed6698db696b9cca411e414e8ce3cd92343f",
|
||||
"h": "95a4b97f13f2",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.26.104_x64-setup.exe",
|
||||
"size": 5116258,
|
||||
"sha256": "63213fc5b2e0ec460f42de7dc55f73f98748cabe3f0bb4bfee6ce255513fd037",
|
||||
"h": "63213fc5b2e0",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.103",
|
||||
"date": "2026-11-26",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.103_aarch64.dmg",
|
||||
"size": 8838704,
|
||||
"sha256": "82a32ef490bf5d8ebb0ef570dac232e28639d6f1a8cd0104ab711a37a490c979",
|
||||
"h": "82a32ef490bf",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.103_x64.dmg",
|
||||
"size": 9256749,
|
||||
"sha256": "9ed07d7f3b978773fa40ba1f6d734e9f15f6ee0c229cdb20ab418fb1bc97b56a",
|
||||
"h": "9ed07d7f3b97",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.102",
|
||||
"date": "2026-11-26",
|
||||
|
||||
@@ -1983,7 +1983,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.102"
|
||||
version = "3.26.104"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.102"
|
||||
version = "3.26.107"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 1013 B After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 118 KiB |
@@ -2,7 +2,10 @@ use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use tauri::menu::{IsMenuItem, Menu, MenuItem, PredefinedMenuItem, Submenu};
|
||||
use tauri::tray::TrayIconBuilder;
|
||||
use tauri::webview::NewWindowResponse;
|
||||
use tauri::{AppHandle, Emitter, Manager, PhysicalPosition, PhysicalSize, WebviewUrl, WebviewWindowBuilder, WindowEvent};
|
||||
use tauri::{
|
||||
AppHandle, Emitter, Manager, PhysicalPosition, PhysicalSize, WebviewUrl, WebviewWindowBuilder,
|
||||
WindowEvent,
|
||||
};
|
||||
use tauri_plugin_fs::FsExt; // 提供 fs_scope():运行时给「资料目录」授权
|
||||
|
||||
// 「是否正在真正退出」:托盘菜单的「退出」或 Cmd+Q 才会置位,
|
||||
@@ -31,14 +34,21 @@ fn geom_file(app: &AppHandle, label: &str) -> Option<std::path::PathBuf> {
|
||||
// 只在窗口处于普通状态时记录:最大化/全屏时的尺寸不是用户想恢复的那个尺寸。
|
||||
// 按 label 取窗口,主窗口与浏览器窗口共用同一套机制,各自存各自的文件。
|
||||
fn save_geom(app: &AppHandle, label: &str) {
|
||||
let Some(win) = app.get_window(label) else { return };
|
||||
let Some(win) = app.get_window(label) else {
|
||||
return;
|
||||
};
|
||||
if win.is_maximized().unwrap_or(false) || win.is_fullscreen().unwrap_or(false) {
|
||||
return;
|
||||
}
|
||||
let (Ok(size), Ok(pos)) = (win.inner_size(), win.outer_position()) else {
|
||||
return;
|
||||
};
|
||||
let g = WindowGeom { x: pos.x, y: pos.y, w: size.width, h: size.height };
|
||||
let g = WindowGeom {
|
||||
x: pos.x,
|
||||
y: pos.y,
|
||||
w: size.width,
|
||||
h: size.height,
|
||||
};
|
||||
if let Some(p) = geom_file(app, label) {
|
||||
if let Some(dir) = p.parent() {
|
||||
let _ = std::fs::create_dir_all(dir);
|
||||
@@ -51,10 +61,18 @@ fn save_geom(app: &AppHandle, label: &str) {
|
||||
|
||||
// 恢复上次窗口大小与位置;中心点不在任何显示器内就只恢复尺寸(换过显示器不至于把窗口丢到屏幕外)
|
||||
fn restore_geom(app: &AppHandle, label: &str, min_w: u32, min_h: u32) {
|
||||
let Some(win) = app.get_window(label) else { return };
|
||||
let Some(p) = geom_file(app, label) else { return };
|
||||
let Ok(txt) = std::fs::read_to_string(p) else { return };
|
||||
let Ok(g) = serde_json::from_str::<WindowGeom>(&txt) else { return };
|
||||
let Some(win) = app.get_window(label) else {
|
||||
return;
|
||||
};
|
||||
let Some(p) = geom_file(app, label) else {
|
||||
return;
|
||||
};
|
||||
let Ok(txt) = std::fs::read_to_string(p) else {
|
||||
return;
|
||||
};
|
||||
let Ok(g) = serde_json::from_str::<WindowGeom>(&txt) else {
|
||||
return;
|
||||
};
|
||||
// 最小尺寸与窗口下限对齐:否则会恢复出一个比下限还小的窗口
|
||||
// (曾实测 1051x488 时画布渲染成空白)
|
||||
let w = g.w.max(min_w);
|
||||
@@ -68,7 +86,10 @@ fn restore_geom(app: &AppHandle, label: &str, min_w: u32, min_h: u32) {
|
||||
ms.iter().any(|m| {
|
||||
let mp = m.position();
|
||||
let ms = m.size();
|
||||
cx >= mp.x && cx <= mp.x + ms.width as i32 && cy >= mp.y && cy <= mp.y + ms.height as i32
|
||||
cx >= mp.x
|
||||
&& cx <= mp.x + ms.width as i32
|
||||
&& cy >= mp.y
|
||||
&& cy <= mp.y + ms.height as i32
|
||||
})
|
||||
})
|
||||
.unwrap_or(false);
|
||||
@@ -113,7 +134,12 @@ fn build_tray(app: &AppHandle) -> tauri::Result<()> {
|
||||
|
||||
// 所有平台统一:左键点图标 = 显示/聚焦主窗口(macOS 也照做,菜单改到右键)
|
||||
builder = builder.on_tray_icon_event(|tray, event| {
|
||||
if let tauri::tray::TrayIconEvent::Click { button: tauri::tray::MouseButton::Left, button_state: tauri::tray::MouseButtonState::Up, .. } = event {
|
||||
if let tauri::tray::TrayIconEvent::Click {
|
||||
button: tauri::tray::MouseButton::Left,
|
||||
button_state: tauri::tray::MouseButtonState::Up,
|
||||
..
|
||||
} = event
|
||||
{
|
||||
show_main(tray.app_handle());
|
||||
}
|
||||
});
|
||||
@@ -138,7 +164,9 @@ fn build_tray(app: &AppHandle) -> tauri::Result<()> {
|
||||
{
|
||||
if let Some(icon) = app.default_window_icon().cloned() {
|
||||
builder = builder.icon(icon);
|
||||
} else if let Ok(ic) = tauri::image::Image::from_bytes(include_bytes!("../icons/tray-template.png")) {
|
||||
} else if let Ok(ic) =
|
||||
tauri::image::Image::from_bytes(include_bytes!("../icons/tray-template.png"))
|
||||
{
|
||||
// 兜底:极端情况拿不到主图标,仍给一张,避免空托盘
|
||||
builder = builder.icon(ic);
|
||||
}
|
||||
@@ -160,19 +188,21 @@ fn app_memory_mb() -> u64 {
|
||||
let out = std::process::Command::new("ps")
|
||||
.args(["-o", "rss=", "-p", &pid.to_string()])
|
||||
.output();
|
||||
if let Ok(o) = out {
|
||||
if o.status.success() {
|
||||
let txt = String::from_utf8_lossy(&o.stdout);
|
||||
if let Ok(kb) = txt.trim().parse::<u64>() {
|
||||
return kb / 1024;
|
||||
}
|
||||
if let Ok(o) = out
|
||||
&& o.status.success()
|
||||
{
|
||||
let txt = String::from_utf8_lossy(&o.stdout);
|
||||
if let Ok(kb) = txt.trim().parse::<u64>() {
|
||||
return kb / 1024;
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use windows_sys::Win32::System::ProcessStatus::{GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS};
|
||||
use windows_sys::Win32::System::ProcessStatus::{
|
||||
GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS,
|
||||
};
|
||||
use windows_sys::Win32::System::Threading::GetCurrentProcess;
|
||||
let mut pmc: PROCESS_MEMORY_COUNTERS = unsafe { std::mem::zeroed() };
|
||||
pmc.cb = std::mem::size_of::<PROCESS_MEMORY_COUNTERS>() as u32;
|
||||
@@ -196,33 +226,51 @@ fn app_memory_mb() -> u64 {
|
||||
const FILE_GRANTS_FILE: &str = "file-grants.json";
|
||||
|
||||
fn file_grants_path(app: &AppHandle) -> Option<std::path::PathBuf> {
|
||||
app.path().app_config_dir().ok().map(|c| c.join(FILE_GRANTS_FILE))
|
||||
app.path()
|
||||
.app_config_dir()
|
||||
.ok()
|
||||
.map(|c| c.join(FILE_GRANTS_FILE))
|
||||
}
|
||||
|
||||
fn persist_file_grants(app: &AppHandle, paths: &[String]) {
|
||||
let Some(p) = file_grants_path(app) else { return };
|
||||
let Some(p) = file_grants_path(app) else {
|
||||
return;
|
||||
};
|
||||
let mut list: Vec<String> = std::fs::read_to_string(&p)
|
||||
.ok()
|
||||
.and_then(|s| serde_json::from_str::<Vec<String>>(&s).ok())
|
||||
.unwrap_or_default();
|
||||
for x in paths {
|
||||
if !x.is_empty() && !list.iter().any(|y| y == x) { list.push(x.clone()) }
|
||||
if !x.is_empty() && !list.iter().any(|y| y == x) {
|
||||
list.push(x.clone())
|
||||
}
|
||||
}
|
||||
if let Some(dir) = p.parent() {
|
||||
let _ = std::fs::create_dir_all(dir);
|
||||
}
|
||||
if let Ok(txt) = serde_json::to_vec(&list) {
|
||||
let _ = std::fs::write(&p, txt);
|
||||
}
|
||||
if let Some(dir) = p.parent() { let _ = std::fs::create_dir_all(dir); }
|
||||
if let Ok(txt) = serde_json::to_vec(&list) { let _ = std::fs::write(&p, txt); }
|
||||
}
|
||||
|
||||
fn restore_file_grants(app: &AppHandle) {
|
||||
let Some(p) = file_grants_path(app) else { return };
|
||||
let Some(p) = file_grants_path(app) else {
|
||||
return;
|
||||
};
|
||||
let list: Vec<String> = std::fs::read_to_string(&p)
|
||||
.ok()
|
||||
.and_then(|s| serde_json::from_str::<Vec<String>>(&s).ok())
|
||||
.unwrap_or_default();
|
||||
for raw in list {
|
||||
let p = std::path::PathBuf::from(&raw);
|
||||
if !p.is_absolute() || !p.exists() { continue }
|
||||
if p.is_dir() { let _ = app.fs_scope().allow_directory(&p, true); }
|
||||
else { let _ = app.fs_scope().allow_file(&p); }
|
||||
if !p.is_absolute() || !p.exists() {
|
||||
continue;
|
||||
}
|
||||
if p.is_dir() {
|
||||
let _ = app.fs_scope().allow_directory(&p, true);
|
||||
} else {
|
||||
let _ = app.fs_scope().allow_file(&p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +291,9 @@ fn grant_paths(app: AppHandle, paths: Vec<String>) -> Result<Vec<String>, String
|
||||
ok.push(p.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
if !ok.is_empty() { persist_file_grants(&app, &ok); }
|
||||
if !ok.is_empty() {
|
||||
persist_file_grants(&app, &ok);
|
||||
}
|
||||
Ok(ok)
|
||||
}
|
||||
|
||||
@@ -259,11 +309,11 @@ fn grant_dir(app: AppHandle, dir: String, record: Option<bool>) -> Result<String
|
||||
.map_err(|e| e.to_string())?;
|
||||
// 只有「资料目录」才记进配置(record 默认 true);下载目录等传 record=false,
|
||||
// 否则会把 data-dir.txt 覆盖成别的目录,导致「打开」跳到错误位置。
|
||||
if record.unwrap_or(true) {
|
||||
if let Ok(cfg) = app.path().app_config_dir() {
|
||||
let _ = std::fs::create_dir_all(&cfg);
|
||||
let _ = std::fs::write(cfg.join("data-dir.txt"), p.to_string_lossy().as_bytes());
|
||||
}
|
||||
if record.unwrap_or(true)
|
||||
&& let Ok(cfg) = app.path().app_config_dir()
|
||||
{
|
||||
let _ = std::fs::create_dir_all(&cfg);
|
||||
let _ = std::fs::write(cfg.join("data-dir.txt"), p.to_string_lossy().as_bytes());
|
||||
}
|
||||
Ok(p.to_string_lossy().to_string())
|
||||
}
|
||||
@@ -276,19 +326,34 @@ fn copy_tree(src: String, dst: String) -> Result<u64, String> {
|
||||
for e in std::fs::read_dir(from)? {
|
||||
let e = e?;
|
||||
let name = e.file_name();
|
||||
if name.to_string_lossy() == "trash" { continue } // 回收站不搬
|
||||
if name.to_string_lossy() == "trash" {
|
||||
continue;
|
||||
} // 回收站不搬
|
||||
let f = e.path();
|
||||
let t = to.join(&name);
|
||||
if e.file_type()?.is_dir() { walk(&f, &t, n)? } else { std::fs::copy(&f, &t)?; *n += 1 }
|
||||
if e.file_type()?.is_dir() {
|
||||
walk(&f, &t, n)?
|
||||
} else {
|
||||
std::fs::copy(&f, &t)?;
|
||||
*n += 1
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
let s = std::path::PathBuf::from(&src);
|
||||
let d = std::path::PathBuf::from(&dst);
|
||||
if !s.is_dir() { return Err("源目录不存在".into()) }
|
||||
if d.starts_with(&s) { return Err("目标不能放在源目录里面".into()) }
|
||||
if d.exists() && std::fs::read_dir(&d).map(|mut i| i.next().is_some()).unwrap_or(false) {
|
||||
return Err("目标目录不是空目录".into())
|
||||
if !s.is_dir() {
|
||||
return Err("源目录不存在".into());
|
||||
}
|
||||
if d.starts_with(&s) {
|
||||
return Err("目标不能放在源目录里面".into());
|
||||
}
|
||||
if d.exists()
|
||||
&& std::fs::read_dir(&d)
|
||||
.map(|mut i| i.next().is_some())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return Err("目标目录不是空目录".into());
|
||||
}
|
||||
std::fs::create_dir_all(&d).map_err(|e| e.to_string())?;
|
||||
let mut n = 0u64;
|
||||
@@ -313,8 +378,13 @@ fn open_data_subpath(app: AppHandle, rel: String) -> Result<String, String> {
|
||||
None => app.path().app_data_dir().map_err(|e| e.to_string())?,
|
||||
};
|
||||
let base = base.canonicalize().map_err(|e| e.to_string())?;
|
||||
let target = base.join(rel.trim_start_matches('/')).canonicalize().map_err(|e| e.to_string())?;
|
||||
if !target.starts_with(&base) { return Err("路径不在资料目录内".into()); }
|
||||
let target = base
|
||||
.join(rel.trim_start_matches('/'))
|
||||
.canonicalize()
|
||||
.map_err(|e| e.to_string())?;
|
||||
if !target.starts_with(&base) {
|
||||
return Err("路径不在资料目录内".into());
|
||||
}
|
||||
std::fs::create_dir_all(&target).map_err(|e| e.to_string())?;
|
||||
let path = target.to_string_lossy().to_string();
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -394,7 +464,9 @@ async fn install_update(app: tauri::AppHandle) -> Result<bool, String> {
|
||||
use tauri::Emitter;
|
||||
let updater = app.updater().map_err(|e| e.to_string())?;
|
||||
let found = updater.check().await.map_err(|e| e.to_string())?;
|
||||
let Some(update) = found else { return Ok(false) };
|
||||
let Some(update) = found else {
|
||||
return Ok(false);
|
||||
};
|
||||
// 真实下载进度(v3.26.95):updater 的 on_chunk 能拿到累计字节与总大小,
|
||||
// 通过事件窗口送回前端画外圈进度环。80ms 节流,避免每个 chunk 都跨进程投递。
|
||||
let emit_app = app.clone();
|
||||
@@ -408,16 +480,22 @@ async fn install_update(app: tauri::AppHandle) -> Result<bool, String> {
|
||||
let done = total.map(|t| downloaded >= t).unwrap_or(false);
|
||||
if last_emit.elapsed().as_millis() >= 80 || done {
|
||||
last_emit = std::time::Instant::now();
|
||||
let _ = emit_app.emit("iwb-update-progress", serde_json::json!({
|
||||
"phase": "downloading",
|
||||
"downloaded": downloaded,
|
||||
"total": total
|
||||
}));
|
||||
let _ = emit_app.emit(
|
||||
"iwb-update-progress",
|
||||
serde_json::json!({
|
||||
"phase": "downloading",
|
||||
"downloaded": downloaded,
|
||||
"total": total
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
move || {
|
||||
// 下载完成 → 进入安装(签名校验/替换文件),这一段没有字节级进度
|
||||
let _ = done_app.emit("iwb-update-progress", serde_json::json!({ "phase": "installing" }));
|
||||
let _ = done_app.emit(
|
||||
"iwb-update-progress",
|
||||
serde_json::json!({ "phase": "installing" }),
|
||||
);
|
||||
},
|
||||
)
|
||||
.await
|
||||
@@ -436,12 +514,18 @@ async fn browser_bookmarks_menu(
|
||||
groups: Vec<serde_json::Value>,
|
||||
current_url: String,
|
||||
) -> Result<bool, String> {
|
||||
let win = app.get_window("main").ok_or_else(|| "主窗口不存在".to_string())?;
|
||||
let win = app
|
||||
.get_window("main")
|
||||
.ok_or_else(|| "主窗口不存在".to_string())?;
|
||||
// 收藏目标组:单组菜单 → 该组;「所有书签」→ 空(插件落第一个组)。
|
||||
// 用户点「海报」里的收藏,应该进「海报」,而不是永远进第一个组「常用」。
|
||||
let single = !mode.is_empty();
|
||||
let add_group = if single { mode.clone() } else { String::new() };
|
||||
let add_id = format!("bm-add:{}:{}", b64_encode(add_group.as_bytes()), b64_encode(current_url.as_bytes()));
|
||||
let add_id = format!(
|
||||
"bm-add:{}:{}",
|
||||
b64_encode(add_group.as_bytes()),
|
||||
b64_encode(current_url.as_bytes())
|
||||
);
|
||||
let add_item = MenuItem::with_id(
|
||||
&app,
|
||||
add_id,
|
||||
@@ -460,20 +544,33 @@ async fn browser_bookmarks_menu(
|
||||
for g in groups.iter() {
|
||||
let gname = g.get("name").and_then(|v| v.as_str()).unwrap_or("收藏夹");
|
||||
let gid = g.get("id").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if single && gid != mode.as_str() { continue; }
|
||||
let items = g.get("items").and_then(|v| v.as_array()).cloned().unwrap_or_default();
|
||||
if single && gid != mode.as_str() {
|
||||
continue;
|
||||
}
|
||||
let items = g
|
||||
.get("items")
|
||||
.and_then(|v| v.as_array())
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
if single {
|
||||
// 单组模式:不再重复显示分组名(用户指出那一层是多余的)
|
||||
if items.is_empty() {
|
||||
let empty = MenuItem::with_id(
|
||||
&app, format!("bm-empty:{counter}"), "这个分组还没有书签", false, None::<&str>,
|
||||
).map_err(|e| e.to_string())?;
|
||||
&app,
|
||||
format!("bm-empty:{counter}"),
|
||||
"这个分组还没有书签",
|
||||
false,
|
||||
None::<&str>,
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
owned_items.push(empty);
|
||||
}
|
||||
for it in items.iter() {
|
||||
let title = it.get("title").and_then(|v| v.as_str()).unwrap_or("书签");
|
||||
let url = it.get("url").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if url.is_empty() { continue; }
|
||||
if url.is_empty() {
|
||||
continue;
|
||||
}
|
||||
counter += 1;
|
||||
let id = format!("bm-open:{}:{}", counter, b64_encode(url.as_bytes()));
|
||||
let mi = MenuItem::with_id(&app, id, title, true, None::<&str>)
|
||||
@@ -486,7 +583,9 @@ async fn browser_bookmarks_menu(
|
||||
for it in items.iter() {
|
||||
let title = it.get("title").and_then(|v| v.as_str()).unwrap_or("书签");
|
||||
let url = it.get("url").and_then(|v| v.as_str()).unwrap_or("");
|
||||
if url.is_empty() { continue; }
|
||||
if url.is_empty() {
|
||||
continue;
|
||||
}
|
||||
counter += 1;
|
||||
let id = format!("bm-open:{}:{}", counter, b64_encode(url.as_bytes()));
|
||||
let mi = MenuItem::with_id(&app, id, title, true, None::<&str>)
|
||||
@@ -495,22 +594,32 @@ async fn browser_bookmarks_menu(
|
||||
}
|
||||
if g_items.is_empty() {
|
||||
let empty = MenuItem::with_id(
|
||||
&app, format!("bm-empty:{}", counter), "(空)", false, None::<&str>,
|
||||
).map_err(|e| e.to_string())?;
|
||||
&app,
|
||||
format!("bm-empty:{}", counter),
|
||||
"(空)",
|
||||
false,
|
||||
None::<&str>,
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
g_items.push(empty);
|
||||
}
|
||||
let mut grefs: Vec<&dyn IsMenuItem<tauri::Wry>> = Vec::new();
|
||||
for mi in g_items.iter() { grefs.push(mi); }
|
||||
let sub = Submenu::with_items(&app, gname, true, &grefs)
|
||||
.map_err(|e| e.to_string())?;
|
||||
for mi in g_items.iter() {
|
||||
grefs.push(mi);
|
||||
}
|
||||
let sub = Submenu::with_items(&app, gname, true, &grefs).map_err(|e| e.to_string())?;
|
||||
owned_subs.push(sub);
|
||||
}
|
||||
}
|
||||
|
||||
if single {
|
||||
for mi in owned_items.iter() { refs.push(mi); }
|
||||
for mi in owned_items.iter() {
|
||||
refs.push(mi);
|
||||
}
|
||||
} else {
|
||||
for sub in owned_subs.iter() { refs.push(sub); }
|
||||
for sub in owned_subs.iter() {
|
||||
refs.push(sub);
|
||||
}
|
||||
}
|
||||
let menu = Menu::with_items(&app, &refs).map_err(|e| e.to_string())?;
|
||||
win.popup_menu(&menu).map_err(|e| e.to_string())?;
|
||||
@@ -677,22 +786,22 @@ mod macos {
|
||||
let mut out: Vec<PathBuf> = Vec::new();
|
||||
let pb = NSPasteboard::generalPasteboard();
|
||||
let ty_url = NSString::from_str("public.file-url");
|
||||
if let Some(s) = pb.stringForType(&ty_url) {
|
||||
if let Some(p) = file_url_to_path(&s.to_string()) {
|
||||
out.push(p);
|
||||
}
|
||||
if let Some(s) = pb.stringForType(&ty_url)
|
||||
&& let Some(p) = file_url_to_path(&s.to_string())
|
||||
{
|
||||
out.push(p);
|
||||
}
|
||||
if out.is_empty() {
|
||||
let ty_names = NSString::from_str("NSFilenamesPboardType");
|
||||
if let Some(plist) = pb.propertyListForType(&ty_names) {
|
||||
if let Ok(arr) = plist.downcast::<NSArray>() {
|
||||
for item in arr.iter() {
|
||||
// 元素理论上是 NSString(路径),但 plist 是弱类型的,逐个降级判断
|
||||
if let Some(s) = item.downcast_ref::<NSString>() {
|
||||
if let Some(p) = file_url_to_path(&s.to_string()) {
|
||||
out.push(p);
|
||||
}
|
||||
}
|
||||
if let Some(plist) = pb.propertyListForType(&ty_names)
|
||||
&& let Ok(arr) = plist.downcast::<NSArray>()
|
||||
{
|
||||
for item in arr.iter() {
|
||||
// 元素理论上是 NSString(路径),但 plist 是弱类型的,逐个降级判断
|
||||
if let Some(s) = item.downcast_ref::<NSString>()
|
||||
&& let Some(p) = file_url_to_path(&s.to_string())
|
||||
{
|
||||
out.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -706,10 +815,10 @@ mod macos {
|
||||
if s.is_empty() {
|
||||
return None;
|
||||
}
|
||||
if let Ok(u) = url::Url::parse(s) {
|
||||
if let Ok(p) = u.to_file_path() {
|
||||
return Some(p);
|
||||
}
|
||||
if let Ok(u) = url::Url::parse(s)
|
||||
&& let Ok(p) = u.to_file_path()
|
||||
{
|
||||
return Some(p);
|
||||
}
|
||||
// NSFilenamesPboardType 给的本来就是裸路径
|
||||
let p = PathBuf::from(s);
|
||||
@@ -786,7 +895,9 @@ fn clipboard_read_image() -> Result<Option<ClipPayload>, String> {
|
||||
#[tauri::command]
|
||||
fn clipboard_write_image(png_base64: String) -> Result<bool, String> {
|
||||
let bytes = b64_decode(&png_base64)?;
|
||||
let img = image::load_from_memory(&bytes).map_err(|e| e.to_string())?.to_rgba8();
|
||||
let img = image::load_from_memory(&bytes)
|
||||
.map_err(|e| e.to_string())?
|
||||
.to_rgba8();
|
||||
let (w, h) = (img.width() as usize, img.height() as usize);
|
||||
let mut cb = Clipboard::new().map_err(|e| e.to_string())?;
|
||||
cb.set_image(arboard::ImageData {
|
||||
@@ -798,11 +909,14 @@ fn clipboard_write_image(png_base64: String) -> Result<bool, String> {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
|
||||
fn open_external(url: &str) -> Result<(), String> {
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
std::process::Command::new("open").arg(url).spawn().map(|_| ()).map_err(|e| e.to_string())
|
||||
std::process::Command::new("open")
|
||||
.arg(url)
|
||||
.spawn()
|
||||
.map(|_| ())
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
@@ -814,7 +928,11 @@ fn open_external(url: &str) -> Result<(), String> {
|
||||
}
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
{
|
||||
std::process::Command::new("xdg-open").arg(url).spawn().map(|_| ()).map_err(|e| e.to_string())
|
||||
std::process::Command::new("xdg-open")
|
||||
.arg(url)
|
||||
.spawn()
|
||||
.map(|_| ())
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -868,12 +986,12 @@ async fn open_browser_window(app: AppHandle, url: String) -> Result<bool, String
|
||||
.center()
|
||||
.on_new_window(move |url, _features| {
|
||||
// 独立浏览器窗口里点画板等 target="_blank" 链接:原地导航,不弹新窗口。
|
||||
if let Some(url) = new_window_url(url) {
|
||||
if let Some(win) = app_for_new_window.get_webview_window("browser") {
|
||||
let _ = win.navigate(url.clone());
|
||||
if let Some(host) = url.host_str().filter(|h| !h.is_empty()) {
|
||||
let _ = win.set_title(host);
|
||||
}
|
||||
if let Some(url) = new_window_url(url)
|
||||
&& let Some(win) = app_for_new_window.get_webview_window("browser")
|
||||
{
|
||||
let _ = win.navigate(url.clone());
|
||||
if let Some(host) = url.host_str().filter(|h| !h.is_empty()) {
|
||||
let _ = win.set_title(host);
|
||||
}
|
||||
}
|
||||
NewWindowResponse::Deny
|
||||
@@ -946,23 +1064,28 @@ static CWV_ROUND_CALLS: AtomicU64 = AtomicU64::new(0);
|
||||
// 画布网页的运行时诊断日志(_cwv.log,落在 app_config_dir)。
|
||||
// 子 webview 建不起来时,渲染层只拿到一个 Err 字符串,落盘日志能还原「哪一步断的」。
|
||||
fn cwv_log(app: &AppHandle, msg: &str) {
|
||||
let Ok(dir) = app.path().app_config_dir() else { return };
|
||||
let Ok(dir) = app.path().app_config_dir() else {
|
||||
return;
|
||||
};
|
||||
let p = dir.join("_cwv.log");
|
||||
// 超过 256KB 只留尾部 32KB:长跑时不能无上限增长
|
||||
if let Ok(meta) = std::fs::metadata(&p) {
|
||||
if meta.len() > 256 * 1024 {
|
||||
if let Ok(bytes) = std::fs::read(&p) {
|
||||
let keep = bytes.len().saturating_sub(32 * 1024);
|
||||
let _ = std::fs::write(&p, &bytes[keep..]);
|
||||
}
|
||||
}
|
||||
if let Ok(meta) = std::fs::metadata(&p)
|
||||
&& meta.len() > 256 * 1024
|
||||
&& let Ok(bytes) = std::fs::read(&p)
|
||||
{
|
||||
let keep = bytes.len().saturating_sub(32 * 1024);
|
||||
let _ = std::fs::write(&p, &bytes[keep..]);
|
||||
}
|
||||
let ts = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_millis())
|
||||
.unwrap_or(0);
|
||||
use std::io::Write;
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open(&p) {
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(&p)
|
||||
{
|
||||
let _ = f.write_all(format!("[{}] {}\n", ts, msg).as_bytes());
|
||||
}
|
||||
}
|
||||
@@ -975,7 +1098,15 @@ fn cwv_label(id: &str) -> String {
|
||||
.filter(|c| c.is_ascii_alphanumeric() || *c == '-' || *c == '_')
|
||||
.take(40)
|
||||
.collect();
|
||||
format!("{}{}", CWV_PREFIX, if cleaned.is_empty() { "x".into() } else { cleaned })
|
||||
format!(
|
||||
"{}{}",
|
||||
CWV_PREFIX,
|
||||
if cleaned.is_empty() {
|
||||
"x".into()
|
||||
} else {
|
||||
cleaned
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn cwv_parse(url: &str) -> Result<url::Url, String> {
|
||||
@@ -1033,7 +1164,12 @@ fn cwv_rect(x: f64, y: f64, w: f64, h: f64, ox: f64, oy: f64) -> tauri::Rect {
|
||||
const CWV_RADIUS: f64 = 14.0;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn cwv_round(app: &AppHandle, wv: &tauri::webview::Webview<tauri::Wry>, zoom: f64, base: Option<f64>) {
|
||||
fn cwv_round(
|
||||
app: &AppHandle,
|
||||
wv: &tauri::webview::Webview<tauri::Wry>,
|
||||
zoom: f64,
|
||||
base: Option<f64>,
|
||||
) {
|
||||
let base = match base {
|
||||
Some(b) if b.is_finite() && b > 0.0 => b.clamp(2.0, 40.0),
|
||||
_ => CWV_RADIUS,
|
||||
@@ -1070,7 +1206,13 @@ fn cwv_round(app: &AppHandle, wv: &tauri::webview::Webview<tauri::Wry>, zoom: f6
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn cwv_round(_app: &AppHandle, _wv: &tauri::webview::Webview<tauri::Wry>, _zoom: f64, _base: Option<f64>) {}
|
||||
fn cwv_round(
|
||||
_app: &AppHandle,
|
||||
_wv: &tauri::webview::Webview<tauri::Wry>,
|
||||
_zoom: f64,
|
||||
_base: Option<f64>,
|
||||
) {
|
||||
}
|
||||
|
||||
// 窗口边框尺寸 vs 内容视图尺寸。
|
||||
//
|
||||
@@ -1084,7 +1226,9 @@ fn cwv_round(_app: &AppHandle, _wv: &tauri::webview::Webview<tauri::Wry>, _zoom:
|
||||
// 差值自然回到 0,不需要额外分支。
|
||||
#[tauri::command]
|
||||
async fn canvas_webview_metrics(app: AppHandle) -> Result<serde_json::Value, String> {
|
||||
let win = app.get_window("main").ok_or_else(|| "主窗口不存在".to_string())?;
|
||||
let win = app
|
||||
.get_window("main")
|
||||
.ok_or_else(|| "主窗口不存在".to_string())?;
|
||||
let size = win.inner_size().map_err(|e| e.to_string())?;
|
||||
let scale = win.scale_factor().unwrap_or(1.0);
|
||||
Ok(serde_json::json!({
|
||||
@@ -1096,6 +1240,8 @@ async fn canvas_webview_metrics(app: AppHandle) -> Result<serde_json::Value, Str
|
||||
|
||||
// 确保某节点对应的子 webview 存在。返回 true = 这次真的新建了。
|
||||
#[tauri::command]
|
||||
// 同 canvas_webview_bounds:参数由前端 invoke 决定,且属 Windows 死锁修复路径。
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn canvas_webview_ensure(
|
||||
app: AppHandle,
|
||||
id: String,
|
||||
@@ -1114,7 +1260,10 @@ async fn canvas_webview_ensure(
|
||||
if let Some(wv) = app.get_webview(&label) {
|
||||
// 已存在:只校正 bounds(不 show/hide —— 见文件头约束 1)
|
||||
if let Err(e) = wv.set_bounds(cwv_rect(x, y, w, h, ox, oy)) {
|
||||
cwv_log(&app, &format!("ensure:bounds-err label={} err={}", label, e));
|
||||
cwv_log(
|
||||
&app,
|
||||
&format!("ensure:bounds-err label={} err={}", label, e),
|
||||
);
|
||||
}
|
||||
if let Some(z) = zoom {
|
||||
let _ = wv.set_zoom(z);
|
||||
@@ -1135,8 +1284,8 @@ async fn canvas_webview_ensure(
|
||||
let built = window.add_child(
|
||||
tauri::webview::WebviewBuilder::new(&label, WebviewUrl::External(parsed.clone()))
|
||||
.on_page_load(|wv, payload| {
|
||||
use tauri::webview::PageLoadEvent;
|
||||
use tauri::Emitter;
|
||||
use tauri::webview::PageLoadEvent;
|
||||
let kind = match payload.event() {
|
||||
PageLoadEvent::Started => "started",
|
||||
PageLoadEvent::Finished => "finished",
|
||||
@@ -1152,18 +1301,17 @@ async fn canvas_webview_ensure(
|
||||
.on_new_window(move |url, _features| {
|
||||
// 左侧栏面板 / 画布网页节点共用这个 builder:画板详情等新开标签链接
|
||||
// 统一在当前 webview 原地打开,地址栏由 cwv-page 事件自动回填。
|
||||
if let Some(url) = new_window_url(url) {
|
||||
if let Some(wv) = app_for_new_window.get_webview(&label_for_new_window) {
|
||||
if let Err(e) = wv.navigate(url) {
|
||||
cwv_log(
|
||||
&app_for_new_window,
|
||||
&format!(
|
||||
"new-window:navigate-err label={} err={}",
|
||||
label_for_new_window, e
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(url) = new_window_url(url)
|
||||
&& let Some(wv) = app_for_new_window.get_webview(&label_for_new_window)
|
||||
&& let Err(e) = wv.navigate(url)
|
||||
{
|
||||
cwv_log(
|
||||
&app_for_new_window,
|
||||
&format!(
|
||||
"new-window:navigate-err label={} err={}",
|
||||
label_for_new_window, e
|
||||
),
|
||||
);
|
||||
}
|
||||
NewWindowResponse::Deny
|
||||
}),
|
||||
@@ -1174,14 +1322,20 @@ async fn canvas_webview_ensure(
|
||||
Ok(wv) => {
|
||||
// add_child 传入的 bounds 在部分 macOS 版本上不立刻生效,用 set_bounds 再摆一次
|
||||
if let Err(e) = wv.set_bounds(cwv_rect(x, y, w, h, ox, oy)) {
|
||||
cwv_log(&app, &format!("ensure:post-bounds-err label={} err={}", label, e));
|
||||
cwv_log(
|
||||
&app,
|
||||
&format!("ensure:post-bounds-err label={} err={}", label, e),
|
||||
);
|
||||
}
|
||||
// 缩放:页面 CSS 像素按 zoom 放大/缩小,配合「矩形随画布缩放」就能让网页
|
||||
// 像图片一样跟着画布一起缩放,而不是一直按原宽度重排。
|
||||
if let Some(z) = zoom {
|
||||
if let Err(e) = wv.set_zoom(z) {
|
||||
cwv_log(&app, &format!("ensure:zoom-err label={} zoom={} err={}", label, z, e));
|
||||
}
|
||||
if let Some(z) = zoom
|
||||
&& let Err(e) = wv.set_zoom(z)
|
||||
{
|
||||
cwv_log(
|
||||
&app,
|
||||
&format!("ensure:zoom-err label={} zoom={} err={}", label, z, e),
|
||||
);
|
||||
}
|
||||
// 新建后立刻上一次圆角(zoom 缺省按 1 倍)。放 here 而不是等首帧 bounds:
|
||||
// 首帧前视图已经贴到卡片上,直角会闪一下;先设好就不会看到方角。
|
||||
@@ -1205,6 +1359,9 @@ async fn canvas_webview_ensure(
|
||||
// 渲染层推送位置/尺寸/可见性。
|
||||
// 返回 false = Rust 侧没有这个 webview(被 close / 进程重启),前端应回滚并重建。
|
||||
#[tauri::command]
|
||||
// 参数由前端 invoke 的 payload 决定(11 个),拆结构体要同步改 JS 侧调用点,
|
||||
// 且这是 Windows 死锁修复的 async 命令,不在本次重构范围内。
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn canvas_webview_bounds(
|
||||
app: AppHandle,
|
||||
id: String,
|
||||
@@ -1233,10 +1390,13 @@ async fn canvas_webview_bounds(
|
||||
return Err(e.to_string());
|
||||
}
|
||||
// 页面缩放:只在渲染层判定「该改了」时才带过来,避免每条消息都重排一次
|
||||
if let Some(z) = zoom {
|
||||
if let Err(e) = wv.set_zoom(z) {
|
||||
cwv_log(&app, &format!("bounds:zoom-err label={} zoom={} err={}", label, z, e));
|
||||
}
|
||||
if let Some(z) = zoom
|
||||
&& let Err(e) = wv.set_zoom(z)
|
||||
{
|
||||
cwv_log(
|
||||
&app,
|
||||
&format!("bounds:zoom-err label={} zoom={} err={}", label, z, e),
|
||||
);
|
||||
}
|
||||
// 圆角:缩放变了(半径要同比缩放)或用户改了「外观设置 → 节点圆角」时重设。
|
||||
// 两个条件都由渲染层判定,正常拖动时这里是 None,不会每帧跨线程投递。
|
||||
@@ -1244,7 +1404,7 @@ async fn canvas_webview_bounds(
|
||||
cwv_round(&app, &wv, zoom.unwrap_or(1.0), radius);
|
||||
}
|
||||
let n = CWV_BOUNDS_CALLS.fetch_add(1, Ordering::Relaxed);
|
||||
if n < 8 || n % 400 == 0 {
|
||||
if n < 8 || n.is_multiple_of(400) {
|
||||
cwv_log(
|
||||
&app,
|
||||
&format!(
|
||||
@@ -1311,10 +1471,10 @@ async fn canvas_webview_close_all(app: AppHandle) -> Result<u32, String> {
|
||||
.collect();
|
||||
let mut n = 0u32;
|
||||
for label in labels {
|
||||
if let Some(wv) = app.get_webview(&label) {
|
||||
if wv.close().is_ok() {
|
||||
n += 1;
|
||||
}
|
||||
if let Some(wv) = app.get_webview(&label)
|
||||
&& wv.close().is_ok()
|
||||
{
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
if n > 0 {
|
||||
@@ -1348,8 +1508,33 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.invoke_handler(tauri::generate_handler![open_app_data_dir, open_data_subpath, grant_paths, grant_dir, copy_tree, check_update, install_update, clipboard_read_image, clipboard_write_image, clipboard_write_text, clipboard_read_text, open_external_url, open_browser_window, browser_control, browser_state, canvas_webview_ensure, canvas_webview_bounds, canvas_webview_navigate, canvas_webview_action, canvas_webview_state, canvas_webview_close_all, canvas_webview_metrics, browser_bookmarks_menu, notify_desktop,
|
||||
app_memory_mb])
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
open_app_data_dir,
|
||||
open_data_subpath,
|
||||
grant_paths,
|
||||
grant_dir,
|
||||
copy_tree,
|
||||
check_update,
|
||||
install_update,
|
||||
clipboard_read_image,
|
||||
clipboard_write_image,
|
||||
clipboard_write_text,
|
||||
clipboard_read_text,
|
||||
open_external_url,
|
||||
open_browser_window,
|
||||
browser_control,
|
||||
browser_state,
|
||||
canvas_webview_ensure,
|
||||
canvas_webview_bounds,
|
||||
canvas_webview_navigate,
|
||||
canvas_webview_action,
|
||||
canvas_webview_state,
|
||||
canvas_webview_close_all,
|
||||
canvas_webview_metrics,
|
||||
browser_bookmarks_menu,
|
||||
notify_desktop,
|
||||
app_memory_mb
|
||||
])
|
||||
.setup(|app| {
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
@@ -1379,19 +1564,24 @@ pub fn run() {
|
||||
let _ = app.emit(kind, serde_json::json!({ "url": url }));
|
||||
};
|
||||
if let Some(rest) = id.strip_prefix("bm-open:") {
|
||||
if let Some((_n, enc)) = rest.split_once(':') {
|
||||
if let Ok(bytes) = b64_decode(enc) {
|
||||
emit("iwb-bookmark-open", String::from_utf8_lossy(&bytes).to_string());
|
||||
}
|
||||
}
|
||||
} else if let Some(rest) = id.strip_prefix("bm-add:") {
|
||||
if let Some((g, enc)) = rest.split_once(':') {
|
||||
if let (Ok(gb), Ok(bytes)) = (b64_decode(g), b64_decode(enc)) {
|
||||
let url = String::from_utf8_lossy(&bytes).to_string();
|
||||
let group = String::from_utf8_lossy(&gb).to_string();
|
||||
let _ = app.emit("iwb-bookmark-add", serde_json::json!({ "url": url, "groupId": group }));
|
||||
}
|
||||
if let Some((_n, enc)) = rest.split_once(':')
|
||||
&& let Ok(bytes) = b64_decode(enc)
|
||||
{
|
||||
emit(
|
||||
"iwb-bookmark-open",
|
||||
String::from_utf8_lossy(&bytes).to_string(),
|
||||
);
|
||||
}
|
||||
} else if let Some(rest) = id.strip_prefix("bm-add:")
|
||||
&& let Some((g, enc)) = rest.split_once(':')
|
||||
&& let (Ok(gb), Ok(bytes)) = (b64_decode(g), b64_decode(enc))
|
||||
{
|
||||
let url = String::from_utf8_lossy(&bytes).to_string();
|
||||
let group = String::from_utf8_lossy(&gb).to_string();
|
||||
let _ = app.emit(
|
||||
"iwb-bookmark-add",
|
||||
serde_json::json!({ "url": url, "groupId": group }),
|
||||
);
|
||||
}
|
||||
})
|
||||
// 点关闭按钮 ⇒ 记住窗口尺寸后收进托盘(不退出,后台任务继续)
|
||||
@@ -1432,9 +1622,18 @@ mod clip_tests {
|
||||
|
||||
#[test]
|
||||
fn sniff_recognises_common_headers() {
|
||||
assert_eq!(sniff_image_mime(&[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a, 0, 0, 0, 0]), Some("image/png"));
|
||||
assert_eq!(sniff_image_mime(&[0xff, 0xd8, 0xff, 0xe0, 0, 0, 0, 0, 0, 0, 0, 0]), Some("image/jpeg"));
|
||||
assert_eq!(sniff_image_mime(b"\0\0\0\x18ftypheic\0\0\0\0"), Some("image/heic"));
|
||||
assert_eq!(
|
||||
sniff_image_mime(&[0x89, b'P', b'N', b'G', 0x0d, 0x0a, 0x1a, 0x0a, 0, 0, 0, 0]),
|
||||
Some("image/png")
|
||||
);
|
||||
assert_eq!(
|
||||
sniff_image_mime(&[0xff, 0xd8, 0xff, 0xe0, 0, 0, 0, 0, 0, 0, 0, 0]),
|
||||
Some("image/jpeg")
|
||||
);
|
||||
assert_eq!(
|
||||
sniff_image_mime(b"\0\0\0\x18ftypheic\0\0\0\0"),
|
||||
Some("image/heic")
|
||||
);
|
||||
assert_eq!(sniff_image_mime(b"definitely-not-an-image"), None);
|
||||
}
|
||||
|
||||
@@ -1454,7 +1653,9 @@ mod clip_tests {
|
||||
// AppleScript 源码编码弄坏,脚本侧不测,解码逻辑靠 url::Url 保证)
|
||||
let path = dir.join("iwb clip copy two.png");
|
||||
// 2x2 红绿蓝白,用 image 编码一份真实 PNG
|
||||
let px: Vec<u8> = vec![255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 255];
|
||||
let px: Vec<u8> = vec![
|
||||
255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 255,
|
||||
];
|
||||
let mut png: Vec<u8> = Vec::new();
|
||||
{
|
||||
use image::ImageEncoder;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.102",
|
||||
"version": "3.26.107",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
return nodes.length + ' 个节点' + gname
|
||||
}
|
||||
|
||||
/* 标记写两份(2026-11-26):
|
||||
* ① HTML 注释 —— Chromium 侧实测原样保留,粘到别的应用也不显示;
|
||||
* ② `data-iwb-graph` 属性 —— WKWebView(mac 桌面端)在写/读剪贴板时会过一遍 HTML 清洗,
|
||||
* 注释被整段丢掉(实测写入 208 B、读回 414 B、标记消失),属性值能活下来。
|
||||
* 两份带的是同一串 base64,谁活着都能解出来;decode() 两个位置都找。 */
|
||||
function htmlFor(clip) {
|
||||
const payload = JSON.stringify({
|
||||
app: clip && clip.app,
|
||||
@@ -76,7 +81,33 @@
|
||||
groups: (clip && clip.groups) || [],
|
||||
})
|
||||
const head = plainFor(clip)
|
||||
return '<!--' + MARK + encodeText(payload) + '--><div>' + esc(head.slice(0, 200)) + '</div>'
|
||||
const b64 = encodeText(payload)
|
||||
return '<!--' + MARK + b64 + '--><div data-iwb-graph="' + b64 + '">' + esc(head.slice(0, 200)) + '</div>'
|
||||
}
|
||||
|
||||
// 属性形态的标记(引号单双都认:不同应用回写 HTML 时引号风格不一致)
|
||||
function b64FromAttr(s) {
|
||||
const m = /data-iwb-graph\s*=\s*("([^"]*)"|'([^']*)')/i.exec(s)
|
||||
if (!m) return ''
|
||||
return str(m[2] != null ? m[2] : m[3]).replace(/[^A-Za-z0-9+/=]/g, '')
|
||||
}
|
||||
|
||||
function b64FromComment(s) {
|
||||
const i = s.indexOf(MARK)
|
||||
if (i < 0) return ''
|
||||
const start = i + MARK.length
|
||||
const end = s.indexOf('-->', start)
|
||||
const raw = (end > start ? s.slice(start, end) : s.slice(start))
|
||||
return raw.replace(/[^A-Za-z0-9+/=]/g, '')
|
||||
}
|
||||
|
||||
function parseB64(b64) {
|
||||
if (!b64) return null
|
||||
try {
|
||||
const obj = JSON.parse(decodeText(b64))
|
||||
if (!obj || !Array.isArray(obj.nodes) || !obj.nodes.length) return null
|
||||
return obj
|
||||
} catch (e) { return null }
|
||||
}
|
||||
|
||||
/* 从 text/html 里把 clip 取回来。找不到标记、base64 坏掉、JSON 坏掉、nodes 为空
|
||||
@@ -85,18 +116,27 @@
|
||||
* 定位标记,不能假设它以注释开头。 */
|
||||
function decode(html) {
|
||||
const s = str(html)
|
||||
const i = s.indexOf(MARK)
|
||||
if (i < 0) return null
|
||||
const start = i + MARK.length
|
||||
const end = s.indexOf('-->', start)
|
||||
const raw = (end > start ? s.slice(start, end) : s.slice(start))
|
||||
const b64 = raw.replace(/[^A-Za-z0-9+/=]/g, '')
|
||||
if (!b64) return null
|
||||
try {
|
||||
const obj = JSON.parse(decodeText(b64))
|
||||
if (!obj || !Array.isArray(obj.nodes) || !obj.nodes.length) return null
|
||||
return obj
|
||||
} catch (e) { return null }
|
||||
return parseB64(b64FromComment(s)) || parseB64(b64FromAttr(s))
|
||||
}
|
||||
|
||||
/* 在 DOM `copy` 事件里**同步**写系统剪贴板(2026-11-26 起这是复制的主通道)。
|
||||
*
|
||||
* 为什么不用 navigator.clipboard.write:它是异步的,在 WKWebView 里写 text/html 经常被拒,
|
||||
* 失败后只能降级成"纯文本摘要 + matchPlain 全等比对"(脆);而且 mac 上 ⌘C 被原生菜单
|
||||
* Edit>Copy 接管时,keydown 根本到不了 JS,异步那条链路连触发都没有。
|
||||
* clipboardData.setData 由用户手势直接授权、同步生效,Chromium / WKWebView 都可用。
|
||||
*
|
||||
* 同时 notePlain():即使 text/html 被清洗掉,粘贴侧还能靠"纯文本摘要全等"认回节点组。 */
|
||||
function writeToEvent(e, clip) {
|
||||
const dt = e && e.clipboardData
|
||||
if (!dt || typeof dt.setData !== 'function') return false
|
||||
const plain = plainFor(clip)
|
||||
let ok = true
|
||||
try { dt.setData('text/plain', plain) } catch (err) { ok = false }
|
||||
try { dt.setData('text/html', htmlFor(clip)) } catch (err) { ok = false }
|
||||
// 即使 setData 抛错也记账:内部剪贴板与 matchPlain 仍能让 ⌘V 贴回来
|
||||
notePlain(plain, clip)
|
||||
return ok
|
||||
}
|
||||
|
||||
/* 写系统剪贴板。返回 Promise<boolean>:false 表示这个环境写不了
|
||||
@@ -147,5 +187,101 @@
|
||||
return Promise.resolve(T.core.invoke('clipboard_write_text', { text: str(plain) })).then(() => true).catch(() => false)
|
||||
}
|
||||
|
||||
g.IWBClipboardGraph = Object.freeze({ MARK, encodeText, decodeText, htmlFor, plainFor, decode, write, matchPlain })
|
||||
/* 复制主通道:DOM `copy` 事件(2026-11-26)。
|
||||
*
|
||||
* 旧实现只有 keydown 一条路(app.js 的 `hit('copy')`)。mac 桌面端 `Menu::default()` 的
|
||||
* Edit>Copy 绑的是 `copy:` 且 `setAutoenablesItems(false)` 永远 enabled —— 只要第一响应者
|
||||
* 认为"有东西可复制"(可编辑焦点 / 文本选区),AppKit 直接处理掉,keydown 到不了 JS,
|
||||
* 于是"复制节点组"静默失败:没有提示、系统剪贴板没内容,用户觉得是随机 bug。
|
||||
*
|
||||
* 改法:复制统一由 `copy` 事件驱动(原生菜单处理的复制同样会派发这个事件),
|
||||
* keydown 只保留一个兜底定时器(个别 WebView 不派发 copy 事件时才用旧异步链路)。
|
||||
* 判定顺序:有文本选区 → 让原生复制文字;没选中节点 → 让原生走(并说一句没东西可复制,
|
||||
* 否则又是一次"按了没反应")。
|
||||
*/
|
||||
let copyCtxOf = null // 最新的取值函数(Workbench 重挂载后必须换成本次渲染的)
|
||||
let copyBound = null // { onCopy, onKey }:已注册的处理函数,供 unbindCopy 摘除
|
||||
function bindCopy(getCtx) {
|
||||
if (typeof getCtx === 'function') copyCtxOf = getCtx
|
||||
if (copyBound || typeof window === 'undefined' || !window.addEventListener) return
|
||||
let handledAt = 0
|
||||
const ctxNow = () => (copyCtxOf ? copyCtxOf() : null)
|
||||
|
||||
function selOf(ctx) {
|
||||
try { const ids = ctx.ids && ctx.ids(); return Array.isArray(ids) ? ids : [] } catch (e) { return [] }
|
||||
}
|
||||
function textSelected(ctx, el) {
|
||||
const C = g.IWBClipboardCopy
|
||||
try {
|
||||
if (C && typeof C.hasTextSelection === 'function') return !!C.hasTextSelection(el)
|
||||
} catch (e) { /* ignore */ }
|
||||
return false
|
||||
}
|
||||
|
||||
const onCopy = (e) => {
|
||||
const ctx = ctxNow()
|
||||
if (!ctx) return
|
||||
handledAt = Date.now()
|
||||
const ids = selOf(ctx)
|
||||
const t = e && e.target
|
||||
if (textSelected(ctx, t)) return // 用户要复制文字 → 原生
|
||||
if (!ids.length) {
|
||||
// 没选中节点、也没选中文字:原生复制是空操作。明确说一句,别让用户以为按键坏了。
|
||||
if (ctx.setNotice) ctx.setNotice({ type: 'err', text: '没有可复制的节点:先在画布上选中或框选节点' })
|
||||
return
|
||||
}
|
||||
let clip = null
|
||||
try { clip = ctx.clipboardOf ? ctx.clipboardOf(ids) : null } catch (err) { clip = null }
|
||||
if (!clip) {
|
||||
if (ctx.setNotice) ctx.setNotice({ type: 'err', text: '选中的节点无法复制(可能还在加载)' })
|
||||
return
|
||||
}
|
||||
const wrote = writeToEvent(e, clip)
|
||||
if (wrote) {
|
||||
try { e.preventDefault() } catch (err) { /* ignore */ }
|
||||
if (ctx.markSys) ctx.markSys(true)
|
||||
if (ctx.stageClip) ctx.stageClip(clip)
|
||||
return
|
||||
}
|
||||
// setData 不可用(极端环境):让原生走,同时用旧异步链路补写系统剪贴板
|
||||
if (ctx.copyNodes) ctx.copyNodes(ids)
|
||||
}
|
||||
|
||||
/* keydown 兜底:copy 事件没派发时(不派发 `copy` 的 WebView / 焦点在 iframe),
|
||||
* 按旧链路再复制一次。keydown 里**不 preventDefault** —— 一 prevent 就取消了原生复制动作,
|
||||
* `copy` 事件反而不会派发。
|
||||
* 80ms 而不是 0:copy 事件由浏览器在 keydown 的默认动作里同步派发,正常都在 10ms 内到;
|
||||
* 留 80ms 是给"事件稍晚一点"的环境,同时保证「⌘C 之后立刻 ⌘V」时剪贴板已经写好
|
||||
* (旧实现没有延迟,但那条路在 mac 上根本走不到 —— 参见 bindCopy 顶部注释)。 */
|
||||
const onKey = (e) => {
|
||||
if (!(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey) return
|
||||
if (String(e.key || '').toLowerCase() !== 'c') return
|
||||
const ctx = ctxNow()
|
||||
if (!ctx) return
|
||||
const at = Date.now()
|
||||
setTimeout(() => {
|
||||
if (handledAt >= at) return // copy 事件已经处理过
|
||||
const ids = selOf(ctx)
|
||||
if (!ids.length) return
|
||||
if (textSelected(ctx, e.target)) return
|
||||
if (ctx.copyNodes) ctx.copyNodes(ids)
|
||||
}, 80)
|
||||
}
|
||||
|
||||
window.addEventListener('copy', onCopy, true)
|
||||
window.addEventListener('keydown', onKey, true)
|
||||
copyBound = { onCopy, onKey }
|
||||
}
|
||||
|
||||
/* 摘掉监听(Workbench 卸载 / 依赖变化时由 app.js 调用)。
|
||||
* 不摘会出事:关掉画布回到首页后 ⌘C 仍走这条路,闭包里是**已经卸载的那份 refs** ——
|
||||
* 会去复制旧画布上"当时的选中节点",用户在首页按一次 ⌘C 就莫名其妙改了剪贴板。 */
|
||||
function unbindCopy() {
|
||||
if (!copyBound) return
|
||||
try { window.removeEventListener('copy', copyBound.onCopy, true) } catch (e) { /* ignore */ }
|
||||
try { window.removeEventListener('keydown', copyBound.onKey, true) } catch (e) { /* ignore */ }
|
||||
copyBound = null
|
||||
}
|
||||
|
||||
g.IWBClipboardGraph = Object.freeze({ MARK, encodeText, decodeText, htmlFor, plainFor, decode, write, writeToEvent, matchPlain, bindCopy, unbindCopy })
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -2,6 +2,14 @@
|
||||
*
|
||||
* 分工:src/clipboard-kind.js 判定「剪贴板里是什么」,本模块只负责「落成什么」。
|
||||
*
|
||||
* 2026-11-26 通道重写(桌面端 mac 对不上号的真因):
|
||||
* mac 的 WKWebView 只在「第一响应者可编辑」时派发 paste 事件;焦点在画布/body 时 ⌘V
|
||||
* 只有 keydown。旧实现把 Ctrl+V 做成「等 paste 事件 + 弹一句请按 Ctrl+Shift+V」,
|
||||
* 于是节点组在 mac 上等于没有 Ctrl+V 通路。现在:
|
||||
* · paste 事件仍是**首选通道**(有真实 clipboardData,保真度最高);
|
||||
* · keydown ⌘V 由 pasteFromKey() 接管:指针在画布就主动读剪贴板(富读取 → 原生文本 →
|
||||
* 原生图片 → 内部剪贴板),150ms 内等到 paste 事件就让给事件通道,一次按键只贴一份。
|
||||
*
|
||||
* 语义(用户 2026-11-11 二次裁定的心智模型:**一个键贴所有**):
|
||||
* · Ctrl+C 复制节点/节点组时,除了内部剪贴板,还会把节点组写进**系统剪贴板**
|
||||
* (text/html 带 iwb:graph 标记,见 src/clipboard-graph.js)。因此 Ctrl+V 能直接贴节点组,
|
||||
@@ -284,13 +292,156 @@
|
||||
ctx.setNotice({ type: 'ok', text: truncated ? '已粘贴文本为提示词节点(超长已截断到 5000 字)' : '已粘贴文本为提示词节点' })
|
||||
}
|
||||
|
||||
/* ── 焦点 / 鼠标:谁决定「这次粘贴归谁」(2026-11-26)─────────────────────────
|
||||
* 桌面端(mac WKWebView)只有第一响应者可编辑时才会派发 paste 事件;焦点在画布/body 时
|
||||
* ⌘V 只到 keydown。而产品语义是「指哪贴哪」—— 落点看指针(anchor),那接管权也该看指针,
|
||||
* 不能一边用鼠标定落点、一边用键盘焦点决定"能不能贴"。
|
||||
* 规则:指针在画布上 → 这次粘贴归画布(接管);指针不在画布且焦点在输入框 → 放行原生。
|
||||
*/
|
||||
function isEditableEl(el) {
|
||||
if (!el) return false
|
||||
const tag = el.tagName
|
||||
return !!(tag && (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT')) || !!el.isContentEditable
|
||||
}
|
||||
function activeEl() {
|
||||
try { return (typeof document !== 'undefined') ? document.activeElement : null } catch (e) { return null }
|
||||
}
|
||||
function blurActive() {
|
||||
try {
|
||||
const a = /** @type {any} */ (activeEl())
|
||||
if (a && typeof a.blur === 'function') a.blur()
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
// 合成一个「只有文本 / 只有文件」的剪贴板事件,把读取结果交回 handle() 分流
|
||||
function fakeEvent(text, files) {
|
||||
const list = files || []
|
||||
const ev = {
|
||||
clipboardData: {
|
||||
items: list.map((f) => ({ kind: 'file', type: (f && f.type) || '', getAsFile: () => f })),
|
||||
files: list,
|
||||
getData: (t) => (t === 'text/plain' ? str(text) : ''),
|
||||
},
|
||||
defaultPrevented: false,
|
||||
preventDefault() { ev.defaultPrevented = true },
|
||||
}
|
||||
return ev
|
||||
}
|
||||
|
||||
/* 系统剪贴板富读取(只有 Chromium / 有权限时可用)。WKWebView 常常直接 reject,
|
||||
* 所以调用方必须准备好「原生文本 + 原生图片 + 内部剪贴板」三级降级。 */
|
||||
function readSystemClip() {
|
||||
return new Promise((resolve) => {
|
||||
const cb = g.navigator && g.navigator.clipboard
|
||||
if (!cb || typeof cb.read !== 'function') { resolve(null); return }
|
||||
let p = null
|
||||
try { p = cb.read() } catch (e) { resolve(null); return }
|
||||
if (!p || typeof p.then !== 'function') { resolve(null); return }
|
||||
p.then((items) => {
|
||||
const out = { html: '', text: '', files: [] }
|
||||
const todos = []
|
||||
for (const it of (items || [])) {
|
||||
const types = Array.isArray(it && it.types) ? it.types : []
|
||||
if (types.indexOf('text/html') >= 0) todos.push(it.getType('text/html').then((b) => b.text()).then((v) => { out.html = str(v) }).catch(() => {}))
|
||||
if (types.indexOf('text/plain') >= 0) todos.push(it.getType('text/plain').then((b) => b.text()).then((v) => { out.text = str(v) }).catch(() => {}))
|
||||
const img = types.find((t) => str(t).indexOf('image/') === 0)
|
||||
if (img) todos.push(it.getType(img).then((blob) => {
|
||||
try { out.files.push(new g.File([blob], 'clipboard-' + Date.now() + '.png', { type: img })) } catch (e) { out.files.push(blob) }
|
||||
}).catch(() => {}))
|
||||
}
|
||||
Promise.all(todos).then(() => resolve(out)).catch(() => resolve(out))
|
||||
}).catch(() => resolve(null))
|
||||
})
|
||||
}
|
||||
|
||||
function failText(ctx) {
|
||||
if (ctx.refs.clipExpired) return '内部剪贴板已过期(10 分钟),请重新复制节点'
|
||||
return nativeReason() || '剪贴板里没有可粘贴的内容:复制图片 / 文本,或先在画布上选中节点复制'
|
||||
}
|
||||
|
||||
/* 系统剪贴板读不出内容时的最后两级:原生图片(Rust arboard)→ 内部剪贴板。 */
|
||||
function fallbackRead(ctx) {
|
||||
const img = (typeof ctx.readNativeImage === 'function')
|
||||
? Promise.resolve().then(() => ctx.readNativeImage()).catch(() => null)
|
||||
: Promise.resolve(null)
|
||||
return img.then((f) => {
|
||||
if (f) { pasteImages([f], ctx); done(ctx); return }
|
||||
if (ctx.pasteCopiedNodes()) { ctx.setNotice(null); done(ctx); return }
|
||||
ctx.setNotice({ type: 'err', text: failText(ctx) })
|
||||
})
|
||||
}
|
||||
|
||||
/* ⌘V 主动粘贴(keydown,2026-11-26)。
|
||||
*
|
||||
* 返回 true = 这次按下由画布接管(调用方无需再做什么);false = 放行原生(往输入框里粘文本)。
|
||||
*
|
||||
* 为什么不在这里 preventDefault:一 prevent 就取消了原生粘贴动作,有 paste 事件的平台
|
||||
* (Windows / WebView2)反而收不到那次**带真实 clipboardData** 的 paste 事件。所以策略是
|
||||
* 「先让原生走,150ms 内没等到 paste 事件才自己读」—— 两条通道互不打架:
|
||||
* · 有 paste 事件 → handle() 用 clipboardData(保真度最高,连 text/html 标记都在)
|
||||
* · 没 paste 事件(mac 无编辑焦点)→ 这里主动读:系统剪贴板富读取 → 原生文本 → 原生图片 → 内部
|
||||
*/
|
||||
function pasteFromKey(ctx) {
|
||||
if (!ctx) return false
|
||||
if (modalOpen(ctx.ui)) return false
|
||||
const editable = isEditableEl(activeEl())
|
||||
// 焦点在输入框里 → 一律放行原生:用户正在打字,⌘V 的语义是「把文字粘进这里」。
|
||||
// (要贴节点组的话,paste 事件里还有一次机会:指针在画布上就改贴到画布,见 handle())
|
||||
if (editable) return false
|
||||
const at = Date.now()
|
||||
ctx.refs.pasteKeyAt = at
|
||||
ctx.refs.pasteEventAt = 0
|
||||
setTimeout(() => {
|
||||
if (ctx.refs.pasteKeyAt !== at) return // 又按了一次,交给最新那次
|
||||
if (ctx.refs.pasteEventAt && ctx.refs.pasteEventAt >= at) return // paste 事件已处理
|
||||
readSystemClip().then((sys) => {
|
||||
if (ctx.refs.pasteEventAt && ctx.refs.pasteEventAt >= at) return
|
||||
const G = g.IWBClipboardGraph
|
||||
if (sys && sys.html) {
|
||||
const clip = (G && typeof G.decode === 'function') ? G.decode(sys.html) : null
|
||||
if (clip && ctx.pasteGraph(clip, anchor(ctx) || safeSeed(ctx))) { done(ctx); return }
|
||||
}
|
||||
if (sys && sys.files && sys.files.length) { pasteImages(sys.files, ctx); done(ctx); return }
|
||||
if (sys && sys.text) {
|
||||
const ev = fakeEvent(sys.text, [])
|
||||
if (handle(ev, ctx, false)) { done(ctx); return }
|
||||
}
|
||||
// 原生文本(桌面端 arboard)。剪贴板内容是「上次我们自己写进去的摘要」时,
|
||||
// matchPlain 会在 handle() 里把节点组认回来 —— 这是 mac 上 ⌘V 贴节点组的关键一条。
|
||||
const textP = (typeof ctx.readNativeText === 'function')
|
||||
? Promise.resolve().then(() => ctx.readNativeText()).catch(() => '')
|
||||
: Promise.resolve('')
|
||||
textP.then((t) => {
|
||||
const text = str(t)
|
||||
// 上次写系统剪贴板失败(refs.sysClipOk === false)时,剪贴板里是**别人的旧内容**,
|
||||
// 不能当成本次粘的内容;直接走内部剪贴板。
|
||||
if (text && ctx.refs.sysClipOk !== false) {
|
||||
if (handle(fakeEvent(text, []), ctx, false)) { done(ctx); return }
|
||||
}
|
||||
fallbackRead(ctx)
|
||||
})
|
||||
})
|
||||
}, 150)
|
||||
return true
|
||||
}
|
||||
|
||||
// 同步通道真的落了东西 → 记一个短窗口,吞掉紧随其后的重复 paste 事件
|
||||
function done(ctx) {
|
||||
ctx.refs.pasteDoneAt = Date.now()
|
||||
ctx.refs.pasteSwallowUntil = Date.now() + 400
|
||||
}
|
||||
|
||||
/* 主入口。返回 true = 已消费这次 paste。
|
||||
* ctx 见 app.js 里 pasteCtx():refs / ui / readClipboardGraph / pasteCopiedNodes / pasteGraph /
|
||||
* wsId / activeWsId() / nodes() / uid / findSpot / nodeW / nodeH /
|
||||
* pushHistory / commitCanvas / setSel / setNotice / importImage
|
||||
* editable = 焦点在 input/textarea/contenteditable 里(提示词节点内、设置项、放大编辑浮层…) */
|
||||
function handle(e, ctx, editable) {
|
||||
// Ctrl+Shift+V 之后浏览器可能再派发一次「纯文本 paste」(Chrome 行为)→ 在这一窗口内吞掉
|
||||
// 主动粘贴(keydown 通道)刚落地 → 吞掉紧随其后的同一次 paste 事件,避免贴两份
|
||||
if (ctx.refs.pasteSwallowUntil && Date.now() < ctx.refs.pasteSwallowUntil) {
|
||||
e.preventDefault()
|
||||
return true
|
||||
}
|
||||
if (ctx.refs.pasteGroupUntil && Date.now() < ctx.refs.pasteGroupUntil) {
|
||||
ctx.refs.pasteGroupUntil = 0
|
||||
e.preventDefault()
|
||||
@@ -303,8 +454,26 @@
|
||||
// 输入框里:文本 / 链接照样走浏览器原生粘贴(这里**不**接管、不 preventDefault),
|
||||
// 但节点组、非图片文件原来会被**静默吞掉** —— 用户以为粘上了,其实什么都没发生。
|
||||
if (c.kind === 'graph') {
|
||||
ctx.setNotice({ type: 'err', text: '输入框里不能粘贴节点;先点一下画布空白处再按 Ctrl+V' })
|
||||
return false
|
||||
/* 焦点在输入框里粘「复制的节点组」,分三种情形:
|
||||
* ① 指针在画布上 → 这是「贴到画布」的意图:接管,blur 掉焦点、贴到指针处。
|
||||
* 这条正是用户报的那个坑(焦点卡在提示词框里,点节点内空白也不会掉焦点)。
|
||||
* ② 指针不在画布、剪贴板里带着**提示词全文** → 放行原生,用户拿到那段文字
|
||||
* (复制提示词贴到另一个输入框是正经用法,拦掉等于把功能做没了)。
|
||||
* ③ 指针不在画布、只有「N 个节点」摘要 → preventDefault。旧实现只提示不拦,
|
||||
* 摘要会被原生粘贴**打进输入框**,把用户的提示词改掉(实测追加了"1 个节点")。 */
|
||||
if (anchor(ctx) !== null) {
|
||||
e.preventDefault()
|
||||
blurActive()
|
||||
try { const PO = g.IWBPasteOnce; if (PO) PO.disarm() } catch (err) { /* ignore */ }
|
||||
if (!ctx.pasteGraph(c.clip, anchor(ctx) || safeSeed(ctx))) ctx.setNotice({ type: 'err', text: '粘贴节点组失败:剪贴板内容无法识别' })
|
||||
return true
|
||||
}
|
||||
const nodes = (c.clip && Array.isArray(c.clip.nodes)) ? c.clip.nodes : []
|
||||
const hasText = nodes.some((n) => n && n.type === 'prompt' && n.data && typeof n.data.text === 'string' && n.data.text.trim())
|
||||
if (hasText) return false
|
||||
e.preventDefault()
|
||||
ctx.setNotice({ type: 'err', text: '节点组不能粘进输入框:把鼠标移到画布上再按 ⌘V(或右键 → 粘贴节点组)' })
|
||||
return true
|
||||
}
|
||||
if (c.kind === 'image') {
|
||||
// 2026-11-25(用户反馈「有时候报错贴不进去」):焦点还留在提示词节点的 textarea /
|
||||
@@ -316,8 +485,9 @@
|
||||
return true
|
||||
}
|
||||
if (c.kind === 'files') {
|
||||
ctx.setNotice({ type: 'err', text: '暂不支持把文件粘进输入框;先点一下画布空白处再粘贴' })
|
||||
return false
|
||||
e.preventDefault()
|
||||
ctx.setNotice({ type: 'err', text: '文件不能粘进输入框:把鼠标移到画布上再粘贴' })
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -440,49 +610,5 @@
|
||||
return true
|
||||
}
|
||||
|
||||
/* Ctrl+V 按下后若一直没等到 paste 事件,说明浏览器认为系统剪贴板是空的 ——
|
||||
* 正常情况下复制节点会把节点组写进系统剪贴板,不该走到这里;走到这里只有一种原因:
|
||||
* 这台环境**写不进系统剪贴板**(老浏览器 / 非 HTTPS / file:// 打开),复制只落了内部那份。
|
||||
*
|
||||
* 这里**只提示、不代替用户粘贴**:旧实现靠 300ms 定时器在这儿回退粘贴,递增 token 只让
|
||||
* 最后一次生效,「复制一份、连按 3 次 Ctrl+V 只贴出 1 份」就是这么来的。 */
|
||||
function probe(ctx) {
|
||||
const t0 = Date.now()
|
||||
ctx.refs.pasteProbe = t0
|
||||
setTimeout(() => {
|
||||
if (ctx.refs.pasteProbe !== t0) return
|
||||
if (ctx.refs.pasteGroupUntil && Date.now() < ctx.refs.pasteGroupUntil) return
|
||||
if (ctx.readClipboardGraph()) {
|
||||
ctx.setNotice({ type: 'ok', text: '这台环境写不进系统剪贴板,粘贴节点请按 Ctrl+Shift+V' })
|
||||
return
|
||||
}
|
||||
if (ctx.refs.clipExpired) ctx.setNotice({ type: 'err', text: '内部剪贴板已过期(10 分钟),请重新复制节点' })
|
||||
}, 420)
|
||||
}
|
||||
|
||||
/* Cmd/Ctrl+V 兜底(桌面端):菜单缺失或 WebView 不派发 paste 时,160ms 内没收到
|
||||
* 真实 paste 事件就主动读一次原生剪贴板图片。getCtx 由 app.js 注入(懒取,避免闭包过期)。 */
|
||||
let hotkeyBound = false
|
||||
function bindHotkeyFallback(getCtx) {
|
||||
if (hotkeyBound || typeof window === 'undefined') return
|
||||
hotkeyBound = true
|
||||
window.addEventListener('keydown', (e) => {
|
||||
if (!(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey) return
|
||||
if (String(e.key || '').toLowerCase() !== 'v') return
|
||||
const t = /** @type {any} */ (e.target)
|
||||
if (t && t.tagName && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return
|
||||
const D = g.IWBDesktop
|
||||
if (!D || !D.clipboardReadImage) return
|
||||
const ctx = (typeof getCtx === 'function') ? getCtx() : null
|
||||
if (ctx && modalOpen(ctx.ui)) return
|
||||
const stamp = ctx && ctx.refs ? (ctx.refs.pasteStamp || 0) : 0
|
||||
setTimeout(() => {
|
||||
const now = ctx && ctx.refs ? (ctx.refs.pasteStamp || 0) : 0
|
||||
if (now !== stamp) return
|
||||
D.clipboardReadImage().then((f) => { if (f) pasteImages([f], ctx) })
|
||||
}, 160)
|
||||
})
|
||||
}
|
||||
|
||||
g.IWBClipboardPaste = Object.freeze({ handle, probe, overlayOpen, modalOpen, libraryOpen, anchor, bindHotkeyFallback, pasteFiles: (files, ctx) => pasteImages(files || [], ctx) })
|
||||
g.IWBClipboardPaste = Object.freeze({ handle, pasteFromKey, readSystemClip, overlayOpen, modalOpen, libraryOpen, anchor, pasteFiles: (files, ctx) => pasteImages(files || [], ctx) })
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -1828,23 +1828,33 @@
|
||||
// 引用只在**本机同源**有效:粘到另一个浏览器 / 另一台电脑,节点结构能还原但图是空的。
|
||||
// ④ 带 at 时间戳 + 内部剪贴板 TTL(见 CLIPBOARD_TTL_MS);系统剪贴板不设 TTL(用户清空即止)。
|
||||
// 注意:stripBigValueSync 返回新的对象树,不会污染内存里 refs.nodes 的节点数据。
|
||||
// 落一份到「应用内剪贴板」(内存 + localStorage)+ 一句成功提示。
|
||||
// 2026-11-26 抽出来给 DOM copy 事件用:那条通道已经把节点组同步写进系统剪贴板了,
|
||||
// 不需要再走 gc.write(异步、WKWebView 常失败、而且会覆盖掉系统剪贴板里的 html 标记)。
|
||||
const stageClip = (clip) => {
|
||||
if (!clip || !Array.isArray(clip.nodes) || !clip.nodes.length) return false
|
||||
refs.clipboardGraph = clip
|
||||
try { const st = _lstore(); if (st) st.set(CLIPBOARD_KEY, clip) } catch (e) { /* 配额超限:内存版仍可用 */ }
|
||||
setNotice({ type: 'ok', text: '已复制 ' + clip.nodes.length + ' 个节点' })
|
||||
return true
|
||||
}
|
||||
const copyNodes = (ids) => {
|
||||
const clip = CanvasOps.clipboardOf(refs.nodes, refs.edges, refs.groups, ids)
|
||||
if (!clip) return false
|
||||
refs.clipboardGraph = clip
|
||||
try { const st = _lstore(); if (st) st.set(CLIPBOARD_KEY, clip) } catch (e) { /* 配额超限:内存版仍可用 */ }
|
||||
// v3.24.68 统一剪贴板:同时写**系统剪贴板**(text/html 带标记 + text/plain 人话摘要),
|
||||
// Ctrl+V 才能直接贴节点组,不必再记 Ctrl+Shift+V(它降级为后门)。
|
||||
// 异步发起、不阻塞、不抛错;写不进去(老浏览器 / 非 HTTPS / file:// 打开)就降级并说明。
|
||||
stageClip(clip)
|
||||
// v3.24.68 统一剪贴板:同时写**系统剪贴板**(text/html 带标记 + text/plain 人话摘要)。
|
||||
// 2026-11-26 起主通道是 DOM copy 事件(src/clipboard-graph.js 的 writeToEvent,同步、必成),
|
||||
// 这里只服务"copy 事件没派发"的兜底路径(异步、WKWebView 常被拒)。
|
||||
// 写失败必须记住(refs.sysClipOk=false):否则 ⌘V 会去读系统剪贴板里的**别人的旧内容**。
|
||||
try {
|
||||
const gc = global.IWBClipboardGraph
|
||||
if (gc) {
|
||||
gc.write(clip).then((ok) => {
|
||||
if (!ok) setNotice({ type: 'err', text: '系统剪贴板不可写,粘贴节点请用 Ctrl+Shift+V' })
|
||||
refs.sysClipOk = !!ok
|
||||
if (!ok) setNotice({ type: 'err', text: '系统剪贴板不可写,节点已存入应用内剪贴板(⌘V 仍可粘贴)' })
|
||||
})
|
||||
}
|
||||
} catch (e) { /* 写剪贴板失败绝不影响复制本身:内部那份已经写好了 */ }
|
||||
setNotice({ type: 'ok', text: '已复制 ' + clip.nodes.length + ' 个节点' })
|
||||
return true
|
||||
}
|
||||
// pasteGraph 已搬到 src/runtime-workbench-logic.js(2026-10-29)
|
||||
@@ -2191,7 +2201,7 @@
|
||||
setViewport({ x: railW + 28 - minX * scale, y: 28 - minY * scale, scale })
|
||||
}
|
||||
|
||||
return { historyStore, HISTORY_IMG_REF_FIELDS, historyRefUsable, historyRefData, historyRawSnapshot, pushHistory, pushHistoryDebounced, restore, undo, redo, addPromptToLibrary, UNDO_KEYS, updateNode, clearGenResults, deleteNodes, deleteEdge, copyOffset, duplicateNodes, floatbarRefPaste, outResultUrls, copyNodes, pasteGraph, readClipboardGraph, pasteCopiedNodes, clearClipboard, cutNodes, groupOf, makeGroup, ungroup, joinGroupOf, renameGroup, duplicateGroup, saveGroupSnapshot, saveSelectionAsGroup, instantiateGroup, loadSavedGroups, findSpot, placeAtDrop, addNode, addPluginNode, addRefFromUrl, refSrcOf, refreshOutputs, deleteOutputs, loadDemo, doFit }
|
||||
return { historyStore, HISTORY_IMG_REF_FIELDS, historyRefUsable, historyRefData, historyRawSnapshot, pushHistory, pushHistoryDebounced, restore, undo, redo, addPromptToLibrary, UNDO_KEYS, updateNode, clearGenResults, deleteNodes, deleteEdge, copyOffset, duplicateNodes, floatbarRefPaste, outResultUrls, stageClip, copyNodes, pasteGraph, readClipboardGraph, pasteCopiedNodes, clearClipboard, cutNodes, groupOf, makeGroup, ungroup, joinGroupOf, renameGroup, duplicateGroup, saveGroupSnapshot, saveSelectionAsGroup, instantiateGroup, loadSavedGroups, findSpot, placeAtDrop, addNode, addPluginNode, addRefFromUrl, refSrcOf, refreshOutputs, deleteOutputs, loadDemo, doFit }
|
||||
}
|
||||
// ── createWorkbenchSessions(2026-11-06 从 Workbench 外移;行为逐字保留)──────────────
|
||||
function createWorkbenchSessions(ctx) {
|
||||
|
||||
@@ -56,9 +56,18 @@
|
||||
* 返回:notice / setNotice / toast / setToast / showToast
|
||||
*/
|
||||
function useNotifications (opts) {
|
||||
const [notice, setNotice] = useState(null)
|
||||
const [notice, setNoticeState] = useState(null)
|
||||
const [toast, setToast] = useState(null)
|
||||
const toastTimer = useRef(null)
|
||||
const noticeTimer = useRef(null)
|
||||
/* 错误/进行中提示 5.2s 自动收(2026-11-26)。
|
||||
* 旧行为只有 toast 会消失,notice 会一直挂在状态栏 —— 粘贴失败那句"剪贴板里没有可粘贴的内容"
|
||||
* 粘在顶部不动,用户过一会儿再看会以为功能坏了。成功提示(ok)保持常驻,它是"最后一次操作结果"。 */
|
||||
const setNotice = (n) => {
|
||||
clearTimeout(noticeTimer.current)
|
||||
setNoticeState(n)
|
||||
if (n && n.type && n.type !== 'ok') noticeTimer.current = setTimeout(() => setNoticeState(null), 5200)
|
||||
}
|
||||
const showToast = (text, type) => {
|
||||
clearTimeout(toastTimer.current)
|
||||
setToast({ text, type: type || 'ok' })
|
||||
|
||||
@@ -276,9 +276,10 @@ test('5. TTL:11 分钟前的内部剪贴板不粘贴且被删除', async ({ pa
|
||||
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
|
||||
await W.waitCanvasOpen(page)
|
||||
const before = await page.locator('.iwb-node').count()
|
||||
// v3.24.67:Ctrl+V 不再有 300ms 回退;改由 probe(~420ms)读一次剪贴板,读到过期即清理并提示。
|
||||
// 因此这里等「条目被清掉」这个条件成立,而不是等固定毫秒。
|
||||
// 注意:**不往系统剪贴板写内容** —— 有内容时浏览器会派发真实 paste,probe 就不会跑了。
|
||||
// 2026-11-26:⌘V 现在会**主动读系统剪贴板**(mac 上没有编辑焦点时不会派发 paste 事件,
|
||||
// 这是唯一通路),而系统剪贴板按设计不设 TTL(用户清空即止)。所以先把它清空 ——
|
||||
// 否则测的就不是「内部剪贴板过期」,而是「系统剪贴板里还有内容」。
|
||||
await page.evaluate(() => navigator.clipboard.writeText(''))
|
||||
await page.keyboard.press('Control+v')
|
||||
await W.poll(page, () => page.evaluate(() => localStorage.getItem('iwb_clipboard')), { timeout: 8000 }).toBeNull()
|
||||
const after = await page.locator('.iwb-node').count()
|
||||
@@ -669,8 +670,10 @@ test('18. 焦点在节点输入框里按 Ctrl+C 仍能复制节点(旧实现
|
||||
expect(errors).toEqual([])
|
||||
})
|
||||
|
||||
test('19. 焦点在节点输入框里粘「复制的节点」→ 明确提示,不落节点(旧实现纯静默)', async ({ page }) => {
|
||||
test('19. 焦点在节点输入框里粘节点组:带提示词→粘文字;只有摘要→拦下且不污染输入框', async ({ page }) => {
|
||||
await boot(page, workspace)
|
||||
// 情形 A(v3.24.70 的原始诉求):复制的是**带提示词**的节点组 → 粘进输入框应该得到那段提示词文字。
|
||||
// 2026-11-26 改口径:这类粘贴放行原生(拦掉等于把「复制提示词贴到别处」这个用法做没了)。
|
||||
await page.keyboard.press('Control+a')
|
||||
await page.keyboard.press('Control+c')
|
||||
await waitGraphInClipboard(page)
|
||||
@@ -678,11 +681,27 @@ test('19. 焦点在节点输入框里粘「复制的节点」→ 明确提示,
|
||||
await url.click()
|
||||
const before = await page.locator('.iwb-node').count()
|
||||
await realPaste(page)
|
||||
// 提示必须出现:旧实现连提示都没有,用户只能看到「什么都没发生」
|
||||
await W.poll(page, () => page.evaluate(() => Array.from(document.querySelectorAll('.iwb-status-item')).map((x) => String(x.textContent || '')).join(' | ')), { timeout: 8000 }).toContain('画布空白处')
|
||||
const after = await page.locator('.iwb-node').count()
|
||||
console.log('[check19] nodes ' + before + ' -> ' + after + '(输入框里不落节点)')
|
||||
expect(after).toBe(before)
|
||||
await page.waitForTimeout(400)
|
||||
const val = await url.inputValue()
|
||||
console.log('[check19] 带提示词 → 输入框 = ' + JSON.stringify(val))
|
||||
expect(val).toBe('画布A 提示词')
|
||||
expect(await page.locator('.iwb-node').count()).toBe(before)
|
||||
|
||||
// 情形 B(本次修的缺陷):复制的只有图片节点,摘要退化成「1 个节点」。
|
||||
// 旧实现只弹提示不拦,摘要被原生粘贴打进输入框,把用户的提示词改掉了。
|
||||
await url.fill('')
|
||||
await clearSelection(page)
|
||||
await page.locator('.iwb-node').nth(1).click()
|
||||
await W.waitSelectedCount(page, 1)
|
||||
await page.keyboard.press('Control+c')
|
||||
await page.waitForTimeout(400)
|
||||
await url.click()
|
||||
await realPaste(page)
|
||||
await W.poll(page, () => statusText(page), { timeout: 8000 }).toContain('画布')
|
||||
const val2 = await url.inputValue()
|
||||
console.log('[check19] 只有摘要 → 输入框 = ' + JSON.stringify(val2) + ';提示 = ' + JSON.stringify(await statusText(page)))
|
||||
expect(val2).toBe('')
|
||||
expect(await page.locator('.iwb-node').count()).toBe(before)
|
||||
expect(errors).toEqual([])
|
||||
})
|
||||
|
||||
|
||||
@@ -137,6 +137,79 @@ eq('标记没闭合(被截断)仍尽力解出', (G.decode('<!--iwb:graph:v1:
|
||||
eq('写入同步抛错 → false(不抛)', await G4.write(mkClip()), false)
|
||||
}
|
||||
|
||||
// ---- ⑧ 双标记 + copy 事件通道(2026-11-26)----
|
||||
// 背景:WKWebView 写/读剪贴板时会剥掉 HTML 注释 ⇒ 只剩 data-iwb-graph 属性可用;
|
||||
// 复制改由 DOM copy 事件同步写 clipboardData(mac 上 ⌘C 被原生菜单接管时 keydown 到不了 JS)。
|
||||
{
|
||||
const c = mkClip()
|
||||
const html = G.htmlFor(c)
|
||||
ok('htmlFor 同时写了注释标记与 data-iwb-graph 属性', html.indexOf('iwb:graph:v1:') >= 0 && html.indexOf('data-iwb-graph=') >= 0)
|
||||
const attrOnly = html.replace(/<!--[\s\S]*?-->/, '') // 模拟 WebKit 把注释剥掉
|
||||
ok('注释被剥掉后属性仍能解回', !!G.decode(attrOnly))
|
||||
eq('属性解回的节点数一致', (G.decode(attrOnly) || {}).nodes ? G.decode(attrOnly).nodes.length : -1, 2)
|
||||
eq('属性用单引号包裹也能解', !!G.decode(html.replace(/data-iwb-graph="[^"]*"/, (m) => m.replace(/"/g, "'"))), true)
|
||||
eq('没有标记 → null', G.decode('<div>普通网页</div>'), null)
|
||||
}
|
||||
{
|
||||
const c = mkClip()
|
||||
const dt = { data: {}, setData(k, v) { this.data[k] = v } }
|
||||
const ev = { clipboardData: dt, defaultPrevented: false, preventDefault() { ev.defaultPrevented = true } }
|
||||
eq('writeToEvent 返回 true', G.writeToEvent(ev, c), true)
|
||||
ok('写了 text/html(带标记)', String(dt.data['text/html']).indexOf('iwb:graph:v1:') >= 0)
|
||||
eq('写了 text/plain(人话摘要,不是裸 JSON)', dt.data['text/plain'], G.plainFor(c))
|
||||
eq('writeToEvent 不碰 preventDefault(交给调用方)', ev.defaultPrevented, false)
|
||||
eq('没有 clipboardData → false(不抛)', G.writeToEvent({}, c), false)
|
||||
}
|
||||
{
|
||||
// bindCopy:注册 copy 监听,事件里同步写剪贴板 + 落内部剪贴板
|
||||
const b = { h: {}, addEventListener(t, fn) { (b.h[t] = b.h[t] || []).push(fn) }, removeEventListener(t, fn) { const a = b.h[t] || []; const i = a.indexOf(fn); if (i >= 0) a.splice(i, 1) } }
|
||||
new Function('window', 'globalThis', SRC)(b, b)
|
||||
let staged = null
|
||||
let notice = null
|
||||
let sysOk = null
|
||||
const ctx = {
|
||||
ids: () => ['n1', 'n2'],
|
||||
clipboardOf: () => mkClip(),
|
||||
stageClip: (c) => { staged = c; notice = { type: 'ok', text: '已复制 ' + c.nodes.length + ' 个节点' }; return true },
|
||||
setNotice: (n) => { notice = n },
|
||||
markSys: (ok) => { sysOk = ok },
|
||||
hasTextSelection: () => false,
|
||||
}
|
||||
let current = ctx
|
||||
b.IWBClipboardGraph.bindCopy(() => current)
|
||||
const fire = (ev) => (b.h.copy || []).forEach((fn) => fn(ev))
|
||||
const dt = { data: {}, setData(k, v) { this.data[k] = v } }
|
||||
const ev = { target: {}, clipboardData: dt, defaultPrevented: false, preventDefault() { ev.defaultPrevented = true } }
|
||||
fire(ev)
|
||||
ok('copy 事件:同步写进 clipboardData', String(dt.data['text/html']).indexOf('iwb:graph:v1:') >= 0)
|
||||
eq('copy 事件:preventDefault(不覆盖用户其它剪贴板内容)', ev.defaultPrevented, true)
|
||||
eq('copy 事件:内部剪贴板也落了一份', !!staged, true)
|
||||
eq('copy 事件:标记系统剪贴板可写', sysOk, true)
|
||||
ok('copy 事件:提示已复制', !!notice && String(notice.text).indexOf('已复制') >= 0)
|
||||
// 有文本选区 → 让原生复制文字(不许抢)
|
||||
staged = null
|
||||
current = Object.assign({}, ctx, { hasTextSelection: () => true })
|
||||
const ev2 = { target: {}, clipboardData: { setData() { throw new Error('不该写剪贴板') } }, defaultPrevented: false, preventDefault() { ev2.defaultPrevented = true } }
|
||||
fire(ev2)
|
||||
eq('有文本选区 → 不写剪贴板(原生复制文字)', staged, null)
|
||||
eq('有文本选区 → 不 preventDefault', ev2.defaultPrevented, false)
|
||||
// 没选中节点 → 说一句,别静默
|
||||
notice = null
|
||||
current = Object.assign({}, ctx, { ids: () => [] })
|
||||
fire({ target: {}, clipboardData: { setData() {} }, defaultPrevented: false, preventDefault() {} })
|
||||
ok('没选中节点 → 提示没有可复制的内容', !!notice && String(notice.text).indexOf('没有可复制') >= 0)
|
||||
// 解绑后必须真的摘掉监听(否则回到首页按 ⌘C 会去复制已卸载那份 refs)
|
||||
b.IWBClipboardGraph.unbindCopy()
|
||||
staged = null
|
||||
current = ctx
|
||||
fire({ target: {}, clipboardData: { setData() { staged = 'wrote' } }, defaultPrevented: false, preventDefault() {} })
|
||||
eq('unbindCopy 之后 copy 事件不再被处理', staged, null)
|
||||
// 重新绑定可以恢复(Workbench 重挂载)
|
||||
b.IWBClipboardGraph.bindCopy(() => current)
|
||||
fire({ target: {}, clipboardData: { setData() {} }, defaultPrevented: false, preventDefault() {} })
|
||||
eq('重新 bindCopy 后恢复处理', !!staged, true)
|
||||
}
|
||||
|
||||
console.log('\n' + (fail ? '❌' : '✅') + ' clipboard-graph: ' + pass + ' passed, ' + fail + ' failed')
|
||||
if (fail) process.exit(1)
|
||||
})()
|
||||
@@ -40,7 +40,7 @@ function makeCtx(over) {
|
||||
const log = []
|
||||
let nodes = [{ id: 'seed', type: 'prompt', x: 0, y: 0, data: { text: 'seed' } }]
|
||||
const ctx = {
|
||||
refs: { pasteGroupUntil: 0, pasteProbe: 0, clipExpired: false },
|
||||
refs: { pasteGroupUntil: 0, pasteSwallowUntil: 0, clipExpired: false },
|
||||
ui: {},
|
||||
readClipboardGraph: () => null,
|
||||
pasteCopiedNodes: () => { log.push('pasteGroup'); return true },
|
||||
@@ -55,7 +55,7 @@ function makeCtx(over) {
|
||||
pushHistory: () => log.push('history'),
|
||||
commitCanvas: (next) => { nodes = next; log.push('commit:' + next.length) },
|
||||
setSel: (ids) => log.push('sel:' + ids.length),
|
||||
setNotice: (n) => log.push('notice:' + n.type + ':' + n.text),
|
||||
setNotice: (n) => log.push(n ? ('notice:' + n.type + ':' + n.text) : 'notice:null'),
|
||||
importImage: (u, opts, cb) => cb({ ok: true, data: 'data:image/png;base64,AAAA' }),
|
||||
}
|
||||
return Object.assign(ctx, over || {}, { log })
|
||||
@@ -112,7 +112,7 @@ function makeCtx(over) {
|
||||
ok('空剪贴板 + 内部也空 → 提示「没有可粘贴的内容」', ctx.log.some((x) => x.indexOf('没有可粘贴的内容') > 0))
|
||||
}
|
||||
{ // 过期要说清是过期,而不是「没有内容」
|
||||
const ctx = makeCtx({ pasteCopiedNodes: () => false, refs: { pasteGroupUntil: 0, pasteProbe: 0, clipExpired: true } })
|
||||
const ctx = makeCtx({ pasteCopiedNodes: () => false, refs: { pasteGroupUntil: 0, pasteSwallowUntil: 0, clipExpired: true } })
|
||||
P.handle(pasteEv({}), ctx)
|
||||
ok('空剪贴板 + 内部已过期 → 提示重新复制', ctx.log.some((x) => x.indexOf('已过期') > 0))
|
||||
}
|
||||
@@ -245,16 +245,26 @@ function makeCtx(over) {
|
||||
ok('输入框内粘文件 → 也给提示(不再静默)', ctx.log.some((x) => x.indexOf('输入框') > 0))
|
||||
}
|
||||
{
|
||||
// 焦点在输入框里粘「刚复制的节点组」—— 旧实现完全静默(剪贴板里还带着 text/plain 摘要,
|
||||
// 用户很容易以为会贴出提示词)。v3.24.70:必须给一句「先点一下画布空白处」。
|
||||
// 焦点在输入框、指针也不在画布、剪贴板里只有「N 个节点」摘要。
|
||||
// 2026-11-26 改口径:旧实现只提示不改行为 → 摘要(text/plain)被原生粘贴打进输入框,污染提示词。
|
||||
// 现在必须 preventDefault(一点摘要都不许落进输入框),并指路「鼠标移到画布上再按 ⌘V」。
|
||||
const ctx = makeCtx()
|
||||
const html = win.IWBClipboardGraph.htmlFor({ app: 'image-workbench', type: 'iwb-clipboard', at: Date.now(), nodes: [{ id: 'r1', type: 'ref', x: 0, y: 0, data: {} }], edges: [], groups: [] })
|
||||
const ev = pasteEv({ html, text: '1 个节点' })
|
||||
eq('输入框内粘摘要 → 消费这次 paste', P.handle(ev, ctx, true), true)
|
||||
eq('输入框内粘摘要 → preventDefault(摘要不许落进输入框)', ev.defaultPrevented, true)
|
||||
ok('输入框内粘摘要 → 提示「鼠标移到画布上」', ctx.log.some((x) => x.indexOf('notice:err') === 0 && x.indexOf('画布') > 0))
|
||||
eq('输入框内粘摘要 → 不贴节点组', ctx.log.filter((x) => x.indexOf('pasteGraph') === 0).length, 0)
|
||||
eq('输入框内粘摘要 → 不落节点', ctx.log.filter((x) => x.startsWith('commit')).length, 0)
|
||||
}
|
||||
{
|
||||
// 剪贴板里带着提示词全文 → 放行原生(复制提示词贴进另一个输入框是正经用法)
|
||||
const ctx = makeCtx()
|
||||
const html = win.IWBClipboardGraph.htmlFor({ app: 'image-workbench', type: 'iwb-clipboard', at: Date.now(), nodes: [{ id: 'n1', type: 'prompt', x: 0, y: 0, data: { text: 'hello' } }], edges: [], groups: [] })
|
||||
const ev = pasteEv({ html, text: 'hello' })
|
||||
eq('输入框内粘节点组 → 不接管', P.handle(ev, ctx, true), false)
|
||||
eq('输入框内粘节点组 → 不 preventDefault', ev.defaultPrevented, false)
|
||||
ok('输入框内粘节点组 → 明确提示「先点一下画布空白处」', ctx.log.some((x) => x.indexOf('notice:err') === 0 && x.indexOf('画布空白处') > 0))
|
||||
eq('输入框内粘节点组 → 不贴节点组', ctx.log.filter((x) => x.indexOf('pasteGraph') === 0).length, 0)
|
||||
eq('输入框内粘节点组 → 不落节点', ctx.log.filter((x) => x.startsWith('commit')).length, 0)
|
||||
eq('输入框内粘「带提示词的节点」→ 不接管(原生贴文字)', P.handle(ev, ctx, true), false)
|
||||
eq('输入框内粘「带提示词的节点」→ 不 preventDefault', ev.defaultPrevented, false)
|
||||
eq('输入框内粘「带提示词的节点」→ 不落节点', ctx.log.filter((x) => x.startsWith('commit')).length, 0)
|
||||
}
|
||||
{
|
||||
// 画布上(editable=false)同样的图片必须照常建节点 —— 证明 editable 只影响输入框这一路
|
||||
@@ -263,33 +273,53 @@ function makeCtx(over) {
|
||||
eq('画布上(editable=false)图片链接照常建 ref', P.handle(ev, ctx, false), true)
|
||||
}
|
||||
|
||||
// ---- ⑧ probe:Ctrl+V 一直没等到 paste 事件时说清楚 ----
|
||||
// ---- ⑧ ⌘V 主动粘贴(2026-11-26 keydown 通道)----
|
||||
// 背景:mac 上焦点不在输入框时根本不会派发 paste 事件(只有 keydown),旧实现只弹一句
|
||||
// 「请按 Ctrl+Shift+V」。现在 keydown 直接接管:先让原生走(150ms 内等到 paste 就交给 handle),
|
||||
// 等不到才自己读剪贴板 —— 顺序是 富读取 → 原生文本 → 原生图片 → 内部剪贴板。
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
;(async () => {
|
||||
{
|
||||
const ctx = makeCtx({ readClipboardGraph: () => ({ nodes: [{ id: 'a' }], edges: [], groups: [] }) })
|
||||
P.probe(ctx)
|
||||
await sleep(520)
|
||||
ok('probe:内部剪贴板有内容 → 提示改用 Ctrl+Shift+V',
|
||||
ctx.log.some((x) => x.indexOf('Ctrl+Shift+V') > 0))
|
||||
eq('probe:只提示,不代替用户粘贴', ctx.log.filter((x) => x === 'pasteGroup').length, 0)
|
||||
// 指针不在画布、没有编辑焦点 → 仍然接管(否则 mac 上 ⌘V 又变成"没反应")
|
||||
const ctx = makeCtx()
|
||||
eq('pasteFromKey:无编辑焦点 → 接管', P.pasteFromKey(ctx), true)
|
||||
await sleep(200)
|
||||
eq('pasteFromKey:没等到 paste 事件 → 回退贴内部剪贴板', ctx.log.filter((x) => x === 'pasteGroup').length, 1)
|
||||
}
|
||||
{
|
||||
const ctx = makeCtx({
|
||||
refs: { pasteGroupUntil: 0, pasteProbe: 0, clipExpired: true },
|
||||
readClipboardGraph: () => null,
|
||||
})
|
||||
P.probe(ctx)
|
||||
await sleep(520)
|
||||
ok('probe:内部剪贴板已过期 → 提示重新复制', ctx.log.some((x) => x.indexOf('已过期') > 0))
|
||||
// 有 paste 事件(Windows / WebView2)→ 定时器不许再贴一次
|
||||
const ctx = makeCtx()
|
||||
P.pasteFromKey(ctx)
|
||||
ctx.refs.pasteEventAt = Date.now()
|
||||
await sleep(220)
|
||||
eq('pasteFromKey:paste 事件已处理 → 不重复贴', ctx.log.filter((x) => x === 'pasteGroup').length, 0)
|
||||
}
|
||||
{
|
||||
// 真实 paste 到达会把 pasteProbe 清零 → probe 不该再提示
|
||||
const ctx = makeCtx({ readClipboardGraph: () => ({ nodes: [{ id: 'a' }] }) })
|
||||
P.probe(ctx)
|
||||
ctx.refs.pasteProbe = 0
|
||||
await sleep(520)
|
||||
eq('probe:收到真实 paste 后静默', ctx.log.length, 0)
|
||||
// 浮层打开 → 不接管,交回原生
|
||||
const ctx = makeCtx({ ui: { settingOpen: true } })
|
||||
eq('pasteFromKey:设置面板开着 → 不接管', P.pasteFromKey(ctx), false)
|
||||
await sleep(200)
|
||||
eq('pasteFromKey:不接管时什么也不做', ctx.log.length, 0)
|
||||
}
|
||||
{
|
||||
// 内部剪贴板也空 → 明确提示,且文案不再教用户"点空白处"
|
||||
const ctx = makeCtx({ pasteCopiedNodes: () => false })
|
||||
P.pasteFromKey(ctx)
|
||||
await sleep(220)
|
||||
const msgs = ctx.log.map(String).join(' | ')
|
||||
ok('pasteFromKey:全空 → 有错误提示', /notice:err/.test(msgs))
|
||||
ok('pasteFromKey:提示不再说「先点一下画布空白处」', msgs.indexOf('画布空白处') < 0)
|
||||
}
|
||||
{
|
||||
// 主动粘贴刚落地 → 紧随其后的同一次 paste 事件必须被吞掉(否则贴两份)
|
||||
const ctx = makeCtx()
|
||||
P.pasteFromKey(ctx)
|
||||
await sleep(220)
|
||||
eq('主动粘贴已落地(内部剪贴板)', ctx.log.filter((x) => x === 'pasteGroup').length, 1)
|
||||
const ev = pasteEv({ text: 'hello' })
|
||||
eq('主动粘贴后 400ms 内的重复 paste → 被吞掉', P.handle(ev, ctx), true)
|
||||
eq('被吞掉的 paste → preventDefault', ev.defaultPrevented, true)
|
||||
eq('被吞掉的 paste → 不落节点', ctx.log.filter((x) => x.startsWith('commit')).length, 0)
|
||||
}
|
||||
|
||||
// ---- ⑥ 粘贴落点跟随指针(v3.24.69 用户裁定:粘贴要跟鼠标)----
|
||||
@@ -311,7 +341,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
const calls = []
|
||||
const ctxOf = () => makeCtx({
|
||||
canvasEl,
|
||||
refs: { pasteGroupUntil: 0, pasteProbe: 0, clipExpired: false, viewport: { x: 0, y: 0, scale: 1 } },
|
||||
refs: { pasteGroupUntil: 0, pasteSwallowUntil: 0, clipExpired: false, viewport: { x: 0, y: 0, scale: 1 } },
|
||||
findSpot: (type, seed, opts) => { calls.push({ type, seed, opts }); return { x: 100, y: 200 } },
|
||||
pasteGraph: (clip, at2) => { calls.push({ graph: clip, at: at2 }); return true },
|
||||
})
|
||||
@@ -334,6 +364,29 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
eq('指针在画布外 → seed 为 undefined(退回视口中心)', calls.find((c) => c.type === 'prompt').seed, undefined)
|
||||
}
|
||||
|
||||
// ── 焦点在输入框 + 指针在画布:节点组必须改贴到画布(2026-11-26)────────────
|
||||
// 用户实测的坑:复制节点 → 点了一下节点内的空白(宿主 preventDefault,焦点没走)→ ⌘V 没反应。
|
||||
// 现在由 paste 事件在「指针在画布」时接管:blur + 贴到指针处。
|
||||
{
|
||||
const rect = { left: 100, top: 50, width: 800, height: 600, right: 900, bottom: 650 }
|
||||
const canvasEl = { el: { getBoundingClientRect: () => rect } }
|
||||
const fire = (x, y) => (win.h.pointermove || []).forEach((fn) => fn({ clientX: x, clientY: y }))
|
||||
const baseRefs = { pasteGroupUntil: 0, pasteSwallowUntil: 0, clipExpired: false, viewport: { x: 0, y: 0, scale: 1 } }
|
||||
fire(500, 350)
|
||||
const calls = []
|
||||
const ctx = makeCtx({ canvasEl, refs: Object.assign({}, baseRefs), pasteGraph: (clip, at) => { calls.push({ clip, at }); return true } })
|
||||
const clip = { nodes: [{ id: 'r1', type: 'ref', x: 0, y: 0, data: {} }], edges: [], groups: [] }
|
||||
const ev = pasteEv({ html: win.IWBClipboardGraph.htmlFor(clip), text: '1 个节点' })
|
||||
eq('输入框内 + 指针在画布 → 接管这次 paste', P.handle(ev, ctx, true), true)
|
||||
eq('输入框内 + 指针在画布 → preventDefault(摘要不落输入框)', ev.defaultPrevented, true)
|
||||
eq('输入框内 + 指针在画布 → 贴到指针处', JSON.stringify(calls[0] && calls[0].at), '{"x":400,"y":300}')
|
||||
// 指针不在画布:回到上面那条「拦下摘要 + 指路」的行为
|
||||
fire(10, 10)
|
||||
const ctx2 = makeCtx({ canvasEl, refs: Object.assign({}, baseRefs) })
|
||||
eq('指针移出画布 → 只拦不贴', P.handle(pasteEv({ html: win.IWBClipboardGraph.htmlFor(clip), text: '1 个节点' }), ctx2, true), true)
|
||||
eq('指针移出画布 → 不贴节点组', ctx2.log.filter((x) => x.indexOf('pasteGraph') === 0).length, 0)
|
||||
}
|
||||
|
||||
// ── 同图去重(v3.24.75)────────────────────────────────────────────────────
|
||||
// 判据与语义边界见 src/image-dedupe.js:只认本地图片字节,URL 与复制节点组不参与。
|
||||
// 这里测分发层的取舍(该拦的拦、该落的落、提示必须说清);真实的"压缩后字节指纹"
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
'use strict'
|
||||
// 应用图标资源完整性守卫(2026-11-26)
|
||||
//
|
||||
// 为什么需要:v3.26.105 换图标时 icon.icns 的**头部总长度**(第 5-8 字节,大端 uint32)
|
||||
// 与实际文件长度不一致(声明 693,114 / 实际 167,838)。sips 不做全量校验照样能解码,
|
||||
// 所以本地"图看着没问题";但 macOS IconServices 按声明长度解析 → 直接失败 →
|
||||
// Dock / 访达 / 关于面板全部显示成空白方块(用户实测截图)。
|
||||
//
|
||||
// 断言口径(全部只看字节结构,不依赖 macOS 工具,CI 在哪都能跑):
|
||||
// ① icns 头部声明长度 == 文件真实字节数
|
||||
// ② 各 chunk 长度累加正好走完文件(没有截断的尾块)
|
||||
// ③ 有 1024 主图块(ic10 / ic14 / ic09@2x),否则 Retina Dock 只能放大 512
|
||||
// ④ 其它图标文件没被顺手写坏(png 尺寸正确、ico 头 6 字节 + 目录项数合理)
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const assert = require('assert')
|
||||
|
||||
const root = path.join(__dirname, '..')
|
||||
const iconsDir = path.join(root, 'src-tauri', 'icons')
|
||||
|
||||
function readIcns (file) {
|
||||
const d = fs.readFileSync(file)
|
||||
assert.strictEqual(d.slice(0, 4).toString('latin1'), 'icns', file + ' 不是 icns(magic 不对)')
|
||||
const declared = d.readUInt32BE(4)
|
||||
return { d, declared }
|
||||
}
|
||||
|
||||
// ── ① 头部长度自洽 ────────────────────────────────────────────────
|
||||
const icnsPath = path.join(iconsDir, 'icon.icns')
|
||||
const { d: icns, declared } = readIcns(icnsPath)
|
||||
assert.strictEqual(declared, icns.length,
|
||||
'icon.icns 头部声明长度 ' + declared + ' != 文件实际 ' + icns.length +
|
||||
'(IconServices 会整包解析失败 → Dock 图标空白)')
|
||||
|
||||
// ── ② chunk 链完整 ───────────────────────────────────────────────
|
||||
const types = []
|
||||
let off = 8
|
||||
while (off + 8 <= icns.length) {
|
||||
const type = icns.slice(off, off + 4).toString('latin1')
|
||||
const size = icns.readUInt32BE(off + 4)
|
||||
assert.ok(size >= 8, 'chunk ' + type + ' 长度非法:' + size)
|
||||
assert.ok(off + size <= icns.length, 'chunk ' + type + ' 越界(文件被截断)')
|
||||
types.push(type)
|
||||
off += size
|
||||
}
|
||||
assert.strictEqual(off, icns.length, 'icns chunk 链没有正好走完文件(尾部有残留字节)')
|
||||
|
||||
// ── ③ 大图块存在 ─────────────────────────────────────────────────
|
||||
const BIG = ['ic10', 'ic14'] // 1024×1024(ic14 = 512@2x)
|
||||
assert.ok(BIG.some((t) => types.includes(t)),
|
||||
'icns 里没有 1024×1024 图块(现有:' + types.join(',') + ')—— Retina Dock 会拿 512 放大')
|
||||
|
||||
// ── ④ 其它图标文件 ───────────────────────────────────────────────
|
||||
function pngSize (file) {
|
||||
const d = fs.readFileSync(file)
|
||||
assert.strictEqual(d.slice(1, 4).toString('latin1'), 'PNG', file + ' 不是 PNG')
|
||||
return { w: d.readUInt32BE(16), h: d.readUInt32BE(20) }
|
||||
}
|
||||
const p512 = pngSize(path.join(iconsDir, 'icon.png'))
|
||||
assert.ok(p512.w >= 512 && p512.w === p512.h, 'icon.png 必须是 >=512 的正方形,实际 ' + p512.w + '×' + p512.h)
|
||||
const p256 = pngSize(path.join(iconsDir, '[email protected]'))
|
||||
assert.strictEqual(p256.w, 256, '[email protected] 必须是 256×256,实际 ' + p256.w)
|
||||
|
||||
const ico = fs.readFileSync(path.join(iconsDir, 'icon.ico'))
|
||||
assert.strictEqual(ico.readUInt16LE(0), 0, 'icon.ico reserved 必须为 0')
|
||||
assert.strictEqual(ico.readUInt16LE(2), 1, 'icon.ico type 必须为 1(icon)')
|
||||
const icoCount = ico.readUInt16LE(4)
|
||||
assert.ok(icoCount >= 4 && icoCount <= 32, 'icon.ico 目录项数异常:' + icoCount)
|
||||
assert.ok(6 + icoCount * 16 <= ico.length, 'icon.ico 目录表越界')
|
||||
|
||||
console.log('icon-assets: icns ' + icns.length + ' B / ' + types.length + ' chunks(含 1024 主图);png / ico 结构正常')
|
||||