feat(browser): 1.8.0 收藏夹下拉 + 地址栏星标;album 1.1.4 hover 加强;gallery 1.7.4 仅缩略图补存
This commit is contained in:
1 parent
b8d19e6eda
commit
f57bc240d7
9 files changed
+213
-87
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/album",
|
||||
"private": true,
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"description": "相册:一个节点装多张本地图(只引用不复制),宫格自适应分页,一图一任务 / 批量两种模式批量生图",
|
||||
"ibwPlugin": {
|
||||
"id": "album",
|
||||
|
||||
+1
-1
@@ -812,7 +812,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'album',
|
||||
name: '相册',
|
||||
version: '1.1.3',
|
||||
version: '1.1.4',
|
||||
apiVersion: 1,
|
||||
capabilities: ['nodeTypes', 'images', 'files'],
|
||||
settings: {
|
||||
|
||||
+7
-1
@@ -29,7 +29,13 @@
|
||||
竖图撑到 167px,和 capacityOf() 按方形算的容量是两套账(最后一行常被裁一半)。
|
||||
aspect-ratio 让每一格高 = 宽,容量因此可精确预测,宫格也终于整齐。
|
||||
padding:0 必须显式写:<button> 的 UA 默认内边距会把图顶出边框。 */
|
||||
.iwb-album-cell { position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: var(--iwb-radius-chip); overflow: hidden; background: color-mix(in srgb, var(--iwb-border) 55%, transparent); border: 1px solid var(--iwb-border); cursor: grab; }
|
||||
.iwb-album-cell { position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: var(--iwb-radius-chip); overflow: hidden; background: color-mix(in srgb, var(--iwb-border) 55%, transparent); border: 1px solid var(--iwb-border); cursor: grab; transition: transform var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out), box-shadow var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out); }
|
||||
/* 1.1.4(用户:1.06 太不明显):放大到 1.08 + 更深的投影 + 2px 品牌描边。
|
||||
网格内**不做位移**(translateY 会让相邻格的 hover 判定抖动);描边用 outline 而不是加粗 border,
|
||||
避免图片内容被 1px 的 border 变化挤动。z-index 走宿主层级 token(插件禁止裸值),
|
||||
且被 .iwb-album-grid 的 overflow:hidden 限制在节点内。 */
|
||||
.iwb-album-cell:hover { transform: scale(1.08); outline: 2px solid var(--iwb-hover-border, var(--iwb-brand)); outline-offset: -2px; box-shadow: 0 10px 26px rgba(0, 0, 0, .42), 0 2px 6px rgba(0, 0, 0, .28); z-index: var(--iwb-z-ctx, 90); }
|
||||
@media (prefers-reduced-motion: reduce) { .iwb-album-cell { transition: none; } .iwb-album-cell:hover { transform: none; } }
|
||||
.iwb-album-cell img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
|
||||
.iwb-album-cell.off img { opacity: .38; }
|
||||
/* 选中线 2px → 1px(用户:太粗)。1px 在浅底上仍分得清「选中」与「描边」。 */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/browser",
|
||||
"private": true,
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.0",
|
||||
"description": "应用内浏览器:独立窗口打开网页,或在画布节点里内嵌网页(跟随画布缩放,可单独调内容缩放)",
|
||||
"ibwPlugin": {
|
||||
"id": "browser",
|
||||
|
||||
+118
-51
@@ -53,6 +53,21 @@
|
||||
'.iwb-browser-gchip{cursor:pointer;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--iwb-text2,#4d5668);font-size:11px;padding:3px 8px;white-space:nowrap;font-family:inherit}' +
|
||||
'.iwb-browser-gchip:hover{background:var(--iwb-layer2,#fff);border-color:var(--iwb-border,#d5d9e0)}' +
|
||||
'.iwb-browser-gchip-on{background:var(--iwb-layer2,#fff);border-color:var(--iwb-brand,#6b7280);color:var(--iwb-text,#1c2333);font-weight:600}' +
|
||||
// 收藏夹下拉(2026-11-26):地址栏后的星标按钮 → 浏览器式分组列表
|
||||
'.iwb-br-bmbtn{flex:0 0 auto}' +
|
||||
'.iwb-browser-bmmenu{position:absolute;top:38px;left:6px;right:6px;max-height:56vh;overflow:auto;padding:4px;background:var(--iwb-bg-menu,#fff);border:1px solid var(--iwb-border,#d5d9e0);border-radius:var(--iwb-radius-panel,12px);box-shadow:var(--iwb-elevation-2,0 10px 30px rgba(0,0,0,.18));z-index:var(--iwb-z-ctx-menu,91);box-sizing:border-box}' +
|
||||
'.iwb-br-bm-head{display:flex;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid var(--iwb-border,#d5d9e0)}' +
|
||||
'.iwb-br-bm-title{font-weight:600;font-size:13px;color:var(--iwb-text,#1c2333);margin-right:auto}' +
|
||||
'.iwb-br-bm-add{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--iwb-border,#d5d9e0);border-radius:var(--iwb-radius-chip,6px);background:var(--iwb-layer,#f5f6f8);color:var(--iwb-text,#1c2333);font:inherit;font-size:12px;padding:4px 8px;cursor:pointer}' +
|
||||
'.iwb-br-bm-add:hover{border-color:var(--iwb-brand,#6b7280);background:var(--iwb-layer2,#fff)}' +
|
||||
'.iwb-br-bm-folder{display:flex;align-items:center;gap:7px;padding:7px 8px 3px;font-size:12px;font-weight:600;color:var(--iwb-text2,#4d5668)}' +
|
||||
'.iwb-br-bm-fname{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
|
||||
'.iwb-br-bm-count{font-size:11px;font-weight:400;opacity:.65}' +
|
||||
'.iwb-br-bm-item{display:flex;align-items:center;gap:8px;width:100%;border:0;border-radius:var(--iwb-radius-chip,6px);background:transparent;color:var(--iwb-text,#1c2333);font:inherit;font-size:12.5px;text-align:left;padding:5px 8px 5px 26px;cursor:pointer}' +
|
||||
'.iwb-br-bm-item:hover{background:var(--iwb-hover,#e9e9e9)}' +
|
||||
'.iwb-br-bm-itext{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
|
||||
'.iwb-br-bm-iurl{flex:0 1 auto;max-width:40%;font-size:11px;color:var(--iwb-text2,#4d5668);opacity:.65;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
|
||||
'.iwb-br-bm-empty{padding:14px 8px;text-align:center;font-size:12px;color:var(--iwb-text2,#4d5668);opacity:.75}' +
|
||||
// ── 设置页:书签管理器(type:'custom')─────────────────────────────
|
||||
'.iwb-bm-set{display:flex;flex-direction:column;gap:10px;margin-top:10px;max-width:720px;font-size:13px;color:var(--iwb-text,#1c2333)}' +
|
||||
'.iwb-bm-groups{display:flex;align-items:center;gap:6px;flex-wrap:wrap}' +
|
||||
@@ -100,7 +115,7 @@
|
||||
'.iwb-cwv-zpct{width:42px;height:24px;border:0;background:transparent;color:var(--iwb-text,#1c2333);font-size:11px;font-family:inherit;text-align:center;padding:0;outline:none;font-variant-numeric:tabular-nums}' +
|
||||
'.iwb-cwv-zpct:focus{background:var(--iwb-layer,#f0f1f4)}' +
|
||||
'.iwb-cwv-sep{width:1px;height:16px;background:var(--iwb-border,#d5d9e0);flex:0 0 auto;margin:0 1px}' +
|
||||
'.iwb-cwv-stage{position:relative;flex:1 1 auto;min-height:0;background:var(--iwb-layer2,#fff)}' +
|
||||
'.iwb-cwv-stage{position:relative;flex:1 1 auto;min-height:0;background:transparent}' +
|
||||
'.iwb-cwv-anchor{position:absolute;inset:0}' +
|
||||
'.iwb-cwv-empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;text-align:center;padding:18px;font-size:12px;line-height:1.7;white-space:pre-line;color:var(--iwb-text2,#4d5668)}' +
|
||||
'.iwb-cwv-spin{animation:iwb-cwv-rot .9s linear infinite}' +
|
||||
@@ -191,6 +206,24 @@
|
||||
// 否则每切一次就多一个监听器,且旧闭包钉住整棵已脱离文档的 DOM,GC 不掉。
|
||||
var settingsOff = null
|
||||
|
||||
// 收藏夹下拉:同一时刻只允许一个面板菜单。document 监听只装一次,
|
||||
// 避免每次切 tab 重建面板都多挂一个监听器。
|
||||
var bmDocBound = false
|
||||
var bmActiveMenu = null
|
||||
function bindBmDoc() {
|
||||
if (bmDocBound || !document.addEventListener) return
|
||||
bmDocBound = true
|
||||
document.addEventListener('pointerdown', function (e) {
|
||||
var c = bmActiveMenu
|
||||
if (!c) return
|
||||
if (c.menu.contains(e.target) || c.btn.contains(e.target)) return
|
||||
c.close()
|
||||
}, true)
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape' && bmActiveMenu) bmActiveMenu.close()
|
||||
}, true)
|
||||
}
|
||||
|
||||
// ── 书签数据层(2026-11-19 从「每行一条文本」升级为分组结构)─────────────
|
||||
// 存储:settings.bookmarks 存一段 JSON 字符串。为什么不用对象:settings 的值会
|
||||
// 被宿主整包写进 localStorage/配置文件,标量最安全;对象在某些写回路径上会被
|
||||
@@ -712,60 +745,82 @@
|
||||
remember(u)
|
||||
}
|
||||
|
||||
// 书签:分组行 + 书签行。两行都单行横向滚动,尽量不占网页的高度。
|
||||
// 只有一个分组时整条分组行不渲染(避免「全部」和组名长得一样,白占一行)。
|
||||
var bmWrap = el('div', { class: 'iwb-browser-bmwrap' })
|
||||
var groupBar = el('div', { class: 'iwb-browser-groups' })
|
||||
var strip = el('div', { class: 'iwb-browser-strip' })
|
||||
bmWrap.appendChild(groupBar)
|
||||
bmWrap.appendChild(strip)
|
||||
var panelGroup = '' // '' = 全部
|
||||
// 书签:地址栏后的「收藏夹」按钮 + 下拉列表(2026-11-26 用户要求改成浏览器样式)。
|
||||
// 旧实现是分组 chips + 横排书签两行,既占网页高度又不像收藏夹;现在默认收起。
|
||||
// 原生子 webview 会盖住 DOM,宿主 canvas-webview.js 已把 .iwb-browser-bmmenu 纳入
|
||||
// 「浮层相交即 park」名单,所以菜单展开时下方网页会暂时 park、关闭后自动恢复。
|
||||
var bmMenu = el('div', { class: 'iwb-browser-bmmenu', role: 'menu', 'aria-label': '收藏夹' })
|
||||
bmMenu.style.display = 'none'
|
||||
host.style.position = 'relative'
|
||||
var bmBtn = el('button', { class: 'iwb-cwv-btn iwb-br-bmbtn', type: 'button', title: '收藏夹:收藏当前页 / 打开书签', 'aria-expanded': 'false' })
|
||||
bmBtn.appendChild(icon('star'))
|
||||
;(st.bmSlot || st.bar).appendChild(bmBtn)
|
||||
host.appendChild(bmMenu)
|
||||
var bmOpen = false
|
||||
|
||||
function renderBookmarks() {
|
||||
bmMenu.innerHTML = ''
|
||||
var data = bmParse(ctx.settings.get('bookmarks'))
|
||||
if (panelGroup && bmGroupAt(data, panelGroup) < 0) panelGroup = ''
|
||||
groupBar.innerHTML = ''
|
||||
strip.innerHTML = ''
|
||||
var head = el('div', { class: 'iwb-br-bm-head' },
|
||||
el('span', { class: 'iwb-br-bm-title', text: '收藏夹' }))
|
||||
var add = el('button', { class: 'iwb-br-bm-add', type: 'button', title: '把当前页面加入第一个分组' })
|
||||
add.appendChild(icon('star'))
|
||||
add.appendChild(document.createTextNode(' 收藏当前页'))
|
||||
add.addEventListener('click', function (e) { e.stopPropagation(); addCurrentBookmark() })
|
||||
head.appendChild(add)
|
||||
bmMenu.appendChild(head)
|
||||
|
||||
if (data.groups.length > 1) {
|
||||
groupBar.style.display = ''
|
||||
var all = el('button', {
|
||||
class: 'iwb-browser-gchip' + (panelGroup === '' ? ' iwb-browser-gchip-on' : ''),
|
||||
type: 'button',
|
||||
title: '显示全部分组的书签'
|
||||
}, '全部 · ' + bmItems(data, '').length)
|
||||
all.addEventListener('click', function () { panelGroup = ''; renderBookmarks() })
|
||||
groupBar.appendChild(all)
|
||||
for (var gi = 0; gi < data.groups.length; gi++) {
|
||||
(function (g) {
|
||||
var on = panelGroup === g.id
|
||||
var chip = el('button', {
|
||||
class: 'iwb-browser-gchip' + (on ? ' iwb-browser-gchip-on' : ''),
|
||||
type: 'button',
|
||||
title: g.name
|
||||
}, g.name + ' · ' + g.items.length)
|
||||
chip.addEventListener('click', function () { panelGroup = g.id; renderBookmarks() })
|
||||
groupBar.appendChild(chip)
|
||||
})(data.groups[gi])
|
||||
var total = 0
|
||||
for (var gi = 0; gi < data.groups.length; gi++) {
|
||||
var g = data.groups[gi]
|
||||
var visible = 0
|
||||
for (var vi = 0; vi < g.items.length; vi++) if (g.items[vi].url) visible++
|
||||
var folder = el('div', { class: 'iwb-br-bm-folder' })
|
||||
folder.appendChild(icon('folder'))
|
||||
folder.appendChild(el('span', { class: 'iwb-br-bm-fname', text: g.name }))
|
||||
folder.appendChild(el('span', { class: 'iwb-br-bm-count', text: String(visible) }))
|
||||
bmMenu.appendChild(folder)
|
||||
for (var ii = 0; ii < g.items.length; ii++) {
|
||||
(function (item) {
|
||||
if (!item.url) return
|
||||
var row = el('button', { class: 'iwb-br-bm-item', type: 'button', title: item.url })
|
||||
row.appendChild(el('span', { class: 'iwb-br-bm-itext', text: item.title || hostOf(item.url) }))
|
||||
row.appendChild(el('span', { class: 'iwb-br-bm-iurl', text: hostOf(item.url) }))
|
||||
row.addEventListener('click', function () { setBmOpen(false); goTo(item.url) })
|
||||
bmMenu.appendChild(row)
|
||||
total++
|
||||
})(g.items[ii])
|
||||
}
|
||||
} else {
|
||||
groupBar.style.display = 'none'
|
||||
}
|
||||
|
||||
var list = bmItems(data, panelGroup)
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
(function (item) {
|
||||
var chip = el('button', { class: 'iwb-browser-chip', type: 'button', title: item.url, text: item.title })
|
||||
chip.addEventListener('click', function () { goTo(item.url) })
|
||||
strip.appendChild(chip)
|
||||
})(list[i])
|
||||
}
|
||||
if (!list.length) {
|
||||
strip.appendChild(el('span', { class: 'iwb-browser-strip-tip', text: '这个分组还没有书签' }))
|
||||
}
|
||||
if (!total) bmMenu.appendChild(el('div', { class: 'iwb-br-bm-empty', text: '还没有书签:打开一个网页后点上方「收藏当前页」' }))
|
||||
}
|
||||
|
||||
function setBmOpen(open) {
|
||||
bmOpen = !!open
|
||||
bmMenu.style.display = bmOpen ? '' : 'none'
|
||||
bmBtn.setAttribute('aria-expanded', bmOpen ? 'true' : 'false')
|
||||
bmActiveMenu = bmOpen ? { menu: bmMenu, btn: bmBtn, close: function () { setBmOpen(false) } } : null
|
||||
if (bmOpen) renderBookmarks()
|
||||
}
|
||||
function addCurrentBookmark() {
|
||||
var u = normalizeUrl(st.pageUrl || st.input.value)
|
||||
if (!u) { flashTitle(bmBtn, '先打开一个网页'); return }
|
||||
var data = bmParse(ctx.settings.get('bookmarks'))
|
||||
var exists = false
|
||||
for (var gi = 0; gi < data.groups.length; gi++) {
|
||||
for (var ii = 0; ii < data.groups[gi].items.length; ii++) if (data.groups[gi].items[ii].url === u) exists = true
|
||||
}
|
||||
if (!exists) {
|
||||
if (!data.groups.length) data.groups.push({ id: bmId('g'), name: '收藏夹', items: [] })
|
||||
data.groups[0].items.push({ id: bmId('i'), title: hostOf(u), url: u })
|
||||
try { ctx.settings.set('bookmarks', bmStringify(data)) } catch (e) { /* 写不进去不影响继续浏览 */ }
|
||||
}
|
||||
renderBookmarks()
|
||||
flashTitle(bmBtn, exists ? '已经收藏过' : '已收藏当前页')
|
||||
}
|
||||
bindBmDoc()
|
||||
bmBtn.addEventListener('click', function (e) { e.stopPropagation(); setBmOpen(!bmOpen) })
|
||||
renderBookmarks()
|
||||
host.appendChild(bmWrap)
|
||||
settingsOff = ctx.settings.onChange(function (name) {
|
||||
if (name === 'bookmarks') renderBookmarks()
|
||||
else if (name === 'panelZoom') {
|
||||
@@ -807,11 +862,13 @@
|
||||
close: 'M6.5 6.5l7 7M13.5 6.5l-7 7',
|
||||
external: 'M8.5 11.5 14 6M14 6h-3.4M14 6v3.4',
|
||||
minus: 'M6.5 10h7',
|
||||
plus: 'M10 6.5v7M6.5 10h7'
|
||||
plus: 'M10 6.5v7M6.5 10h7',
|
||||
star: 'M10 3.2l2.05 4.15 4.58.67-3.31 3.23.78 4.56L10 13.68l-4.1 2.15.78-4.56-3.31-3.23 4.58-.67z',
|
||||
folder: 'M3.2 6.3h4.6l1.5 2h7.5v7.2H3.2z'
|
||||
}
|
||||
var ICON_TEXT = {
|
||||
back: '←', forward: '→', reload: '⟳', stop: '■', close: '✕',
|
||||
external: '↗', minus: '−', plus: '+'
|
||||
external: '↗', minus: '−', plus: '+', star: '★', folder: '📁'
|
||||
}
|
||||
function icon(name) {
|
||||
// 测试用的极简 DOM(tools/harness.mjs)没有 SVG API:退回文字图标,
|
||||
@@ -973,8 +1030,10 @@
|
||||
zpct.value = '100%'
|
||||
var zoomBox = el('div', { class: 'iwb-cwv-zoom' }, [zMinus, zpct, zPlus])
|
||||
var input = el('input', { class: 'iwb-cwv-url', type: 'text', placeholder: '输入网址后回车' })
|
||||
// 收藏夹按钮槽位:面板挂载时把星标按钮放进来(画布节点留空)。放在地址栏后面。
|
||||
var bmSlot = el('span', { class: 'iwb-cwv-bmslot' })
|
||||
var sep = el('div', { class: 'iwb-cwv-sep' })
|
||||
var bar = el('div', { class: 'iwb-cwv-bar' }, [back, fwd, reload, input, zoomBox, sep, open, close])
|
||||
var bar = el('div', { class: 'iwb-cwv-bar' }, [back, fwd, reload, input, bmSlot, zoomBox, sep, open, close])
|
||||
// 锚点:宿主 canvas-webview.js 按这个 div 的屏幕矩形去摆原生 webview
|
||||
var anchor = el('div', { class: 'iwb-cwv-anchor' })
|
||||
var empty = el('div', { class: 'iwb-cwv-empty' })
|
||||
@@ -983,7 +1042,7 @@
|
||||
host.appendChild(stage)
|
||||
return {
|
||||
id: '', node: null, props: null, ctx: ctx,
|
||||
bar: bar, input: input, anchor: anchor, empty: empty, stage: stage,
|
||||
bar: bar, input: input, bmSlot: bmSlot, anchor: anchor, empty: empty, stage: stage,
|
||||
back: back, fwd: fwd, reload: reload, close: close, open: open,
|
||||
zMinus: zMinus, zPlus: zPlus, zpct: zpct,
|
||||
acts: [back, fwd, reload, close, open],
|
||||
@@ -1121,6 +1180,14 @@
|
||||
if (p.url) s.pageUrl = p.url
|
||||
setLoading(s, !!p.loading)
|
||||
setAddress(s, s.pageUrl)
|
||||
// 加载失败不再用整块白底提示盖住网页:地址栏描红 + tooltip 说明(v3.26.93)
|
||||
if (p.failed) {
|
||||
s.input.setAttribute('aria-invalid', 'true')
|
||||
s.input.title = '网页没有加载完成:可点 ⟳ 重试,或改用系统浏览器打开'
|
||||
} else {
|
||||
s.input.removeAttribute('title')
|
||||
if (!s.input.value || normalizeUrl(s.input.value)) s.input.removeAttribute('aria-invalid')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+14
-27
@@ -189,9 +189,11 @@ const okInvoke = () => (name) => {
|
||||
check('内容区里有原生网页锚点 panel:browser', !!anchor)
|
||||
check('锚点标记 scope=panel(不跟画布缩放)', anchor && anchor.attrs['data-iwb-cwv-scope'] === 'panel')
|
||||
check('未输入网址时锚点不带 url(不建视图)', anchor && anchor.attrs['data-iwb-cwv-url'] === undefined)
|
||||
const strip = findClass(root, 'iwb-browser-strip')
|
||||
const chips = strip ? strip.children.filter((c) => c.className === 'iwb-browser-chip') : []
|
||||
check('底部书签条默认 4 个 chip', chips.length === 4, '实际 ' + chips.length)
|
||||
const slot = findClass(root, 'iwb-cwv-bmslot')
|
||||
check('地址栏后有收藏夹按钮', !!slot && slot.children.some((c) => String(c.className).indexOf('iwb-br-bmbtn') >= 0))
|
||||
const bmMenu = findClass(root, 'iwb-browser-bmmenu')
|
||||
const bmRows = bmMenu ? bmMenu.children.filter((c) => c.className === 'iwb-br-bm-item') : []
|
||||
check('收藏夹下拉默认 4 个书签', bmRows.length === 4, '实际 ' + bmRows.length)
|
||||
const closeBtn = bar.children.find((c) => c.attrs.title && c.attrs.title.indexOf('关闭这个网页') >= 0)
|
||||
check('面板隐藏「✕ 关闭这个网页」(关掉面板就等于关闭)', !!closeBtn && closeBtn.style.display === 'none')
|
||||
}
|
||||
@@ -219,11 +221,11 @@ const okInvoke = () => (name) => {
|
||||
{
|
||||
const r = runPlugin({ invokeImpl: okInvoke() })
|
||||
const root = mountPanel(r.panel, r.doc)
|
||||
const strip = findClass(root, 'iwb-browser-strip')
|
||||
const chips = strip.children.filter((c) => c.className === 'iwb-browser-chip')
|
||||
const bmMenu = findClass(root, 'iwb-browser-bmmenu')
|
||||
const rows = bmMenu.children.filter((c) => c.className === 'iwb-br-bm-item')
|
||||
const stage = root.children.find((c) => c.className === 'iwb-cwv-stage')
|
||||
const anchor = stage.children.find((c) => c.attrs['data-iwb-cwv'] === 'panel:browser')
|
||||
chips[0].fire('click', {})
|
||||
rows[0].fire('click', {})
|
||||
check('书签点击写锚点 url', !!anchor.attrs['data-iwb-cwv-url'] && /^https:\/\//.test(anchor.attrs['data-iwb-cwv-url']),
|
||||
anchor.attrs['data-iwb-cwv-url'])
|
||||
check('书签点击同样不开独立窗口', openCalls(r).length === 0, JSON.stringify(r.calls))
|
||||
@@ -340,7 +342,7 @@ const okInvoke = () => (name) => {
|
||||
check('stringify 后再 parse 结构不丢', api.parse(api.stringify(d2)).groups[0].items.length === 2)
|
||||
}
|
||||
|
||||
// ---------- 面板:分组 chip 切换 ----------
|
||||
// ---------- 面板:收藏夹按分组显示(浏览器式下拉) ----------
|
||||
{
|
||||
const r = runPlugin()
|
||||
const twoGroups = {
|
||||
@@ -352,26 +354,11 @@ const okInvoke = () => (name) => {
|
||||
}
|
||||
r.setSetting('bookmarks', JSON.stringify(twoGroups))
|
||||
const root = mountPanel(r.panel, r.doc)
|
||||
const gbar = findClass(root, 'iwb-browser-groups')
|
||||
const gchips = gbar ? gbar.children.filter((c) => String(c.className).indexOf('iwb-browser-gchip') === 0) : []
|
||||
check('多分组时出现分组条(全部 + 2 组)', gchips.length === 3, '实际 ' + gchips.length)
|
||||
const strip = findClass(root, 'iwb-browser-strip')
|
||||
const countChips = () => strip.children.filter((c) => c.className === 'iwb-browser-chip').length
|
||||
check('默认显示全部书签', countChips() === 3, '实际 ' + countChips())
|
||||
gchips[2].fire('click', {})
|
||||
check('点分组只显示该组书签', countChips() === 2, '实际 ' + countChips())
|
||||
gchips[1].fire('click', {})
|
||||
check('切到另一组', countChips() === 1, '实际 ' + countChips())
|
||||
gchips[0].fire('click', {})
|
||||
check('回到「全部」', countChips() === 3, '实际 ' + countChips())
|
||||
}
|
||||
|
||||
// ---------- 面板:只有一个分组时不显示分组条 ----------
|
||||
{
|
||||
const r = runPlugin()
|
||||
const root = mountPanel(r.panel, r.doc)
|
||||
const gbar = findClass(root, 'iwb-browser-groups')
|
||||
check('单分组隐藏分组条', !!gbar && gbar.style.display === 'none')
|
||||
const menu = findClass(root, 'iwb-browser-bmmenu')
|
||||
const folders = menu ? menu.children.filter((c) => c.className === 'iwb-br-bm-folder') : []
|
||||
const items = menu ? menu.children.filter((c) => c.className === 'iwb-br-bm-item') : []
|
||||
check('收藏夹按分组渲染文件夹(2 组)', folders.length === 2, '实际 ' + folders.length)
|
||||
check('收藏夹显示全部书签(3 条)', items.length === 3, '实际 ' + items.length)
|
||||
}
|
||||
|
||||
// ---------- 画布内网页节点 ----------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/gallery",
|
||||
"private": true,
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.4",
|
||||
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
|
||||
"ibwPlugin": {
|
||||
"id": "gallery",
|
||||
|
||||
+31
-2
@@ -116,6 +116,13 @@
|
||||
var failEl = el('span', { class: 'iwb-gal-fail', text: '' })
|
||||
failEl.style.display = 'none'
|
||||
failEl.addEventListener('click', function () { retryAll() })
|
||||
// v1.7.4:「仅缩略图」统计 —— 原图没落盘时点一下批量补存(宿主把远程字节写回 images/gallery)
|
||||
var origEl = el('span', { class: 'iwb-gal-orig', text: '' })
|
||||
origEl.style.display = 'none'
|
||||
origEl.addEventListener('click', function () {
|
||||
var names = items.filter(function (x) { return x.orig && x.orig !== 'ok' }).map(function (x) { return x.name })
|
||||
if (names.length) doBackfill(names)
|
||||
})
|
||||
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')
|
||||
@@ -157,7 +164,7 @@
|
||||
// v1.4.2:刷新与设置同放右侧工具组(此前刷新在左侧信息区,空间不足时会向右溢出、压住设置图标)
|
||||
var tools = el('div', { class: 'iwb-gal-tools' }, refreshBtn, folderBtn, setBtn)
|
||||
var foot = el('div', { class: 'iwb-gal-foot' },
|
||||
el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, failEl, statusEl), tools)
|
||||
el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, failEl, origEl, statusEl), tools)
|
||||
var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot, settings])
|
||||
|
||||
function setOpen (open) {
|
||||
@@ -202,6 +209,7 @@
|
||||
.then(function () { setStatus('已插入:' + it.name) })
|
||||
.catch(function () { setStatus('插入失败') })
|
||||
})
|
||||
if (it.orig && it.orig !== 'ok') item('补存原图', function () { doBackfill([it.name]) })
|
||||
item('下载', function () { doDownload([it.name]) })
|
||||
item('预览大图', function () { try { ctx.gallery.preview(it.name) } catch (err) { /* ignore */ } })
|
||||
item('复制文件名', function () {
|
||||
@@ -271,6 +279,9 @@
|
||||
clear(actions)
|
||||
countEl.textContent = items.length + ' / ' + total + ' 张'
|
||||
pickedEl.textContent = count() ? ('已选 ' + count()) : ''
|
||||
var missing = items.filter(function (x) { return x.orig && x.orig !== 'ok' }).length
|
||||
if (missing) { origEl.style.display = ''; origEl.textContent = missing + ' 张仅缩略图 · 补存'; origEl.title = '这些图的原图没有写进本地(只有 320px 缩略图)。点一下把远程原图补存到 images/gallery' }
|
||||
else { origEl.style.display = 'none'; origEl.textContent = '' }
|
||||
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 })
|
||||
@@ -372,6 +383,11 @@
|
||||
// 缩略图是**异步**的(ctx.gallery.thumb 返回 Promise):先占位,拿到地址再挂 img。
|
||||
// v1.2.0:加载失败自动重试 2 次(图片还没落盘/临时不可读),仍失败才显示可点击重试的占位。
|
||||
box.title = it.name + '(单击单选 · Shift+单击多选 · 双击放大 · 拖到画布=参考图节点)'
|
||||
var origBadge = null
|
||||
if (it.orig && it.orig !== 'ok') {
|
||||
origBadge = el('span', { class: 'iwb-gal-origbadge', text: it.orig === 'off' ? '未备份' : '仅缩略图' })
|
||||
origBadge.title = it.orig === 'off' ? '原图入库已关闭:这张只有缩略图' : '原图没有写进本地:右键可「补存原图」'
|
||||
}
|
||||
var holder = el('div', { class: 'iwb-history-missing', text: '加载中…' })
|
||||
box.appendChild(holder)
|
||||
var tries = 0
|
||||
@@ -459,6 +475,8 @@
|
||||
// v1.7.2:图片卡片上只留「下载」;插入仍可从顶部工具栏或右键菜单进入。
|
||||
acts.appendChild(act('下载', '下载到本地', function () { doDownload([it.name]) }))
|
||||
box.appendChild(acts)
|
||||
// 角标最后挂:不要 z-index(插件层级闸门禁止裸值),靠 DOM 顺序盖在图片上
|
||||
if (origBadge) box.appendChild(origBadge)
|
||||
return box
|
||||
}
|
||||
|
||||
@@ -468,6 +486,17 @@
|
||||
clearTimeout(statusTimer)
|
||||
if (text) statusTimer = setTimeout(function () { statusEl.textContent = '' }, 4000)
|
||||
}
|
||||
function doBackfill (names) {
|
||||
if (!ctx.gallery || typeof ctx.gallery.backfill !== 'function') { setStatus('当前宿主不支持补存原图'); return }
|
||||
setStatus('补存中…(' + names.length + ' 张)')
|
||||
Promise.resolve(ctx.gallery.backfill(names)).then(function (r) {
|
||||
var ok = (r && (r.ok || r.count)) || 0
|
||||
var failed = (r && r.failed) || []
|
||||
if (failed.length) setStatus('补存完成 ' + ok + ' 张,' + failed.length + ' 张失败(远程链接取不到)')
|
||||
else setStatus('已补存 ' + ok + ' 张原图')
|
||||
return load()
|
||||
}).catch(function () { setStatus('补存失败,可稍后重试') })
|
||||
}
|
||||
function doDownload (names) {
|
||||
setStatus('下载中…')
|
||||
return Promise.resolve(ctx.gallery.download(names)).then(function (r) {
|
||||
@@ -590,7 +619,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.7.2',
|
||||
version: '1.7.4',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
+39
-2
@@ -69,14 +69,39 @@
|
||||
.iwb-history-embedded .iwb-history-item img {
|
||||
width: 100%; height: auto; display: block; object-fit: contain; margin: 0 auto;
|
||||
border-radius: 6px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); cursor: pointer;
|
||||
transition: transform var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out),
|
||||
border-color var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out),
|
||||
box-shadow var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out);
|
||||
}
|
||||
/* v1.7.3:卡片悬停上浮 + 阴影 + 品牌描边(与输出节点共用宿主 L2 token)。
|
||||
用 item:hover 而不是 img:hover:指针移到下载浮层按钮上时卡片仍保持浮起,不抖。 */
|
||||
.iwb-history-embedded .iwb-history-item:hover img {
|
||||
transform: translateY(var(--iwb-hover-lift, -2px)) scale(var(--iwb-hover-scale, 1.02));
|
||||
border-color: var(--iwb-hover-border, var(--iwb-brand));
|
||||
box-shadow: var(--iwb-hover-shadow, 0 5px 16px rgba(0, 0, 0, .22));
|
||||
}
|
||||
.iwb-history-missing {
|
||||
display: flex; align-items: center; justify-content: center; text-align: center;
|
||||
min-height: 84px; padding: 8px; border-radius: 6px; border: 1px dashed var(--iwb-border);
|
||||
font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all;
|
||||
}
|
||||
.iwb-history-actions { display: flex; gap: 4px; padding: 4px 2px 0; }
|
||||
.iwb-history-actions .iwb-btn-sm { padding: 2px 6px; font-size: 11px; }
|
||||
/* v1.7.3:把「下载」做成卡片底部渐变的下载浮层(与输出节点同一套语义)。
|
||||
条本身 pointer-events:none,只有悬停后按钮可点,避免挡住卡片点击/双击预览。 */
|
||||
.iwb-history-actions {
|
||||
position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px;
|
||||
padding: var(--iwb-space-16) var(--iwb-space-4) var(--iwb-space-4); border-radius: 0 0 6px 6px;
|
||||
background-image: linear-gradient(to top, rgba(0, 0, 0, .62), transparent);
|
||||
opacity: 0; transition: opacity var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out);
|
||||
pointer-events: none;
|
||||
}
|
||||
.iwb-history-embedded .iwb-history-item:hover .iwb-history-actions,
|
||||
.iwb-history-embedded .iwb-history-item:focus-within .iwb-history-actions { opacity: 1; pointer-events: auto; }
|
||||
.iwb-history-actions .iwb-btn-sm { padding: 2px 8px; font-size: 11px; border: none; background: var(--iwb-panel); color: var(--iwb-text); }
|
||||
.iwb-history-actions .iwb-btn-sm:hover { background: var(--iwb-panel); color: var(--iwb-brand); }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.iwb-history-embedded .iwb-history-item img { transition: none; }
|
||||
.iwb-history-embedded .iwb-history-item:hover img { transform: none; }
|
||||
}
|
||||
.iwb-history-more { display: flex; justify-content: center; padding: 4px 0 2px; }
|
||||
/* 只作用于图库自己的空态提示:不加前缀会泄漏到设置页等使用 .iwb-hint 的地方(文字被居中) */
|
||||
.iwb-history-embedded .iwb-hint { font-size: 11px; color: var(--iwb-text2); text-align: center; padding: 12px 6px; }
|
||||
@@ -88,3 +113,15 @@
|
||||
}
|
||||
.iwb-gal-fail:hover { color: var(--iwb-err); opacity: .85; }
|
||||
.iwb-gal-menu .iwb-ctx-title { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
/* ---- v1.7.4:原图未落盘(仅缩略图)可见化 ---- */
|
||||
.iwb-gal-orig {
|
||||
font-size: 11px; color: var(--iwb-warn); cursor: pointer; white-space: nowrap;
|
||||
text-decoration: underline dotted; text-underline-offset: 2px; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.iwb-gal-orig:hover { color: var(--iwb-warn); opacity: .85; }
|
||||
.iwb-gal-origbadge {
|
||||
position: absolute; left: var(--iwb-space-4, 4px); top: var(--iwb-space-4, 4px);
|
||||
padding: 0 var(--iwb-space-4, 4px); border-radius: var(--iwb-radius-full, 999px);
|
||||
background: var(--iwb-panel); color: var(--iwb-warn); border: 1px solid var(--iwb-border);
|
||||
font-size: var(--iwb-font-2xs, 10px); line-height: 1.5; pointer-events: none;
|
||||
}
|
||||
Reference in new issue
Block a user