From 318a7a29800eb20010c71a90207a653877e2c76d Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 20 Nov 2026 15:02:47 +0800 Subject: [PATCH] =?UTF-8?q?chore(plugin):=20=E5=90=8C=E6=AD=A5=20gallery?= =?UTF-8?q?=201.6.2=EF=BC=88=E5=9B=BE=E5=B9=85=E5=88=97=E5=AE=BD=E4=B8=8A?= =?UTF-8?q?=E9=99=90=EF=BC=89+=20=E5=B8=83=E5=B1=80=E5=9B=9E=E5=BD=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/gallery/main.js | 16 ++++++++++------ plugins/gallery/manifest.json | 6 +++--- plugins/gallery/styles.css | 4 +++- plugins/index.json | 6 +++--- tests/plugin-gallery-recovery-test.js | 4 ++-- tests/plugin-gallery-ux-test.js | 24 +++++++++++++++++++++++- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/plugins/gallery/main.js b/plugins/gallery/main.js index be12e2c..84bdcda 100644 --- a/plugins/gallery/main.js +++ b/plugins/gallery/main.js @@ -8,8 +8,9 @@ if (!global.IWBPluginHost) return var PANEL_ID = 'gallery-panel' - var DEF = { insertK: '1k', tile: 130, range: '' } - var TILES = [[110, '小'], [130, '中'], [170, '大'], [220, '特大']] + var DEF = { insertK: '1k', tile: 110, range: '' } + // v1.6.2:图幅=**实际显示宽度上限**(此前只当「算列数」用,独列时会被拉到撑满面板,选「小」也很大) + var TILES = [[80, '小'], [110, '中'], [150, '大'], [200, '特大']] var KS = [['orig', '原图'], ['2k', '2K'], ['1k', '1K'], ['0.5k', '0.5K']] var RANGES = [['', '全部'], ['today', '今天'], ['7d', '7 天'], ['30d', '30 天']] @@ -296,7 +297,10 @@ function renderGrid () { clear(grid) var gap = 6 - var n = Math.max(1, Math.floor((gridW + gap) / (Number(cfg.tile) + gap))) + var tileW = Math.max(40, Number(cfg.tile) || 110) + var n = Math.max(1, Math.floor((gridW + gap) / (tileW + gap))) + // 列宽 = min(图幅, 均分宽度):图幅是「显示宽度上限」,不再把单列拉满面板 + var colW = Math.min(tileW, (gridW - gap * (n - 1)) / n) var cols = [] var heights = [] for (var c = 0; c < n; c++) { cols.push([]); heights.push(0) } @@ -306,10 +310,10 @@ var min = 0 for (var j = 1; j < n; j++) if (heights[j] < heights[min]) min = j cols[min].push(it) - heights[min] += ((gridW - gap * (n - 1)) / n) * ratio + gap + heights[min] += colW * ratio + gap } for (var ci = 0; ci < cols.length; ci++) { - var col = el('div', { class: 'iwb-history-col' }) + var col = el('div', { class: 'iwb-history-col', style: 'width:' + Math.round(colW) + 'px;flex:0 0 auto' }) for (var k = 0; k < cols[ci].length; k++) col.appendChild(itemNode(cols[ci][k])) grid.appendChild(col) } @@ -483,7 +487,7 @@ global.IWBPluginHost.register({ id: 'gallery', name: '图库', - version: '1.6.1', + version: '1.6.2', apiVersion: 1, capabilities: ['panels', 'gallery'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json index dd6468a..489e956 100644 --- a/plugins/gallery/manifest.json +++ b/plugins/gallery/manifest.json @@ -1,7 +1,7 @@ { "id": "gallery", "name": "图库", - "version": "1.6.1", + "version": "1.6.2", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "图库" ], "files": { - "main.js": "6d16259327ea048cda59bf7db480acd112efaa2ee60ede5ea3462f7c7b76d1fd", - "styles.css": "5d1a2a72e9dd7468284ab0143e15b0b340b0f29061c93e108037e3fa812a39e5" + "main.js": "da30d606598e9a6e6afd0fce845f937b23c7461938b5ca08623be32dcac9c23e", + "styles.css": "81b23c43b0308c678bf95e00d6663abcb8b300242ab952ca56b1390fd74bb53e" } } diff --git a/plugins/gallery/styles.css b/plugins/gallery/styles.css index c779f0e..2acd8a4 100644 --- a/plugins/gallery/styles.css +++ b/plugins/gallery/styles.css @@ -6,7 +6,9 @@ /* ---- 面板留白:边缘收小,避免窄栏里浪费空间 ---- */ .iwb-history-embedded { padding: 8px 8px 6px; gap: 6px; } -.iwb-history-embedded .iwb-history-grid { gap: 6px; padding: 0 0 4px; } +.iwb-history-embedded .iwb-history-grid { gap: 6px; padding: 0 0 4px; justify-content: center; } +/* 列宽由插件按「图幅」写死(style width),这里禁用宿主的 flex:1 拉伸 */ +.iwb-history-embedded .iwb-history-col { flex: 0 0 auto; gap: 6px; } /* ---- 顶栏 ---- */ .iwb-gal-head { display: flex; align-items: center; gap: 6px; min-height: 0; } diff --git a/plugins/index.json b/plugins/index.json index c464da2..07bef30 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -22,10 +22,10 @@ "dir": "gallery", "main": "main.js", "style": "styles.css", - "version": "1.6.1", + "version": "1.6.2", "files": { - "main.js": "6d16259327ea048cda59bf7db480acd112efaa2ee60ede5ea3462f7c7b76d1fd", - "styles.css": "5d1a2a72e9dd7468284ab0143e15b0b340b0f29061c93e108037e3fa812a39e5" + "main.js": "da30d606598e9a6e6afd0fce845f937b23c7461938b5ca08623be32dcac9c23e", + "styles.css": "81b23c43b0308c678bf95e00d6663abcb8b300242ab952ca56b1390fd74bb53e" } }, { diff --git a/tests/plugin-gallery-recovery-test.js b/tests/plugin-gallery-recovery-test.js index cea9593..073af27 100644 --- a/tests/plugin-gallery-recovery-test.js +++ b/tests/plugin-gallery-recovery-test.js @@ -156,11 +156,11 @@ async function boot ({ items, thumb, clock }) { // 改图幅 → 落盘 + 重排 btn.dispatchEvent(new env.window.MouseEvent('click', { bubbles: true })) const tileSel = Array.from(panel.querySelectorAll('select'))[1] - tileSel.value = '170' + tileSel.value = '150' // v1.6.2 图幅档位:80 小 / 110 中 / 150 大 / 200 特大 tileSel.dispatchEvent(new env.window.Event('change')) await wait(320) assert.ok(env.patched, '改设置应通过 ctx.data 落盘') - assert.strictEqual(env.patched.cfg.tile, '170', '落盘应带新的图幅') + assert.strictEqual(env.patched.cfg.tile, '150', '落盘应带新的图幅') } console.log('plugin-gallery recovery checks passed(坏图不留白块 / 自动恢复 / 防抖 / 手动刷新 / 设置浮层)') diff --git a/tests/plugin-gallery-ux-test.js b/tests/plugin-gallery-ux-test.js index 1cd8fde..4db2cee 100644 --- a/tests/plugin-gallery-ux-test.js +++ b/tests/plugin-gallery-ux-test.js @@ -135,5 +135,27 @@ async function boot (opts) { assert.strictEqual(env.calls.insert[0][0].length, 2, '批量插入应含 2 张,实际 ' + env.calls.insert[0][0].length) } - console.log('gallery ux checks passed(失败统计+全部重试 / 右键菜单 5 项 / 多选拖拽批量插入)') + // ---------- ⑤ 图幅=显示宽度上限(v1.6.2:不再被拉满面板)---------- + { + const env = await boot({ + items: Array.from({ length: 6 }, (_, i) => ({ name: 'p' + i + '.png', w: 200, h: 300 })), + thumb: () => GOOD, + }) + const widths = () => Array.from(env.host.querySelectorAll('.iwb-history-col')).map((c) => c.style.width) + // 默认「中」=110px:列宽应为 110(而不是被 flex 拉满) + assert.ok(widths().every((w) => w === '110px'), '默认列宽应为 110px,实际 ' + widths().join(',')) + const cols = env.host.querySelectorAll('.iwb-history-col').length + assert.ok(cols >= 2, '应至少 2 列,实际 ' + cols) + + // 切到「特大」=200px:列宽应变 200 + env.host.querySelector('.iwb-gal-setbtn').dispatchEvent(new env.window.MouseEvent('click', { bubbles: true })) + const panel = env.host.querySelector('.iwb-gal-settings') + const tileSel = panel.querySelectorAll('select')[1] + tileSel.value = '200' + tileSel.dispatchEvent(new env.window.Event('change')) + await wait(60) + assert.ok(widths().every((w) => w === '200px'), '切到特大后列宽应为 200px,实际 ' + widths().join(',')) + } + + console.log('gallery ux checks passed(失败统计+全部重试 / 右键菜单 5 项 / 多选拖拽批量插入 / 图幅列宽上限)') })().catch((e) => { console.error(e); process.exit(1) }) \ No newline at end of file