feat(gallery): 图库只由插件提供,宿主删除第二份界面 v3.25.52

- 删除 src/ui-gallery-panel.js / ui-gallery-head.js 与 app.js 的图库面板装配(8951→8879 行)
- dock 图库固定 pluginId:'gallery',未安装显示安装提示
- 宿主仅保留 gallery capability(list/thumb/preview/download/insert/remove)+ 索引
- insert 支持插件传入 insertK 档位压缩
- 插件仓新增 gallery 1.0.0 并发布市场(9 个插件)
This commit is contained in:
qiqi committed 2026-11-20 11:32:16 +08:00
1 parent 2594623c09
commit e8d782b4da
17 files changed
+281 -214

No files matched your search

+1 -1
View File
@@ -300,7 +300,7 @@
if (p.node) return p.node
if (p.pluginId) {
const mount = (props.pluginMount && props.pluginMount(p.pluginId)) || null
if (!mount) return el('div', { className: 'iwb-dock-empty' }, (p.title || '插件') + ' 未加载')
if (!mount) return el('div', { className: 'iwb-dock-empty' }, p.hint || ((p.title || '插件') + ' 未加载'))
return el(PluginBox, { mount, fallback: p.fallback || null })
}
return el('div', { className: 'iwb-dock-empty' }, '面板不可用')
-56
View File
@@ -1,56 +0,0 @@
/* 图库面板头部(v3.25.39)
*
* 结构(对齐用户 2026-11-20 的定稿):
* 第 1 行:标题 + 计数(标题单独一行,不与按钮并排)
* 第 2 行:全选 / 反选 / 下载 / 插入 / 删除(后三个需要先选中)
* 第 3 行:插入尺寸 · 显示大小 · 时间筛选(三个窄下拉,各带 2 字标签)
*
* 纪律:纯展示组件,只接收已算好的值与回调;不读 Workbench 内部状态。
*/
;(function (global) {
'use strict'
const React = global.React || {}
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
function optPairs (list) {
return (list || []).map(([v, l]) => el('option', { key: String(v), value: String(v) }, l))
}
function IWBUIGalleryHead (props) {
const sel = Number(props.sel) || 0
const act = (label, title, onClick, opts) => {
const o = opts || {}
const blocked = !!o.needSel && !sel
return el('button', {
className: 'iwb-btn iwb-btn-sm' + (o.danger ? ' iwb-btn-danger' : '') + (blocked ? ' iwb-gal-off' : ''),
title: blocked ? '先在图库里选中图片' : title,
onClick: onClick,
}, label)
}
// v3.25.40:去掉三行文字标签(省空间),含义靠 title / aria-label 承担
const field = (label, value, onChange, pairs, title) => el('label', { className: 'iwb-gal-opt', title },
el('select', { className: 'iwb-input iwb-select-compact', value: String(value), title, 'aria-label': label, onChange: (e) => onChange(e.target.value) }, optPairs(pairs)),
)
return el('div', { className: 'iwb-gal-head' },
el('div', { className: 'iwb-gal-title' },
el('span', { className: 'iwb-toolbar-title' }, '图库'),
el('span', { className: 'iwb-hint' }, (Number(props.count) || 0) + ' / ' + (Number(props.total) || 0) + ' 张'),
sel ? el('span', { className: 'iwb-gal-sel' }, '已选 ' + sel) : null,
),
el('div', { className: 'iwb-gal-actions' },
act('全选', '全选当前筛选结果', props.onAll),
act('反选', '反选当前筛选结果', props.onInvert),
act('下载', '下载选中的图片到本地(多张会依次触发)', props.onDownload, { needSel: true }),
act('插入', '把选中图片插入画布(参考图节点,压缩档位见下方「插入」)', props.onInsert, { needSel: true }),
act('删除', '删除选中的图片(缩略图 + 原图 + 索引一并移除,不可恢复)', props.onDelete, { needSel: true, danger: true }),
),
el('div', { className: 'iwb-gal-opts' },
field('插入', props.insertK, props.onInsertK, [['orig', '原图'], ['2k', '2K'], ['1k', '1K'], ['0.5k', '0.5K']], '插入画布时的图片尺寸:原图最清晰但最大;2K/1K/0.5K 会等比压到对应边长'),
field('显示', props.tile, props.onTile, [[110, '小'], [130, '中'], [170, '大'], [220, '特大']], '图库图片显示宽度:面板变宽只增加列数,图片大小不变'),
field('时间', props.range, props.onRange, [['', '全部'], ['today', '今天'], ['7d', '7 天'], ['30d', '30 天']], '按生成时间筛选图库'),
),
)
}
global.IWBUIGalleryHead = IWBUIGalleryHead
})(typeof window !== 'undefined' ? window : globalThis)
-64
View File
@@ -1,64 +0,0 @@
/* ui-gallery-panel.js —— 图库面板(右栏)视图(M5 第 1 步:从 app.js 抽出,行为不变)
*
* 为什么抽:app.js 有 8952 行硬上限,而 M5 要在这里接 `gallery` capability(+桥接代码)。
* 先把视图搬走腾出空间,再谈插件化——视图抽干净后,插件化才有地方落。
*
* 纪律:纯展示组件(数据 + 回调全部由 props 传入),不读 Workbench 内部状态。
*/
;(function (global) {
'use strict'
const React = global.React || {}
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
function GalleryPanel (props) {
const Head = global.IWBUIGalleryHead || null
const sel = props.sel || []
const buckets = props.buckets || []
const outputs = props.outputs || []
const filtered = props.filtered || []
const limit = props.limit || 0
return el('div', { className: 'iwb-history-embedded' },
Head ? el(Head, {
count: filtered.length, total: outputs.length, sel: sel.length,
onAll: props.onAll, onInvert: props.onInvert,
onDownload: props.onDownloadSel, onInsert: props.onInsertSel, onDelete: props.onDeleteSel,
insertK: props.insertK, onInsertK: props.onInsertK,
tile: props.tile, onTile: props.onTile,
range: props.range, onRange: props.onRange,
}) : null,
el('div', { className: 'iwb-history-grid', ref: props.gridRef },
buckets.map((col, ci) => el('div', { key: 'c' + ci, className: 'iwb-history-col' },
col.map((f) => el('div', {
key: f.name,
className: 'iwb-history-item' + (sel.length ? ' iwb-history-managed' : '') + (sel.indexOf(f.name) >= 0 ? ' iwb-history-selected' : ''),
},
(f.data || f.url)
? el('img', {
src: props.thumbOf(f),
loading: 'lazy',
style: { aspectRatio: (f.w && f.h) ? String(f.w) + ' / ' + String(f.h) : '1 / 1' },
title: f.name + '(单击单选 · Shift+单击多选 · 双击放大 · 拖到画布=参考图节点)',
draggable: true,
onDragStart: (e) => { try { e.dataTransfer.setData('application/x-iwb-localref', (f.data || f.url) || f.name); e.dataTransfer.setData('application/x-iwb-gallery-orig', f.name); e.dataTransfer.effectAllowed = 'copy' } catch (err) { /* ignore */ } },
onClick: (e) => props.onPick(f.name, !!(e && e.shiftKey)),
onDoubleClick: () => props.onPreview(f.name),
})
: el('div', { className: 'iwb-history-missing' }, '图片已丢失'),
null,
el('div', { className: 'iwb-history-actions' },
el('button', { className: 'iwb-btn iwb-btn-sm', title: '插入到画布(参考图节点)', onClick: (e) => { e.stopPropagation(); props.onInsertOne(f) } }, '插入'),
el('button', { className: 'iwb-btn iwb-btn-sm', title: '复制图片到剪贴板', onClick: (e) => { e.stopPropagation(); props.onCopyOne(f) } }, '复制'),
el('button', { className: 'iwb-btn iwb-btn-sm', title: '下载到本地', onClick: (e) => { e.stopPropagation(); props.onDownloadOne(f) } }, '下载'),
),
)),
)),
),
!outputs.length ? el('div', { className: 'iwb-hint' }, '暂无图片 · 运行生图后会出现在这里') : null,
filtered.length > limit ? el('div', { className: 'iwb-history-more' },
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: props.onMore }, '显示更多(' + (filtered.length - limit) + ' 张)'),
) : null,
)
}
global.IWBUIGalleryPanel = GalleryPanel
})(typeof window !== 'undefined' ? window : globalThis)