mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 11:11:53 +00:00
Show in-progress preview of the running task in the queue (#1091)
This commit is contained in:
@@ -8,10 +8,14 @@
|
|||||||
@preview="handlePreview"
|
@preview="handlePreview"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<i
|
<template v-if="task.displayStatus === TaskItemDisplayStatus.Running">
|
||||||
v-else-if="task.displayStatus === TaskItemDisplayStatus.Running"
|
<i v-if="!progressPreviewBlobUrl" class="pi pi-spin pi-spinner"></i>
|
||||||
class="pi pi-spin pi-spinner"
|
<img
|
||||||
></i>
|
v-else
|
||||||
|
:src="progressPreviewBlobUrl"
|
||||||
|
class="progress-preview-img"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
<span v-else-if="task.displayStatus === TaskItemDisplayStatus.Pending"
|
<span v-else-if="task.displayStatus === TaskItemDisplayStatus.Pending"
|
||||||
>...</span
|
>...</span
|
||||||
>
|
>
|
||||||
@@ -60,12 +64,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, onUnmounted } from 'vue'
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import Tag from 'primevue/tag'
|
import Tag from 'primevue/tag'
|
||||||
import ResultItem from './ResultItem.vue'
|
import ResultItem from './ResultItem.vue'
|
||||||
import { TaskItemDisplayStatus, type TaskItemImpl } from '@/stores/queueStore'
|
import { TaskItemDisplayStatus, type TaskItemImpl } from '@/stores/queueStore'
|
||||||
import { ComfyNode } from '@/types/comfyWorkflow'
|
import { ComfyNode } from '@/types/comfyWorkflow'
|
||||||
import { app } from '@/scripts/app'
|
import { app } from '@/scripts/app'
|
||||||
|
import { api } from '@/scripts/api'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
task: TaskItemImpl
|
task: TaskItemImpl
|
||||||
@@ -82,6 +88,7 @@ const node: ComfyNode | null = flatOutputs.length
|
|||||||
(n: ComfyNode) => n.id == coverResult.nodeId
|
(n: ComfyNode) => n.id == coverResult.nodeId
|
||||||
) ?? null
|
) ?? null
|
||||||
: null
|
: null
|
||||||
|
const progressPreviewBlobUrl = ref('')
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(
|
(
|
||||||
@@ -92,6 +99,14 @@ const emit = defineEmits<{
|
|||||||
(e: 'task-output-length-clicked', value: TaskItemImpl): void
|
(e: 'task-output-length-clicked', value: TaskItemImpl): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
api.addEventListener('b_preview', onProgressPreviewReceived)
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
api.removeEventListener('b_preview', onProgressPreviewReceived)
|
||||||
|
})
|
||||||
|
|
||||||
const handleContextMenu = (e: MouseEvent) => {
|
const handleContextMenu = (e: MouseEvent) => {
|
||||||
emit('contextmenu', { task: props.task, event: e, node })
|
emit('contextmenu', { task: props.task, event: e, node })
|
||||||
}
|
}
|
||||||
@@ -124,7 +139,7 @@ const taskStatusText = (status: TaskItemDisplayStatus) => {
|
|||||||
case TaskItemDisplayStatus.Pending:
|
case TaskItemDisplayStatus.Pending:
|
||||||
return 'Pending'
|
return 'Pending'
|
||||||
case TaskItemDisplayStatus.Running:
|
case TaskItemDisplayStatus.Running:
|
||||||
return 'Running'
|
return '<i class="pi pi-spin pi-spinner" style="font-weight: bold"></i> Running'
|
||||||
case TaskItemDisplayStatus.Completed:
|
case TaskItemDisplayStatus.Completed:
|
||||||
return '<i class="pi pi-check" style="font-weight: bold"></i>'
|
return '<i class="pi pi-check" style="font-weight: bold"></i>'
|
||||||
case TaskItemDisplayStatus.Failed:
|
case TaskItemDisplayStatus.Failed:
|
||||||
@@ -140,6 +155,12 @@ const formatTime = (time?: number) => {
|
|||||||
}
|
}
|
||||||
return `${time.toFixed(2)}s`
|
return `${time.toFixed(2)}s`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onProgressPreviewReceived = async ({ detail }: CustomEvent) => {
|
||||||
|
if (props.task.displayStatus === TaskItemDisplayStatus.Running) {
|
||||||
|
progressPreviewBlobUrl.value = URL.createObjectURL(detail)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -197,4 +218,11 @@ are floating on top of images. */
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.progress-preview-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user