chore(plugin): 同步 gallery 1.6.2(图幅列宽上限)+ 布局回归
This commit is contained in:
1 parent
440c4d6590
commit
318a7a2980
6 files changed
+44
-16
No files matched your search
+10
-6
@@ -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 },
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
+3
-3
@@ -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"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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(坏图不留白块 / 自动恢复 / 防抖 / 手动刷新 / 设置浮层)')
|
||||
|
||||
@@ -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) })
|
||||
Reference in new issue
Block a user