fix(queue): 选中态/缩略图复用/提示词标题/画布归属/状态与下载语义
This commit is contained in:
1 parent
7b2bb0d58e
commit
48232bec5c
9 files changed
+58
-23
No files matched your search
+24
-10
@@ -33,6 +33,12 @@
|
||||
node.appendChild(typeof v === 'string' ? document.createTextNode(v) : v)
|
||||
}
|
||||
function clear (node) { while (node.firstChild) node.removeChild(node.firstChild) }
|
||||
var SVG_NS = 'http://www.w3.org/2000/svg'
|
||||
function svgEl (tag, attrs) {
|
||||
var node = document.createElementNS(SVG_NS, tag)
|
||||
if (attrs) for (var k in attrs) if (Object.prototype.hasOwnProperty.call(attrs, k)) node.setAttribute(k, attrs[k])
|
||||
return node
|
||||
}
|
||||
function fmtTime (ms) {
|
||||
var d = new Date(Number(ms) || 0)
|
||||
if (!isFinite(d.getTime())) return ''
|
||||
@@ -40,6 +46,13 @@
|
||||
return p(d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes())
|
||||
}
|
||||
function fmtSize (w, h) { return (w > 0 && h > 0) ? (w + '×' + h) : '' }
|
||||
function titleOf (it) {
|
||||
var m = it.meta || {}
|
||||
var base = String(m.promptText || m.prompt || '').trim()
|
||||
if (!base) return '历史记录 · ' + fmtTime(it.createdAt) + ' · #' + String(it.id || '').slice(-4)
|
||||
if (m.variant) base += ' · 第 ' + m.variant + ' 张'
|
||||
return base.length > 28 ? (base.slice(0, 28) + '…') : base
|
||||
}
|
||||
|
||||
function mount (host, ctx) {
|
||||
clear(host)
|
||||
@@ -96,17 +109,19 @@
|
||||
function thumbOf (it) {
|
||||
if (it.thumbUrl) return el('img', { class: 'iwb-tq-img', src: it.thumbUrl, alt: '', draggable: 'false' })
|
||||
return el('div', { class: 'iwb-tq-ph' },
|
||||
el('svg', { viewBox: '0 0 24 24', width: '20', height: '20', fill: 'none', stroke: 'currentColor', 'stroke-width': '1.6', 'aria-hidden': 'true' },
|
||||
el('path', { d: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4' }),
|
||||
el('polyline', { points: '7 10 12 15 17 10' }),
|
||||
el('line', { x1: '12', x2: '12', y1: '15', y2: '3' })),
|
||||
(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' ? '仅记录' : '' }))
|
||||
}
|
||||
|
||||
function badgeOf (it) {
|
||||
var label = STATUS[it.kind] || '记录'
|
||||
if (it.kind === 'down' && it.progress > 0) label = '下载中 ' + Math.round(it.progress * 100) + '%'
|
||||
return el('span', { class: 'iwb-tq-badge ' + (it.kind || ''), text: label })
|
||||
if (it.kind === 'ok') return el('span', { class: 'iwb-tq-badge ' + (it.inGallery ? 'ok' : 'warn'), text: it.inGallery ? '已入图库' : '待入库' })
|
||||
if (it.kind === 'down') {
|
||||
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 })
|
||||
}
|
||||
if (it.kind === 'fail') return el('span', { class: 'iwb-tq-badge fail', text: '下载失败' })
|
||||
return el('span', { class: 'iwb-tq-badge warn', text: '未下载' })
|
||||
}
|
||||
|
||||
function btn (label, cls, onClick) {
|
||||
@@ -119,9 +134,9 @@
|
||||
var meta = it.meta || {}
|
||||
var thumb = el('div', { class: 'iwb-tq-thumb', title: '点击预览' }, thumbOf(it))
|
||||
thumb.addEventListener('click', function () { try { Promise.resolve(ctx.queue.preview(it.id)).catch(function () { setMsg('预览失败') }) } catch (e) { setMsg('预览失败') } })
|
||||
var line1 = el('div', { class: 'iwb-tq-line1' }, el('span', { class: 'iwb-tq-name', text: String(meta.prompt || '生成结果') }), badgeOf(it))
|
||||
var line1 = el('div', { class: 'iwb-tq-line1' }, el('span', { class: 'iwb-tq-name', text: titleOf(it), title: String(meta.promptText || meta.prompt || '') }), badgeOf(it))
|
||||
var bits = []
|
||||
if (meta.boardName) bits.push(meta.boardName)
|
||||
bits.push(meta.boardName || '未知画布')
|
||||
if (it.createdAt) bits.push(fmtTime(it.createdAt))
|
||||
var sz = fmtSize(it.w, it.h); if (sz) bits.push(sz)
|
||||
if (meta.model) bits.push(meta.model)
|
||||
@@ -131,7 +146,6 @@
|
||||
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 === 'fail') acts.appendChild(btn('重试', 'iwb-tq-primary', function () { Promise.resolve(ctx.queue.retry(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('定位失败') }) })
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"记录"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "b307c2fdf70d87c5128bd730294c0d3f381f24d5d249e403ce92a8c42ff5cf9a",
|
||||
"styles.css": "322e5b2336a87a796bd9c3fcfef99754e19833091d0bc0567ea8afe9d5d61a80"
|
||||
"main.js": "0e12acc088aebe6476b128936aeba595ec2044673e301731c1b52bc6e438df94",
|
||||
"styles.css": "420ed2b5ce4dec2f054c2cbecc2f055868fa29e5583c6a364ef82ddefb227262"
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
.iwb-tq-badge.ok { color: var(--iwb-ok); border-color: var(--iwb-ok-bd); background: var(--iwb-ok-bg); }
|
||||
.iwb-tq-badge.fail { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
|
||||
.iwb-tq-badge.only { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
|
||||
.iwb-tq-badge.warn { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
|
||||
.iwb-tq-meta { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.iwb-tq-err { font-size: var(--iwb-font-xs); color: var(--iwb-err); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.iwb-tq-actions { display: flex; align-items: center; gap: var(--iwb-space-6); flex-wrap: wrap; justify-content: flex-end; }
|
||||
|
||||
Reference in new issue
Block a user