From c8ae61a3edcbefce9c5e487b18296186f351cd09 Mon Sep 17 00:00:00 2001 From: qiqi Date: Sat, 21 Nov 2026 23:23:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(gallery):=201.6.4=20=E9=A6=96=E5=B1=8F?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E6=B5=8B=E9=87=8F=20+=20=E8=BE=B9=E8=B7=9D?= =?UTF-8?q?=E6=94=B6=E7=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gallery/package.json | 2 +- gallery/src/index.js | 20 +++++++++++++++++--- gallery/styles.css | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/gallery/package.json b/gallery/package.json index e091059..9540c52 100644 --- a/gallery/package.json +++ b/gallery/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/gallery", "private": true, - "version": "1.6.3", + "version": "1.6.4", "description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供", "ibwPlugin": { "id": "gallery", diff --git a/gallery/src/index.js b/gallery/src/index.js index 498c2be..9b73e05 100644 --- a/gallery/src/index.js +++ b/gallery/src/index.js @@ -443,13 +443,27 @@ } // 宽度测量:列数只由「面板宽 / 图幅」决定 - function measure () { + // v1.6.4:面板刚挂载时 grid 宽度可能是 0,而 grid 宽度又取决于列宽 → RO 不会触发,图库一直空白。 + function availableW () { var w = grid.clientWidth + if (!w && wrap) w = wrap.clientWidth + if (!w && wrap && wrap.parentNode) w = wrap.parentNode.clientWidth + return w || 0 + } + function measure () { + var w = availableW() if (w > 0 && Math.abs(w - gridW) > 1) { gridW = w; renderGrid() } } var ro = typeof ResizeObserver === 'function' ? new ResizeObserver(function () { measure() }) : null - if (ro) ro.observe(grid) + if (ro) { ro.observe(grid); if (wrap) ro.observe(wrap) } measure() + var tries = 0 + function retry () { + if (gridW > 0 || tries++ > 40) { if (gridW <= 0) { gridW = Math.max(160, Number(cfg.tile) || 110) * 2; renderGrid() } return } + measure() + if (gridW <= 0) global.requestAnimationFrame(retry) + } + global.requestAnimationFrame(retry) // v1.3.0:自动恢复 —— 面板重新可见(切回 tab / 窗口聚焦 / 后台回来)且距上次拉取 >5s 时重拉一次, // 这样图床恢复、后台补图后不必手动刷新;同时保留底部「刷新」按钮做即时重试。 @@ -488,7 +502,7 @@ global.IWBPluginHost.register({ id: 'gallery', name: '图库', - version: '1.6.3', + version: '1.6.4', apiVersion: 1, capabilities: ['panels', 'gallery'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/gallery/styles.css b/gallery/styles.css index 2acd8a4..d4e9af4 100644 --- a/gallery/styles.css +++ b/gallery/styles.css @@ -5,8 +5,8 @@ */ /* ---- 面板留白:边缘收小,避免窄栏里浪费空间 ---- */ -.iwb-history-embedded { padding: 8px 8px 6px; gap: 6px; } -.iwb-history-embedded .iwb-history-grid { gap: 6px; padding: 0 0 4px; justify-content: center; } +.iwb-history-embedded { padding: 6px 6px 4px; gap: 6px; } +.iwb-history-embedded .iwb-history-grid { gap: 6px; padding: 0 0 2px; justify-content: flex-start; } /* 列宽由插件按「图幅」写死(style width),这里禁用宿主的 flex:1 拉伸 */ .iwb-history-embedded .iwb-history-col { flex: 0 0 auto; gap: 6px; }