From b6d3cd580c6f57018043ed2e20d3711822bb9e3f Mon Sep 17 00:00:00 2001 From: qiqi Date: Mon, 30 Nov 2026 18:25:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(gallery):=20=E5=90=8C=E6=AD=A5=201.9.8?= =?UTF-8?q?=EF=BC=88=E4=BF=AE=E5=8D=A1=E7=89=87=E6=B7=98=E6=B1=B0=E8=AF=AF?= =?UTF-8?q?=E5=88=A0=E5=B1=8F=E4=B8=8A=E8=8A=82=E7=82=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/gallery/main.js | 36 +++++++++++++++++++++-------------- plugins/gallery/manifest.json | 4 ++-- plugins/index.json | 4 ++-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/plugins/gallery/main.js b/plugins/gallery/main.js index c86bf92..b7eb66a 100644 --- a/plugins/gallery/main.js +++ b/plugins/gallery/main.js @@ -588,21 +588,29 @@ box.__iwbBoot = boot nodeCache[it.name] = box nodeOrder.push(it.name) - // v1.9.7(Windows 实测:开图库面板涨 ~200MB、关闭后不降): - // 原上限 400 张卡,每张都挂着一张已解码的 ;淘汰时只从 Map 里 delete, - // detached 节点上的解码位图要等 GC 才放。现在 60 张(虚拟列表窗口约 30 张)+ 淘汰时**显式摘 src**。 - while (nodeOrder.length > 60) { - var oldN = nodeOrder.shift() - if (!oldN || oldN === it.name) continue - try { - var oldBox = nodeCache[oldN] - if (oldBox) { - var oldImg = oldBox.querySelector('img') - if (oldImg) oldImg.removeAttribute('src') - if (oldBox.parentNode) oldBox.parentNode.removeChild(oldBox) + // v1.9.8(修 1.9.7 的回归):1.9.7 把上限压到 60 并顺手把节点从 DOM 移除, + // 但面板在**没有滚动容器**时会整屏渲染全部卡片(实测 100+ 张)⇒ 淘汰到还在屏上的卡, + // 正在「加载中」的那张被移出 DOM 就永远画不出来(用户实测:整墙卡在加载中)。 + // 现在的规则:① 上限放到 300;② **只淘汰已脱离文档**的卡(虚拟列表滚走的那些); + // ③ 淘汰时显式摘 src,让解码位图尽快回收。屏上的卡永远不动。 + if (nodeOrder.length > 300) { + var drop = nodeOrder.length - 300 + var keepOrder = [] + for (var oi = 0; oi < nodeOrder.length; oi++) { + var on = nodeOrder[oi] + var ob = nodeCache[on] + if (drop > 0 && ob && !ob.isConnected) { + try { + var oimg = ob.querySelector('img') + if (oimg) oimg.removeAttribute('src') + delete nodeCache[on] + drop-- + continue + } catch (e3) { /* ignore */ } } - delete nodeCache[oldN] - } catch (e3) { /* ignore */ } + keepOrder.push(on) + } + nodeOrder = keepOrder } return box } diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json index 7fbb8ba..14397af 100644 --- a/plugins/gallery/manifest.json +++ b/plugins/gallery/manifest.json @@ -1,7 +1,7 @@ { "id": "gallery", "name": "图库", - "version": "1.9.7", + "version": "1.9.8", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "图库" ], "files": { - "main.js": "6c459033a31263fbd12e244d40c51b39a5dcbe3bc46fdf133760bc87a3fb862e", + "main.js": "8586409417599dec4b0f229e88eaf937f991f1942db49df97ce9a27e16a35d9f", "styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d" } } diff --git a/plugins/index.json b/plugins/index.json index 39065e5..d2b0bb7 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -33,9 +33,9 @@ "dir": "gallery", "main": "main.js", "style": "styles.css", - "version": "1.9.7", + "version": "1.9.8", "files": { - "main.js": "6c459033a31263fbd12e244d40c51b39a5dcbe3bc46fdf133760bc87a3fb862e", + "main.js": "8586409417599dec4b0f229e88eaf937f991f1942db49df97ce9a27e16a35d9f", "styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d" } },