feat(gallery): 图标按钮样式 + 同步 gallery 1.4.1(刷新/设置不占字宽)

This commit is contained in:
qiqi committed 2026-11-20 12:50:39 +08:00
1 parent 03c79bf5e8
commit 1ddfa7f601
4 files changed
+102 -11

No files matched your search

@@ -36,6 +36,31 @@
node.appendChild(typeof v === 'string' ? document.createTextNode(v) : v)
}
function clear (node) { while (node.firstChild) node.removeChild(node.firstChild) }
// v1.4.1:底栏按钮改用图标(窄栏里「刷新/设置」会被挤成竖排两行)
var SVG_NS = 'http://www.w3.org/2000/svg'
function iconBtn (label, build, title) {
var b = el('button', { class: 'iwb-btn iwb-btn-sm iwb-gal-icobtn', title: title || label, 'aria-label': label })
var svg = document.createElementNS(SVG_NS, 'svg')
svg.setAttribute('viewBox', '0 0 16 16')
svg.setAttribute('width', '14')
svg.setAttribute('height', '14')
svg.setAttribute('fill', 'none')
svg.setAttribute('stroke', 'currentColor')
svg.setAttribute('stroke-width', '1.5')
svg.setAttribute('stroke-linecap', 'round')
svg.setAttribute('stroke-linejoin', 'round')
svg.setAttribute('aria-hidden', 'true')
build(svg)
b.appendChild(svg)
return b
}
function svgPath (svg, d) {
var p = document.createElementNS(SVG_NS, 'path')
p.setAttribute('d', d)
svg.appendChild(p)
return p
}
function sel (options, value) {
var s = el('select', { class: 'iwb-input iwb-select-compact' })
for (var i = 0; i < options.length; i++) {
@@ -70,10 +95,30 @@
var countEl = el('span', { class: 'iwb-gal-count', text: '0 / 0 张' })
var pickedEl = el('span', { class: 'iwb-gal-sel', text: '' })
var statusEl = el('span', { class: 'iwb-gal-status', text: '' })
var refreshBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '刷新', title: '重新向宿主拉取图库(图床恢复/外部改动后点这里)' })
var refreshBtn = iconBtn('刷新', function (svg) {
svgPath(svg, 'M13.2 6.4A5.4 5.4 0 1 0 13.4 9.4')
svgPath(svg, 'M13.2 2.6v3.8H9.4')
}, '刷新:重新向宿主拉取图库(图床恢复/外部改动后点这里)')
refreshBtn.addEventListener('click', function () { load(true) })
// v1.4.0:三个下拉不再占用前台(窄栏放不下、也显乱)——收进「设置」浮层,点按钮才展开。
var setBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-gal-setbtn', text: '设置', title: '图库设置:插入尺寸 / 图幅 / 时间范围', 'aria-expanded': 'false' })
var setBtn = iconBtn('设置', function (svg) {
var c1 = document.createElementNS(SVG_NS, 'circle')
c1.setAttribute('cx', '8'); c1.setAttribute('cy', '8'); c1.setAttribute('r', '4.2')
svg.appendChild(c1)
var c2 = document.createElementNS(SVG_NS, 'circle')
c2.setAttribute('cx', '8'); c2.setAttribute('cy', '8'); c2.setAttribute('r', '1.6')
svg.appendChild(c2)
for (var i = 0; i < 8; i++) {
var a = i * Math.PI / 4
var x1 = (8 + Math.cos(a) * 4.2).toFixed(2)
var y1 = (8 + Math.sin(a) * 4.2).toFixed(2)
var x2 = (8 + Math.cos(a) * 5.6).toFixed(2)
var y2 = (8 + Math.sin(a) * 5.6).toFixed(2)
svgPath(svg, 'M' + x1 + ' ' + y1 + 'L' + x2 + ' ' + y2)
}
}, '图库设置:插入尺寸 / 图幅 / 时间范围')
setBtn.classList.add('iwb-gal-setbtn')
setBtn.setAttribute('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' },
@@ -325,7 +370,7 @@
global.IWBPluginHost.register({
id: 'gallery',
name: '图库',
version: '1.4.0',
version: '1.4.1',
apiVersion: 1,
capabilities: ['panels', 'gallery'],
data: { schemaVersion: 1, maxBytes: 65536 },