taskqueue 1.0.3:页头/页签固定,列表自己滚(修页脚被压、页签被滚走)
validate / validate (push) Canceled after 0s

This commit is contained in:
qiqi committed 2026-12-03 11:35:07 +08:00
1 parent b43f094571
commit d4b1ee4029
3 files changed
+29 -9

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@iwb-plugin/taskqueue",
"private": true,
"version": "1.0.0",
"version": "1.0.3",
"description": "任务队列:全局生图记录(链接/状态/画布节点),可下载落地图库、重试、复制链接、定位节点;数据由宿主保存",
"ibwPlugin": {
"id": "taskqueue",
+26 -6
View File
@@ -50,8 +50,9 @@
var m = it.meta || {}
var base = String(m.promptText || m.prompt || '').trim()
if (!base) return '历史记录 · ' + fmtTime(it.createdAt) + ' · #' + String(it.id || '').slice(-4)
if (base.length > 24) base = base.slice(0, 24) + '…'
if (m.variant) base += ' · 第 ' + m.variant + ' 张'
return base.length > 28 ? (base.slice(0, 28) + '…') : base
return base
}
function mount (host, ctx) {
@@ -86,6 +87,8 @@
}
var list = el('div', { class: 'iwb-tq-list' })
var foot = el('div', { class: 'iwb-tq-foot' })
// 2026-12-03:整页高度由宿主给满(.iwb-tq{height:100%}),只有列表自己滚;
// 页头/页签/底部说明全程不动,也不会再出现列表撑出容器压住底部说明。
append(host, [head, tabs, list, foot])
function setMsg (m) { state.msg = m || ''; renderFoot() }
@@ -106,16 +109,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 })
@@ -145,7 +164,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('定位失败') }) })
@@ -214,7 +234,7 @@
global.IWBPluginHost.register({
id: 'taskqueue',
name: '任务队列',
version: '1.0.0',
version: '1.0.3',
apiVersion: 1,
capabilities: ['pages', 'queue'],
}, function (ctx) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* 任务队列页(插件)—— 颜色/字号/圆角/间距全部走宿主 token;结构尺寸允许字面量。 */
.iwb-tq { display: flex; flex-direction: column; min-height: 0; gap: var(--iwb-space-10); }
.iwb-tq { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: var(--iwb-space-10); }
.iwb-tq-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--iwb-space-16); flex-wrap: nowrap; }
.iwb-tq-sub { color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
.iwb-tq-tools { display: flex; align-items: center; gap: var(--iwb-space-8); flex: 0 0 auto; flex-wrap: nowrap; }
@@ -12,7 +12,7 @@
.iwb-tq-tab.on { color: var(--iwb-accent-on-surface); background: var(--iwb-accent-tint); }
.iwb-tq-n { font-size: var(--iwb-font-2xs); line-height: 15px; padding: 0 var(--iwb-space-6); border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border); color: var(--iwb-text2); }
.iwb-tq-tab.on .iwb-tq-n { border-color: var(--iwb-accent-on-surface); color: var(--iwb-accent-on-surface); background: transparent; }
.iwb-tq-list { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--iwb-space-8); }
.iwb-tq-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; display: flex; flex-direction: column; gap: var(--iwb-space-8); }
.iwb-tq-row { display: grid; grid-template-columns: 96px minmax(0,1fr) auto; gap: var(--iwb-space-12); align-items: center; padding: var(--iwb-space-10); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-card); }
.iwb-tq-row:hover { border-color: var(--iwb-hover-border); }
.iwb-tq-row.fail { border-color: var(--iwb-err-bd); background: color-mix(in srgb, var(--iwb-err) 9%, var(--iwb-panel)); }