mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-20 14:54:12 +00:00
feat: add text preview rendering in LinearPreview
Amp-Thread-ID: https://ampcode.com/threads/T-019c0be0-9fc6-71ac-853a-7c7cc846b375 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -2713,7 +2713,8 @@
|
||||
"runCount": "Run count:",
|
||||
"rerun": "Rerun",
|
||||
"reuseParameters": "Reuse Parameters",
|
||||
"downloadAll": "Download All"
|
||||
"downloadAll": "Download All",
|
||||
"textTruncated": "Text truncated to 1KB for preview. View full output in job details."
|
||||
},
|
||||
"missingNodes": {
|
||||
"cloud": {
|
||||
|
||||
@@ -19,11 +19,13 @@ const zJobStatus = z.enum([
|
||||
])
|
||||
|
||||
const zPreviewOutput = z.object({
|
||||
filename: z.string(),
|
||||
subfolder: z.string(),
|
||||
type: resultItemType,
|
||||
filename: z.string().optional(),
|
||||
subfolder: z.string().optional(),
|
||||
type: resultItemType.optional(),
|
||||
nodeId: z.string(),
|
||||
mediaType: z.string()
|
||||
mediaType: z.string(),
|
||||
content: z.string().optional(),
|
||||
truncated: z.boolean().optional()
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
@@ -170,8 +170,14 @@ async function rerun(e: Event) {
|
||||
<article
|
||||
v-else-if="getMediaType(selectedOutput) === 'text'"
|
||||
class="w-full max-w-128 m-auto my-12 overflow-y-auto"
|
||||
v-text="selectedOutput!.url"
|
||||
/>
|
||||
>
|
||||
<pre class="whitespace-pre-wrap font-mono text-sm">{{
|
||||
selectedOutput!.content
|
||||
}}</pre>
|
||||
<p v-if="selectedOutput!.truncated" class="text-muted mt-2 text-xs">
|
||||
{{ t('linearMode.textTruncated') }}
|
||||
</p>
|
||||
</article>
|
||||
<Preview3d
|
||||
v-else-if="getMediaType(selectedOutput) === '3d'"
|
||||
:model-url="selectedOutput!.url"
|
||||
|
||||
@@ -29,5 +29,6 @@ export const mediaTypes: Record<string, StatItem> = {
|
||||
export function getMediaType(output?: ResultItemImpl) {
|
||||
if (!output) return ''
|
||||
if (output.isVideo) return 'video'
|
||||
if (output.isText) return 'text'
|
||||
return output.mediaType
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ export class ResultItemImpl {
|
||||
format?: string
|
||||
frame_rate?: number
|
||||
|
||||
// Text output specific fields
|
||||
content?: string
|
||||
truncated?: boolean
|
||||
|
||||
constructor(obj: Record<string, any>) {
|
||||
this.filename = obj.filename ?? ''
|
||||
this.subfolder = obj.subfolder ?? ''
|
||||
@@ -54,6 +58,9 @@ export class ResultItemImpl {
|
||||
|
||||
this.format = obj.format
|
||||
this.frame_rate = obj.frame_rate
|
||||
|
||||
this.content = obj.content
|
||||
this.truncated = obj.truncated
|
||||
}
|
||||
|
||||
get urlParams(): URLSearchParams {
|
||||
@@ -202,8 +209,14 @@ export class ResultItemImpl {
|
||||
return getMediaTypeFromFilename(this.filename) === '3D'
|
||||
}
|
||||
|
||||
get isText(): boolean {
|
||||
return this.mediaType === 'text' && this.content !== undefined
|
||||
}
|
||||
|
||||
get supportsPreview(): boolean {
|
||||
return this.isImage || this.isVideo || this.isAudio || this.is3D
|
||||
return (
|
||||
this.isImage || this.isVideo || this.isAudio || this.is3D || this.isText
|
||||
)
|
||||
}
|
||||
|
||||
static filterPreviewable(
|
||||
|
||||
Reference in New Issue
Block a user