diff --git a/gallery/package.json b/gallery/package.json index 066f4a5..1ca6679 100644 --- a/gallery/package.json +++ b/gallery/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/gallery", "private": true, - "version": "1.9.5", + "version": "1.9.6", "description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供", "ibwPlugin": { "id": "gallery", diff --git a/gallery/src/index.js b/gallery/src/index.js index e5a852b..2a58951 100644 --- a/gallery/src/index.js +++ b/gallery/src/index.js @@ -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 },