chore: v3.26.235(测试版:任务队列修复)

This commit is contained in:
qiqi committed 2026-12-03 10:46:33 +08:00
1 parent 2e62769421
commit ac6a0062c3
16 files changed
+81 -35

No files matched your search

+22 -5
View File
@@ -107,16 +107,32 @@
}
}
function thumbOf (it) {
if (it.thumbUrl) return el('img', { class: 'iwb-tq-img', src: it.thumbUrl, alt: '', draggable: 'false' })
function phEl (it) {
return el('div', { class: 'iwb-tq-ph' },
(function () { var s = svgEl('svg', { viewBox: '0 0 24 24', width: '20', height: '20', fill: 'none', stroke: 'currentColor', 'stroke-width': '1.6', 'aria-hidden': 'true' }); s.appendChild(svgEl('path', { d: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4' })); s.appendChild(svgEl('polyline', { points: '7 10 12 15 17 10' })); s.appendChild(svgEl('line', { x1: '12', x2: '12', y1: '15', y2: '3' })); return s })(),
el('span', { text: it.kind === 'only' ? '仅记录' : '' }))
el('span', { text: it && it.kind === 'only' ? '仅记录' : '' }))
}
function thumbOf (it) {
if (it.thumbUrl) {
var img = el('img', { class: 'iwb-tq-img', src: it.thumbUrl, alt: '', draggable: 'false' })
img.addEventListener('error', function () { try { if (img.parentNode) img.parentNode.replaceChild(phEl(it), img) } catch (e) { /* ignore */ } })
return img
}
return phEl(it)
}
function stuckMin (it) {
if (!it || it.kind !== 'down' || it.status !== 'downloading') return 0
var t = Number(it.updatedAt) || Number(it.createdAt) || 0
if (!t) return 0
var ms = Date.now() - t
return ms > 60000 ? Math.floor(ms / 60000) : 0
}
function badgeOf (it) {
if (it.kind === 'ok') return el('span', { class: 'iwb-tq-badge ' + (it.inGallery ? 'ok' : 'warn'), text: it.inGallery ? '已入图库' : '待入库' })
if (it.kind === 'down') {
var sm = stuckMin(it)
if (sm) return el('span', { class: 'iwb-tq-badge warn', text: '可能卡住 · ' + sm + ' 分' })
var label = it.status === 'queued' ? '排队中' : '下载中'
if (it.status === 'downloading' && it.progress > 0) label += ' ' + Math.round(it.progress * 100) + '%'
return el('span', { class: 'iwb-tq-badge', text: label })
@@ -146,7 +162,8 @@
if (it.kind === 'fail' && it.error) main.appendChild(el('div', { class: 'iwb-tq-err', text: it.error + (it.retries ? (' · 已重试 ' + it.retries + ' 次') : '') }))
var acts = el('div', { class: 'iwb-tq-actions' })
if (it.kind === 'ok' && it.inGallery) acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '已在图库', disabled: 'disabled' }))
else if (it.kind === 'down') acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '下载中…', disabled: 'disabled' }))
else if (it.kind === 'down' && !stuckMin(it)) acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '下载中…', disabled: 'disabled' }))
else if (it.kind === 'down') acts.appendChild(btn('重新下载', 'iwb-tq-primary', function () { Promise.resolve(ctx.queue.restart(it.id)).then(function () { setMsg('已重新排队'); schedule() }).catch(function () { setMsg('重新下载失败') }) }))
else acts.appendChild(btn('下载', 'iwb-tq-primary', function (b) { b.disabled = true; ctx.queue.land(it.id).then(function (r) { b.disabled = false; setMsg(r && r.already ? '已在图库' : (r && r.ok ? '已加入落地队列,图库会自动刷新' : '下载失败')) ; schedule() }).catch(function () { b.disabled = false; setMsg('下载失败') }) }))
acts.appendChild(btn('复制原始链接', '', function () { ctx.queue.copyLink(it.id).then(function (r) { setMsg(r && r.ok ? '链接已复制' : '复制失败') }).catch(function () { setMsg('复制失败') }) }))
var loc = btn('定位', '', function (b) { b.disabled = true; ctx.queue.locate(it.id).then(function (r) { b.disabled = false; setMsg(r && r.ok ? '已定位到节点' : ({ 'board-missing': '画布已删除', 'node-missing': '节点已删除', 'missing-meta': '没有定位信息' }[r && r.error] || '定位失败')) }).catch(function () { b.disabled = false; setMsg('定位失败') }) })
@@ -215,7 +232,7 @@
global.IWBPluginHost.register({
id: 'taskqueue',
name: '任务队列',
version: '1.0.1',
version: '1.0.2',
apiVersion: 1,
capabilities: ['pages', 'queue'],
}, function (ctx) {
+2 -2
View File
@@ -1,7 +1,7 @@
{
"id": "taskqueue",
"name": "任务队列",
"version": "1.0.1",
"version": "1.0.2",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"记录"
],
"files": {
"main.js": "b7d95beeeb8c3aa9fa5e283e825e618e7e828bd1a90a0c12d9ff89a0a3858324",
"main.js": "7fcefb26d1f5126f3f90e086bc6c36903083f4366b38c0d8b0c9cc10dfb86ee1",
"styles.css": "420ed2b5ce4dec2f054c2cbecc2f055868fa29e5583c6a364ef82ddefb227262"
}
}