feat(gallery): 去掉标题、设定移到右侧底部横栏、下拉再窄 1/3、顶部去掉插入 v1.1.0

This commit is contained in:
qiqi committed 2026-11-20 12:01:02 +08:00
1 parent fa13eb5997
commit 6c3b21232c
2 files changed
+12 -12

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/gallery",
"private": true,
"version": "1.0.1",
"version": "1.1.0",
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
"ibwPlugin": {
"id": "gallery",
+11 -11
View File
@@ -60,18 +60,19 @@
var raf = 0
var head = el('div', { class: 'iwb-gal-head' })
var title = el('div', { class: 'iwb-gal-title' },
el('span', { class: 'iwb-toolbar-title', text: '图库' }),
el('span', { class: 'iwb-hint', text: '0 / 0 张' }),
el('span', { class: 'iwb-gal-sel', text: '' }))
var actions = el('div', { class: 'iwb-gal-actions' })
var opts = el('div', { class: 'iwb-gal-opts' })
head.appendChild(title); head.appendChild(actions); head.appendChild(opts)
head.appendChild(actions)
var grid = el('div', { class: 'iwb-history-grid' })
var empty = el('div', { class: 'iwb-hint', text: '暂无图片 · 运行生图后会出现在这里' })
var more = el('div', { class: 'iwb-history-more' })
var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, empty, more])
// v1.1.0:底部横栏 —— 左边张数/已选,右边三个设定(右对齐)
var countEl = el('span', { class: 'iwb-gal-count', text: '0 / 0 张' })
var pickedEl = el('span', { class: 'iwb-gal-sel', text: '' })
var opts = el('div', { class: 'iwb-gal-opts' })
var foot = el('div', { class: 'iwb-gal-foot' },
el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl), opts)
var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot])
host.appendChild(wrap)
function count () { return Object.keys(picked).length }
@@ -79,8 +80,8 @@
function renderHead () {
clear(actions); clear(opts)
title.childNodes[1].textContent = items.length + ' / ' + total + ' 张'
title.childNodes[2].textContent = count() ? ('已选 ' + count()) : ''
countEl.textContent = items.length + ' / ' + total + ' 张'
pickedEl.textContent = count() ? ('已选 ' + count()) : ''
var n = count()
function btn (label, title0, fn, need, danger) {
var b = el('button', { class: 'iwb-btn iwb-btn-sm' + (danger ? ' iwb-btn-danger' : '') + (need && !n ? ' iwb-gal-off' : ''), text: label, title: need && !n ? '先选中图片' : title0 })
@@ -90,7 +91,6 @@
actions.appendChild(btn('全选', '全选当前筛选结果', function () { for (var i = 0; i < items.length; i++) picked[items[i].name] = 1; render() }))
actions.appendChild(btn('反选', '反选当前筛选结果', function () { for (var i = 0; i < items.length; i++) { var k = items[i].name; if (picked[k]) delete picked[k]; else picked[k] = 1 } render() }))
actions.appendChild(btn('下载', '下载选中的图片', function () { ctx.gallery.download(pickedNames()).catch(function () {}) }, true))
actions.appendChild(btn('插入', '插入选中图片到画布', function () { ctx.gallery.insert(pickedNames()).catch(function () {}) }, true))
actions.appendChild(btn('删除', '删除选中的图片(不可恢复)', function () {
var C = global.IWBUIConfirm
var ask = C && C.askOrNative ? C.askOrNative('删除选中的 ' + n + ' 张图片?不可恢复。', { title: '删除图片', okText: '删除' }) : Promise.resolve(global.confirm('删除选中的 ' + n + ' 张图片?'))
@@ -220,7 +220,7 @@
global.IWBPluginHost.register({
id: 'gallery',
name: '图库',
version: '1.0.1',
version: '1.1.0',
apiVersion: 1,
capabilities: ['panels', 'gallery'],
data: { schemaVersion: 1, maxBytes: 65536 },