perf(gallery): v3.26.131 缩略图改 objectURL(修宫格加载慢)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s

This commit is contained in:
qiqi committed 2026-11-30 18:37:25 +08:00
1 parent 3e0fb3bdf8
commit e59011b591
8 files changed
+51 -7

No files matched your search

+5 -1
View File
@@ -186,7 +186,7 @@
// 等缩略图就绪(最多 ~3s):宫格显示「加载中…」好过把 8MB base64 塞进 DOM
const settle = async (src) => {
if (!src) return ''
for (let i = 0; i < 15; i++) {
for (let i = 0; i < 8; i++) { // v3.26.131:3s → 1.6s,缺缩略图的卡别把宫格拖住
const u = display(src)
if (u && !HUGE_DATA(u)) return u
await new Promise((r) => setTimeout(r, 200))
@@ -198,6 +198,10 @@
// 原因:displayThumbOf 会给每张图 mint 一个 objectURL 并写进宿主 displayThumbs(300),
// 点开图库面板就是上百个 objectURL + 上百张 512 解码位图;关闭面板后这些 URL 仍被缓存持有,
// 位图也就跟着留着。320 缩略图本身是 ~20KB 的 data URL,内核可随时丢弃,直接给 <img> 最省。
// v3.26.131:优先要 **objectURL**(首帧可用、重复打开零成本);拿不到再退回 dataURL。
if (f.thumbHash && typeof e.galleryThumbUrl === 'function') {
try { const v = await e.galleryThumbUrl(f.thumbHash); if (v) return v } catch (err) { /* 继续 */ }
}
if (f.thumbHash && typeof e.galleryThumb === 'function') {
try { const v = await e.galleryThumb(f.thumbHash); if (v && !HUGE_DATA(v)) return v } catch (err) { /* 继续本地副本 */ }
}