diff --git a/plugins/index.json b/plugins/index.json index 7a06de4..022c181 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -19,9 +19,9 @@ }, { "id": "gallery", - "file": "plugin-gallery.4d7d2d5d9875.js", - "version": "1.3.0", - "integrity": "sha256-TX0tXZh1XchHl+UHYZbR1+yOgENgXPBOggYFTOBq84M=" + "file": "plugin-gallery.e92b04e71bd5.js", + "version": "1.4.0", + "integrity": "sha256-6SsE5xvVaOqk4EZrlF62AZVSfyjlj6IoOV7Yc+3aYWw=" }, { "id": "image-annotate", diff --git a/plugins/runtime/plugin-gallery.4d7d2d5d9875.js b/plugins/runtime/plugin-gallery.e92b04e71bd5.js similarity index 85% rename from plugins/runtime/plugin-gallery.4d7d2d5d9875.js rename to plugins/runtime/plugin-gallery.e92b04e71bd5.js index 8f2fbb5..56b6f7a 100644 --- a/plugins/runtime/plugin-gallery.4d7d2d5d9875.js +++ b/plugins/runtime/plugin-gallery.e92b04e71bd5.js @@ -72,17 +72,33 @@ var statusEl = el('span', { class: 'iwb-gal-status', text: '' }) var refreshBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '刷新', title: '重新向宿主拉取图库(图床恢复/外部改动后点这里)' }) refreshBtn.addEventListener('click', function () { load(true) }) - var opts = el('div', { class: 'iwb-gal-opts' }) + // v1.4.0:三个下拉不再占用前台(窄栏放不下、也显乱)——收进「设置」浮层,点按钮才展开。 + var setBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-gal-setbtn', text: '设置', title: '图库设置:插入尺寸 / 图幅 / 时间范围', 'aria-expanded': 'false' }) + var settings = el('div', { class: 'iwb-gal-settings', role: 'dialog', 'aria-label': '图库设置' }) + settings.style.display = 'none' var foot = el('div', { class: 'iwb-gal-foot' }, - el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, statusEl, refreshBtn), opts) - var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot]) + el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, statusEl, refreshBtn), setBtn) + var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot, settings]) + + function setOpen (open) { + settings.style.display = open ? '' : 'none' + setBtn.setAttribute('aria-expanded', open ? 'true' : 'false') + setBtn.classList.toggle('iwb-gal-setbtn-on', !!open) + if (open) document.addEventListener('pointerdown', onDocDown, true) + else document.removeEventListener('pointerdown', onDocDown, true) + } + function onDocDown (e) { + if (settings.contains(e.target) || setBtn.contains(e.target)) return + setOpen(false) + } + setBtn.addEventListener('click', function (e) { e.stopPropagation(); setOpen(settings.style.display === 'none') }) host.appendChild(wrap) function count () { return Object.keys(picked).length } function pickedNames () { return Object.keys(picked) } function renderHead () { - clear(actions); clear(opts) + clear(actions) countEl.textContent = items.length + ' / ' + total + ' 张' pickedEl.textContent = count() ? ('已选 ' + count()) : '' var n = count() @@ -111,16 +127,26 @@ }).catch(function () {}) }, true, true)) - function field (key, options, label) { + } + + // 设置浮层内容只建一次(不随每次 render 重建,避免下拉被重置) + function buildSettings () { + clear(settings) + settings.appendChild(el('div', { class: 'iwb-gal-settings-title', text: '图库设置' })) + function row (key, options, label, hint) { var s = sel(options, cfg[key]) - s.title = label + s.title = hint || label s.setAttribute('aria-label', label) - s.addEventListener('change', function () { cfg[key] = s.value; saveCfg(); if (key === 'range') { limit = 100; load() } else if (key === 'tile') render() }) - return s + s.addEventListener('change', function () { + cfg[key] = s.value + saveCfg() + if (key === 'range') { limit = 100; load() } else if (key === 'tile') render() + }) + return el('label', { class: 'iwb-gal-setrow' }, el('span', { class: 'iwb-gal-setlabel', text: label }), s) } - opts.appendChild(field('insertK', KS, '插入画布时的图片尺寸')) - opts.appendChild(field('tile', TILES, '图库图片显示宽度')) - opts.appendChild(field('range', RANGES, '按生成时间筛选')) + settings.appendChild(row('insertK', KS, '插入尺寸', '插入画布时的图片尺寸')) + settings.appendChild(row('tile', TILES, '图幅', '图库图片显示宽度')) + settings.appendChild(row('range', RANGES, '时间范围', '按生成时间筛选')) } function renderGrid () { @@ -286,17 +312,20 @@ // 先读配置,再拉列表 Promise.resolve(ctx.data && ctx.data.read ? ctx.data.read() : {}).then(function (d) { if (d && d.cfg) cfg = Object.assign({}, DEF, d.cfg) - renderHead() // 三个下拉要反映读到的配置 + buildSettings() // 设置浮层里的下拉要反映读到的配置 return load() - }).catch(function () { load() }) + }).catch(function () { buildSettings(); load() }) - return function dispose () { if (ro) { try { ro.disconnect() } catch (e) { /* ignore */ } } } + return function dispose () { + if (ro) { try { ro.disconnect() } catch (e) { /* ignore */ } } + try { document.removeEventListener('pointerdown', onDocDown, true) } catch (e) { /* ignore */ } + } } global.IWBPluginHost.register({ id: 'gallery', name: '图库', - version: '1.3.0', + version: '1.4.0', apiVersion: 1, capabilities: ['panels', 'gallery'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/style.css b/style.css index 2890a99..3fa38ef 100644 --- a/style.css +++ b/style.css @@ -2125,6 +2125,20 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-gal-count { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; } .iwb-gal-status { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; } .iwb-gal-opts { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; margin-left: auto; } +/* 图库设置浮层(v1.4.0):三个下拉不再占前台,点「设置」从底栏上方浮出 */ +.iwb-history-embedded { position: relative; } +.iwb-gal-setbtn { margin-left: auto; flex: 0 0 auto; } +.iwb-gal-setbtn-on { background: var(--iwb-layer2); border-color: var(--iwb-border-strong, var(--iwb-border)); } +.iwb-gal-settings { + position: absolute; right: 12px; bottom: 44px; z-index: 30; width: 186px; max-width: calc(100% - 24px); + display: flex; flex-direction: column; gap: 8px; padding: 10px; + background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 8px; + box-shadow: 0 6px 18px rgba(0, 0, 0, .14); +} +.iwb-gal-settings-title { font-size: 11px; font-weight: 600; color: var(--iwb-text2); } +.iwb-gal-setrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--iwb-text2); } +.iwb-gal-setlabel { flex: 0 0 auto; } +.iwb-gal-setrow select, .iwb-gal-settings select { flex: 1 1 auto; width: auto; min-width: 62px; max-width: 96px; height: 22px; font-size: 11px; padding: 0 2px 0 4px; } .iwb-gal-opt { display: inline-flex; align-items: center; gap: 3px; } /* 三个下拉尽量窄:只留内容 + 箭头的最小宽度(0.5K / 特大 / 全部 都放得下) */ .iwb-gal-opt select, .iwb-gal-opts select { width: auto; min-width: 34px; max-width: 44px; height: 20px; padding: 0 0 0 3px; font-size: 10px; }