feat(gallery): 下载重试与失败上报 + 缩略图失败重试(gallery 1.2.0)v3.25.54
- capability.download 每张最多 3 次尝试,返回 failed[];不再恒 ok - gallery 1.2.0:缩略图 error 自动重试 2 次、可点击重试;alt 置空避免破图文字;底部状态位显示下载结果 - 市场已发布 gallery 1.2.0
This commit is contained in:
1 parent
9d92059aac
commit
163e62f5a3
9 files changed
+95
-32
No files matched your search
@@ -14,6 +14,15 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.25.54(2026-11-20)图库:缩略图失败重试 + 下载失败可重试
|
||||
|
||||
- 宿主 `ctx.gallery.download`:每张最多尝试 3 次(间隔 300/700/1100ms),返回 `{ok, count, failed[]}`;
|
||||
之前是 fire-and-forget 且恒返回 ok,网络慢/图床抖动时用户完全不知道有没有下成功。
|
||||
- gallery 插件 1.2.0:
|
||||
- 缩略图 `onerror` 自动重试 2 次;仍失败显示「缩略图加载失败(点击重试)」,点击重新向宿主取图。
|
||||
- `img` 的 `alt` 置空、长说明挪到卡片 `title`——不再出现截图里"破图标 + 一长串提示文字撑满格子"。
|
||||
- 底部状态位显示「下载中… / 已下载 N 张 / N 张下载失败,可再点一次重试」。
|
||||
|
||||
## v3.25.53(2026-11-20)图库面板改版:无标题 + 底部横栏(张数左 / 设定右)
|
||||
|
||||
- 去掉顶部「图库」标题,顶部只留 全选 / 反选 / 下载 / 删除(「插入」移到图片悬浮操作,避免重复)。
|
||||
|
||||
@@ -8024,7 +8024,20 @@ const tbCenterSeed = (type, refs) => {
|
||||
list: (o) => window.IWBPluginGallery.query(outputs, o),
|
||||
thumb: (name) => { const f = (outputs || []).find((x) => x.name === name); return f ? wDisplayThumbOf((f.data || f.url) || '') : '' },
|
||||
preview: (name) => setPreview({ list: outputs.map((x) => ({ __gallery: true, name: x.name, origIdb: x.origIdb, idb: x.idb, url: x.url, thumb: x.data || null })), idx: Math.max(0, outputs.findIndex((x) => x.name === name)) }),
|
||||
download: async (names) => { let n = 0; for (const f of (outputs || [])) if (names.indexOf(f.name) >= 0) { downloadUrl(await wResolveOutputSrc(f), f.name); n++ } return { ok: true, count: n } },
|
||||
download: async (names) => {
|
||||
const failed = []
|
||||
let n = 0
|
||||
for (const f of (outputs || [])) {
|
||||
if (names.indexOf(f.name) < 0) continue
|
||||
let done = false
|
||||
for (let i = 0; i < 3 && !done; i++) {
|
||||
try { const src = await wResolveOutputSrc(f); if (src) { downloadUrl(src, f.name); done = true } } catch (e) { /* 网络抖动:重试 */ }
|
||||
if (!done) await new Promise((r) => setTimeout(r, 300 + i * 400))
|
||||
}
|
||||
if (done) n++; else failed.push(f.name)
|
||||
}
|
||||
return { ok: failed.length === 0, count: n, failed: failed }
|
||||
},
|
||||
insert: async (names, o) => ({ ok: true, inserted: await insertOutputsToCanvas((outputs || []).filter((f) => names.indexOf(f.name) >= 0), (o && o.insertK) || '1k') }),
|
||||
remove: (names) => { deleteOutputs(names); return { ok: true } },
|
||||
})
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.25.53",
|
||||
"version": "3.25.54",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
|
||||
+3
-3
@@ -19,9 +19,9 @@
|
||||
},
|
||||
{
|
||||
"id": "gallery",
|
||||
"file": "plugin-gallery.04021d66c1a2.js",
|
||||
"version": "1.1.0",
|
||||
"integrity": "sha256-BAIdZsGiukFPKMCzf/f2aDfwzB+aZW/DkyWIJXyHuhQ="
|
||||
"file": "plugin-gallery.a88dbe92b7ad.js",
|
||||
"version": "1.2.0",
|
||||
"integrity": "sha256-qI2+kretsEF6Pdn2FVFpb6v4/yIHzmSc7yyNxfJ61/s="
|
||||
},
|
||||
{
|
||||
"id": "image-annotate",
|
||||
|
||||
+64
-24
@@ -69,9 +69,10 @@
|
||||
// v1.1.0:底部横栏 —— 左边张数/已选,右边三个设定(右对齐)
|
||||
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 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)
|
||||
el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, statusEl), opts)
|
||||
var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot])
|
||||
host.appendChild(wrap)
|
||||
|
||||
@@ -90,7 +91,7 @@
|
||||
}
|
||||
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 () { doDownload(pickedNames()) }, true))
|
||||
actions.appendChild(btn('删除', '删除选中的图片(不可恢复)', function () {
|
||||
var C = global.IWBUIConfirm
|
||||
var ask = C && C.askOrNative ? C.askOrNative('删除选中的 ' + n + ' 张图片?不可恢复。', { title: '删除图片', okText: '删除' }) : Promise.resolve(global.confirm('删除选中的 ' + n + ' 张图片?'))
|
||||
@@ -141,28 +142,51 @@
|
||||
function itemNode (it) {
|
||||
var on = !!picked[it.name]
|
||||
var box = el('div', { class: 'iwb-history-item' + (count() ? ' iwb-history-managed' : '') + (on ? ' iwb-history-selected' : '') })
|
||||
// 缩略图是**异步**的(ctx.gallery.thumb 返回 Promise):先占位,拿到地址再挂 img
|
||||
// 缩略图是**异步**的(ctx.gallery.thumb 返回 Promise):先占位,拿到地址再挂 img。
|
||||
// v1.2.0:加载失败自动重试 2 次(图片还没落盘/临时不可读),仍失败才显示可点击重试的占位。
|
||||
box.title = it.name + '(单击单选 · Shift+单击多选 · 双击放大 · 拖到画布=参考图节点)'
|
||||
var holder = el('div', { class: 'iwb-history-missing', text: '加载中…' })
|
||||
box.appendChild(holder)
|
||||
Promise.resolve(ctx.gallery.thumb(it.name)).then(function (url) {
|
||||
if (!url || typeof url !== 'string') {
|
||||
holder.textContent = '图片已丢失'
|
||||
return
|
||||
}
|
||||
if (!box.isConnected) return
|
||||
var img = el('img', { src: url, loading: 'lazy', title: it.name + '(单击单选 · Shift+单击多选 · 双击放大 · 拖到画布=参考图节点)', draggable: 'true' })
|
||||
if (it.w && it.h) img.setAttribute('style', 'aspect-ratio:' + it.w + ' / ' + it.h)
|
||||
img.addEventListener('click', function (e) { pick(it.name, !!(e && e.shiftKey)) })
|
||||
img.addEventListener('dblclick', function () { ctx.gallery.preview(it.name) })
|
||||
img.addEventListener('dragstart', function (e) {
|
||||
try {
|
||||
e.dataTransfer.setData('application/x-iwb-localref', it.name)
|
||||
e.dataTransfer.setData('application/x-iwb-gallery-orig', it.name)
|
||||
e.dataTransfer.effectAllowed = 'copy'
|
||||
} catch (err) { /* ignore */ }
|
||||
})
|
||||
box.replaceChild(img, holder)
|
||||
}).catch(function () { holder.textContent = '图片已丢失' })
|
||||
var tries = 0
|
||||
function fail (text) {
|
||||
holder.textContent = text || '缩略图加载失败(点击重试)'
|
||||
holder.style.cursor = 'pointer'
|
||||
holder.onclick = function () { tries = 0; boot() }
|
||||
}
|
||||
function boot () {
|
||||
holder.style.cursor = ''
|
||||
holder.onclick = null
|
||||
holder.textContent = '加载中…'
|
||||
Promise.resolve(ctx.gallery.thumb(it.name)).then(function (url) {
|
||||
if (!url || typeof url !== 'string') { fail('图片已丢失'); return }
|
||||
if (!box.isConnected) return
|
||||
var img = el('img', { src: url, alt: '', loading: 'lazy', draggable: 'true' })
|
||||
if (it.w && it.h) img.setAttribute('style', 'aspect-ratio:' + it.w + ' / ' + it.h)
|
||||
img.addEventListener('load', function () {
|
||||
if (holder.parentNode === box) box.replaceChild(img, holder)
|
||||
})
|
||||
img.addEventListener('error', function () {
|
||||
tries++
|
||||
if (tries <= 2) { setTimeout(boot, 400 * tries); return }
|
||||
if (img.parentNode === box) box.replaceChild(holder, img)
|
||||
fail('缩略图加载失败(点击重试)')
|
||||
})
|
||||
img.addEventListener('click', function (e) { pick(it.name, !!(e && e.shiftKey)) })
|
||||
img.addEventListener('dblclick', function () { ctx.gallery.preview(it.name) })
|
||||
img.addEventListener('dragstart', function (e) {
|
||||
try {
|
||||
e.dataTransfer.setData('application/x-iwb-localref', it.name)
|
||||
e.dataTransfer.setData('application/x-iwb-gallery-orig', it.name)
|
||||
e.dataTransfer.effectAllowed = 'copy'
|
||||
} catch (err) { /* ignore */ }
|
||||
})
|
||||
img.style.display = 'none'
|
||||
box.appendChild(img)
|
||||
// 加载成功后再替换占位(避免破图标 + 长 title 占满格子)
|
||||
if (img.complete && img.naturalWidth > 0) { img.style.display = ''; if (holder.parentNode === box) box.replaceChild(img, holder) }
|
||||
}).catch(function () { fail('缩略图加载失败(点击重试)') })
|
||||
}
|
||||
boot()
|
||||
var acts = el('div', { class: 'iwb-history-actions' })
|
||||
function act (label, title, fn) {
|
||||
var b = el('button', { class: 'iwb-btn iwb-btn-sm', text: label, title: title })
|
||||
@@ -170,11 +194,27 @@
|
||||
return b
|
||||
}
|
||||
acts.appendChild(act('插入', '插入到画布(参考图节点)', function () { ctx.gallery.insert([it.name]).catch(function () {}) }))
|
||||
acts.appendChild(act('下载', '下载到本地', function () { ctx.gallery.download([it.name]).catch(function () {}) }))
|
||||
acts.appendChild(act('下载', '下载到本地', function () { doDownload([it.name]) }))
|
||||
box.appendChild(acts)
|
||||
return box
|
||||
}
|
||||
|
||||
var statusTimer = 0
|
||||
function setStatus (text) {
|
||||
statusEl.textContent = text || ''
|
||||
clearTimeout(statusTimer)
|
||||
if (text) statusTimer = setTimeout(function () { statusEl.textContent = '' }, 4000)
|
||||
}
|
||||
function doDownload (names) {
|
||||
setStatus('下载中…')
|
||||
return Promise.resolve(ctx.gallery.download(names)).then(function (r) {
|
||||
var failed = (r && r.failed) || []
|
||||
var ok = (r && r.count) || 0
|
||||
if (failed.length) setStatus(failed.length + ' 张下载失败,可再点一次重试')
|
||||
else setStatus(ok ? ('已下载 ' + ok + ' 张') : '没有可下载的图片')
|
||||
}).catch(function () { setStatus('下载失败,可再点一次重试') })
|
||||
}
|
||||
|
||||
function pick (name, shift) {
|
||||
if (shift) { if (picked[name]) delete picked[name]; else picked[name] = 1 } else { picked = {}; picked[name] = 1 }
|
||||
render()
|
||||
@@ -220,7 +260,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.1.0',
|
||||
version: '1.2.0',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
Generated
+1
-1
@@ -1983,7 +1983,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.25.53"
|
||||
version = "3.25.54"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.25.53"
|
||||
version = "3.25.54"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.25.53",
|
||||
"version": "3.25.54",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
@@ -2123,6 +2123,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s
|
||||
.iwb-gal-foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--iwb-border); }
|
||||
.iwb-gal-foot-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
||||
.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; }
|
||||
.iwb-gal-opt { display: inline-flex; align-items: center; gap: 3px; }
|
||||
/* 三个下拉尽量窄:只留内容 + 箭头的最小宽度(0.5K / 特大 / 全部 都放得下) */
|
||||
|
||||
Reference in new issue
Block a user