release: v3.26.103 相册重选与缩略图自愈
This commit is contained in:
1 parent
9a35e71e41
commit
24fdb0bca6
8 files changed
+72
-19
No files matched your search
@@ -16,6 +16,12 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## 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 是运行时授权,重启后失效;缩略图有插件缓存还能显示,组合/参考图读原图失败,只有本次新导入的图正常。
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
6. **外部路径的 fs 授权不是持久的。**
|
||||
`{__file}` 只存路径;Tauri fs scope 重启即失效。`grant_paths` 必须落盘,启动时恢复;
|
||||
旧画布还要扫描已知 `{__file}` 再 grant 一次。否则“缩略图有缓存、组合节点全感叹号”,且只有新导入的图正常。
|
||||
重选文件夹也不要直接 append:按归一化路径就地更新,清 missing + 缩略图缓存 + forceThumbs,否则坏格留在前面、重复项排到后面/下一页。
|
||||
|
||||
---
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.102",
|
||||
"version": "3.26.103",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
|
||||
+58
-12
@@ -66,6 +66,9 @@
|
||||
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/张,不碰画布存储)────────────
|
||||
@@ -143,6 +146,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 +358,25 @@
|
||||
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 || img.isConnected === false) return
|
||||
img.onerror = () => {
|
||||
if (thumbRetried) return
|
||||
thumbRetried = true
|
||||
st.thumbs.delete(key)
|
||||
if (st.forceThumbs) st.forceThumbs.add(key)
|
||||
try { if (ctx.files) ctx.files.remove(thumbNameOf(key)) } catch (e) { /* ignore */ }
|
||||
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
|
||||
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 })
|
||||
else loadThumb(ctx, st, it, key).then(applyThumb)
|
||||
btn.appendChild(img)
|
||||
btn.appendChild(el('span', { className: 'iwb-album-idx' }, String(index + 1)))
|
||||
// 批次角标(右上角那个「1」)已删除:顶栏「N 张 → M 个任务」已经说清楚,角标是重复信息,
|
||||
@@ -442,19 +460,20 @@
|
||||
// ── 缩略图取用:内存 → 插件文件 → 现做 ───────────────────
|
||||
// 并发去重(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)
|
||||
async function loadThumbInner (ctx, st, it, key, force) {
|
||||
if (!force && st.thumbs.has(key)) return st.thumbs.get(key)
|
||||
const name = thumbNameOf(key)
|
||||
try {
|
||||
if (ctx.files) {
|
||||
if (!force && ctx.files) {
|
||||
const got = await ctx.files.get(name)
|
||||
if (got && got.ok && got.url) { st.thumbs.set(key, got.url); return got.url }
|
||||
}
|
||||
@@ -470,6 +489,7 @@
|
||||
const thumb = await makeThumb(dataUrl)
|
||||
if (!thumb) return ''
|
||||
st.thumbs.set(key, thumb)
|
||||
if (st.forceThumbs) st.forceThumbs.delete(key)
|
||||
// 内存里已经有一张就够本会话用了;写盘失败(配额满)不影响显示
|
||||
try { if (ctx.files) await ctx.files.put(name, thumb) } catch (e) { /* ignore */ }
|
||||
return thumb
|
||||
@@ -645,7 +665,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 +716,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)
|
||||
try { if (ctx.files) await ctx.files.remove(thumbNameOf(oldKey)) } catch (e) { /* ignore */ }
|
||||
// 路径大小写/分隔符不同 ⇒ 新 key 也要清掉旧缓存并强制重读
|
||||
const newKey = thumbKeyOf(items[at])
|
||||
if (newKey !== oldKey) {
|
||||
st.thumbs.delete(newKey)
|
||||
if (st.forceThumbs) st.forceThumbs.add(newKey)
|
||||
try { if (ctx.files) await ctx.files.remove(thumbNameOf(newKey)) } catch (e) { /* ignore */ }
|
||||
}
|
||||
} else {
|
||||
items.push({ src: nextSrc, name: ref.item.name, size: ref.item.size, mtime: ref.item.mtime, on: true })
|
||||
}
|
||||
}
|
||||
st.busy = ''
|
||||
st.checkedMissing = false // 新图要重新做一次失联检测(否则清空后再导入,检测永远不再跑)
|
||||
@@ -812,7 +858,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'album',
|
||||
name: '相册',
|
||||
version: '1.1.4',
|
||||
version: '1.1.5',
|
||||
apiVersion: 1,
|
||||
capabilities: ['nodeTypes', 'images', 'files'],
|
||||
settings: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "album",
|
||||
"name": "相册",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -14,7 +14,7 @@
|
||||
"出图"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "7e092c7b38842661fde9bd301306609b38f3927c7025d97f4ab29bfc04683914",
|
||||
"main.js": "af2e2dc9331b62e7a49945b855bca95bf52e6dad8e4a52c74f50c11a031e5527",
|
||||
"styles.css": "f8af2310bc5fe099f726f05b5234f928fe31a651f2143c96c88e474b9797fdf7"
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -4,9 +4,9 @@
|
||||
"dir": "album",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.5",
|
||||
"files": {
|
||||
"main.js": "7e092c7b38842661fde9bd301306609b38f3927c7025d97f4ab29bfc04683914",
|
||||
"main.js": "af2e2dc9331b62e7a49945b855bca95bf52e6dad8e4a52c74f50c11a031e5527",
|
||||
"styles.css": "f8af2310bc5fe099f726f05b5234f928fe31a651f2143c96c88e474b9797fdf7"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.102"
|
||||
version = "3.26.103"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.102",
|
||||
"version": "3.26.103",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
Reference in new issue
Block a user