Files
short-drama-agent-front/src/features/production/components/VideoCard.vue
T

144 lines
7.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { videoOperationAllowed } from '../video-permissions'
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import { ReceiptText } from '@lucide/vue'
import { computed } from 'vue'
import { NButton, NTag } from 'naive-ui'
import { AssetOpenLink, StatusBadge } from '../../../components/ui'
import { mediaAssetUrl } from '../../../lib/assets'
import { formatDate } from '../../../lib/format'
import { productionStatusLabel } from '../model'
import type { ShotVideo } from '../types'
/** 主视频与候选视频共用的播放、质量检查和主视频切换参数。 */
const props = defineProps<{
/** 当前视频记录。 */
item: ShotVideo
/** 当前镜头编号,用于播放区域的可访问名称。 */
shotNo: number
/** 视频未返回时长时使用当前镜头时长。 */
durationSeconds?: number
/** 当前主视频是否需要更新。 */
stale: boolean
/** 当前状态是否禁止切换主视频。 */
blocked: boolean
/** 当前会话的检查结论,null 表示没有检查。 */
validationPassed: boolean | null
/** 此视频已有的持久化检查结论,仅用于展示,不改变候选晋升条件。 */
recordedValidationPassed?: boolean | null
/** 是否正在确认切换当前候选。 */
confirming: boolean
}>()
/** 交由父面板执行检查与切换,卡片不直接调用生成接口。 */
const emit = defineEmits<{ quality: []; repair: []; history: []; audit: []; select: []; confirm: []; cancel: [] }>()
/** 播放和外链共用经过协议与资源路径校验的地址。 */
const videoUrl = computed(() => (props.item.videoUrl ? mediaAssetUrl(props.item.videoUrl) : null))
/** 优先显示本次会话的检查结果,否则显示此视频已有的记录。 */
const previousValidation = computed(() => props.validationPassed ?? props.recordedValidationPassed ?? null)
/** 晋升资格只使用本候选的后端权限,历史通过不恢复过期资格。 */
const canSelect = computed(
() =>
props.item.status === 'completed' &&
!!videoUrl.value &&
!props.item.isPrimary &&
videoOperationAllowed(props.item, 'primary')
)
</script>
<template>
<!-- 以下是视频播放与候选操作卡片模块 -->
<article class="min-w-0 overflow-hidden bg-(--app-subtle)">
<!-- 以下是正方形视频画面与右上角打开原文件入口模块 -->
<div class="relative aspect-square w-full overflow-hidden bg-(--app-subtle)">
<video
v-if="item.status === 'completed' && videoUrl"
:src="videoUrl"
:aria-label="`镜头 ${shotNo} ${item.isPrimary ? '主视频' : '候选视频'}`"
controls
preload="metadata"
class="block aspect-square w-full bg-[#080808] object-contain"
></video>
<!-- 以下是尚无可播放视频时的正方形占位模块,与完成记录保持相同尺寸 -->
<div v-else class="flex h-full w-full items-center justify-center p-5 text-xs text-muted">
{{
item.status === 'failed'
? '视频生成失败'
: item.status === 'completed'
? '暂无视频文件'
: '视频任务进行中'
}}
</div>
<AssetOpenLink v-if="item.status === 'completed'" :src="videoUrl" label="打开视频" />
</div>
<div class="min-w-0 p-3">
<div class="flex flex-wrap items-center gap-2">
<StatusBadge :status="item.status" :label="productionStatusLabel(item.status)" />
<NTag size="small" :bordered="false">{{ item.isPrimary ? '主视频' : '候选视频' }}</NTag>
<NTag
v-if="stale || item.motionPlanStale || item.qualityTerminalStatus === 'stale_motion_plan'"
size="small"
type="warning"
:bordered="false"
>需更新</NTag
>
<span class="text-[10px] text-muted">{{ item.durationSeconds || durationSeconds || '—' }}s</span>
</div>
<!-- 以下是此视频此前检查结果模块,历史通过不代表当前素材仍然适用 -->
<p v-if="item.staleReason" class="mt-2 text-xs text-muted">{{ item.staleReason }}</p>
<p
v-if="item.motionPlanRevisionId || item.currentMotionPlanRevisionId"
class="mt-2 break-all text-[10px] text-muted"
>
生成动作版本 {{ item.motionPlanRevisionId ?? 'AI 原始' }} · 当前
{{ item.currentMotionPlanRevisionId ?? 'AI 原始' }}
</p>
<p v-if="previousValidation !== null" class="mt-2 text-[11px] text-muted">
{{ previousValidation ? '此前画面检查通过' : '此前画面检查未通过' }}
</p>
<FeedbackMessage v-if="item.error" :message="item.error" />
<p class="mt-3 break-all text-[10px] text-muted">
{{ item.provider }} · {{ item.model }} · {{ formatDate(item.createdAt) }}
</p>
<div class="mt-3 flex flex-wrap gap-3">
<NButton
v-if="item.status === 'completed' && videoUrl"
:disabled="blocked || !videoOperationAllowed(item, 'validate')"
text
size="small"
@click="emit('quality')"
>
质量检查
</NButton>
<NButton
v-if="item.status === 'completed' && videoUrl && videoOperationAllowed(item, 'repair')"
:disabled="blocked"
text
size="small"
@click="emit('repair')"
>创建修复候选</NButton
>
<NButton text size="small" @click="emit('history')">查看质量记录</NButton>
<NButton class="workspace-action-button" size="small" @click="emit('audit')"
><template #icon><ReceiptText :size="16" /></template>费用审计</NButton
>
<NButton v-if="canSelect" :disabled="blocked" text size="small" @click="emit('select')">
设为主视频
</NButton>
</div>
<!-- 以下是候选切换确认模块,不更改已有费用确认与质量检查流程 -->
<ContextNotice v-if="confirming" type="info" :show-icon="false" class="mt-3 text-xs">
<p>确认把此候选设为当前镜头主视频?旧成片仍会保留。</p>
<div class="mt-2 flex gap-3">
<NButton :disabled="blocked || !canSelect" type="primary" @click="emit('confirm')"
>确认切换</NButton
>
<NButton text size="small" @click="emit('cancel')">取消</NButton>
</div>
</ContextNotice>
</div>
</article>
</template>