chore: v3.26.238(图片读取/下载本地优先 + 命名统一图库行名)

This commit is contained in:
qiqi committed 2026-12-03 11:55:28 +08:00
1 parent ec9ca02a82
commit 48a68a7e8a
12 files changed
+173 -27

No files matched your search

+31 -1
View File
@@ -1100,6 +1100,36 @@
} catch (e) { return '' }
}
// 2026-12-03:图库条目 → **本地原图**。桌面端原图在 images/gallery/<文件>,老记录没有 origIdb。
// 预览用 galleryOriginalOf(原生按 max 解码,落 thumbs 缓存,可反复命中);下载用 galleryOriginalBlob(原始字节)。
function galleryOrigAssetOf (f) {
try {
if (!enabled() || !dir || !f) return null
const key = String(f.origIdb || ('out_orig_' + String(f.name || '')))
const a = assets[key]
return (a && a.f) ? a : null
} catch (e) { return null }
}
async function galleryOriginalOf (f, max) {
try {
const a = galleryOrigAssetOf(f)
if (!a) return null
const abs = await join(dir, a.f)
const m = Math.max(256, Number(max) || 2048)
const h16 = await sha16(new TextEncoder().encode('galorig:' + String(f.name || a.f)))
const r = await makeDisplayThumbFromPath(h16, abs, m)
return (r && r.url) ? { url: r.url, w: r.w || 0, h: r.h || 0 } : null
} catch (e) { return null }
}
async function galleryOriginalBlob (f) {
try {
const a = galleryOrigAssetOf(f)
if (!a) return null
const abs = await join(dir, a.f)
const u8 = await fs().readFile(abs)
return (u8 && u8.length) ? new Blob([u8], { type: a.m || 'application/octet-stream' }) : null
} catch (e) { return null }
}
// v3.26.131:宫格缩略图改发 **objectURL**(同一张只读一次盘、只建一次 URL)。
// 原来每张都 base64 成 dataURL(20~40KB 字符串),164 张 ⇒ 每次开面板 3~6MB 字符串 + 164 次 IPC,
// 这就是「能加载但很慢」的来源。objectURL 首帧即用,重复打开直接命中。
@@ -1613,7 +1643,7 @@
enabled, ready: init, flush,
// 供其它模块把诊断写进 _boot.log(v3.26.109)
logLine: (m) => blog(m),
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, galleryThumbOfEntry, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, galleryThumbOfEntry, galleryOriginalOf, galleryOriginalBlob, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
plugins: { manifest: pluginManifest, read: pluginRead, write: pluginWrite, remove: pluginRemove, dir: pluginDir, listLocal: pluginListLocal, listDirs: pluginListDirs, readFile: pluginReadFile, writeFile: pluginWriteFile, writeBinary: pluginWriteBinary, mkdir: pluginMkdir, removeDir: pluginRemoveDir, renameDir: pluginRenameDir, existsDir: pluginExistsDir },
pluginData: { read: pluginDataRead, write: pluginDataWrite, remove: pluginDataRemove, list: pluginDataList },
pluginFiles: { put: pluginFilePut, get: pluginFileGet, list: pluginFileList, remove: pluginFileRemove, stat: pluginFileStat, dir: pluginFilesDir, readBytes: pluginFileReadBytes, listAll: pluginFilesListAll },
+18 -2
View File
@@ -20,7 +20,7 @@
const useCallback = React.useCallback
const useLayoutEffect = React.useLayoutEffect
let ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl
let ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, wOutNameOf, nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl
function inject (d) {
if (!d) throw new Error('[iwb][IWBUICanvasView] 依赖未注入')
@@ -29,6 +29,7 @@
computeEdgePath = d.computeEdgePath
copyImageToClipboard = d.copyImageToClipboard
downloadUrl = d.downloadUrl
wOutNameOf = d.wOutNameOf
nodeTypeColor = d.nodeTypeColor
nodeTypeH = d.nodeTypeH
nodeWidth = d.nodeWidth
@@ -339,6 +340,15 @@ function ImagePreview(props) {
if (!e || typeof e === 'string' || !e.__gallery) return Promise.resolve(placeholderOf(e))
const key = 'orig:' + entryKeyOf(e)
const hit = cachedOf(key); if (hit) return Promise.resolve(hit)
// 2026-12-03(用户裁定「本地优先」):没有 origIdb 的老记录,直接按行名读 images/gallery 原图(原生解码),
// 不再退回 320 缩略图、也不直连远程;返回的是宿主持有的 objectURL,不进本组件的回收表。
const SF = (typeof window !== 'undefined') ? window.IWBStorageFile : null
if (!e.origIdb && e.name && SF && typeof SF.galleryOriginalOf === 'function') {
return Promise.resolve(SF.galleryOriginalOf({ name: e.name, origIdb: e.origIdb }, 2048))
.then((g) => (g && g.url) || '')
.catch(() => '')
.then((u) => u || urlOfFallback(e.url || placeholderOf(e), key, 'orig'))
}
const idbKey = e.origIdb || e.idb
if (!idbKey) return urlOfFallback(e.url || placeholderOf(e), key, 'orig')
const p = (typeof IDB.getBlob === 'function') ? IDB.getBlob(idbKey) : IDB.get(idbKey)
@@ -363,6 +373,10 @@ function ImagePreview(props) {
return wBlobFromDataUrl(str)
}
const fallbackStr = e.url || placeholderOf(e)
const SF2 = (typeof window !== 'undefined') ? window.IWBStorageFile : null
if (!e.origIdb && e.name && SF2 && typeof SF2.galleryOriginalBlob === 'function') {
return Promise.resolve(SF2.galleryOriginalBlob({ name: e.name, origIdb: e.origIdb })).then((b) => b || null).catch(() => null)
}
const idbKey = e.origIdb || e.idb
if (!idbKey) return Promise.resolve(asBlobOf(fallbackStr)).then((b) => ((b && b.size) ? b : null)).catch(() => null)
const p = (typeof IDB.getBlob === 'function') ? IDB.getBlob(idbKey) : IDB.get(idbKey)
@@ -533,7 +547,9 @@ function ImagePreview(props) {
// downloadUrl 只吃 URL:把字节登记成**可取回**的 objectURL(wBlobRefGet 能反查),否则下载链路取不到 Blob
const blob = await loadOriginalBlob(entry).catch(() => null)
const blobUrl = (blob && typeof wRegisterBlobUrl === 'function') ? wRegisterBlobUrl(blob) : ''
downloadUrl(blobUrl || src, 'image.png')
// 2026-12-03:预览下载同样走图库行名(图库条目直接用行名,其余按 url 查),未落地才回退 image.png
const dlName = (entry && entry.__gallery && entry.name) ? String(entry.name) : ((typeof wOutNameOf === 'function' && wOutNameOf(entry && entry.url)) || 'image.png')
downloadUrl(blobUrl || src, dlName)
},
}, I('download'), ' 下载'),
),
+4 -2
View File
@@ -11,7 +11,7 @@
// · ctx = { onUpdate, busy, progress, h, stop, refMini },由调用方 renderBodyInner 组装。
// ── 注入依赖(app.js 在首次渲染时调用 inject 注入)─────────────────────────
let ingestView, I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, isImageProducer, nodePreviewRefsV2, nodeInheritOf, orderedUniqueRefNodes, outProgUI, outThumbCache, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg, wThumbSrc, el, wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder, GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName, ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, wThumbBump
let ingestView, I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, wOutNameOf, isImageProducer, nodePreviewRefsV2, nodeInheritOf, orderedUniqueRefNodes, outProgUI, outThumbCache, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg, wThumbSrc, el, wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder, GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName, ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, wThumbBump
// 2026-12-03:输出格「NEW」标记 —— 只认本次启动之后生成的图;已确认的 key 记在内存里,不写画布存档。
const OUT_NEW_SINCE = Date.now()
const outNewSeen = new Set()
@@ -29,6 +29,7 @@
combineSourcePairs = D.combineSourcePairs
downloadUrl = D.downloadUrl
wResolveOutSrc = D.wResolveOutputSrc
wOutNameOf = D.wOutNameOf
isImageProducer = D.isImageProducer
nodePreviewRefsV2 = D.nodePreviewRefsV2
nodeInheritOf = D.nodeInheritOf
@@ -919,7 +920,8 @@
let src = r.url
// v3.25.18:从资料目录的本地归档取图(原图优先),远端 URL 只作兜底
try { if (wResolveOutSrc) src = (await wResolveOutSrc(r, true)) || r.url } catch (e) { /* 回退远端 */ }
downloadUrl(src, 'image.png')
// 2026-12-03:文件名统一用图库行名(未落地才回退 image.png),与图库下载一致
downloadUrl(src, (typeof wOutNameOf === 'function' && wOutNameOf(r.url)) || 'image.png')
}
// 生成中(2026-12-02,用户裁定「方案 1」):某一轮还在跑时,旧图压暗 + 角标「生成中」,
// 但不改 data.result —— 失败时旧图原样保留,不会出现「图没了」。