feat(canvas-v3): P2 out 结果缩略图 Canvas 化
This commit is contained in:
1 parent
db50733876
commit
2d0abb1b79
9 files changed
+61
-10
No files matched your search
+17
-1
@@ -1190,6 +1190,22 @@
|
||||
return line.length > 40 ? (line.slice(0, 40) + '…') : line
|
||||
}
|
||||
|
||||
// Canvas V3:out 节点的结果图 URL 列表(只读;仍复用 outGroupsOf 的分组/排序)。
|
||||
function outThumbUrlsOf (node, nodes, edges) {
|
||||
const nodeMap = new Map((nodes || []).map((n) => [n.id, n]))
|
||||
// Canvas V3 可能在 NodeCard 还没渲染过时调用本函数,此时 inject 还没发生 —— 用本职能兜底。
|
||||
const isProducer = typeof isImageProducer === 'function' ? isImageProducer : (n) => !!(n && (n.type === 'gen' || n.type === 'out' || n.type === 'ref' || n.type === 'combine' || n.type === 'batch'))
|
||||
const tasksOf = typeof cachedGenerationTasks === 'function' ? cachedGenerationTasks : () => []
|
||||
const srcGens = (edges || [])
|
||||
.filter((e) => e.to === node.id)
|
||||
.map((e) => nodeMap.get(e.from))
|
||||
.filter((n) => isProducer(n) && !(n.data && n.data.enabled === false))
|
||||
const merged = outGroupsOf(srcGens, (g) => tasksOf(g, nodes || [], edges || []).map((t) => ({ id: t.id, title: t.title || '' })))
|
||||
const urls = []
|
||||
for (const m of merged) for (const r of m.items) if (r && r.url) urls.push(r.url)
|
||||
return urls
|
||||
}
|
||||
|
||||
function lodBody(node, mode) {
|
||||
const isImg = LOD_IMG_TYPES.indexOf(node.type) >= 0
|
||||
if (mode !== 'plain' && isImg) {
|
||||
@@ -1213,5 +1229,5 @@
|
||||
}
|
||||
|
||||
// md:纯函数(Markdown ⇄ 编辑器 HTML)的测试钩子 —— 行距翻倍的回归由 tests/prompt-md-roundtrip-test.js 守住
|
||||
global.IWBNodeBodies = { inject, openPromptExpand, md: { toHtml: mdToHtml, toMd: htmlToMd }, relay: renderRelayBody, prompt: renderPromptBody, plugin: renderPluginBody, textout: renderTextoutBody, combine: renderCombineBody, llm: renderLlmBody, batch: renderBatchBody, ref: renderRefBody, out: renderOutBody, gen: renderGenBody, outGroupsOf, lodBody }
|
||||
global.IWBNodeBodies = { inject, openPromptExpand, md: { toHtml: mdToHtml, toMd: htmlToMd }, relay: renderRelayBody, prompt: renderPromptBody, plugin: renderPluginBody, textout: renderTextoutBody, combine: renderCombineBody, llm: renderLlmBody, batch: renderBatchBody, ref: renderRefBody, out: renderOutBody, gen: renderGenBody, outGroupsOf, outThumbUrlsOf, lodBody }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
Reference in new issue
Block a user