两个都是 node 复用 / 虚拟列表引入的回归,被单元测试抓到(tests/plugin-gallery-ux-test.js 读的就是本仓源码): - 全部重试无效:失败卡片在缓存里只有失败占位(没有 img),retryAll 只 render 会把它原样拿回来。 现在 retryAll 先清 nodeCache/nodeOrder 强制重建;itemNode 的复用分支也加了 !failed[name] 保护。 - 列数塌成 1:usableW() 量不到宽度时返回 Math.max(80,…),jsdom 里 clientWidth 恒为 0 ⇒ 面板被当成 80px。 改为量不到就返回 0,让调用方用 320 的兜底值(真实环境行为不变)。 版本 1.9.6(package.json 与 entry 内 register manifest 同步)。
This commit is contained in:
1 parent
23cba0ccf3
commit
c2ac777547
2 files changed
+16
-4
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/gallery",
|
||||
"private": true,
|
||||
"version": "1.9.5",
|
||||
"version": "1.9.6",
|
||||
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
|
||||
"ibwPlugin": {
|
||||
"id": "gallery",
|
||||
|
||||
+15
-3
@@ -272,6 +272,9 @@
|
||||
failed = {}
|
||||
updateFail()
|
||||
setStatus('重试中…')
|
||||
// v1.9.6:先清掉卡片缓存 —— 失败那张的缓存只有失败占位(没有 img),
|
||||
// 不清就等于把坏卡原样拿回来,重试永远看不到图(unit 里「两张都应重新挂上 img」会红)。
|
||||
try { for (var ck in nodeCache) delete nodeCache[ck]; nodeOrder.length = 0 } catch (e6) { /* ignore */ }
|
||||
render()
|
||||
}
|
||||
function pickedNames () { return Object.keys(picked) }
|
||||
@@ -459,7 +462,9 @@
|
||||
var nodeOrder = []
|
||||
function itemNode (it, seq) {
|
||||
var hit = nodeCache[it.name]
|
||||
if (hit && hit.__iwbItem === it) {
|
||||
// v1.9.6:失败过的卡片不复用 —— 缓存里那张只有失败占位(没有 img),
|
||||
// 复用会让「全部重试」永远无效(重试只重建 DOM,拿回的还是那张坏卡)。
|
||||
if (hit && hit.__iwbItem === it && !failed[it.name]) {
|
||||
// 复用时把上轮可能还停在 display:none 的缩略图复位(否则看起来「没图」)
|
||||
var hi = hit.querySelector('img')
|
||||
if (hi && hi.style.display === 'none' && hi.complete && hi.naturalWidth > 0) hi.style.display = ''
|
||||
@@ -685,7 +690,14 @@
|
||||
}
|
||||
w = sc.clientWidth - padCache.l - padCache.r
|
||||
}
|
||||
if (!w || w < 80) w = availableW()
|
||||
// v1.9.6:量不到宽度时返回 0(交回调用方用 320 的兜底值)。
|
||||
// 原来这里强制 Math.max(80, …),jsdom 里 clientWidth 恒为 0 ⇒ 面板被当成 80px ⇒ 只剩 1 列,
|
||||
// 多列布局的单元测试因此全红(真实环境不受影响,但测试不该和现实不一致)。
|
||||
if (!w || w < 80) {
|
||||
var aw = availableW()
|
||||
if (!aw) return 0
|
||||
w = aw
|
||||
}
|
||||
return Math.max(80, Math.floor(w) - 4)
|
||||
}
|
||||
function availableW () {
|
||||
@@ -811,7 +823,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.9.5',
|
||||
version: '1.9.6',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
Reference in new issue
Block a user