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

1367 lines
65 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 { RouterLink } from 'vue-router'
import { videoOperationAllowed } from '../video-permissions'
import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import IssueHint from '../../../components/ui/IssueHint.vue'
import { useActionMessage } from '../../../components/ui/useActionMessage'
import ProviderInputInspector from './ProviderInputInspector.vue'
import { NButton, NCheckbox, NCollapse, NCollapseItem, NSelect, NTag, NTabs, NTabPane } from 'naive-ui'
import { computed, onScopeDispose, ref, watch } from 'vue'
import { ImagePlus, RefreshCw } from '@lucide/vue'
import { AssetImage } from '../../../components/ui'
import { usePolling } from '../../../composables/usePolling'
import { useQuery } from '../../../composables/useQuery'
import { releaseRecoveredImageRequest } from '../../subject-images/image-request-guard'
import { ApiError, errorMessage } from '../../../lib/http'
import { candidateDialogWidth } from '../../../lib/candidate-layout'
import type { DesignedShot } from '../../storyboard/types'
import { storyboardApi } from '../../storyboard/api'
import ConfirmAction from '../../workflows/ConfirmAction.vue'
import { runOperation } from '../../workflows/operations'
import { productionApi } from '../api'
import { qualityApi } from '../quality-api'
import { isActiveVideo, primaryKeyframe, primaryVideo, productionStatusLabel, videoRecordedValidation } from '../model'
import { productionIssueText, productionMessage, videoInputStaleReason } from '../production-messages'
import type {
GenerateKeyframeInput,
KeyframeReadinessItem,
KeyframeSpec,
PromptReadinessItem,
VideoGenerationSpec,
VideoReadinessItem
} from '../types'
import MotionPlanPanel from '../../storyboard/components/MotionPlanPanel.vue'
import SpatialBindingsPanel from '../../storyboard/components/SpatialBindingsPanel.vue'
import KeyframeDialog from './KeyframeDialog.vue'
import KeyframeEditDialog from './KeyframeEditDialog.vue'
import type { ShotKeyframe } from '../types'
import { getOperation, isOperationRunning } from '../../workflows/operations'
import KeyframeCard from './KeyframeCard.vue'
import VideoCard from './VideoCard.vue'
import ProductionStageStatus from './ProductionStageStatus.vue'
import QualityDialog from './QualityDialog.vue'
import VideoAuditPanel from './VideoAuditPanel.vue'
import VideoQualityDiagnostics from './VideoQualityDiagnostics.vue'
import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
import { AppDialog, AppDrawer } from '../../../components/ui'
import ModelCapabilities from './ModelCapabilities.vue'
import type { QualityTarget } from '../quality.types'
import KeyframeInputDetails from './KeyframeInputDetails.vue'
import { visionState } from '../keyframe-vision'
import { clearVideoConflict, clearVideoQualification, sessionKeyframePassed, sessionVideoValidation } from '../quality'
import { useProjectGenerationRevision } from '../../generation-config/context'
import { generationConfigApi } from '../../generation-config/api'
import type {
CreativeProfileAspectRatio,
GenerationModelCatalog,
GenerationOptions
} from '../../generation-config/types'
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
/** 当前页面操作反馈使用消息提示,不长期占据正文。 */
const actionMessage = useActionMessage()
/** 动作与视线按需打开,避免进入生产页便编译全部镜头。 */
const motionOpen = ref(false)
/** 编辑源图保持正式资产身份,不能把视频输入变体当作业务源图。 */
const editOpen = ref(false)
const editSource = ref<ShotKeyframe | null>(null)
/**
* 编辑具体主图或历史候选,切镜时废弃原源图。
* @param source 当前镜头已完成首帧
*/
function openEdit(source: ShotKeyframe) {
if (assetBlocked.value || source.status !== 'completed' || source.source === 'provider_variant') return
editSource.value = source
editOpen.value = true
}
/** 单镜头动作按钮反映本镜头操作,不把整个项目锁显示为所有按钮加载。 */
const promptLoading = computed(() => {
const op = getOperation(props.projectId)
return op.pending && op.label === `生成镜头 ${props.shot.shotNo} 视频提示词`
})
/** 离开镜头后忽略迟到的手动读取反馈。 */
let disposed = false
onScopeDispose(() => {
disposed = true
})
/** 单镜头生产面板只负责正式资产,不修改上游导演设计与即时状态。 */
const props = defineProps<{
/** 当前正式项目 ID。 */
projectId: string
/** 当前正式镜头。 */
shot: DesignedShot
/** 当前剧集编号,用于限制单镜头质量生成。 */
episodeNo?: number
/** 视频提示词就绪项。 */
promptReadiness?: PromptReadinessItem
/** 首帧条件检查状态,在角标内展示以避免正文跳动。 */
keyframeReadinessLoading?: boolean
/** 首帧就绪项。 */
keyframeReadiness?: KeyframeReadinessItem
/** 视频就绪项。 */
videoReadiness?: VideoReadinessItem
/** 分镜工作台只展示单镜头首帧,不进入项目级制作。 */
keyframeOnly?: boolean
/** 是否从深链接打开首帧生成。 */
openKeyframe?: boolean
/** 页面上游状态是否阻断操作。 */
disabled: boolean
}>()
/** 通知父页面刷新及观察已启动的质量任务。 */
const emit = defineEmits<{ changed: []; qualityStarted: [executionId: string] }>()
const key = computed(() => props.shot.shotId)
watch(
() => props.shot.shotId,
() => {
editOpen.value = false
editSource.value = null
motionOpen.value = false
}
)
/** 仅当前镜头存在后台首帧或视频任务时临时轮询,终态后自动停止。 */
let query!: ReturnType<
typeof usePolling<{
keyframes: Awaited<ReturnType<typeof productionApi.listKeyframes>>
videos: Awaited<ReturnType<typeof productionApi.listVideos>>
qualityStatus: Awaited<ReturnType<typeof productionApi.videoQualityStatus>> | null
qualityStatusError: string
inputPlan: Awaited<ReturnType<typeof productionApi.videoInputPlan>> | null
inputPlanError: string
}>
>
const assetPollInterval = computed(() => {
const data = query?.data.value
if (!data) return false
const keyframeRunning = data.keyframes.some(item => ['pending', 'generating'].includes(item.status))
const videoRunning = data.videos.some(isActiveVideo)
return keyframeRunning || videoRunning ? 5000 : false
})
query = usePolling(
key,
async (shotId, signal) => {
if (props.keyframeOnly) {
const keyframes = await productionApi.listKeyframes(shotId, signal)
if (keyframes.some(item => item.shotId !== shotId)) throw new Error('候选与当前镜头不匹配。')
return {
keyframes,
videos: [],
qualityStatus: null,
qualityStatusError: '',
inputPlan: null,
inputPlanError: ''
}
}
const [keyframes, videos, qualityState, inputPlanState] = await Promise.all([
productionApi.listKeyframes(shotId, signal),
productionApi.listVideos(shotId, signal),
productionApi
.videoQualityStatus(shotId, signal)
.then(data => ({ data, error: '' }))
.catch(cause => ({ data: null, error: errorMessage(cause) })),
productionApi
.videoInputPlan(shotId, signal)
.then(data => ({ data, error: '' }))
.catch(cause => ({ data: null, error: errorMessage(cause) }))
])
if (keyframes.some(item => item.shotId !== shotId) || videos.some(item => item.shotId !== shotId))
throw new Error('资产记录与当前镜头不匹配,请刷新后重试。')
const qualityStatus = qualityState.data?.shotId === shotId ? qualityState.data : null
const inputPlan = inputPlanState.data?.shotId === shotId ? inputPlanState.data : null
return {
keyframes,
videos,
qualityStatus,
qualityStatusError: qualityState.error,
inputPlan,
inputPlanError: inputPlanState.error
}
},
assetPollInterval
)
/** 单独读取已保存的提示词,查询失败不影响首帧和视频资产展示。 */
const promptQuery = usePolling(
key,
(shotId, signal) => (props.keyframeOnly ? Promise.resolve(null) : storyboardApi.videoPrompt(shotId, signal)),
false
)
const savedPrompt = computed(() => (promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null))
/** 当前视频生成规格的首帧和主体参考图,独立查询避免影响资产列表。 */
const videoInputQuery = usePolling(
key,
(shotId, signal) =>
props.keyframeOnly ? Promise.resolve(null) : productionApi.videoGenerationSpec(shotId, signal),
false
)
/** 素材查询问题与就绪检查使用同一中文说明,避免重复展示后端术语。 */
const videoInputError = computed(() => productionMessage(videoInputQuery.error.value))
/** 视频准备问题按实际含义去重,保留所有不同的处理建议。 */
const videoIssueMessages = computed(() => [...new Set((props.videoReadiness?.issues ?? []).map(productionIssueText))])
const currentVideoInput = computed(() =>
videoInputQuery.data.value?.shotId === key.value ? videoInputQuery.data.value : null
)
const keyframes = computed(() => query.data.value?.keyframes ?? [])
/** 下载回执丢失或刷新后,只用列表明确保存的恢复结果解除同镜头的保护。 */
watch(keyframes, rows => {
const shotId = props.shot.shotId
for (const item of rows) {
if (
item.shotId === shotId &&
item.status === 'completed' &&
item.imageUrl &&
item.recoveryRequired === false &&
item.canRecoverSavedResult === false &&
item.recoveryReason === 'provider_result_recovered'
)
releaseRecoveredImageRequest('keyframe:' + shotId, item.id, item.providerInputFingerprint)
}
})
const videos = computed(() => query.data.value?.videos ?? [])
/** 当前镜头尚未结束的首帧任务数量,包含等待提交和生成中。 */
const activeKeyframeCount = computed(
() => keyframes.value.filter(item => ['pending', 'generating'].includes(item.status)).length
)
/** 当前镜头尚未结束的视频任务数量,包含等待提交、排队和生成中。 */
const activeVideoCount = computed(() => videos.value.filter(isActiveVideo).length)
const videoQualityStatus = computed(() => query.data.value?.qualityStatus ?? null)
const videoInputPlan = computed(() => query.data.value?.inputPlan ?? null)
const currentKeyframe = computed(() => primaryKeyframe(keyframes.value))
/** 主区只展示正式成功主视频,不用候选代替尚未确认的主视频。 */
const currentVideo = computed(() => primaryVideo(videos.value))
/** 其它视频记录统一放入候选弹窗,包含生成中和失败记录。 */
const videoCandidates = computed(() => videos.value.filter(item => item.id !== currentVideo.value?.id))
const activeVideo = computed(() => videos.value.find(isActiveVideo))
const assetBlocked = computed(() => props.disabled || !!query.error.value)
/**
* 项目级 operation 只用于防止同一批量命令重复提交,不应锁住其它 Shot 的单资产操作。
* 当前 Shot 的图片/视频重复提交分别由本镜头持久化资产状态约束。
*/
const keyframeOpen = ref(false)
watch(
() => props.openKeyframe,
requested => {
if (requested) keyframeOpen.value = true
},
{ immediate: true }
)
const qualityOpen = ref(false)
const candidatesOpen = ref(false)
/** 视频候选仅在用户打开弹窗后展示。 */
const videoCandidatesOpen = ref(false)
/** 仅点击视频卡片入口后显示已有质量记录。 */
const videoHistoryOpen = ref(false)
/** 费用审计和原质量共用视频详情,独立标签与固定底栏。 */
const videoHistoryTab = ref('quality')
/** 费用事务提交期间锁住关闭及切换。 */
const videoAuditBusy = ref(false)
/** 固定底栏调用当前原任务表单。 */
const videoAuditForm = ref<InstanceType<typeof VideoAuditPanel> | null>(null)
/** 当前查看记录的视频 ID,按资产隔离主视频和候选。 */
const videoHistoryId = ref('')
/** 历史弹窗按用户选择的候选独立判断过期,不套用主视频结论。 */
const videoHistoryAsset = computed(() => videos.value.find(item => item.id === videoHistoryId.value))
/** 当前选中视频的过期终态独立于主视频判断。 */
const videoHistoryStale = computed(
() =>
!!videoHistoryAsset.value?.motionPlanStale ||
videoHistoryAsset.value?.qualityTerminalStatus === 'stale_motion_plan' ||
(videoHistoryId.value === currentVideo.value?.id && videoStale.value)
)
/** 质量操作绑定当前视频的权限,每次刷新列表都会更新。 */
const qualityVideo = computed(() => {
const target = qualityTarget.value
return target?.kind === 'video' ? (videos.value.find(item => item.id === target.assetId) ?? null) : null
})
const qualityTarget = ref<QualityTarget | null>(null)
/** 修复入口打开面板时选择对应动作,仍需重新确认费用。 */
const qualityAction = ref<'validate' | 'repair'>('validate')
const specsOpen = ref(false)
const generationCatalog = ref<GenerationModelCatalog | null>(null)
const generationCatalogError = ref('')
const videoProvider = ref('')
const videoGenerationOptions = ref<GenerationOptions>({})
const videoInputModeOverride = ref<'auto' | 'first_frame' | 'omni_reference'>('auto')
const projectAspectRatio = ref<CreativeProfileAspectRatio>('9:16')
/** 项目配置成功保存后同步当前单镜头默认参数。 */
const generationRevision = useProjectGenerationRevision()
/** 单镜手动生成默认继承项目配置,用户修改只作用于本次请求;取消旧项目响应。 */
watch(
[() => props.projectId, generationRevision],
async ([projectId], _previous, onCleanup) => {
const controller = new AbortController()
onCleanup(() => controller.abort())
generationCatalogError.value = ''
try {
const [catalog, profile] = await Promise.all([
generationConfigApi.catalog(controller.signal),
generationConfigApi.profile(projectId, controller.signal)
])
if (controller.signal.aborted) return
generationCatalog.value = catalog
projectAspectRatio.value = profile?.aspectRatio ?? '9:16'
videoProvider.value = profile?.videoProvider || catalog.defaults.videoProvider
const selected = catalog.videos.find(item => item.provider === videoProvider.value)
videoGenerationOptions.value = {
...selected?.defaults,
...profile?.videoOptions
}
} catch (cause) {
if (!controller.signal.aborted) generationCatalogError.value = errorMessage(cause)
}
},
{ immediate: true }
)
/**
* 从实际候选打开质量面板,先关闭候选弹窗,避免遮挡费用与操作确认。
* @param kind 需要检查的资产种类
* @param assetId 当前选中的真实资产编号
* @param repair 是否直接进入修复选项,仍须确认费用
*/
function openQuality(kind: 'keyframe' | 'video', assetId: string, repair = false) {
qualityAction.value = repair ? 'repair' : 'validate'
candidatesOpen.value = false
videoCandidatesOpen.value = false
qualityTarget.value = {
kind,
shotId: props.shot.shotId,
assetId,
title: `${props.shot.title} · ${kind === 'keyframe' ? '首帧' : '视频'}`
}
qualityOpen.value = true
}
/**
* 从主视频或候选卡片打开只读记录,关闭候选弹窗以避免弹窗叠加。
* @param videoId 当前选中视频 ID
* @param tab 本次打开的记录分类
*/
function openVideoHistory(videoId: string, tab: 'quality' | 'audit' = 'quality') {
videoCandidatesOpen.value = false
videoHistoryTab.value = tab
videoHistoryId.value = videoId
videoHistoryOpen.value = true
}
/** 只打开当前镜头的有限质量重跑表单,费用确认后才发送任务。 */
function openShotKeyframeQuality() {
if (!props.episodeNo || !canGenerateKeyframe.value) return
qualityTarget.value = {
kind: 'batch',
episodeNo: props.episodeNo,
shotId: props.shot.shotId,
title: `${props.shot.title} · 本镜首帧质量重跑`
}
qualityOpen.value = true
}
/** 当前查看历史的候选 ID;历史记录在独立弹窗内按候选隔离。 */
const historyKeyframeId = ref('')
/** 历史候选画幅或来源失效时保留浏览、禁止人工采用。 */
const historyBlocked = computed(() => {
const item = keyframes.value.find(candidate => candidate.id === historyKeyframeId.value)
return (
assetBlocked.value ||
!item ||
item.canvasDiagnosis?.status === 'mismatch' ||
item.inputSnapshotStatus === 'invalid' ||
(item.isPrimary && keyframeStale.value)
)
})
/** 首帧校验历史弹窗的显示状态。 */
const historyOpen = ref(false)
/** 历史授权提交期间锁定记录弹窗。 */
const historyAuthorizationPending = ref(false)
/** 记录弹窗在统一底栏提交独立审核授权。 */
const visionHistoryRef = ref<InstanceType<typeof KeyframeValidationHistory> | null>(null)
/**
* 打开指定首帧的校验历史,供主首帧与候选卡片共用。
* @param keyframeId 需要查看历史的首帧 ID
*/
function openKeyframeHistory(keyframeId: string) {
historyKeyframeId.value = keyframeId
historyOpen.value = true
}
const confirmingKeyframe = ref('')
const confirmingVideo = ref('')
const inspecting = ref(false)
const specError = ref('')
const keyframeSpec = ref<KeyframeSpec | null>(null)
const videoSpec = ref<VideoGenerationSpec | null>(null)
const canGeneratePrompt = computed(
() => !assetBlocked.value && !!props.promptReadiness && props.promptReadiness.issues.length === 0
)
/** 付费生成同时要求当前镜头就绪和有效正式预览。 */
const canGenerateKeyframe = computed(
() =>
!assetBlocked.value &&
!query.loading.value &&
!!query.data.value &&
!keyframes.value.some(item => item.recoveryRequired || ['pending', 'generating'].includes(item.status)) &&
!!props.keyframeReadiness &&
props.keyframeReadiness.issues.length === 0
)
const canGenerateVideo = computed(
() =>
!assetBlocked.value &&
!activeVideo.value &&
!!props.videoReadiness &&
props.videoReadiness.issues.length === 0 &&
/** 真正的视频质量门仍由后端编译器执行,前端不以易过期的会话结果代替持久化状态。 */
!!currentKeyframe.value &&
!primaryQualityBlocked.value
)
const keyframeStale = computed(() => !!props.keyframeReadiness?.primaryKeyframeStale)
/** 当前主首帧的持久化质量状态,避免会话缓存与按钮状态冲突。 */
const primaryQualityKey = computed(() =>
currentKeyframe.value ? JSON.stringify([props.shot.shotId, currentKeyframe.value.id, reviewRevision.value]) : ''
)
const primaryQualityQuery = useQuery(primaryQualityKey, (value, signal) => {
if (!value) return Promise.resolve(null)
const [shotId, keyframeId] = JSON.parse(value) as [string, string, number]
return qualityApi.keyframeQualityReview(shotId, keyframeId, signal)
})
const primaryQualityBlocked = computed(() => {
const status = primaryQualityQuery.data.value?.effectiveQualityStatus
return !status || status === 'failed' || status === 'needs_review' || status === 'unknown'
})
const reviewRevision = ref(0)
/** 审核后强制更新每张卡片的数据库质量状态。 */
async function refreshAfterReview() {
reviewRevision.value += 1
await refreshAll()
}
const keyframeCandidates = computed(() => keyframes.value.filter(item => item.id !== currentKeyframe.value?.id))
/** 首帧弹窗按当前候选数适配一至五列,实际宽度由公共弹窗限制在视口内。 */
const keyframeCandidatesWidth = computed(() => candidateDialogWidth(keyframeCandidates.value.length))
/** 视频弹窗与首帧共用固定列宽,少量候选不留多余的整列空白。 */
const videoCandidatesWidth = computed(() => candidateDialogWidth(videoCandidates.value.length))
/** 仅用于本会话即时提示;最终质量判定以持久化审核结果为准。 */
function keyframePassed(assetId: string) {
return sessionKeyframePassed(props.projectId, props.shot.shotId, assetId)
}
/** 主视频过期由资产终态及 readiness 共同说明。 */
const videoStale = computed(
() =>
!!props.videoReadiness?.primaryVideoStale ||
!!currentVideo.value?.motionPlanStale ||
currentVideo.value?.qualityTerminalStatus === 'stale_motion_plan'
)
/** 后端具体原因优先,缺省时使用兼容概括说明。 */
const videoStaleReason = computed(
() =>
props.videoReadiness?.primaryVideoStaleReasons?.join(';') ||
currentVideo.value?.staleReason ||
videoInputStaleReason
)
/** 权限或版本变化后撤销已失效的本会话结论与切换确认。 */
watch(videos, items => {
for (const item of items) {
if (item.motionPlanStale || item.qualityTerminalStatus === 'stale_motion_plan') {
clearVideoQualification(props.projectId, item.shotId, item.id)
if (confirmingVideo.value === item.id) confirmingVideo.value = ''
}
}
if (confirmingVideo.value && !items.find(item => item.id === confirmingVideo.value)?.canSetPrimary)
confirmingVideo.value = ''
})
watch(key, () => {
qualityOpen.value = false
qualityTarget.value = null
specsOpen.value = false
confirmingKeyframe.value = ''
historyOpen.value = false
historyKeyframeId.value = ''
confirmingVideo.value = ''
videoCandidatesOpen.value = false
videoHistoryOpen.value = false
videoHistoryId.value = ''
keyframeSpec.value = null
videoSpec.value = null
specError.value = ''
})
/** 重新读取单镜头资产,并通知父页刷新项目就绪状态。 */
async function refreshAll() {
await Promise.all([query.refresh(), promptQuery.refresh(), videoInputQuery.refresh()])
emit('changed')
}
/** 手动更新素材时才反馈查询结果,切换镜头后不显示旧目标提示。 */
async function refreshVideoInput() {
if (videoInputQuery.loading.value) return
const target = `${props.projectId}:${props.shot.shotId}`
await videoInputQuery.refresh()
if (disposed || target !== `${props.projectId}:${props.shot.shotId}`) return
if (videoInputQuery.error.value)
actionMessage?.warning(productionMessage(videoInputQuery.error.value), { duration: 7000, closable: true })
else actionMessage?.success('视频素材已更新。', { duration: 3000 })
}
/** 单镜头提示词根据现有状态决定是否 force 覆盖。 */
async function generatePrompt() {
if (!canGeneratePrompt.value) return
const shotId = props.shot.shotId
const overwrite = props.promptReadiness?.status === 'skipped'
await runOperation(props.projectId, `生成镜头 ${props.shot.shotNo} 视频提示词`, async () => {
const result = await storyboardApi.generatePrompt(shotId, overwrite)
if (!result || result.shotId !== shotId || !result.videoPrompt) throw new Error('接口未返回有效视频提示词。')
})
await refreshAll()
}
/**
* 提交已确认的首帧输入,并刷新该镜头候选。
* @param input 预览绑定的生成参数
* @returns 真实提交结果与可能的冲突
*/
async function generateKeyframe(input: GenerateKeyframeInput) {
if (!canGenerateKeyframe.value || !input.expectedPreviewFingerprint) return { accepted: false }
const shotId = props.shot.shotId
const projectId = props.projectId
const accepted = await runOperation(projectId, `生成镜头 ${props.shot.shotNo} 首帧`, async () => {
const result = await productionApi.generateKeyframe(shotId, input)
if (
!result?.id ||
result.shotId !== shotId ||
result.status !== 'completed' ||
!result.imageUrl ||
result.recoveryRequired !== false ||
result.providerInputFingerprint !== input.expectedPreviewFingerprint
)
throw new ApiError('首帧生成结果待核对。', 200)
})
const cause = getOperation(projectId).cause
if (props.projectId === projectId && props.shot.shotId === shotId) await refreshAll()
return { accepted, cause }
}
/**
* 恢复原候选下载,只在服务明确有可恢复结果时允许。
* @param item 当前候选
*/
async function recoverSavedKeyframe(item: ShotKeyframe) {
if (assetBlocked.value || !item.canRecoverSavedResult || item.shotId !== props.shot.shotId) return
const projectId = props.projectId
const shotId = props.shot.shotId
await runOperation(projectId, `恢复已生成首帧 ${item.id}`, async () => {
const result = await productionApi.recoverSavedKeyframe(shotId, item.id)
if (
!result ||
result.id !== item.id ||
result.shotId !== shotId ||
result.status !== 'completed' ||
!result.imageUrl ||
result.recoveryRequired !== false ||
result.canRecoverSavedResult !== false ||
result.providerInputFingerprint !== item.providerInputFingerprint
)
throw new Error('下载结果待核对,请刷新候选。')
releaseRecoveredImageRequest('keyframe:' + shotId, result.id, result.providerInputFingerprint)
})
if (projectId === props.projectId && shotId === props.shot.shotId) await refreshAll()
}
/** 切换主首帧不调用模型,但会改变后续视频生成输入。 */
async function setPrimaryKeyframe() {
const keyframeId = confirmingKeyframe.value
if (
assetBlocked.value ||
!keyframeId ||
!keyframes.value.some(
item =>
item.id === keyframeId &&
item.source !== 'provider_variant' &&
item.status === 'completed' &&
!!item.imageUrl &&
item.canvasDiagnosis?.status !== 'mismatch' &&
item.inputSnapshotStatus !== 'invalid' &&
!item.recoveryRequired
)
)
return
const shotId = props.shot.shotId
confirmingKeyframe.value = ''
await runOperation(props.projectId, `设置镜头 ${props.shot.shotNo} 主首帧`, async () => {
// 晋升前重新读取持久化质量结论,刷新页面后也认可真实历史通过。
const [review, history] = await Promise.all([
qualityApi.keyframeQualityReview(shotId, keyframeId),
qualityApi.keyframeHistory(shotId, keyframeId, undefined, props.projectId)
])
const vision = visionState(history)
if (
vision.active ||
vision.unknown ||
vision.resumable ||
history.some(item => item.id === review.validationTaskId && item.legacyTermination)
)
throw new Error('审核尚未结算,暂不能设为主首帧。')
if (!['passed', 'manual_accepted'].includes(review.effectiveQualityStatus))
throw new Error('此候选尚未通过当前质量要求,请先完成质量检查或有效人工复核。')
const result = await productionApi.setPrimaryKeyframe(shotId, keyframeId)
if (!result || result.id !== keyframeId || !result.isPrimary || result.status !== 'completed')
throw new Error('接口未确认主首帧切换。')
})
await refreshAll()
}
/** 创建单镜头严格质量候选;后端完成生成后自动校验、有限修复并按结果晋升。 */
async function generateVideo() {
if (!canGenerateVideo.value) return
const shotId = props.shot.shotId
await runOperation(props.projectId, `提交镜头 ${props.shot.shotNo} 视频质量任务`, async () => {
const result = await productionApi.generateQualityVideo(shotId, {
provider: videoProvider.value || undefined,
inputMode:
videoInputModeOverride.value === 'auto'
? videoInputPlan.value?.inputMode
: videoInputModeOverride.value,
generationOptions: videoGenerationOptions.value,
maxRepairAttempts: 2,
allowedTexts: []
})
if (!result || result.shotId !== shotId || !result.candidate || !isActiveVideo(result.candidate))
throw new Error('接口未返回有效的视频质量候选任务。')
})
await refreshAll()
}
/** 手动向 Provider 查询活动视频状态,终态任务不重复查询。 */
async function refreshActiveVideo() {
const video = activeVideo.value
if (!video || assetBlocked.value) return
await runOperation(props.projectId, `刷新镜头 ${props.shot.shotNo} 视频状态`, async () => {
const result = await productionApi.refreshVideo(video.id)
if (!result || result.id !== video.id) throw new Error('接口未返回当前视频任务状态。')
})
await refreshAll()
}
/** 根据本候选后端权限切换主视频;冲突后撤销资格并重新读取真实资产。 */
async function setPrimaryVideo() {
const videoId = confirmingVideo.value
if (assetBlocked.value || !videoId) return
const video = videos.value.find(item => item.id === videoId)
if (!video || video.status !== 'completed' || !video.videoUrl || !videoOperationAllowed(video, 'primary')) return
const shotId = props.shot.shotId
confirmingVideo.value = ''
await runOperation(props.projectId, `设置镜头 ${props.shot.shotNo} 主视频`, async () => {
const result = await productionApi
.setPrimaryVideo(shotId, videoId, video.currentMotionPlanRevisionId)
.catch(cause => {
clearVideoConflict(cause, props.projectId, shotId, videoId)
throw cause
})
if (!result || result.id !== videoId || !result.isPrimary || result.status !== 'completed')
throw new Error('接口未确认主视频切换。')
})
await refreshAll()
}
/** 显式检查两份确定性生成规格;某一阶段未就绪时保留另一份可读结果。 */
async function inspectSpecs() {
specsOpen.value = true
inspecting.value = true
specError.value = ''
const shotId = props.shot.shotId
const [keyframeResult, videoResult] = await Promise.allSettled([
productionApi.keyframeSpec(shotId),
productionApi.videoGenerationSpec(shotId)
])
if (props.shot.shotId !== shotId) {
inspecting.value = false
return
}
keyframeSpec.value = keyframeResult.status === 'fulfilled' ? keyframeResult.value : null
videoSpec.value = videoResult.status === 'fulfilled' ? videoResult.value : null
const errors = [keyframeResult, videoResult]
.filter(result => result.status === 'rejected')
.map(result => errorMessage(result.reason))
specError.value = [...new Set(errors)].join(' ')
inspecting.value = false
}
/** 将只读检查入口与读取状态交给镜头标题行,保留弹窗在资产组件内管理。 */
defineExpose({ inspectSpecs, inspecting })
</script>
<template>
<section class="production-assets">
<ContextNotice v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mt-4"
>{{ query.error.value }} 当前保留上次成功读取的资产,操作已暂停。
</ContextNotice>
<!-- 以下是项目制作中的视频提示词模块 -->
<!-- 以下是连续性门禁的原审核处理入口 -->
<RouterLink
v-if="
[
...(keyframeReadiness?.issues ?? []),
...(promptReadiness?.issues ?? []),
...(videoReadiness?.issues ?? [])
].some(issue => issue.code === 'continuity_review_required')
"
class="workspace-action-button"
:to="`/projects/${projectId}/storyboard?action=continuity`"
>复核连续性有序组</RouterLink
>
<div v-if="!keyframeOnly" class="production-stage">
<div class="production-stage-heading">
<div>
<h5 class="text-sm font-medium">01 · 视频提示词</h5>
</div>
<!-- 以下是视频提示词状态与对应原因入口模块 -->
<ProductionStageStatus
:status="promptReadiness?.status"
:label="promptReadiness ? productionStatusLabel(promptReadiness.status) : undefined"
:messages="(promptReadiness?.issues ?? []).map(productionIssueText)"
/>
</div>
<div v-if="savedPrompt?.videoPrompt" class="surface-inset mt-4 p-4" aria-label="本镜视频提示词">
<div class="flex flex-wrap items-center justify-between gap-3">
<p class="text-xs font-medium">本镜视频提示词</p>
<NButton text size="small" @click="motionOpen = true">查看动作与视线</NButton>
</div>
<p class="mt-3 whitespace-pre-wrap break-words text-sm leading-6">{{ savedPrompt.videoPrompt }}</p>
<template v-if="savedPrompt.negativePrompt">
<p class="mt-4 text-xs font-medium">负向提示词</p>
<p class="mt-2 whitespace-pre-wrap break-words text-xs leading-6 text-muted">
{{ savedPrompt.negativePrompt }}
</p>
</template>
<p v-if="promptReadiness?.stalePrompt" class="mt-3 text-xs text-danger">
此提示词已过期,请重新生成后再制作视频。
</p>
</div>
<p v-else-if="promptQuery.loading.value" role="status" class="mt-4 text-xs text-muted">
正在读取视频提示词…
</p>
<p v-else-if="!promptQuery.error.value" class="mt-4 text-xs text-muted">尚未生成本镜视频提示词。</p>
<ContextNotice
v-if="promptQuery.error.value"
role="alert"
type="warning"
:show-icon="false"
class="mt-4 text-xs"
>
提示词读取失败:{{ promptQuery.error.value }}
<NButton text size="small" @click="promptQuery.refresh">重试</NButton>
</ContextNotice>
<div class="production-stage-actions">
<ConfirmAction
:label="promptReadiness?.status === 'skipped' ? '重新生成本镜提示词' : '生成本镜提示词'"
:loading="promptLoading"
:disabled="!canGeneratePrompt"
acknowledgement
:description="
promptReadiness?.status === 'skipped'
? '依据当前 GenerationSpec 与参考图重写本镜提示词。旧提示词会被覆盖,已有首帧和视频不会自动更新。'
: '依据当前 GenerationSpec 与参考图生成本镜视频提示词。'
"
@confirm="generatePrompt"
/>
</div>
</div>
<div class="production-stage" :class="{ 'production-stage-with-corner': keyframeOnly }">
<div class="production-stage-heading" :class="{ 'pr-24': keyframeOnly }">
<div>
<h5 class="text-sm font-medium">{{ keyframeOnly ? '本镜首帧' : '02 · 首帧' }}</h5>
</div>
<!-- 以下是首帧状态与对应原因入口模块,过期使用警告色 -->
<ProductionStageStatus
:icon-only="keyframeOnly"
:loading="keyframeReadinessLoading"
:class="{ 'production-stage-corner': keyframeOnly }"
:status="keyframeReadiness?.status"
:label="keyframeReadiness ? productionStatusLabel(keyframeReadiness.status) : undefined"
:warning-label="keyframeStale ? '主首帧已过期' : undefined"
:messages="(keyframeReadiness?.issues ?? []).map(productionIssueText)"
/>
</div>
<!-- 以下是主首帧卡片模块,校验历史通过卡片入口在弹窗内查看 -->
<div v-if="currentKeyframe" class="keyframe-grid mt-4">
<KeyframeCard
:project-id="projectId"
:shot-id="shot.shotId"
:review-revision="reviewRevision"
:item="currentKeyframe"
:editing="
editSource?.id === currentKeyframe.id &&
isOperationRunning(getOperation(projectId), `编辑镜头 ${shot.shotId} 首帧`)
"
:shot-no="shot.shotNo"
:stale="keyframeStale"
:blocked="assetBlocked"
:validation-passed="keyframePassed(currentKeyframe.id)"
:confirming="false"
@quality="openQuality('keyframe', currentKeyframe.id)"
@edit="openEdit(currentKeyframe)"
@history="openKeyframeHistory(currentKeyframe.id)"
@settled="refreshAfterReview"
/>
</div>
<p v-else class="mt-4 text-xs text-muted">尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。</p>
<ContextNotice
v-if="currentKeyframe && keyframePassed(currentKeyframe.id) === false"
type="error"
:show-icon="false"
class="mt-3 text-xs"
>
主首帧未通过检查,请更换合格候选后生成视频。
</ContextNotice>
<ContextNotice
v-if="query.data.value?.qualityStatusError"
type="warning"
:show-icon="false"
class="mt-3 text-xs"
>
暂时无法读取检查结果,请刷新。
</ContextNotice>
<div class="production-stage-actions">
<NButton
v-if="!keyframeOnly"
:disabled="!episodeNo || !canGenerateKeyframe"
@click="openShotKeyframeQuality"
>本镜首帧质量重跑</NButton
>
<NButton v-if="keyframeCandidates.length" @click="candidatesOpen = true">
管理候选({{ keyframeCandidates.length }})
</NButton>
<!-- 以下是首帧候选任务进行中的数量提示模块 -->
<NTag v-if="activeKeyframeCount" size="small" type="warning" :bordered="false" role="status">
首帧任务进行中({{ activeKeyframeCount }})
</NTag>
<NButton
:loading="isOperationRunning(getOperation(projectId), `生成镜头 ${shot.shotNo} 首帧`)"
:disabled="!query.data.value"
@click="keyframeOpen = true"
><ImagePlus :size="14" />{{
keyframeStale ? '生成替代候选' : currentKeyframe ? '再生成一张候选' : '生成首帧候选'
}}</NButton
>
</div>
</div>
<!-- 以下是项目制作中的视频资产模块 -->
<div v-if="!keyframeOnly" class="production-stage">
<div class="production-stage-heading">
<div>
<h5 class="text-sm font-medium">03 · 视频</h5>
</div>
<!-- 以下是视频状态与对应原因入口模块,需更新使用警告色 -->
<ProductionStageStatus
:status="videoReadiness?.status"
:label="videoReadiness ? productionStatusLabel(videoReadiness.status) : undefined"
:warning-label="videoStale ? '主视频需更新' : undefined"
:messages="videoIssueMessages"
/>
</div>
<!-- 以下是主视频输入或动作规划版本变化说明模块,与此前画面检查结论分别说明 -->
<p v-if="videoStale" class="mt-3 text-xs text-muted">{{ videoStaleReason }},请重新生成视频。</p>
<!-- 以下是主视频展示模块,位于素材引用之前,其它记录在候选弹窗中查看 -->
<div v-if="currentVideo" class="video-grid mt-4">
<VideoCard
:item="currentVideo"
:shot-no="shot.shotNo"
:duration-seconds="shot.durationSeconds"
:stale="videoStale"
:blocked="assetBlocked"
:validation-passed="sessionVideoValidation(projectId, shot.shotId, currentVideo.id)?.passed ?? null"
:recorded-validation-passed="
videoRecordedValidation(videoQualityStatus, shot.shotId, currentVideo.id)
"
:confirming="false"
@quality="openQuality('video', currentVideo.id)"
@repair="openQuality('video', currentVideo.id, true)"
@history="openVideoHistory(currentVideo.id)"
@audit="openVideoHistory(currentVideo.id, 'audit')"
/>
</div>
<p v-else class="mt-4 text-xs text-muted">
{{ videoCandidates.length ? '尚无已确认主视频,请在候选中检查并选择。' : '尚无视频任务记录。' }}
</p>
<!-- 以下是视频素材输入方式与原因说明模块,位于主视频下方、素材引用之前 -->
<div v-if="videoInputPlan" class="mt-4 flex flex-wrap items-center gap-2 text-xs">
<NTag size="small" :bordered="false" type="info">
{{ videoInputPlan.inputMode === 'omni_reference' ? '使用多张参考图' : '使用首帧' }}
</NTag>
<span class="text-muted">{{ videoInputPlan.reasons.map(productionMessage).join(';') }}</span>
</div>
<!-- 以下是外层铺满、单行紧凑排列、换行后按可用宽度等分的视频素材模块 -->
<section
class="video-input-section surface-inset mt-4 p-4"
:style="{ '--video-input-count': (currentVideoInput?.references.length ?? 0) + 1 }"
aria-label="当前视频生成素材引用"
>
<div class="flex flex-wrap items-center justify-between gap-2">
<h6 class="text-xs font-medium">视频使用的素材</h6>
<span v-if="currentVideoInput" class="text-[11px] text-muted">
首帧 1 张 · 参考图 {{ currentVideoInput.references.length }} 张
</span>
</div>
<div v-if="currentVideoInput" class="video-input-grid mt-4">
<article class="video-input-card">
<div class="video-input-image">
<AssetImage
:src="currentVideoInput.providerInputKeyframe.imageUrl"
:alt="`镜头 ${shot.shotNo} 视频输入首帧`"
preview
object-fit="cover"
/>
</div>
<div class="min-w-0 p-2 text-center text-xs">
<p class="font-medium">视频输入首帧</p>
<p class="mt-1 text-[11px] text-muted">
{{
currentVideoInput.providerInputKeyframe.source === 'provider_variant'
? '模型专用变体'
: '当前主首帧'
}}
</p>
</div>
</article>
<article
v-for="reference in currentVideoInput.references"
:key="`${reference.subjectId}:${reference.imageId}`"
class="video-input-card"
>
<div class="video-input-image">
<AssetImage
:src="reference.imageUrl"
:alt="`${reference.subjectName} ${reference.subjectFormName} 参考图`"
preview
object-fit="cover"
/>
</div>
<div class="min-w-0 p-2 text-center text-xs">
<p class="truncate font-medium" :title="reference.subjectName">
{{ reference.subjectName }}
</p>
<p class="mt-1 truncate text-[11px] text-muted" :title="reference.subjectFormName">
{{ reference.subjectFormName }}
</p>
</div>
</article>
</div>
<p v-else-if="videoInputQuery.loading.value" role="status" class="mt-4 text-xs text-muted">
正在读取视频生成素材…
</p>
<div v-else class="mt-4 text-xs text-muted">
<p>视频素材还未准备好,请先检查视频提示词、首帧和参考图。</p>
<IssueHint v-if="!videoIssueMessages.length" :messages="videoInputError ? [videoInputError] : []" />
<!-- 以下是重新获取素材的操作模块,与上下正文保持间距 -->
<div v-if="videoInputQuery.error.value" class="mt-3 flex pb-1">
<NButton text size="small" :loading="videoInputQuery.loading.value" @click="refreshVideoInput"
>重新获取</NButton
>
</div>
</div>
</section>
<!-- 以下是视频候选弹窗入口模块 -->
<div v-if="videoCandidates.length" class="mt-4 flex flex-wrap gap-3">
<NButton @click="videoCandidatesOpen = true">管理候选({{ videoCandidates.length }})</NButton>
<!-- 以下是视频候选任务进行中的数量提示模块 -->
<NTag v-if="activeVideoCount" size="small" type="warning" :bordered="false" role="status">
视频任务进行中({{ activeVideoCount }})
</NTag>
</div>
<section
v-if="generationCatalog"
class="generation-settings-panel surface-inset mt-4"
aria-label="本次视频生成模型设置"
>
<div class="generation-settings-content">
<div>
<h6 class="text-sm font-medium">本次生成设置</h6>
<p class="mt-1 text-[11px] leading-5 text-muted">
仅覆盖当前镜头本次生成,不修改项目默认模型。
</p>
</div>
<GenerationModelControls
class="mt-5"
type="video"
:catalog="generationCatalog"
:provider="videoProvider"
:options="videoGenerationOptions"
:aspect-ratio="projectAspectRatio"
:disabled="assetBlocked"
@update:provider="videoProvider = $event"
@update:options="videoGenerationOptions = $event"
/>
<div class="generation-input-mode">
<p class="generation-input-mode-label">生成方式</p>
<NSelect
:value="videoInputModeOverride"
:disabled="assetBlocked"
:options="[
{
label: `自动(推荐:${videoInputPlan?.inputMode === 'omni_reference' ? '多张参考图' : '首帧'})`,
value: 'auto'
},
{ label: '首帧模式', value: 'first_frame' },
{ label: '多张参考图', value: 'omni_reference' }
]"
@update:value="videoInputModeOverride = $event"
/>
<p class="mt-1.5 text-[11px] leading-5 text-muted">可手动调整本次生成方式。</p>
</div>
</div>
</section>
<ContextNotice v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-4 text-xs">
生成模型目录读取失败:{{ generationCatalogError }}
</ContextNotice>
<div class="production-stage-actions">
<ConfirmAction
:label="
videoStale ? '重新生成质量视频' : currentVideo ? '再生成一个质量候选' : '提交本镜视频质量任务'
"
:disabled="!canGenerateVideo"
acknowledgement
:description="
videoStale
? '使用当前视频提示词、主首帧和主体参考图启动严格质量流水线;最多自动修复 2 次,通过后才接替当前过期主视频。'
: currentVideo
? '新增一个视频候选,自动检查并最多修复 2 次;通过检查后才替换主视频。'
: '启动严格视频质量流水线;任务在后台生成、校验并有限修复,通过后才晋升主视频。'
"
primary
@confirm="generateVideo"
/>
<NButton v-if="activeVideo" :disabled="assetBlocked" @click="refreshActiveVideo"
><RefreshCw :size="14" />刷新任务状态
</NButton>
</div>
</div>
<AppDialog v-model:open="specsOpen" title="生成设置与模型限制" description="查看不收费。" wide>
<FeedbackMessage v-if="specError" :message="specError" />
<p v-if="inspecting" role="status" class="mt-4 text-xs text-muted">正在读取生成规格…</p>
<ModelCapabilities :shot-id="shot.shotId" />
<ProviderInputInspector :shot-id="shot.shotId" />
<NCollapse v-if="keyframeSpec || videoSpec" class="mt-5 pt-4 text-xs"
><NCollapseItem name="details"
><template #header>查看生成描述</template>
<div class="mt-4 grid gap-5 lg:grid-cols-2">
<div v-if="keyframeSpec">
<h5 class="font-medium">首帧描述 · {{ keyframeSpec.references.length }} 张参考图</h5>
<p class="mt-3 whitespace-pre-wrap leading-6 text-muted">{{ keyframeSpec.prompt }}</p>
<ul v-if="keyframeSpec.references.length" class="mt-3 space-y-1 text-[11px] text-muted">
<li
v-for="reference in keyframeSpec.references"
:key="`${reference.role}:${reference.imageId}`"
>
{{ reference.subjectRef }} ·
{{ reference.role === 'identity-anchor' ? '演员身份母版' : '形态主图' }}
</li>
</ul>
</div>
<div v-if="videoSpec">
<h5 class="font-medium">视频描述 · {{ videoSpec.durationSeconds }} 秒</h5>
<p class="mt-3 whitespace-pre-wrap leading-6 text-muted">{{ videoSpec.videoPrompt }}</p>
<p v-if="videoSpec.negativePrompt" class="mt-3 whitespace-pre-wrap leading-6 text-muted">
不希望出现的内容: {{ videoSpec.negativePrompt }}
</p>
</div>
</div></NCollapseItem
></NCollapse
>
</AppDialog>
<AppDialog v-model:open="motionOpen" title="镜头动作与视线" wide>
<!-- 以下是与分镜详情一致的动作和视线模块间距 -->
<div v-if="motionOpen" class="workspace-section-stack workspace-section-stack-spacious">
<MotionPlanPanel
:key="shot.shotId"
:shot-id="shot.shotId"
:project-id="projectId"
:disabled="assetBlocked"
:revision="savedPrompt?.updatedAt"
@changed="refreshAll"
/>
<SpatialBindingsPanel
:key="shot.shotId"
:project-id="projectId"
:shot-id="shot.shotId"
:disabled="assetBlocked"
@changed="refreshAll"
/>
</div>
</AppDialog>
<KeyframeEditDialog
v-model:open="editOpen"
:project-id="projectId"
:shot-id="shot.shotId"
:source="editSource"
:disabled="assetBlocked"
@started="emit('qualityStarted', $event)"
/>
<QualityDialog
v-model:open="qualityOpen"
:project-id="projectId"
:target="qualityTarget"
:video="qualityVideo"
:initial-action="qualityAction"
:disabled="assetBlocked"
@changed="refreshAll"
@started="emit('qualityStarted', $event)"
/>
<AppDialog
v-model:open="candidatesOpen"
title="首帧候选管理"
description="通过检查或人工复核后可设为主首帧。"
:width="keyframeCandidatesWidth"
>
<!-- 候选图片和对应的人工复核入口按相同候选 ID 分组。 -->
<div v-if="keyframeCandidates.length" class="asset-candidate-grid mt-4">
<div v-for="item in keyframeCandidates" :key="item.id" class="min-w-0">
<KeyframeCard
:project-id="projectId"
:shot-id="shot.shotId"
:review-revision="reviewRevision"
:item="item"
:recovering="isOperationRunning(getOperation(projectId), `恢复已生成首帧 ${item.id}`)"
@recover="recoverSavedKeyframe(item)"
:editing="
editSource?.id === item.id &&
isOperationRunning(getOperation(projectId), `编辑镜头 ${shot.shotId} 首帧`)
"
:shot-no="shot.shotNo"
:stale="false"
:blocked="assetBlocked"
:validation-passed="keyframePassed(item.id)"
:confirming="confirmingKeyframe === item.id"
@quality="openQuality('keyframe', item.id)"
@edit="openEdit(item)"
@history="openKeyframeHistory(item.id)"
@settled="refreshAfterReview"
@select="confirmingKeyframe = item.id"
@confirm="setPrimaryKeyframe"
@cancel="confirmingKeyframe = ''"
/>
</div>
</div>
<p v-else class="text-xs text-muted">暂无其它首帧候选。</p>
</AppDialog>
<!-- 以下是视频候选管理弹窗模块,复用主视频卡片操作与公共弹窗滚动布局 -->
<AppDialog
v-model:open="videoCandidatesOpen"
title="视频候选管理"
description="完成质量检查后,可以将通过的候选设为主视频。"
:width="videoCandidatesWidth"
>
<div v-if="videoCandidatesOpen && videoCandidates.length" class="asset-candidate-grid mt-4">
<VideoCard
v-for="item in videoCandidates"
:key="item.id"
:item="item"
:shot-no="shot.shotNo"
:duration-seconds="shot.durationSeconds"
:stale="item.motionPlanStale || item.qualityTerminalStatus === 'stale_motion_plan'"
:blocked="assetBlocked"
:validation-passed="sessionVideoValidation(projectId, item.shotId, item.id)?.passed ?? null"
:recorded-validation-passed="videoRecordedValidation(videoQualityStatus, item.shotId, item.id)"
:confirming="confirmingVideo === item.id"
@quality="openQuality('video', item.id)"
@repair="openQuality('video', item.id, true)"
@history="openVideoHistory(item.id)"
@audit="openVideoHistory(item.id, 'audit')"
@select="confirmingVideo = item.id"
@confirm="setPrimaryVideo"
@cancel="confirmingVideo = ''"
/>
</div>
<p v-else class="text-xs text-muted">暂无其它视频候选。</p>
</AppDialog>
<!-- 以下是指定视频质量记录弹窗模块,打开后直接展示结果与修改建议 -->
<AppDrawer v-model:open="videoHistoryOpen" title="视频记录" :busy="videoAuditBusy">
<NTabs v-if="videoHistoryOpen && videoHistoryId" v-model:value="videoHistoryTab" type="line">
<NTabPane name="quality" tab="视频质量" :disabled="videoAuditBusy" display-directive="show:lazy">
<VideoQualityDiagnostics
:key="`${shot.shotId}:${videoHistoryId}:${reviewRevision}`"
:shot-id="shot.shotId"
:video-id="videoHistoryId"
:stale="videoHistoryStale"
:stale-reason="
videoHistoryId === currentVideo?.id ? videoStaleReason : videoHistoryAsset?.staleReason
"
/>
</NTabPane>
<NTabPane name="audit" tab="费用审计" :disabled="videoAuditBusy" display-directive="show:lazy">
<VideoAuditPanel
ref="videoAuditForm"
:key="`${shot.shotId}:${videoHistoryId}`"
:project-id="projectId"
:shot-id="shot.shotId"
:video-id="videoHistoryId"
:disabled="disabled"
@busy="videoAuditBusy = $event"
@changed="refreshAfterReview"
/>
</NTabPane>
</NTabs>
<template #footer>
<NButton :disabled="videoAuditBusy" @click="videoHistoryOpen = false">关闭</NButton>
<NButton
v-if="videoHistoryTab === 'audit' && videoAuditForm"
type="primary"
:disabled="!videoAuditForm.canSubmit"
:loading="videoAuditBusy"
@click="videoAuditForm.submit()"
>{{ videoAuditForm.submitLabel }}</NButton
>
</template>
</AppDrawer>
<AppDialog v-model:open="historyOpen" title="首帧记录" :busy="historyAuthorizationPending" wide>
<div v-if="historyOpen && historyKeyframeId" :key="historyKeyframeId" class="workspace-section-stack">
<!-- 以下是按需读取的候选生成证据 -->
<KeyframeInputDetails :project-id="projectId" :shot-id="shot.shotId" :keyframe-id="historyKeyframeId" />
<KeyframeValidationHistory
ref="visionHistoryRef"
:project-id="projectId"
:shot-id="shot.shotId"
:keyframe-id="historyKeyframeId"
:disabled="historyBlocked"
@busy="historyAuthorizationPending = $event"
initial-open
@reviewed="refreshAfterReview"
/>
</div>
<template #footer>
<NCheckbox
v-if="visionHistoryRef?.authorizationAvailable"
:checked="visionHistoryRef.authorizationAcknowledged"
:disabled="historyAuthorizationPending"
@update:checked="visionHistoryRef.setAuthorizationAcknowledged($event)"
>我已确认授权、费用与本次处理范围</NCheckbox
>
<NButton :disabled="historyAuthorizationPending" @click="historyOpen = false">关闭</NButton
><NButton
v-if="visionHistoryRef?.authorizationAvailable"
type="primary"
:loading="historyAuthorizationPending"
:disabled="!visionHistoryRef.authorizationReady"
@click="visionHistoryRef.submitAuthorization()"
>{{ visionHistoryRef.authorizationLabel }}</NButton
></template
>
</AppDialog>
<KeyframeDialog
v-model:open="keyframeOpen"
:shot-id="shot.shotId"
:shot-title="shot.title"
:project-id="projectId"
:replace-primary="keyframeStale"
:direction="shot.direction"
:visual-state="shot.visualState"
:disabled="!canGenerateKeyframe"
:previous-candidate-ids="keyframes.map(item => item.id)"
:submit-generation="generateKeyframe"
/>
</section>
</template>
<style>
/* 本组件专属布局与 Naive 内部结构覆盖。 */
@reference "../../../styles/styles.css";
.production-stage {
@apply py-5 px-0;
}
.production-stage:first-of-type {
@apply border-t-0;
}
/* 分镜详情由标签正文统一提供顶部留白,此处不再叠加生产阶段内边距;圆章保持右上定位。 */
.production-stage-with-corner {
position: relative;
padding-top: 0;
}
.production-stage-corner {
position: absolute;
top: 0;
right: 0;
}
.production-stage-heading {
@apply flex items-start justify-between gap-4;
}
.production-stage-actions {
@apply mt-4 flex min-h-[34px] flex-wrap items-center gap-3;
}
/* 主首帧与主视频共用 260px 宽度,画面保持正方形,小屏下不超过可用空间。 */
.keyframe-grid,
.video-grid {
@apply grid w-full max-w-[260px] grid-cols-1 gap-3;
}
/* 候选画面固定 260px,最多五列;列数减少时仍保持左右边缘对齐。 */
.asset-candidate-grid {
@apply grid w-full max-w-[1348px] items-start gap-3;
grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 260px));
justify-content: space-between;
}
.keyframe-card {
@apply min-w-0 overflow-hidden rounded-none bg-(--app-subtle);
}
.keyframe-card .asset-image {
@apply aspect-square rounded-none;
}
/* 素材背景与标题铺满外层内容宽度。 */
.video-input-section {
width: 100%;
}
/* 单行按 220px 紧凑排列;放不下时网格铺满可用宽度,自动换行并等分列,左右贴齐。 */
.video-input-grid {
@apply grid w-full gap-3;
max-width: calc(var(--video-input-count) * 220px + (var(--video-input-count) - 1) * 12px);
grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}
.video-input-grid .asset-image {
@apply aspect-square rounded-none;
}
.video-input-card {
@apply flex min-w-0 flex-col overflow-hidden bg-(--app-control);
}
.video-input-image {
@apply aspect-square w-full overflow-hidden bg-(--app-subtle);
}
.video-input-image .asset-image {
@apply h-full w-full aspect-auto;
}
.generation-settings-panel {
@apply p-5;
}
.generation-settings-content {
@apply w-full max-w-[1120px];
}
.generation-input-mode {
@apply mt-5 w-full max-w-[550px];
}
.generation-input-mode-label {
@apply mb-[7px] text-xs font-medium leading-5;
}
@media (max-width: 760px) {
/* 手机画面占满内容宽度,图片与视频的高度继续由正方形比例确定。 */
.keyframe-grid,
.video-grid {
@apply max-w-none;
}
/* 手机候选按整行展示,避免固定 260px 造成侧边留白。 */
.asset-candidate-grid {
@apply max-w-none grid-cols-[minmax(0,_1fr)];
}
/* 窄屏优先并排展示两列;素材较少时仍等分占满可用宽度。 */
.video-input-grid {
grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
}
.generation-settings-panel {
@apply p-4;
}
}
/* 窄屏标题区固定预留圆章和原因入口的空间,检查状态切换时正文位置保持稳定。 */
@media (max-width: 639px) {
.production-stage-with-corner > .production-stage-heading {
min-height: 72px;
}
}
</style>