2026-11-10 21:36:09 +08:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed } from 'vue'
|
2026-11-11 10:29:01 +08:00
|
|
|
|
import DeleteRecordButton from './DeleteRecordButton.vue'
|
2026-11-14 14:07:26 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Picture,
|
|
|
|
|
|
VideoPlay,
|
|
|
|
|
|
MoreFilled,
|
|
|
|
|
|
Clock,
|
|
|
|
|
|
Document,
|
|
|
|
|
|
Warning,
|
|
|
|
|
|
Loading,
|
|
|
|
|
|
} from '@element-plus/icons-vue'
|
2026-11-10 21:36:09 +08:00
|
|
|
|
import type { Asset, Job } from '../types'
|
2026-11-14 14:07:26 +08:00
|
|
|
|
import { formatDate, isActive, phaseLabel, stateLabel, taskLabels } from '../utils/format'
|
2026-11-10 21:36:09 +08:00
|
|
|
|
const props = defineProps<{ job: Job }>()
|
|
|
|
|
|
const emit = defineEmits<{ open: [string]; preview: [Asset] }>()
|
2026-11-14 14:07:26 +08:00
|
|
|
|
const cover = computed(() =>
|
|
|
|
|
|
props.job.result_assets?.find((asset) => ['image', 'video'].includes(asset.kind)),
|
|
|
|
|
|
)
|
|
|
|
|
|
function open() {
|
|
|
|
|
|
if (cover.value && props.job.state === 'succeeded') emit('preview', cover.value)
|
|
|
|
|
|
else emit('open', props.job.id)
|
|
|
|
|
|
}
|
2026-11-10 21:36:09 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<template>
|
2026-11-14 14:07:26 +08:00
|
|
|
|
<article
|
|
|
|
|
|
class="result-card"
|
|
|
|
|
|
:class="{ working: isActive(job), failed: ['failed', 'timed_out'].includes(job.state) }"
|
|
|
|
|
|
>
|
|
|
|
|
|
<button
|
|
|
|
|
|
class="result-media"
|
|
|
|
|
|
@click="open"
|
|
|
|
|
|
>
|
|
|
|
|
|
<img
|
|
|
|
|
|
v-if="cover?.kind === 'image' || cover?.thumbnail_url"
|
|
|
|
|
|
:src="cover.thumbnail_url || cover.preview_url"
|
|
|
|
|
|
:alt="job.prompt"
|
|
|
|
|
|
loading="lazy"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<video
|
|
|
|
|
|
v-else-if="cover?.kind === 'video'"
|
|
|
|
|
|
:src="cover.preview_url"
|
|
|
|
|
|
preload="metadata"
|
|
|
|
|
|
muted
|
|
|
|
|
|
playsinline
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-else
|
|
|
|
|
|
class="pending-art"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="isActive(job)"
|
|
|
|
|
|
class="generation-orbit"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-icon
|
|
|
|
|
|
v-else
|
|
|
|
|
|
:size="34"
|
|
|
|
|
|
><Warning v-if="job.error" /><Document v-else /></el-icon
|
|
|
|
|
|
><strong>{{ stateLabel(job) }}</strong
|
|
|
|
|
|
><span>{{ phaseLabel(job) }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span
|
|
|
|
|
|
class="media-badge"
|
|
|
|
|
|
:class="job.state"
|
|
|
|
|
|
><i :class="{ pulse: isActive(job) }" />{{ stateLabel(job) }}</span
|
|
|
|
|
|
>
|
|
|
|
|
|
<span
|
|
|
|
|
|
v-if="cover?.kind === 'video'"
|
|
|
|
|
|
class="play-circle"
|
|
|
|
|
|
><el-icon><VideoPlay /></el-icon
|
|
|
|
|
|
></span>
|
2026-11-10 21:36:09 +08:00
|
|
|
|
</button>
|
2026-11-14 14:07:26 +08:00
|
|
|
|
<div class="result-caption">
|
|
|
|
|
|
<div class="result-kicker">
|
|
|
|
|
|
<span>{{ taskLabels[job.task_type] }}</span
|
|
|
|
|
|
><button
|
|
|
|
|
|
class="icon-button"
|
|
|
|
|
|
aria-label="查看任务详情"
|
|
|
|
|
|
@click="emit('open', job.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><MoreFilled /></el-icon>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button
|
|
|
|
|
|
class="result-prompt"
|
|
|
|
|
|
@click="emit('open', job.id)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ job.prompt || taskLabels[job.task_type] }}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
<div class="result-footnote">
|
|
|
|
|
|
<span>{{ formatDate(job.created_at) }}</span
|
|
|
|
|
|
><span v-if="job.preemptions">让行 {{ job.preemptions }} 次</span
|
|
|
|
|
|
><span v-else-if="job.parameters.width"
|
|
|
|
|
|
>{{ job.parameters.width }} × {{ job.parameters.height }}</span
|
|
|
|
|
|
>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<DeleteRecordButton
|
|
|
|
|
|
kind="job"
|
|
|
|
|
|
:record="job"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-11-10 21:36:09 +08:00
|
|
|
|
</article>
|
|
|
|
|
|
</template>
|