fix: v3.26.172 新图无缩略图时最多占位 300ms 后回退原图(修标注替换原图后节点空白)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s

This commit is contained in:
qiqi committed 2026-12-01 17:40:43 +08:00
1 parent 56975e69fd
commit 7bc0752cec
5 files changed
+14 -6

No files matched your search

+10 -2
View File
@@ -11,6 +11,7 @@
function create (deps) {
const d = deps || {}
const missAt = new Map() // key -> 首次发现「无缩略图」的时间(300ms 后回退原图)
const cache = d.cache // Map<stableKey, url>
const max = Math.max(64, Number(d.max) || 768)
// v3.26.121:小档(256)缓存与队列;缺省不启用(只有注入时才分档)
@@ -56,13 +57,20 @@
// 小图没就绪时先给 512(已有就秒出)或占位,绝不为了"小一档"去同步解原图。
if (key && smallCache && need <= smallMax) {
const sm = smallCache.get(key)
if (sm) return sm
if (sm) { missAt.delete(key); return sm }
const orig0 = (v && typeof v === 'object')
? ((typeof d.resolveImg === 'function' ? d.resolveImg(v) : '') || '')
: String(v || '')
if (orig0 && !/^https?:/i.test(orig0) && typeof smallQueue === 'function') smallQueue(key, orig0)
if (thumb) return thumb
return /^https?:/i.test(orig0) ? orig0 : (thumb || '')
// v3.26.172:小图还没生成时**最多占位 300ms**,超时就退回原图 ——
// 之前本地图无缩略图时一律返回空串,遇到「标注替换原图」这类新字节,
// 新 key 没有缓存、缩略图又生成失败/很慢时,节点就一直是空白(观感=图片丢了)。
if (/^https?:/i.test(orig0)) return orig0
const t0 = missAt.get(key)
if (t0 === undefined) missAt.set(key, Date.now())
else if (Date.now() - t0 > 300) return orig0
return thumb || ''
}
if (thumb && need <= ORIG_HARD_CAP) return thumb
const orig = (v && typeof v === 'object')