feat: 按质量结果管理主首帧候选
This commit is contained in:
1 parent
a72d96506a
commit
4298438219
6 files changed
+243
-88
No files matched your search
@@ -0,0 +1,73 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { BadgeCheck } from '@lucide/vue'
|
||||||
|
import { NAlert, NButton, NTag } from 'naive-ui'
|
||||||
|
import { AssetImage, StatusBadge } from '../../../components/ui'
|
||||||
|
import { formatDate } from '../../../lib/format'
|
||||||
|
import { productionStatusLabel } from '../model'
|
||||||
|
import type { ShotKeyframe } from '../types'
|
||||||
|
|
||||||
|
/** 首帧卡片统一主图标识、质量结论和晋升限制。 */
|
||||||
|
const props = defineProps<{
|
||||||
|
item: ShotKeyframe
|
||||||
|
shotNo: number
|
||||||
|
stale: boolean
|
||||||
|
blocked: boolean
|
||||||
|
validationPassed: boolean | null
|
||||||
|
confirming: boolean
|
||||||
|
}>()
|
||||||
|
const emit = defineEmits<{ quality: []; select: []; confirm: []; cancel: [] }>()
|
||||||
|
const canSelect = computed(
|
||||||
|
() =>
|
||||||
|
props.item.status === 'completed' &&
|
||||||
|
!!props.item.imageUrl &&
|
||||||
|
props.item.source !== 'provider_variant' &&
|
||||||
|
!props.item.isPrimary &&
|
||||||
|
props.validationPassed === true
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<article class="keyframe-card">
|
||||||
|
<div class="keyframe-image">
|
||||||
|
<AssetImage
|
||||||
|
:src="item.status === 'completed' ? item.imageUrl : null"
|
||||||
|
:alt="`镜头 ${shotNo} 首帧`"
|
||||||
|
preview
|
||||||
|
:empty-text="item.status === 'failed' ? '首帧生成失败' : '首帧生成中'"
|
||||||
|
/>
|
||||||
|
<span v-if="item.isPrimary" class="primary-keyframe-mark" aria-label="当前主首帧" title="当前主首帧">
|
||||||
|
<BadgeCheck :size="15" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="p-3">
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<StatusBadge :status="item.status" :label="productionStatusLabel(item.status)" />
|
||||||
|
<NTag v-if="validationPassed === true" size="small" type="success" :bordered="false">质量通过</NTag>
|
||||||
|
<NTag v-else-if="validationPassed === false" size="small" type="error" :bordered="false"
|
||||||
|
>质量未通过</NTag
|
||||||
|
>
|
||||||
|
<NTag v-if="item.source === 'provider_variant'" size="small" :bordered="false">模型输入变体</NTag>
|
||||||
|
<NTag v-if="item.isPrimary && stale" size="small" :bordered="false">已过期</NTag>
|
||||||
|
<span class="text-[10px] text-muted">{{ item.width || '—' }} × {{ item.height || '—' }}</span>
|
||||||
|
</div>
|
||||||
|
<p v-if="item.error" class="mt-2 line-clamp-3 text-xs text-danger">{{ item.error }}</p>
|
||||||
|
<p class="mt-2 text-[10px] text-muted">{{ formatDate(item.createdAt) }}</p>
|
||||||
|
<div v-if="item.status === 'completed' && item.imageUrl" class="mt-2 flex flex-wrap items-center gap-3">
|
||||||
|
<NButton text size="small" @click="emit('quality')">
|
||||||
|
{{ validationPassed === null ? '质量检查' : '重新检查' }}
|
||||||
|
</NButton>
|
||||||
|
<NButton v-if="canSelect" :disabled="blocked" text size="small" @click="emit('select')">
|
||||||
|
设为主首帧
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
<NAlert v-if="confirming" type="info" :show-icon="false" class="mt-2 text-xs">
|
||||||
|
<p>该候选已通过本次质量检查。确认让后续视频使用此首帧?</p>
|
||||||
|
<div class="mt-2 flex gap-3">
|
||||||
|
<NButton type="primary" @click="emit('confirm')">确认切换</NButton>
|
||||||
|
<NButton text size="small" @click="emit('cancel')">取消</NButton>
|
||||||
|
</div>
|
||||||
|
</NAlert>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</template>
|
||||||
@@ -8,13 +8,12 @@ import { AppDialog } from '../../../components/ui'
|
|||||||
import { errorMessage } from '../../../lib/http'
|
import { errorMessage } from '../../../lib/http'
|
||||||
import { productionApi } from '../api'
|
import { productionApi } from '../api'
|
||||||
import { validOptionalSize } from '../model'
|
import { validOptionalSize } from '../model'
|
||||||
import type { GenerateKeyframeInput, KeyframeGenerationPreview, ShotKeyframe } from '../types'
|
import type { GenerateKeyframeInput, KeyframeGenerationPreview } from '../types'
|
||||||
|
|
||||||
/** 单镜头首帧表单;普通候选仍由用户明确选择,过期主首帧默认替换为新图。 */
|
/** 单镜头首帧表单;所有新图先生成候选,通过质量检查后再人工晋升。 */
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
shotId: string
|
shotId: string
|
||||||
shotTitle: string
|
shotTitle: string
|
||||||
keyframes: ShotKeyframe[]
|
|
||||||
disabled: boolean
|
disabled: boolean
|
||||||
replacePrimary?: boolean
|
replacePrimary?: boolean
|
||||||
}>()
|
}>()
|
||||||
@@ -22,20 +21,17 @@ const open = defineModel<boolean>('open', { default: false })
|
|||||||
const emit = defineEmits<{ generate: [input: GenerateKeyframeInput] }>()
|
const emit = defineEmits<{ generate: [input: GenerateKeyframeInput] }>()
|
||||||
const width = ref<number | ''>('')
|
const width = ref<number | ''>('')
|
||||||
const height = ref<number | ''>('')
|
const height = ref<number | ''>('')
|
||||||
const setPrimary = ref(false)
|
|
||||||
const confirmed = ref(false)
|
const confirmed = ref(false)
|
||||||
const preview = ref<KeyframeGenerationPreview | null>(null)
|
const preview = ref<KeyframeGenerationPreview | null>(null)
|
||||||
const previewError = ref('')
|
const previewError = ref('')
|
||||||
const previewPending = ref(false)
|
const previewPending = ref(false)
|
||||||
const hasPrimary = computed(() => props.keyframes.some(item => item.isPrimary && item.status === 'completed'))
|
|
||||||
const sizeValid = computed(() => validOptionalSize(width.value, height.value))
|
const sizeValid = computed(() => validOptionalSize(width.value, height.value))
|
||||||
const canSubmit = computed(() => !props.disabled && sizeValid.value && confirmed.value)
|
const canSubmit = computed(() => !props.disabled && sizeValid.value && confirmed.value)
|
||||||
|
|
||||||
/** 切换镜头或重新打开时清空费用确认;过期首帧默认让新结果成为 Primary。 */
|
/** 切换镜头或重新打开时清空费用确认;新图一律先作为候选。 */
|
||||||
function reset() {
|
function reset() {
|
||||||
width.value = ''
|
width.value = ''
|
||||||
height.value = ''
|
height.value = ''
|
||||||
setPrimary.value = !!props.replacePrimary || !hasPrimary.value
|
|
||||||
confirmed.value = false
|
confirmed.value = false
|
||||||
preview.value = null
|
preview.value = null
|
||||||
previewError.value = ''
|
previewError.value = ''
|
||||||
@@ -48,7 +44,7 @@ function submit() {
|
|||||||
if (!canSubmit.value) return
|
if (!canSubmit.value) return
|
||||||
emit('generate', {
|
emit('generate', {
|
||||||
...(width.value === '' ? {} : { width: width.value, height: height.value as number }),
|
...(width.value === '' ? {} : { width: width.value, height: height.value as number }),
|
||||||
setPrimary: setPrimary.value
|
setPrimary: false
|
||||||
})
|
})
|
||||||
open.value = false
|
open.value = false
|
||||||
reset()
|
reset()
|
||||||
@@ -77,8 +73,8 @@ async function loadPreview() {
|
|||||||
<template>
|
<template>
|
||||||
<AppDialog
|
<AppDialog
|
||||||
v-model:open="open"
|
v-model:open="open"
|
||||||
:title="`${replacePrimary ? '重新生成主首帧' : '生成首帧'} · ${shotTitle}`"
|
:title="`${replacePrimary ? '生成替代候选' : '生成首帧候选'} · ${shotTitle}`"
|
||||||
description="依据视觉风格、GenerationSpec 和主体主参考图编译首帧提示词,并调用 图片模型。"
|
description="新图先作为候选;完成质量检查并通过后,才能设为主首帧。"
|
||||||
>
|
>
|
||||||
<AppForm
|
<AppForm
|
||||||
:model="formModel"
|
:model="formModel"
|
||||||
@@ -152,12 +148,6 @@ async function loadPreview() {
|
|||||||
></NInputNumber
|
></NInputNumber
|
||||||
></NFormItem>
|
></NFormItem>
|
||||||
</div>
|
</div>
|
||||||
<NCheckbox v-model:checked="setPrimary" class="mt-5 flex items-start gap-3 text-sm leading-6"
|
|
||||||
>生成成功后设为当前主首帧
|
|
||||||
</NCheckbox>
|
|
||||||
<NAlert v-if="hasPrimary && setPrimary" type="info" :show-icon="false" class="mt-3 text-xs">
|
|
||||||
当前已有主首帧。新图成功后将成为视频生成使用的首帧,旧图仍保留为候选。
|
|
||||||
</NAlert>
|
|
||||||
<NCheckbox
|
<NCheckbox
|
||||||
id="confirm-keyframe-cost"
|
id="confirm-keyframe-cost"
|
||||||
v-model:checked="confirmed"
|
v-model:checked="confirmed"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import ProviderInputInspector from './ProviderInputInspector.vue'
|
|||||||
import { NAlert, NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
import { NAlert, NButton, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { ExternalLink, ImagePlus, RefreshCw } from '@lucide/vue'
|
import { ExternalLink, ImagePlus, RefreshCw } from '@lucide/vue'
|
||||||
import { AssetImage, StatusBadge } from '../../../components/ui'
|
import { StatusBadge } from '../../../components/ui'
|
||||||
import { usePolling } from '../../../composables/usePolling'
|
import { usePolling } from '../../../composables/usePolling'
|
||||||
import { mediaAssetUrl } from '../../../lib/assets'
|
import { mediaAssetUrl } from '../../../lib/assets'
|
||||||
import { errorMessage } from '../../../lib/http'
|
import { errorMessage } from '../../../lib/http'
|
||||||
@@ -23,12 +23,13 @@ import type {
|
|||||||
VideoReadinessItem
|
VideoReadinessItem
|
||||||
} from '../types'
|
} from '../types'
|
||||||
import KeyframeDialog from './KeyframeDialog.vue'
|
import KeyframeDialog from './KeyframeDialog.vue'
|
||||||
|
import KeyframeCard from './KeyframeCard.vue'
|
||||||
import QualityDialog from './QualityDialog.vue'
|
import QualityDialog from './QualityDialog.vue'
|
||||||
import ActionMenu from '../../../components/ui/ActionMenu.vue'
|
import ActionMenu from '../../../components/ui/ActionMenu.vue'
|
||||||
import { AppDialog } from '../../../components/ui'
|
import { AppDialog } from '../../../components/ui'
|
||||||
import ModelCapabilities from './ModelCapabilities.vue'
|
import ModelCapabilities from './ModelCapabilities.vue'
|
||||||
import type { QualityTarget } from '../quality.types'
|
import type { QualityTarget } from '../quality.types'
|
||||||
import { sessionVideoValidation } from '../quality'
|
import { sessionKeyframePassed, sessionVideoValidation } from '../quality'
|
||||||
|
|
||||||
/** 单镜头生产面板只负责正式资产,不修改上游导演设计与即时状态。 */
|
/** 单镜头生产面板只负责正式资产,不修改上游导演设计与即时状态。 */
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -72,11 +73,13 @@ watch(
|
|||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
)
|
)
|
||||||
const qualityOpen = ref(false)
|
const qualityOpen = ref(false)
|
||||||
|
const candidatesOpen = ref(false)
|
||||||
const qualityTarget = ref<QualityTarget | null>(null)
|
const qualityTarget = ref<QualityTarget | null>(null)
|
||||||
const specsOpen = ref(false)
|
const specsOpen = ref(false)
|
||||||
|
|
||||||
/** 从实际候选打开质量面板,保留单镜头主操作。 */
|
/** 从实际候选打开质量面板,保留单镜头主操作。 */
|
||||||
function openQuality(kind: 'keyframe' | 'video', assetId: string) {
|
function openQuality(kind: 'keyframe' | 'video', assetId: string) {
|
||||||
|
candidatesOpen.value = false
|
||||||
qualityTarget.value = {
|
qualityTarget.value = {
|
||||||
kind,
|
kind,
|
||||||
shotId: props.shot.shotId,
|
shotId: props.shot.shotId,
|
||||||
@@ -103,9 +106,20 @@ const canGenerateKeyframe = computed(
|
|||||||
)
|
)
|
||||||
const canGenerateVideo = computed(
|
const canGenerateVideo = computed(
|
||||||
() =>
|
() =>
|
||||||
!assetBlocked.value && !activeVideo.value && !!props.videoReadiness && props.videoReadiness.issues.length === 0
|
!assetBlocked.value &&
|
||||||
|
!activeVideo.value &&
|
||||||
|
!!props.videoReadiness &&
|
||||||
|
props.videoReadiness.issues.length === 0 &&
|
||||||
|
(!currentKeyframe.value || keyframePassed(currentKeyframe.value.id) !== false)
|
||||||
)
|
)
|
||||||
const keyframeStale = computed(() => !!props.keyframeReadiness?.primaryKeyframeStale)
|
const keyframeStale = computed(() => !!props.keyframeReadiness?.primaryKeyframeStale)
|
||||||
|
const keyframeCandidates = computed(() =>
|
||||||
|
keyframes.value.filter(item => item.id !== currentKeyframe.value?.id)
|
||||||
|
)
|
||||||
|
/** 质量历史尚无 GET;只消费当前会话中该候选的真实校验结果。 */
|
||||||
|
function keyframePassed(assetId: string) {
|
||||||
|
return sessionKeyframePassed(props.projectId, props.shot.shotId, assetId)
|
||||||
|
}
|
||||||
const videoStale = computed(() => !!props.videoReadiness?.primaryVideoStale)
|
const videoStale = computed(() => !!props.videoReadiness?.primaryVideoStale)
|
||||||
|
|
||||||
watch(key, () => {
|
watch(key, () => {
|
||||||
@@ -159,6 +173,7 @@ async function setPrimaryKeyframe() {
|
|||||||
if (
|
if (
|
||||||
assetBlocked.value ||
|
assetBlocked.value ||
|
||||||
!keyframeId ||
|
!keyframeId ||
|
||||||
|
keyframePassed(keyframeId) !== true ||
|
||||||
keyframes.value.find(item => item.id === keyframeId)?.source === 'provider_variant'
|
keyframes.value.find(item => item.id === keyframeId)?.source === 'provider_variant'
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -321,70 +336,35 @@ async function inspectSpecs() {
|
|||||||
{{ issueLabel(issue.code) }}:{{ issue.reason }}
|
{{ issueLabel(issue.code) }}:{{ issue.reason }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div v-if="keyframes.length" class="keyframe-grid mt-4">
|
<div v-if="currentKeyframe" class="keyframe-grid mt-4">
|
||||||
<article v-for="item in keyframes" :key="item.id" class="keyframe-card">
|
<KeyframeCard
|
||||||
<AssetImage
|
:item="currentKeyframe"
|
||||||
:src="item.status === 'completed' ? item.imageUrl : null"
|
:shot-no="shot.shotNo"
|
||||||
:alt="`镜头 ${shot.shotNo} 首帧`"
|
:stale="keyframeStale"
|
||||||
preview
|
:blocked="assetBlocked"
|
||||||
:empty-text="item.status === 'failed' ? '首帧生成失败' : '首帧生成中'"
|
:validation-passed="keyframePassed(currentKeyframe.id)"
|
||||||
/>
|
:confirming="false"
|
||||||
<div class="p-3">
|
@quality="openQuality('keyframe', currentKeyframe.id)"
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
/>
|
||||||
<StatusBadge :status="item.status" :label="productionStatusLabel(item.status)" />
|
|
||||||
<NTag v-if="item.isPrimary" size="small" :bordered="false">主首帧</NTag>
|
|
||||||
<NTag v-if="item.source === 'provider_variant'" size="small" :bordered="false"
|
|
||||||
>模型输入变体</NTag
|
|
||||||
>
|
|
||||||
<NTag v-if="item.isPrimary && keyframeStale" size="small" :bordered="false">已过期</NTag>
|
|
||||||
<span class="text-[10px] text-muted"
|
|
||||||
>{{ item.width || '—' }} × {{ item.height || '—' }}</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<p v-if="item.error" class="mt-2 line-clamp-3 text-xs text-danger">{{ item.error }}</p>
|
|
||||||
<p class="mt-2 text-[10px] text-muted">{{ formatDate(item.createdAt) }}</p>
|
|
||||||
<NButton
|
|
||||||
v-if="item.status === 'completed' && item.imageUrl"
|
|
||||||
text
|
|
||||||
size="small"
|
|
||||||
class="mt-2 mr-3"
|
|
||||||
@click="openQuality('keyframe', item.id)"
|
|
||||||
>质量检查</NButton
|
|
||||||
>
|
|
||||||
<NButton
|
|
||||||
v-if="
|
|
||||||
item.status === 'completed' &&
|
|
||||||
item.imageUrl &&
|
|
||||||
item.source !== 'provider_variant' &&
|
|
||||||
!item.isPrimary
|
|
||||||
"
|
|
||||||
:disabled="assetBlocked"
|
|
||||||
@click="confirmingKeyframe = item.id"
|
|
||||||
text
|
|
||||||
size="small"
|
|
||||||
class="mt-2"
|
|
||||||
>
|
|
||||||
设为主首帧
|
|
||||||
</NButton>
|
|
||||||
<NAlert
|
|
||||||
v-if="confirmingKeyframe === item.id"
|
|
||||||
type="info"
|
|
||||||
:show-icon="false"
|
|
||||||
class="mt-2 text-xs"
|
|
||||||
><p>确认让后续视频使用此首帧?已有视频不会自动重生成。</p>
|
|
||||||
<div class="mt-2 flex gap-3">
|
|
||||||
<NButton @click="setPrimaryKeyframe" type="primary">确认切换</NButton>
|
|
||||||
<NButton @click="confirmingKeyframe = ''" text size="small">取消</NButton>
|
|
||||||
</div></NAlert
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
</div>
|
||||||
<p v-else class="mt-4 text-xs text-muted">尚无首帧记录。</p>
|
<p v-else class="mt-4 text-xs text-muted">
|
||||||
|
尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。
|
||||||
|
</p>
|
||||||
|
<NAlert
|
||||||
|
v-if="currentKeyframe && keyframePassed(currentKeyframe.id) === false"
|
||||||
|
type="error"
|
||||||
|
:show-icon="false"
|
||||||
|
class="mt-3 text-xs"
|
||||||
|
>
|
||||||
|
当前主首帧在本次质量检查中未通过,已阻止继续生成视频。请从候选中选择质量通过的图片。
|
||||||
|
</NAlert>
|
||||||
<div class="production-stage-actions">
|
<div class="production-stage-actions">
|
||||||
|
<NButton v-if="keyframeCandidates.length" @click="candidatesOpen = true">
|
||||||
|
管理候选({{ keyframeCandidates.length }})
|
||||||
|
</NButton>
|
||||||
<NButton :disabled="!canGenerateKeyframe" @click="keyframeOpen = true"
|
<NButton :disabled="!canGenerateKeyframe" @click="keyframeOpen = true"
|
||||||
><ImagePlus :size="14" />{{
|
><ImagePlus :size="14" />{{
|
||||||
keyframeStale ? '重新生成主首帧' : currentKeyframe ? '再生成一张候选' : '生成首帧'
|
keyframeStale ? '生成替代候选' : currentKeyframe ? '再生成一张候选' : '生成首帧候选'
|
||||||
}}</NButton
|
}}</NButton
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
@@ -561,11 +541,34 @@ async function inspectSpecs() {
|
|||||||
:disabled="assetBlocked"
|
:disabled="assetBlocked"
|
||||||
@changed="refreshAll"
|
@changed="refreshAll"
|
||||||
/>
|
/>
|
||||||
|
<AppDialog
|
||||||
|
v-model:open="candidatesOpen"
|
||||||
|
title="首帧候选管理"
|
||||||
|
description="先完成质量检查;只有本会话校验通过的候选才能设为主首帧。"
|
||||||
|
wide
|
||||||
|
>
|
||||||
|
<div v-if="keyframeCandidates.length" class="keyframe-grid">
|
||||||
|
<KeyframeCard
|
||||||
|
v-for="item in keyframeCandidates"
|
||||||
|
:key="item.id"
|
||||||
|
:item="item"
|
||||||
|
:shot-no="shot.shotNo"
|
||||||
|
:stale="false"
|
||||||
|
:blocked="assetBlocked"
|
||||||
|
:validation-passed="keyframePassed(item.id)"
|
||||||
|
:confirming="confirmingKeyframe === item.id"
|
||||||
|
@quality="openQuality('keyframe', item.id)"
|
||||||
|
@select="confirmingKeyframe = item.id"
|
||||||
|
@confirm="setPrimaryKeyframe"
|
||||||
|
@cancel="confirmingKeyframe = ''"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p v-else class="text-xs text-muted">暂无其它首帧候选。</p>
|
||||||
|
</AppDialog>
|
||||||
<KeyframeDialog
|
<KeyframeDialog
|
||||||
v-model:open="keyframeOpen"
|
v-model:open="keyframeOpen"
|
||||||
:shot-id="shot.shotId"
|
:shot-id="shot.shotId"
|
||||||
:shot-title="shot.title"
|
:shot-title="shot.title"
|
||||||
:keyframes="keyframes"
|
|
||||||
:replace-primary="keyframeStale"
|
:replace-primary="keyframeStale"
|
||||||
:disabled="!canGenerateKeyframe"
|
:disabled="!canGenerateKeyframe"
|
||||||
@generate="generateKeyframe"
|
@generate="generateKeyframe"
|
||||||
@@ -592,11 +595,17 @@ async function inspectSpecs() {
|
|||||||
@apply grid grid-cols-[repeat(auto-fill,_minmax(180px,_1fr))] gap-3;
|
@apply grid grid-cols-[repeat(auto-fill,_minmax(180px,_1fr))] gap-3;
|
||||||
}
|
}
|
||||||
.keyframe-card {
|
.keyframe-card {
|
||||||
@apply overflow-hidden rounded-none bg-(--app-subtle);
|
@apply relative overflow-hidden rounded-none bg-(--app-subtle);
|
||||||
}
|
}
|
||||||
.keyframe-card .asset-image {
|
.keyframe-card .asset-image {
|
||||||
@apply aspect-video rounded-none;
|
@apply aspect-video rounded-none;
|
||||||
}
|
}
|
||||||
|
.keyframe-image {
|
||||||
|
@apply relative;
|
||||||
|
}
|
||||||
|
.primary-keyframe-mark {
|
||||||
|
@apply absolute top-2 left-2 z-1 flex size-7 items-center justify-center bg-success text-white;
|
||||||
|
}
|
||||||
.video-record {
|
.video-record {
|
||||||
@apply flex overflow-hidden rounded-none bg-(--app-subtle);
|
@apply flex overflow-hidden rounded-none bg-(--app-subtle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,3 +89,15 @@ export function isVisualValidation(value: unknown): value is VisualValidation {
|
|||||||
export function sessionVideoValidation(projectId: string, shotId: string, assetId: string): VideoValidation | null {
|
export function sessionVideoValidation(projectId: string, shotId: string, assetId: string): VideoValidation | null {
|
||||||
return qualitySession(qualityKey(projectId, { kind: 'video', shotId, assetId, title: '' })).videoValidation ?? null
|
return qualitySession(qualityKey(projectId, { kind: 'video', shotId, assetId, title: '' })).videoValidation ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 首帧暂无质量历史 GET,只用本会话后端真实回执决定是否允许人工晋升。 */
|
||||||
|
export function sessionKeyframePassed(projectId: string, shotId: string, assetId: string): boolean | null {
|
||||||
|
const receipt = qualitySession(
|
||||||
|
qualityKey(projectId, { kind: 'keyframe', shotId, assetId, title: '' })
|
||||||
|
).receipt
|
||||||
|
if (receipt?.kind === 'keyframe' && receipt.result.keyframeId === assetId) return receipt.result.passed
|
||||||
|
if (receipt?.kind !== 'repair') return null
|
||||||
|
if (receipt.result.finalKeyframeId === assetId) return receipt.result.passed
|
||||||
|
if (!receipt.result.repaired && receipt.result.initialKeyframeId === assetId) return receipt.result.passed
|
||||||
|
return null
|
||||||
|
}
|
||||||
@@ -136,10 +136,10 @@ describe('镜头生产数据契约', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('首个首帧默认设主图,已有主图时默认只新增候选,并要求费用确认', async () => {
|
it('所有首帧生成都先成为候选,并要求费用确认', async () => {
|
||||||
wrapper = mount(KeyframeDialog, {
|
wrapper = mount(KeyframeDialog, {
|
||||||
attachTo: document.body,
|
attachTo: document.body,
|
||||||
props: { open: true, shotId: 'shot-1', shotTitle: '开场', keyframes: [], disabled: false }
|
props: { open: true, shotId: 'shot-1', shotTitle: '开场', disabled: false }
|
||||||
})
|
})
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(button('确认生成首帧').disabled).toBe(true)
|
expect(button('确认生成首帧').disabled).toBe(true)
|
||||||
@@ -147,12 +147,13 @@ describe('镜头生产数据契约', () => {
|
|||||||
await flushPromises()
|
await flushPromises()
|
||||||
button('确认生成首帧').click()
|
button('确认生成首帧').click()
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(wrapper.emitted('generate')).toEqual([[{ setPrimary: true }]])
|
expect(wrapper.emitted('generate')).toEqual([[{ setPrimary: false }]])
|
||||||
|
|
||||||
await wrapper.setProps({ open: false })
|
await wrapper.setProps({ open: false })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
await wrapper.setProps({ open: true, shotId: 'shot-2', keyframes: [keyframeFixture({ shotId: 'shot-2' })] })
|
await wrapper.setProps({ open: true, shotId: 'shot-2', replacePrimary: true })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
|
expect(document.body.textContent).toContain('生成替代候选')
|
||||||
document.querySelector<HTMLInputElement>('#confirm-keyframe-cost')!.click()
|
document.querySelector<HTMLInputElement>('#confirm-keyframe-cost')!.click()
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
button('确认生成首帧').click()
|
button('确认生成首帧').click()
|
||||||
@@ -203,7 +204,7 @@ describe('镜头生产数据契约', () => {
|
|||||||
vi.stubGlobal('fetch', fetcher)
|
vi.stubGlobal('fetch', fetcher)
|
||||||
wrapper = mount(KeyframeDialog, {
|
wrapper = mount(KeyframeDialog, {
|
||||||
attachTo: document.body,
|
attachTo: document.body,
|
||||||
props: { open: true, shotId: 'shot-1', shotTitle: '开场', keyframes: [], disabled: false }
|
props: { open: true, shotId: 'shot-1', shotTitle: '开场', disabled: false }
|
||||||
})
|
})
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
button('预览实际生成输入').click()
|
button('预览实际生成输入').click()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import QualityResult from '@/features/production/components/QualityResult.vue'
|
|||||||
import { expandSections } from '@/testing/naive'
|
import { expandSections } from '@/testing/naive'
|
||||||
import ShotProductionAssets from '@/features/production/components/ShotProductionAssets.vue'
|
import ShotProductionAssets from '@/features/production/components/ShotProductionAssets.vue'
|
||||||
import { primaryKeyframe } from '@/features/production/model'
|
import { primaryKeyframe } from '@/features/production/model'
|
||||||
import { qualityKey, qualitySession, sessionVideoValidation } from '@/features/production/quality'
|
import { qualityKey, qualitySession, sessionKeyframePassed, sessionVideoValidation } from '@/features/production/quality'
|
||||||
import { keyframeFixture, videoFixture } from '@/features/production/testing/fixtures'
|
import { keyframeFixture, videoFixture } from '@/features/production/testing/fixtures'
|
||||||
import { storyboardApi } from '@/features/storyboard/api'
|
import { storyboardApi } from '@/features/storyboard/api'
|
||||||
import { hasRunningWorkflow } from '@/features/workflows/selectors'
|
import { hasRunningWorkflow } from '@/features/workflows/selectors'
|
||||||
@@ -110,13 +110,83 @@ describe('精简公开资产回归', () => {
|
|||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(wrapper.text()).toContain('模型输入变体')
|
await wrapper.findAll('button').find(item => item.text().includes('管理候选'))!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
expect(document.body.textContent).toContain('模型输入变体')
|
||||||
expect(wrapper.findAll('button').some(button => button.text() === '设为主首帧')).toBe(false)
|
expect(wrapper.findAll('button').some(button => button.text() === '设为主首帧')).toBe(false)
|
||||||
} finally {
|
} finally {
|
||||||
wrapper.unmount()
|
wrapper.unmount()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('主页面只展示主首帧,候选通过质量检查后才允许晋升', async () => {
|
||||||
|
const projectId = 'keyframe-promotion-contract'
|
||||||
|
const primary = keyframeFixture()
|
||||||
|
const candidate = keyframeFixture({ id: 'keyframe-2', isPrimary: false })
|
||||||
|
vi.stubGlobal(
|
||||||
|
'fetch',
|
||||||
|
vi.fn<typeof fetch>().mockImplementation(
|
||||||
|
async url =>
|
||||||
|
new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
data: String(url).endsWith('/keyframes') ? [primary, candidate] : []
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const wrapper = mount(ShotProductionAssets, {
|
||||||
|
attachTo: document.body,
|
||||||
|
props: { projectId, shot, disabled: false }
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
await flushPromises()
|
||||||
|
expect(wrapper.findAll('.keyframe-card')).toHaveLength(1)
|
||||||
|
expect(wrapper.find('.primary-keyframe-mark').attributes('aria-label')).toBe('当前主首帧')
|
||||||
|
expect(wrapper.findAll('button').some(item => item.text().includes('设为主首帧'))).toBe(false)
|
||||||
|
|
||||||
|
await wrapper.findAll('button').find(item => item.text().includes('管理候选'))!.trigger('click')
|
||||||
|
await flushPromises()
|
||||||
|
expect(document.body.textContent).toContain('首帧候选管理')
|
||||||
|
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).toBe(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
const session = qualitySession(
|
||||||
|
qualityKey(projectId, { kind: 'keyframe', shotId: shot.shotId, assetId: candidate.id, title: '' })
|
||||||
|
)
|
||||||
|
session.receipt = {
|
||||||
|
kind: 'keyframe',
|
||||||
|
result: {
|
||||||
|
shotId: shot.shotId,
|
||||||
|
keyframeId: candidate.id,
|
||||||
|
validationTaskId: 'validation-2',
|
||||||
|
imageUrl: candidate.imageUrl!,
|
||||||
|
isPrimary: false,
|
||||||
|
passed: false,
|
||||||
|
summary: '人物身份不一致',
|
||||||
|
subjects: [],
|
||||||
|
subjectCountConsistent: true,
|
||||||
|
unauthorizedText: { detected: false, texts: [] },
|
||||||
|
issues: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await flushPromises()
|
||||||
|
expect(sessionKeyframePassed(projectId, shot.shotId, candidate.id)).toBe(false)
|
||||||
|
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).toBe(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
session.receipt.result.passed = true
|
||||||
|
await flushPromises()
|
||||||
|
expect(sessionKeyframePassed(projectId, shot.shotId, candidate.id)).toBe(true)
|
||||||
|
expect([...document.querySelectorAll('button')].some(item => item.textContent?.includes('设为主首帧'))).toBe(
|
||||||
|
true
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
|
wrapper.unmount()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('提示词返回使用 shotId,保留正文、状态和更新时间', async () => {
|
it('提示词返回使用 shotId,保留正文、状态和更新时间', async () => {
|
||||||
const result = {
|
const result = {
|
||||||
shotId: 'shot/db',
|
shotId: 'shot/db',
|
||||||
|
|||||||
Reference in new issue
Block a user