fix(gallery): 删除后先本地摘除再重拉,避免残留「图片已丢失」格子 v1.2.1

This commit is contained in:
qiqi committed 2026-11-20 12:13:11 +08:00
1 parent dccac9d88b
commit 70b50dc654
2 files changed
+14 -3

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/gallery",
"private": true,
"version": "1.2.0",
"version": "1.2.1",
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
"ibwPlugin": {
"id": "gallery",
+13 -2
View File
@@ -95,7 +95,18 @@
actions.appendChild(btn('删除', '删除选中的图片(不可恢复)', function () {
var C = global.IWBUIConfirm
var ask = C && C.askOrNative ? C.askOrNative('删除选中的 ' + n + ' 张图片?不可恢复。', { title: '删除图片', okText: '删除' }) : Promise.resolve(global.confirm('删除选中的 ' + n + ' 张图片?'))
ask.then(function (ok) { if (!ok) return; return ctx.gallery.remove(pickedNames()) }).then(function () { picked = {}; load() }).catch(function () {})
var names = pickedNames()
ask.then(function (ok) {
if (!ok) return
// 先本地摘掉,避免删除后还渲染一格「图片已丢失」;随后再向宿主重拉(等它删完+刷新)
items = items.filter(function (x) { return names.indexOf(x.name) < 0 })
total = Math.max(0, total - names.length)
picked = {}
render()
return Promise.resolve(ctx.gallery.remove(names)).then(function () {
setTimeout(load, 250)
})
}).catch(function () {})
}, true, true))
function field (key, options, label) {
@@ -260,7 +271,7 @@
global.IWBPluginHost.register({
id: 'gallery',
name: '图库',
version: '1.2.0',
version: '1.2.1',
apiVersion: 1,
capabilities: ['panels', 'gallery'],
data: { schemaVersion: 1, maxBytes: 65536 },