fix(gallery): 1.6.4 首屏宽度测量 + 边距收紧
validate / validate (push) Canceled after 0s

This commit is contained in:
qiqi committed 2026-11-21 23:23:23 +08:00
1 parent 3ea7c239ac
commit c8ae61a3ed
3 files changed
+20 -6

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/gallery",
"private": true,
"version": "1.6.3",
"version": "1.6.4",
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
"ibwPlugin": {
"id": "gallery",
+17 -3
View File
@@ -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 },
+2 -2
View File
@@ -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; }