feat(short-drama-agent-front): 补齐后端生产与质量功能

This commit is contained in:
GJ committed 2026-10-08 18:28:35 +08:00
1 parent 967c4ebea1
commit 470b52e26d
52 files changed
+3754 -1075

No files matched your search

+364 -353
View File
@@ -4,15 +4,7 @@ import { NFormItem } from 'naive-ui'
import { integerRule, sizeRules } from '../../lib/form-rules'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
import {
NScrollbar,
NAlert,
NButton,
NCheckbox,
NInputNumber,
NProgress,
NSelect
} from 'naive-ui'
import { NScrollbar, NAlert, NButton, NCheckbox, NInputNumber, NProgress, NSelect } from 'naive-ui'
import { computed, inject, ref, watch } from 'vue'
import { ArrowLeft, CheckCircle2, CircleAlert, Film, Image, MessageSquareText, RefreshCw } from '@lucide/vue'
import { EmptyState, StatusBadge } from '../../components/ui'
@@ -30,6 +22,7 @@ import QualityDialog from './components/QualityDialog.vue'
import CreativeProfileSettings from '../generation-config/components/CreativeProfileSettings.vue'
import EpisodeAssemblyPanel from './components/EpisodeAssemblyPanel.vue'
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
import { useWorkflowExecution } from '../workflows/execution'
const qualityOpen = ref(false)
/** 镜头生产页将项目批处理与单镜头资产管理放在同一条可核验链路中。 */
@@ -42,10 +35,12 @@ const {
shots,
shot,
promptItem,
keyframeExecution,
keyframeItem,
videoItem,
videoStatusItem,
query,
episodeSourceUnavailable,
operation,
session,
concurrency,
@@ -66,6 +61,26 @@ const {
promptExecution,
videoExecution
} = useProduction()
/** 首帧质量任务在关闭弹窗后仍可观察,刷新页面后恢复持久化句柄。 */
const keyframeQualityExecution = useWorkflowExecution(id, 'keyframe-quality')
/**
* 将首帧质量启动句柄交给页面级观察器,始终保存当前原项目归属。
* @param executionId 后端返回的真实任务编号
* @returns 当前观察状态刷新完成
*/
async function trackKeyframeQuality(executionId: string) {
await keyframeQualityExecution.track(executionId, id.value)
}
/** 后台首帧质量结束后刷新当前项目资产,不把开始任务当作完成。 */
watch(
() => keyframeQualityExecution.query.data.value?.status,
status => {
const record = keyframeQualityExecution.query.data.value
if (record?.projectId === id.value && (status === 'completed' || status === 'failed')) void refreshProject()
}
)
const route = inject(routeLocationKey, undefined)
/** 从素材页返回时恢复到指定剧集与正式镜头,不按重复的 Shot 编号定位。 */
watch(
@@ -365,353 +380,322 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
<section class="workspace-overview-panel production-tool-section workspace-panel">
<div class="overview-content workspace-section-stack">
<h3 class="text-sm font-semibold">项目生产总览与批量操作</h3>
<NAlert
v-if="videoRunning"
role="status"
type="info"
:show-icon="false"
>
当前有 {{ videoRunning }} 个视频任务等待或生成中。系统会持续更新任务状态,同一镜头不会重复提交。
</NAlert>
<NAlert v-if="identityBlocked" type="info" :show-icon="false">
当前有 {{ identityBlocked }} 项角色身份尚未准备完成。请先确认角色母版并完成身份锁定,再生成镜头首帧。
<RouterLink
:to="`/projects/${id}/subject-identity`"
class="text-button ml-2"
>前往主体身份 →</RouterLink
></NAlert
>
<NAlert
v-if="invalidGenerationSpecs"
type="warning"
:show-icon="false"
>
当前有 {{ invalidGenerationSpecs }} 个镜头的设计信息还不完整。请先补齐镜头设计和即时视觉状态。
<RouterLink :to="`/projects/${id}/storyboard`" class="text-button ml-2">
前往分镜设计 →
</RouterLink>
</NAlert>
<NAlert
v-if="staleKeyframes"
role="status"
type="info"
:show-icon="false"
>
当前有
{{ staleKeyframes }}
个主首帧已过期。它们使用的主体参考资产已经变化,视频阶段会被阻止;可在下方逐镜重新生成,或使用“补齐
/ 更新主首帧”批量处理。
</NAlert>
<NAlert
v-if="staleVideos"
role="status"
type="info"
:show-icon="false"
>
当前有
{{ staleVideos }}
个主视频已过期。它们使用的主首帧或主体参考图已经变化;非覆盖模式批量生成时会只重建这些过期主视频。
</NAlert>
<ProductionReceipt v-if="session.receipt" :receipt="session.receipt" />
<WorkflowExecutionPanel
v-if="promptExecution.executionId.value"
title="视频提示词任务"
:execution="promptExecution.query.data.value"
:loading="promptExecution.query.loading.value"
:error="promptExecution.query.error.value"
@refresh="promptExecution.query.refresh"
@dismiss="promptExecution.dismiss"
/>
<WorkflowExecutionPanel
v-if="videoExecution.executionId.value"
title="视频质量任务"
:execution="videoExecution.query.data.value"
:loading="videoExecution.query.loading.value"
:error="videoExecution.query.error.value"
@refresh="videoExecution.query.refresh"
@dismiss="videoExecution.dismiss"
/>
<div v-if="query.data.value" class="production-pipeline">
<article
v-for="stage in stages"
:key="stage.key"
class="production-pipeline-card"
>
<div class="flex items-start justify-between gap-3">
<div class="flex items-start gap-3">
<span class="production-step"
><component :is="stage.icon" :size="17"
/></span>
<div>
<p class="eyebrow">STEP {{ stage.code }}</p>
<h3 class="mt-2 text-sm font-semibold">
{{ stage.title }}
</h3>
</div>
</div>
<span class="font-mono text-xs text-muted"
>{{ stage.done }} / {{ stage.data?.total ?? 0 }}</span
>
</div>
<p class="min-h-10 text-xs leading-5 text-muted">
{{ stage.description }}
</p>
<NProgress
:aria-label="`${stage.title}完成数量`"
type="line"
:show-indicator="false"
:height="4"
:percentage="
Math.min(
100,
Math.max(
0,
(stage.done /
Math.max(
1,
Math.max(stage.data?.total ?? 0, 1)
)) *
100
)
)
"
></NProgress>
<dl class="production-stats">
<div>
<dt>可执行</dt>
<dd>{{ stage.data?.ready ?? 0 }}</dd>
</div>
<div>
<dt>已有结果</dt>
<dd>{{ stage.data?.skipped ?? 0 }}</dd>
</div>
<div>
<dt>阻塞</dt>
<dd>{{ stage.data?.blocked ?? 0 }}</dd>
</div>
</dl>
<p
v-if="stage.key === 'keyframes' && staleKeyframes"
class="text-[11px] leading-5"
>
已过期 {{ staleKeyframes }} · 会按当前主体参考资产重新生成
</p>
<p
v-if="stage.key === 'videos' && staleVideos"
class="text-[11px] leading-5"
>
主视频已过期 {{ staleVideos }} ·
会按当前主首帧与参考资产重新生成
</p>
<p
v-if="stage.key === 'keyframes' && identityBlocked"
class="text-[11px] leading-5 text-danger"
>
身份缺失
{{ query.data.value?.keyframes.missingIdentity ?? 0 }} ·
母版缺失
{{ query.data.value?.keyframes.missingIdentityAnchor ?? 0 }} ·
未锁定
{{ query.data.value?.keyframes.identityUnlocked ?? 0 }}
</p>
<ConfirmAction
:label="stage.action"
:disabled="
blocked ||
!batchValid ||
(stage.key === 'prompts' && !promptValid) ||
(stage.key === 'keyframes' && !keyframeValid) ||
(stage.key === 'videos' && !videoQualityValid) ||
(stage.key === 'videos' && !selectedPlanCount) ||
!(stage.data?.ready ?? 0)
"
acknowledgement
:description="
stage.key === 'videos'
? staleVideos && !force
? `只处理第 ${episodeNo} 集的${videoInputModeLabel},其中至多 ${videoLimit || '—'} 个过期镜头会启动严格质量流水线;通过后才接替旧主视频。`
: `只处理第 ${episodeNo} 集的${videoInputModeLabel},本批至多 ${videoLimit || '—'} 镜。最多自动修复 ${videoRepairAttempts || '—'} 次,通过后才晋升主视频。`
: stage.key === 'keyframes'
? `处理缺失或过期主首帧。过期首帧成功后自动接替旧主图(覆盖模式也如此),其余已有主图只新增候选。本批上限:${keyframeLimit || '不限制'};尺寸:${keyframeWidth && keyframeHeight ? `${keyframeWidth} × ${keyframeHeight}` : '项目默认'}。`
: `只处理第 ${episodeNo} 集中通过就绪检查的镜头,本批最多 ${promptLimit || '—'} 镜;覆盖模式会重写已有提示词。`
"
:primary="stage.key === 'videos'"
@confirm="run(stage.key)"
/>
<AppForm
v-if="stage.key === 'prompts'"
:model="promptModel"
:rules="promptRules"
:disabled="operation.pending"
validate-on-change
class="grid gap-3"
>
<NFormItem path="promptLimit" label="本批镜头上限"
><NInputNumber
v-model:value="promptLimit"
:min="1"
:precision="0"
:disabled="operation.pending"
:input-props="{ 'aria-label': '视频提示词本批镜头上限' }"
/></NFormItem>
</AppForm>
<AppForm
v-if="stage.key === 'keyframes'"
:model="keyframeModel"
:rules="keyframeRules"
:disabled="operation.pending"
validate-on-change
class="grid gap-3"
>
<NFormItem path="keyframeLimit" label="本批上限(可选)"
><NInputNumber
:input-props="{ 'aria-label': '本批上限(可选)' }"
:value="keyframeLimit === '' ? null : keyframeLimit"
@update:value="keyframeLimit = $event ?? ''"
:min="1"
:precision="0"
:disabled="operation.pending"
placeholder="留空不限制"
/></NFormItem>
<div class="grid grid-cols-2 gap-3">
<NFormItem path="keyframeWidth" label="宽度(像素)"
><NInputNumber
:input-props="{ 'aria-label': '宽度(像素)' }"
:value="keyframeWidth === '' ? null : keyframeWidth"
@update:value="keyframeWidth = $event ?? ''"
:min="1"
:disabled="operation.pending"
placeholder="默认" /></NFormItem
><NFormItem path="keyframeHeight" label="高度(像素)"
><NInputNumber
:input-props="{ 'aria-label': '高度(像素)' }"
:value="
keyframeHeight === '' ? null : keyframeHeight
"
@update:value="keyframeHeight = $event ?? ''"
:min="1"
:disabled="operation.pending"
placeholder="默认"
/></NFormItem>
</div>
</AppForm>
<AppForm
v-if="stage.key === 'videos'"
:model="videoModel"
:rules="videoRules"
:disabled="operation.pending"
validate-on-change
class="grid gap-3"
>
<div class="video-input-plan-summary" aria-label="视频输入规划">
<div>
<span>首帧模式</span>
<strong>{{ inputPlan?.firstFrameCount ?? 0 }}</strong>
</div>
<div>
<span>全模态参考</span>
<strong>{{ inputPlan?.omniReferenceCount ?? 0 }}</strong>
</div>
</div>
<NAlert
v-if="query.data.value?.videoInputPlansError"
type="warning"
:show-icon="false"
class="text-xs"
>
输入规划暂不可用,仍可按“全部推荐模式”提交;刷新后可重试规划。
</NAlert>
<NFormItem path="videoInputMode" label="输入规划范围">
<NSelect
v-model:value="videoInputMode"
:disabled="operation.pending"
:options="[
{
label: `全部推荐模式(${inputPlan?.readyCount ?? 0})`,
value: 'all'
},
{
label: `首帧模式(${inputPlan?.firstFrameCount ?? 0})`,
value: 'first_frame',
disabled: !inputPlan
},
{
label: `全模态参考(${inputPlan?.omniReferenceCount ?? 0})`,
value: 'omni_reference',
disabled: !inputPlan
}
]"
aria-label="视频输入规划范围"
/>
</NFormItem>
<NFormItem path="videoLimit" label="本批镜头上限"
><NInputNumber
v-model:value="videoLimit"
:min="1"
:precision="0"
:disabled="operation.pending"
:input-props="{ 'aria-label': '视频质量任务镜头上限' }"
/></NFormItem>
<NFormItem path="videoRepairAttempts" label="每镜最多自动修复"
><NInputNumber
v-model:value="videoRepairAttempts"
:min="1"
:precision="0"
:disabled="operation.pending"
:input-props="{ 'aria-label': '视频自动修复次数' }"
/></NFormItem>
</AppForm>
</article>
</div>
<div v-if="query.data.value" class="workspace-panel production-video-status">
<div class="flex flex-wrap items-center justify-between gap-3">
<NAlert v-if="videoRunning" role="status" type="info" :show-icon="false">
当前有
{{ videoRunning }}
个视频任务等待或生成中。系统会持续更新任务状态,同一镜头不会重复提交。
</NAlert>
<NAlert v-if="identityBlocked" type="info" :show-icon="false">
当前有
{{ identityBlocked }}
项角色身份尚未准备完成。请先确认角色母版并完成身份锁定,再生成镜头首帧。
<RouterLink :to="`/projects/${id}/subject-identity`" class="text-button ml-2"
>前往主体身份 →</RouterLink
></NAlert
>
<NAlert v-if="invalidGenerationSpecs" type="warning" :show-icon="false">
当前有
{{ invalidGenerationSpecs }}
个镜头的设计信息还不完整。请先补齐镜头设计和即时视觉状态。
<RouterLink :to="`/projects/${id}/storyboard`" class="text-button ml-2">
前往分镜设计 →
</RouterLink>
</NAlert>
<NAlert v-if="staleKeyframes" role="status" type="info" :show-icon="false">
当前有
{{ staleKeyframes }}
个主首帧已过期。它们使用的主体参考资产已经变化,视频阶段会被阻止;可在下方逐镜重新生成,或使用“补齐
/ 更新主首帧”批量处理。
</NAlert>
<NAlert v-if="staleVideos" role="status" type="info" :show-icon="false">
当前有
{{ staleVideos }}
个主视频已过期。它们使用的主首帧或主体参考图已经变化;非覆盖模式批量生成时会只重建这些过期主视频。
</NAlert>
<ProductionReceipt v-if="session.receipt" :receipt="session.receipt" />
<WorkflowExecutionPanel
v-if="promptExecution.executionId.value"
title="视频提示词任务"
:execution="promptExecution.query.data.value"
:loading="promptExecution.query.loading.value"
:error="promptExecution.query.error.value"
@refresh="promptExecution.query.refresh"
@dismiss="promptExecution.dismiss"
/>
<WorkflowExecutionPanel
v-if="videoExecution.executionId.value"
title="视频质量任务"
:execution="videoExecution.query.data.value"
:loading="videoExecution.query.loading.value"
:error="videoExecution.query.error.value"
@refresh="videoExecution.query.refresh"
@dismiss="videoExecution.dismiss"
/>
<div v-if="query.data.value" class="production-pipeline">
<article
v-for="stage in stages"
:key="stage.key"
class="production-pipeline-card"
>
<div class="flex items-start justify-between gap-3">
<div class="flex items-start gap-3">
<span class="production-step"
><component :is="stage.icon" :size="17"
/></span>
<div>
<h3 class="text-sm font-semibold">视频任务状态</h3>
<p class="mt-2 text-xs text-muted">
状态统计取每个镜头最近一次任务,不等同于主视频数量。
</p>
<p class="eyebrow">STEP {{ stage.code }}</p>
<h3 class="mt-2 text-sm font-semibold">
{{ stage.title }}
</h3>
</div>
<ConfirmAction
label="重试失败视频"
:disabled="
blocked ||
!batchValid ||
!query.data.value.videoStatus.failed
"
acknowledgement
description="只重新提交可以重试的失败视频;其他项目会跳过,并在结果中显示数量。"
@confirm="run('retry-videos')"
/>
</div>
<dl class="production-status-grid">
<div>
<dt>完成</dt>
<dd>{{ query.data.value.videoStatus.completed }}</dd>
</div>
<div>
<dt>排队/生成</dt>
<dd>{{ videoRunning }}</dd>
</div>
<div>
<dt>失败</dt>
<dd>{{ query.data.value.videoStatus.failed }}</dd>
</div>
<div>
<dt>取消</dt>
<dd>{{ query.data.value.videoStatus.cancelled }}</dd>
</div>
<div>
<dt>未开始</dt>
<dd>{{ query.data.value.videoStatus.notStarted }}</dd>
</div>
</dl>
<span class="font-mono text-xs text-muted"
>{{ stage.done }} / {{ stage.data?.total ?? 0 }}</span
>
</div>
<p class="min-h-10 text-xs leading-5 text-muted">
{{ stage.description }}
</p>
<NProgress
:aria-label="`${stage.title}完成数量`"
type="line"
:show-indicator="false"
:height="4"
:percentage="
Math.min(
100,
Math.max(
0,
(stage.done /
Math.max(1, Math.max(stage.data?.total ?? 0, 1))) *
100
)
)
"
></NProgress>
<dl class="production-stats">
<div>
<dt>可执行</dt>
<dd>{{ stage.data?.ready ?? 0 }}</dd>
</div>
<div>
<dt>已有结果</dt>
<dd>{{ stage.data?.skipped ?? 0 }}</dd>
</div>
<div>
<dt>阻塞</dt>
<dd>{{ stage.data?.blocked ?? 0 }}</dd>
</div>
</dl>
<p
v-if="stage.key === 'keyframes' && staleKeyframes"
class="text-[11px] leading-5"
>
已过期 {{ staleKeyframes }} · 会按当前主体参考资产重新生成
</p>
<p
v-if="stage.key === 'videos' && staleVideos"
class="text-[11px] leading-5"
>
主视频已过期 {{ staleVideos }} · 会按当前主首帧与参考资产重新生成
</p>
<p
v-if="stage.key === 'keyframes' && identityBlocked"
class="text-[11px] leading-5 text-danger"
>
身份缺失
{{ query.data.value?.keyframes.missingIdentity ?? 0 }} · 母版缺失
{{ query.data.value?.keyframes.missingIdentityAnchor ?? 0 }} · 未锁定
{{ query.data.value?.keyframes.identityUnlocked ?? 0 }}
</p>
<ConfirmAction
:label="stage.action"
:disabled="
blocked ||
!batchValid ||
(stage.key === 'prompts' && !promptValid) ||
(stage.key === 'keyframes' && !keyframeValid) ||
(stage.key === 'videos' && !videoQualityValid) ||
(stage.key === 'videos' && !selectedPlanCount) ||
!(stage.data?.ready ?? 0)
"
acknowledgement
:description="
stage.key === 'videos'
? staleVideos && !force
? `只处理第 ${episodeNo} 集的${videoInputModeLabel},其中至多 ${videoLimit || '—'} 个过期镜头会启动严格质量流水线;通过后才接替旧主视频。`
: `只处理第 ${episodeNo} 集的${videoInputModeLabel},本批至多 ${videoLimit || '—'} 镜。最多自动修复 ${videoRepairAttempts || '—'} 次,通过后才晋升主视频。`
: stage.key === 'keyframes'
? `处理缺失或过期主首帧。过期首帧成功后自动接替旧主图(覆盖模式也如此),其余已有主图只新增候选。本批上限:${keyframeLimit || '不限制'};尺寸:${keyframeWidth && keyframeHeight ? `${keyframeWidth} × ${keyframeHeight}` : '项目默认'}。`
: `只处理第 ${episodeNo} 集中通过就绪检查的镜头,本批最多 ${promptLimit || '—'} 镜;覆盖模式会重写已有提示词。`
"
:primary="stage.key === 'videos'"
@confirm="run(stage.key)"
/>
<AppForm
v-if="stage.key === 'prompts'"
:model="promptModel"
:rules="promptRules"
:disabled="operation.pending"
validate-on-change
class="grid gap-3"
>
<NFormItem path="promptLimit" label="本批镜头上限"
><NInputNumber
v-model:value="promptLimit"
:min="1"
:precision="0"
:disabled="operation.pending"
:input-props="{ 'aria-label': '视频提示词本批镜头上限' }"
/></NFormItem>
</AppForm>
<AppForm
v-if="stage.key === 'keyframes'"
:model="keyframeModel"
:rules="keyframeRules"
:disabled="operation.pending"
validate-on-change
class="grid gap-3"
>
<NFormItem path="keyframeLimit" label="本批上限(可选)"
><NInputNumber
:input-props="{ 'aria-label': '本批上限(可选)' }"
:value="keyframeLimit === '' ? null : keyframeLimit"
@update:value="keyframeLimit = $event ?? ''"
:min="1"
:precision="0"
:disabled="operation.pending"
placeholder="留空不限制"
/></NFormItem>
<div class="grid grid-cols-2 gap-3">
<NFormItem path="keyframeWidth" label="宽度(像素)"
><NInputNumber
:input-props="{ 'aria-label': '宽度(像素)' }"
:value="keyframeWidth === '' ? null : keyframeWidth"
@update:value="keyframeWidth = $event ?? ''"
:min="1"
:disabled="operation.pending"
placeholder="默认" /></NFormItem
><NFormItem path="keyframeHeight" label="高度(像素)"
><NInputNumber
:input-props="{ 'aria-label': '高度(像素)' }"
:value="keyframeHeight === '' ? null : keyframeHeight"
@update:value="keyframeHeight = $event ?? ''"
:min="1"
:disabled="operation.pending"
placeholder="默认"
/></NFormItem>
</div>
</AppForm>
<AppForm
v-if="stage.key === 'videos'"
:model="videoModel"
:rules="videoRules"
:disabled="operation.pending"
validate-on-change
class="grid gap-3"
>
<div class="video-input-plan-summary" aria-label="视频输入规划">
<div>
<span>首帧模式</span>
<strong>{{ inputPlan?.firstFrameCount ?? 0 }}</strong>
</div>
<div>
<span>全模态参考</span>
<strong>{{ inputPlan?.omniReferenceCount ?? 0 }}</strong>
</div>
</div>
<NAlert
v-if="query.data.value?.videoInputPlansError"
type="warning"
:show-icon="false"
class="text-xs"
>
输入规划暂不可用,仍可按“全部推荐模式”提交;刷新后可重试规划。
</NAlert>
<NFormItem path="videoInputMode" label="输入规划范围">
<NSelect
v-model:value="videoInputMode"
:disabled="operation.pending"
:options="[
{
label: `全部推荐模式(${inputPlan?.readyCount ?? 0})`,
value: 'all'
},
{
label: `首帧模式(${inputPlan?.firstFrameCount ?? 0})`,
value: 'first_frame',
disabled: !inputPlan
},
{
label: `全模态参考(${inputPlan?.omniReferenceCount ?? 0})`,
value: 'omni_reference',
disabled: !inputPlan
}
]"
aria-label="视频输入规划范围"
/>
</NFormItem>
<NFormItem path="videoLimit" label="本批镜头上限"
><NInputNumber
v-model:value="videoLimit"
:min="1"
:precision="0"
:disabled="operation.pending"
:input-props="{ 'aria-label': '视频质量任务镜头上限' }"
/></NFormItem>
<NFormItem path="videoRepairAttempts" label="每镜最多自动修复"
><NInputNumber
v-model:value="videoRepairAttempts"
:min="1"
:precision="0"
:disabled="operation.pending"
:input-props="{ 'aria-label': '视频自动修复次数' }"
/></NFormItem>
</AppForm>
</article>
</div>
<div v-if="query.data.value" class="workspace-panel production-video-status">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h3 class="text-sm font-semibold">视频任务状态</h3>
<p class="mt-2 text-xs text-muted">
状态统计取每个镜头最近一次任务,不等同于主视频数量。
</p>
</div>
<ConfirmAction
label="重试失败视频"
:disabled="
blocked || !batchValid || !query.data.value.videoStatus.failed
"
acknowledgement
description="只重新提交可以重试的失败视频;其他项目会跳过,并在结果中显示数量。"
@confirm="run('retry-videos')"
/>
</div>
<dl class="production-status-grid">
<div>
<dt>完成</dt>
<dd>{{ query.data.value.videoStatus.completed }}</dd>
</div>
<div>
<dt>排队/生成</dt>
<dd>{{ videoRunning }}</dd>
</div>
<div>
<dt>失败</dt>
<dd>{{ query.data.value.videoStatus.failed }}</dd>
</div>
<div>
<dt>取消</dt>
<dd>{{ query.data.value.videoStatus.cancelled }}</dd>
</div>
<div>
<dt>未开始</dt>
<dd>{{ query.data.value.videoStatus.notStarted }}</dd>
</div>
</dl>
</div>
</div>
</section>
<EpisodeAssemblyPanel :project-id="id" />
@@ -720,6 +704,30 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
</WorkspaceTools>
</div></div
></template>
<!-- 以下是关闭弹窗后仍可查看的首帧质量后台任务模块 -->
<!-- 以下是普通首帧后台执行状态模块 -->
<WorkflowExecutionPanel
v-if="keyframeExecution.executionId.value"
title="普通首帧生成"
:execution="keyframeExecution.query.data.value"
:loading="keyframeExecution.query.loading.value"
:error="keyframeExecution.query.error.value"
@refresh="keyframeExecution.query.refresh"
@dismiss="keyframeExecution.dismiss"
/>
<WorkflowExecutionPanel
v-if="keyframeQualityExecution.executionId.value"
title="首帧质量后台任务"
:execution="keyframeQualityExecution.query.data.value"
:loading="keyframeQualityExecution.query.loading.value"
:error="keyframeQualityExecution.query.error.value"
@refresh="keyframeQualityExecution.query.refresh"
@dismiss="keyframeQualityExecution.dismiss"
/>
<!-- 以下是重生成后正文缺省的真实数据说明模块 -->
<NAlert v-if="episodeSourceUnavailable" type="info" :show-icon="false">
本集镜头已重新生成。新标题和剧情详情尚未提供,当前只显示正式镜头编号;请按实际生成规格核对内容。
</NAlert>
<div v-if="preparationComplete" class="workspace-inline-status">
<span v-if="finalVideosComplete">本项目镜头素材和视频成片已经准备完成。</span>
<span v-else>镜头制作准备已经完成。视频生成费用较高,可按需要逐批提交视频任务。</span>
@@ -852,12 +860,14 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
:key="shot.shotId"
:project-id="id"
:shot="shot"
:episode-no="episodeNo"
:prompt-readiness="promptItem"
:keyframe-readiness="keyframeItem"
:video-readiness="videoItem"
:open-keyframe="openRequestedKeyframe"
:disabled="blocked || !!linkedShotMissing"
:disabled="blocked || keyframeQualityExecution.active.value || !!linkedShotMissing"
@changed="refreshProject"
@quality-started="trackKeyframeQuality"
/>
</NScrollbar>
</article>
@@ -879,6 +889,7 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
:disabled="blocked"
@changed="refreshProject"
@locate="locateQualityShot"
@started="trackKeyframeQuality"
/>
</WorkspacePage>
</template>
+30 -20
View File
@@ -4,7 +4,6 @@ import type {
GenerateKeyframeInput,
GenerateKeyframesInput,
GenerateQualityVideosInput,
KeyframeBatchResult,
KeyframeReadiness,
KeyframeGenerationPreview,
KeyframeSpec,
@@ -12,6 +11,8 @@ import type {
ProjectVideoInputPlan,
PromptReadiness,
ProductionPlan,
ProductionPlanInput,
ProductionStartInput,
ProviderInputSpec,
ProjectProductionStatus,
RetryVideosResult,
@@ -56,29 +57,32 @@ export const productionApi = {
request<ProviderInputSpec>(`${shotPath(shotId)}/provider-input-spec?provider=${encodeURIComponent(provider)}`, {
signal
}),
/** 查询当前计划,不生成图片、视频或提示词。 */
plan: (projectId: string, signal?: AbortSignal, providers?: { imageProvider?: string; videoProvider?: string }) => {
const params = new URLSearchParams()
if (providers?.imageProvider) params.set('imageProvider', providers.imageProvider)
if (providers?.videoProvider) params.set('videoProvider', providers.videoProvider)
const query = params.size ? `?${params}` : ''
return request<ProductionPlan>(`${projectPath(projectId)}/production/plan${query}`, { signal })
},
/**
* 使用正式 POST 预检当前生产计划,不产生生成费用。
* @param projectId 正式项目 ID
* @param signal 取消信号
* @param input 与启动同源的模型及图片参数
* @returns 后端实际生产计划
*/
plan: (projectId: string, signal?: AbortSignal, input: ProductionPlanInput = {}) =>
request<ProductionPlan>(`${projectPath(projectId)}/production/plan`, {
method: 'POST',
body: input,
signal
}),
/** 读取真实主资产完成状态,不能用任务提交回执代替。 */
status: (projectId: string, signal?: AbortSignal) =>
request<ProjectProductionStatus>(`${projectPath(projectId)}/production/status`, { signal }),
startPipeline: (
projectId: string,
input?: {
imageProvider?: string
videoProvider?: string
stopAfter?: 'keyframes' | 'videoPrompts'
keyframeLimit?: number
}
) =>
/**
* 启动有限范围的串联生产,最终结果通过任务查询取得。
* @param projectId 正式项目 ID
* @param input 模型、断点、停止阶段和各阶段上限
* @returns 真实后台任务观察句柄
*/
startPipeline: (projectId: string, input: ProductionStartInput = {}) =>
request<WorkflowExecutionStart>(`${projectPath(projectId)}/production/start`, {
method: 'POST',
body: input ?? {}
body: input
}),
promptReadiness: (projectId: string, force: boolean, signal?: AbortSignal) =>
request<PromptReadiness>(`${projectPath(projectId)}/video-prompts/readiness?force=${force}`, { signal }),
@@ -96,8 +100,14 @@ export const productionApi = {
}),
keyframeReadiness: (projectId: string, force: boolean, signal?: AbortSignal) =>
request<KeyframeReadiness>(`${projectPath(projectId)}/keyframes/readiness?force=${force}`, { signal }),
/**
* 后台批量生成普通首帧候选。
* @param projectId 正式项目 ID
* @param input 当前生成范围和模型参数
* @returns 真实后台任务观察句柄
*/
generateKeyframes: (projectId: string, input: GenerateKeyframesInput) =>
request<KeyframeBatchResult>(`${projectPath(projectId)}/keyframes/generate`, {
request<WorkflowExecutionStart>(`${projectPath(projectId)}/keyframes/generate`, {
method: 'POST',
body: input,
timeoutMs: 0
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber } from 'naive-ui'
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NSelect } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import ConfirmAction from '../../workflows/ConfirmAction.vue'
import { downloadText, formatDate } from '../../../lib/format'
@@ -19,10 +19,19 @@ const {
blocked,
safeMode,
testKeyframeLimit,
startFrom,
stopAfter,
stableIdentityAnchorLimit,
subjectImageLimit,
videoPromptLimit,
scope,
scopeError,
preflight,
start
} = useAdvancedProduction()
/** 本轮真实生产回执。 */
const receipt = computed(() => session.value.pipelineReceipt)
/** 高级工具折叠状态。 */
const expanded = ref<string[]>(['advanced'])
watch(
receipt,
@@ -31,6 +40,7 @@ watch(
},
{ immediate: true }
)
/** 实际批次结果展示行。 */
const rows = computed(() => [
{ name: '形态正式提示词', result: receipt.value?.visualPromptResult },
{ name: '形态参考图', result: receipt.value?.subjectImageResult },
@@ -41,6 +51,21 @@ function exportReceipt() {
if (receipt.value)
downloadText(`project-${id.value}-pipeline.json`, JSON.stringify(receipt.value, null, 2), 'application/json')
}
/** 失败任务保留后端真实结果,独立于完成回执展示。 */
const failedResult = computed(() =>
execution.query.data.value?.status === 'failed' ? execution.query.data.value.result : null
)
/** 后端支持的断点阶段选项。 */
const stageOptions = [
{ label: '主体图片', value: 'subjectImages' },
{ label: '首帧质量', value: 'keyframes' },
{ label: '视频提示词', value: 'videoPrompts' }
]
/** 确认内容涵盖所有付费范围,变更后公共确认组件会废弃原勾选。 */
const confirmationDescription = computed(
() =>
`项目 ${id.value}:从 ${startFrom.value ?? '默认入口'} 执行至 ${scope.value.stopAfter ?? '视频任务提交'};稳定身份母版最多 ${stableIdentityAnchorLimit.value} 个、主体图片最多 ${subjectImageLimit.value} 张、首帧最多 ${testKeyframeLimit.value} 张、视频提示词最多 ${videoPromptLimit.value} 条。${scope.value.stopAfter ? '会产生图片、语言或视觉模型费用,不提交视频任务。' : '会产生较高视频模型费用。'} 项目模型和图片参数以本次预检为准。`
)
</script>
<template>
<NCollapse v-model:expanded-names="expanded" class="production-tool-section"
@@ -49,41 +74,64 @@ function exportReceipt() {
>依次补齐形态提示词、参考图、首帧质量校验与修复、视频提示词,再提交视频任务。视觉风格、身份母版、导演设计和即时状态仍需提前准备。</NAlert
>
<p class="mt-3 text-xs leading-6 text-muted">
范围固定为全项目并跳过已有有效结果。默认开启测试安全模式:允许 LLM、Vision、主体图、少量首帧和 Video Prompt,但会在视频生成前正常停止,不向视频 Provider 提交任务。
范围固定为全项目并跳过已有有效结果。默认开启测试安全模式:允许 LLM、Vision、主体图、少量首帧和 Video
Prompt,但会在视频生成前正常停止,不向视频 Provider 提交任务。
</p>
<!-- 以下是生产范围配置模块,修改任一参数后须重新预检。 -->
<div class="surface-inset mt-3 p-3">
<NCheckbox v-model:checked="safeMode">测试安全模式(不生成视频)</NCheckbox>
<div v-if="safeMode" class="mt-3 flex items-center gap-3 text-xs">
<span>本轮最多生成首帧</span>
<NInputNumber
:value="testKeyframeLimit"
:min="1"
:step="1"
class="w-28"
@update:value="testKeyframeLimit = $event"
/>
<span class="text-muted">张;Video Prompt 仍会正常生成。</span>
<!-- 以下是本轮断点与生成上限模块。 -->
<div class="mt-3 grid grid-cols-2 gap-3 text-xs">
<label
>起始阶段<NSelect
v-model:value="startFrom"
:options="stageOptions"
clearable
placeholder="默认入口"
/></label>
<label
>结束阶段<NSelect
v-model:value="stopAfter"
:options="stageOptions"
clearable
:placeholder="safeMode ? '视频提示词(安全模式)' : '完整流程(提交视频)'"
/></label>
<label
>稳定身份母版上限<NInputNumber
v-model:value="stableIdentityAnchorLimit"
:min="1"
:step="1"
:precision="0"
/></label>
<label
>主体图片上限<NInputNumber v-model:value="subjectImageLimit" :min="1" :step="1" :precision="0"
/></label>
<label
>首帧上限<NInputNumber v-model:value="testKeyframeLimit" :min="1" :step="1" :precision="0"
/></label>
<label
>视频提示词上限<NInputNumber v-model:value="videoPromptLimit" :min="1" :step="1" :precision="0"
/></label>
</div>
<NAlert v-else type="warning" :show-icon="false" class="mt-3">
<NAlert v-if="scopeError" type="error" :show-icon="false" class="mt-3">{{ scopeError }}</NAlert>
<NAlert v-if="!safeMode && !stopAfter" type="warning" :show-icon="false" class="mt-3">
已关闭测试安全模式。启动后会进入视频任务提交阶段并产生较高视频生成费用。
</NAlert>
</div>
<!-- 以下是无消耗预检与费用确认模块。 -->
<div class="mt-4 flex flex-wrap items-center gap-3">
<NButton :disabled="blocked || checking" :loading="checking" @click="preflight"
<NButton :disabled="blocked || checking || !!scopeError" :loading="checking" @click="preflight"
>检查串联生产条件</NButton
>
<ConfirmAction
label="启动串联生产"
:disabled="blocked || checking || !check || !!check.issues.length"
:disabled="blocked || checking || !!scopeError || !check || !!check.issues.length"
acknowledgement
:description="
safeMode
? `项目 ${id}:测试安全模式将运行到 Video Prompt,并最多生成 ${testKeyframeLimit || 1} 张首帧;不会提交视频生成任务。`
: `项目 ${id}:将执行完整串联生产并提交视频生成任务,会产生较高视频模型费用。`
"
:description="confirmationDescription"
@confirm="start"
/>
</div>
<!-- 以下是后台任务与真实结果模块。 -->
<WorkflowExecutionPanel
v-if="execution.executionId.value"
title="串联生产后台任务"
@@ -93,6 +141,11 @@ function exportReceipt() {
@refresh="execution.query.refresh"
@dismiss="execution.dismiss"
/>
<!-- 以下是失败任务真实结果详情模块。 -->
<details v-if="failedResult" class="mt-3 text-xs">
<summary>失败任务结果详情</summary>
<pre class="mt-2 whitespace-pre-wrap break-all">{{ JSON.stringify(failedResult, null, 2) }}</pre>
</details>
<NAlert v-if="error" type="error" class="mt-3" :show-icon="false">{{ error }}</NAlert>
<NAlert
v-if="operation.label === '高级串联生产' && operation.error"
@@ -130,6 +183,11 @@ function exportReceipt() {
</h3>
<NButton text size="small" @click="exportReceipt">导出回执</NButton>
</div>
<p v-if="receipt.stableIdentityAnchorResult" class="mt-2 text-xs">
稳定身份母版:共 {{ receipt.stableIdentityAnchorResult.total }} · 生成
{{ receipt.stableIdentityAnchorResult.generated }} · 失败
{{ receipt.stableIdentityAnchorResult.failed }}
</p>
<p class="mt-3 text-xs text-muted">
流程返回不等于成片完成。已保存结果不会回滚,最终结果以各资产页为准。
</p>
@@ -0,0 +1,74 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
import { useQuery } from '../../../composables/useQuery'
import { formatDate } from '../../../lib/format'
import { qualityApi } from '../quality-api'
import { parseKeyframeValidationOutput } from '../quality'
/** 历史仅按正式首帧目标读取,不写入手动晋升会话。 */
const props = defineProps<{
/** 项目范围用于隔离切换 */
projectId?: string
/** 所属镜头 */
shotId: string
/** 当前首帧 */
keyframeId: string
}>()
/** 默认折叠,仅展开后查询。 */
const open = ref(false)
/** 查询键包含全部归属信息,旧请求会被取消。 */
const key = computed(() =>
open.value && props.shotId && props.keyframeId
? JSON.stringify([props.projectId, props.shotId, props.keyframeId])
: ''
)
/** 后端历史查询支持取消,空目标不请求。 */
const query = useQuery(key, (value, signal) => {
if (!value) return Promise.resolve([])
const [, shotId, keyframeId] = JSON.parse(value) as [string | undefined, string, string]
return qualityApi.keyframeHistory(shotId, keyframeId, signal)
})
/** 仅真实结构化结论可以显示通过,调用完成不等于视觉通过。 */
const records = computed(() =>
(query.data.value ?? []).map(item => ({ ...item, validation: parseKeyframeValidationOutput(item.output) }))
)
</script>
<template>
<!-- 以下是首帧已有校验记录的只读查询模块 -->
<ReadonlyInspection
v-model:open="open"
title="首帧校验历史"
description="读取已有记录不产生费用;历史通过不会自动晋升,也不保证当前素材仍然一致。"
:loading="query.loading.value"
:error="query.error.value"
@refresh="query.refresh"
>
<p v-if="!records.length" class="text-muted">暂无校验记录。</p>
<!-- 以下是实际校验结论、问题与调用错误模块 -->
<article v-for="record in records" :key="record.id" class="panel mt-3 p-3">
<p>
{{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} · {{ record.status }} ·
{{
record.status === 'completed' && record.validation
? record.validation.passed
? '视觉通过'
: '视觉未通过'
: '未取得完整视觉结论'
}}
</p>
<p v-if="record.error" class="text-danger">{{ record.error }}</p>
<template v-if="record.validation">
<p>{{ record.validation.summary }}</p>
<p v-for="(issue, index) in record.validation.issues" :key="index" class="text-danger">
{{ issue.description }}
</p>
</template>
<details class="mt-2">
<summary class="cursor-pointer text-muted">原始记录</summary>
<pre class="whitespace-pre-wrap wrap-anywhere">{{ JSON.stringify(record.output, null, 2) }}</pre>
</details>
</article>
</ReadonlyInspection>
</template>
@@ -5,8 +5,13 @@ import { qualityApi } from '../quality-api'
import type { ImageProviderCapability, ShotProviderCapability } from '../quality.types'
import { errorMessage } from '../../../lib/http'
/** 模型由后端配置;此入口只读公开能力,不提供无效的前端模型切换。 */
const props = defineProps<{ shotId?: string }>()
/** 只读查询指定镜头及本次选择模型的公开能力。 */
const props = defineProps<{
/** 当前正式镜头 ID。 */
shotId?: string
/** 本次选择的图片模型,未提供时读取后端默认。 */
provider?: string
}>()
const providers = ref<ImageProviderCapability[] | null>(null)
const capability = ref<ShotProviderCapability | null>(null)
const error = ref('')
@@ -15,27 +20,26 @@ let revision = 0
onScopeDispose(() => {
revision++
})
watch(
() => props.shotId,
() => {
revision++
providers.value = null
capability.value = null
error.value = ''
loading.value = false
}
)
/** 按需检查,不自动生成图片;空上限表示未声明,不冒充无限制。 */
/** 切换镜头或本次模型后清除旧能力记录,迟到响应不能覆盖新目标。 */
watch([() => props.shotId, () => props.provider], () => {
revision++
providers.value = null
capability.value = null
error.value = ''
loading.value = false
})
/** 按需检查当前模型,不自动生成图片;空上限表示未声明,不冒充无限制。 */
async function inspect() {
if (loading.value) return
const version = ++revision
const shotId = props.shotId
const provider = props.provider
loading.value = true
error.value = ''
try {
const list = await qualityApi.providers()
if (version !== revision) return
const result = shotId ? await qualityApi.capability(shotId) : null
const result = shotId ? await qualityApi.capability(shotId, undefined, provider) : null
if (version !== revision) return
if (!Array.isArray(list) || list.some(item => !item.capabilities?.references))
throw new Error('模型能力接口返回不完整。')
@@ -69,8 +73,13 @@ async function inspect() {
</template>
<NAlert v-if="capability" :type="capability.valid ? 'info' : 'error'" :show-icon="false" class="mt-3">{{
capability.valid
? `当前镜头需要 ${capability.referenceCount} 张参考图,符合 ${capability.provider} 的已声明能力。`
? capability.message ||
`当前镜头共有 ${capability.referenceCount} 张业务参考图,后端已判定本次规划符合 ${capability.provider} 能力。`
: capability.message || '当前镜头不满足模型能力限制。'
}}</NAlert>
<p v-if="capability?.valid && capability.plannedReferenceCount !== undefined" class="mt-2 text-muted">
本次计划输入 {{ capability.plannedReferenceCount }} 张 · 转为文字约束
{{ capability.omittedReferenceCount ?? 0 }} 张
</p>
</section>
</template>
@@ -5,8 +5,8 @@ import type { ProductionPlan, ProjectProductionStatus } from '../types'
/** 展示当前制作计划与真实资产状态,不在页面重复推断业务规则。 */
const props = defineProps<{ plan: ProductionPlan; status: ProjectProductionStatus }>()
/** 生产阶段共享计划字段,角色身份就绪信息单独展示,避免混用不同 DTO。 */
const rows = computed(() => [
...(props.plan.characterIdentity ? [{ label: '角色身份', stage: props.plan.characterIdentity }] : []),
...(props.plan.stableIdentityAnchors ? [{ label: '稳定身份锚点', stage: props.plan.stableIdentityAnchors }] : []),
{ label: '主体参考图', stage: props.plan.subjectImages },
{ label: '首帧质量', stage: props.plan.keyframes },
@@ -48,6 +48,12 @@ const problems = computed(() => [
<span class="status-chip">图片模型:{{ plan.providers.image }}</span>
<span class="status-chip">视频模型:{{ plan.providers.video }}</span>
</div>
<!-- 以下是角色身份实际就绪统计模块 -->
<p v-if="plan.characterIdentity" class="mt-2 text-xs">
角色身份:已就绪 {{ plan.characterIdentity.ready }} / {{ plan.characterIdentity.total }} · 待就绪
{{ plan.characterIdentity.pending }} · 可自动补齐 {{ plan.characterIdentity.autoResolvable }} · 需人工处理
{{ plan.characterIdentity.manualBlocked }}
</p>
<p class="mt-2 text-xs" role="status">
当前制作状态:{{ status.completed ? '制作已完成' : `待完成${stageNames[status.stage]}` }} · 有效主体图
{{ status.subjectImages.current }}/{{ status.subjectImages.total }} · 有效首帧
@@ -19,35 +19,84 @@ import { allowedTextLines, validQualityInput } from '../quality'
import type { QualityAction, QualityInput, QualityTarget } from '../quality.types'
import { useQuality } from '../useQuality'
import QualityResult from './QualityResult.vue'
import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
import WorkflowExecutionPanel from '../../workflows/WorkflowExecutionPanel.vue'
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
import { generationConfigApi } from '../../generation-config/api'
import type { GenerationOptions } from '../../generation-config/types'
import { useQuery } from '../../../composables/useQuery'
import ModelCapabilities from './ModelCapabilities.vue'
/** 单素材与当前集质量生成共用一个按需打开的面板,默认小批量且不自动调用模型。 */
const props = defineProps<{
/** 当前项目 */
projectId: string
/** 固定质量目标 */
target: QualityTarget | null
/** 上游状态阻断 */
disabled: boolean
}>()
/** 质量面板的open状态,随目标更新。 */
const open = defineModel<boolean>('open', { default: false })
const emit = defineEmits<{ changed: []; locate: [shotId: string] }>()
const { key, session, operation, blocked, run } = useQuality(
/** 通知外部刷新、定位与后台任务开始。 */
const emit = defineEmits<{ changed: []; locate: [shotId: string]; started: [executionId: string] }>()
const { key, session, operation, execution, blocked, run } = useQuality(
props,
() => open.value,
() => emit('changed')
() => emit('changed'),
id => emit('started', id)
)
/** 模型目录只读查询,随当前项目和弹窗状态取消过期请求。 */
const modelKey = computed(() =>
open.value && props.target?.kind === 'batch' && props.projectId ? props.projectId : ''
)
/** 模型与项目画幅读取,不自动写入配置。 */
const modelQuery = useQuery(modelKey, async (projectId, signal) =>
projectId
? {
catalog: await generationConfigApi.catalog(signal),
profile: await generationConfigApi.profile(projectId, signal)
}
: null
)
/** 本次明确选择的图片供应方。 */
const provider = ref('')
/** 本次生成与修复共用参数。 */
const generationOptions = ref<GenerationOptions>({})
/** 后台任务期间表单也保持锁定。 */
const pending = computed(() => operation.value.pending || execution.active.value)
/** 当前目标的单镜头范围。 */
const singleShot = computed(() => props.target?.kind === 'batch' && !!props.target.shotId)
/** 质量面板的formRef状态,随目标更新。 */
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
/** 质量面板的action状态,随目标更新。 */
const action = ref<QualityAction>('validate')
/** 质量面板的attempts状态,随目标更新。 */
const attempts = ref<number | null>(1)
/** 质量面板的concurrency状态,随目标更新。 */
const concurrency = ref<number | null>(1)
/** 质量面板的limit状态,随目标更新。 */
const limit = ref<number | null>(1)
/** 质量面板的force状态,随目标更新。 */
const force = ref(false)
/** 质量面板的width状态,随目标更新。 */
const width = ref<number | null>(null)
/** 质量面板的height状态,随目标更新。 */
const height = ref<number | null>(null)
/** 质量面板的texts状态,随目标更新。 */
const texts = ref('')
/** 质量面板的acknowledged状态,随目标更新。 */
const acknowledged = ref(false)
/** 质量面板的videoRepair状态,随目标更新。 */
const videoRepair = computed(() => props.target?.kind === 'video' && action.value === 'repair')
/** 质量面板的input状态,随目标更新。 */
const input = computed<QualityInput>(() => ({
concurrency: action.value === 'batch' ? (concurrency.value ?? 0) : 1,
limit: action.value === 'batch' ? (limit.value ?? 0) : 1,
limit: action.value === 'batch' && !singleShot.value ? (limit.value ?? 0) : 1,
...(props.target?.kind === 'batch' && props.target.shotId ? { shotId: props.target.shotId } : {}),
...(action.value === 'batch' && provider.value
? { provider: provider.value, generationOptions: { ...generationOptions.value } }
: {}),
maxRepairAttempts: action.value === 'validate' ? 0 : (attempts.value ?? -1),
force: force.value,
episodeNo: props.target?.kind === 'batch' ? props.target.episodeNo : 1,
@@ -55,10 +104,23 @@ const input = computed<QualityInput>(() => ({
...(action.value === 'validate' || width.value === null ? {} : { width: width.value }),
...(action.value === 'validate' || height.value === null ? {} : { height: height.value })
}))
const valid = computed(
() => validQualityInput(input.value) && (!videoRepair.value || input.value.maxRepairAttempts > 0)
/** 批量生图必须读到真实配置并显式选定启用模型,不能回退到未确认的全局默认。 */
const modelReady = computed(
() =>
props.target?.kind !== 'batch' ||
(!modelQuery.loading.value &&
!modelQuery.error.value &&
!!modelQuery.data.value?.profile &&
modelQuery.data.value.catalog.images.some(model => model.provider === provider.value && model.enabled))
)
/** 参数及模型均有效时才允许进入费用确认后的提交。 */
const valid = computed(
() =>
modelReady.value && validQualityInput(input.value) && (!videoRepair.value || input.value.maxRepairAttempts > 0)
)
/** 质量面板的generating状态,随目标更新。 */
const generating = computed(() => action.value !== 'validate')
/** 质量面板的label状态,随目标更新。 */
const label = computed(() =>
action.value === 'batch'
? '开始质量生成'
@@ -68,6 +130,7 @@ const label = computed(() =>
: '校验并修复'
: '开始视觉校验'
)
/** 质量面板的maxImages状态,随目标更新。 */
const maxImages = computed(() =>
action.value === 'batch'
? input.value.limit * (1 + input.value.maxRepairAttempts)
@@ -75,10 +138,13 @@ const maxImages = computed(() =>
? input.value.maxRepairAttempts
: 0
)
/** 质量面板的maxValidations状态,随目标更新。 */
const maxValidations = computed(() =>
action.value === 'batch' ? maxImages.value : action.value === 'repair' ? input.value.maxRepairAttempts + 1 : 1
)
/** 质量面板的saved状态,随目标更新。 */
const saved = computed(() => (props.target?.kind === 'video' ? (session.value.videoValidation ?? null) : null))
/** 质量面板的repairAvailable状态,随目标更新。 */
const repairAvailable = computed(
() =>
!videoRepair.value ||
@@ -99,19 +165,35 @@ watch(
width.value = null
height.value = null
texts.value = ''
provider.value = ''
generationOptions.value = {}
acknowledged.value = false
},
{ immediate: true }
)
/** 参数变化撤销付费确认。 */
watch([input, action], () => {
acknowledged.value = false
})
/** 模型目录加载后使用项目已保存的供应方与参数,切镜头重置单次覆盖。 */
watch(
[() => modelQuery.data.value, key],
([data]) => {
if (!data?.profile || props.target?.kind !== 'batch') return
const selected = data.catalog.images.find(item => item.provider === data.profile!.imageProvider && item.enabled)
if (!selected) return
provider.value = selected.provider
generationOptions.value = { ...selected.defaults, ...data.profile.imageOptions }
},
{ flush: 'post' }
)
/** 付费入口保留明确确认,不因菜单选择或查看历史自动提交。 */
async function submit() {
if (!acknowledged.value || !valid.value || blocked.value || !repairAvailable.value) return
acknowledged.value = false
await run(action.value, input.value)
}
/** 质量面板的formModel状态,随目标更新。 */
const formModel = computed(() => ({
attempts: attempts.value,
concurrency: concurrency.value,
@@ -120,16 +202,19 @@ const formModel = computed(() => ({
height: height.value,
texts: texts.value
}))
/** 质量面板的rules状态,随目标更新。 */
const rules = computed(() => ({
attempts: integerRule('修复次数', videoRepair.value ? 1 : 0),
concurrency: integerRule('批量并发'),
limit: integerRule('本批镜头上限'),
...sizeRules(() => formModel.value)
}))
/** 更多参数折叠状态。 */
const optionsExpanded = ref<string[]>(['options'])
</script>
<template>
<!-- 以下是质量操作与显式费用确认模块 -->
<AppDialog
v-model:open="open"
:title="`质量检查 · ${target?.title ?? ''}`"
@@ -140,7 +225,7 @@ const optionsExpanded = ref<string[]>(['options'])
ref="formRef"
:model="formModel"
:rules="rules"
:disabled="operation.pending"
:disabled="pending"
:reset-key="`${open}:${key}:${action}`"
validate-on-change
@invalid="optionsExpanded = ['options']"
@@ -149,7 +234,7 @@ const optionsExpanded = ref<string[]>(['options'])
<NRadioGroup
v-if="target && target.kind !== 'batch'"
v-model:value="action"
:disabled="operation.pending"
:disabled="pending"
class="mt-4"
aria-label="素材质量操作"
>
@@ -165,30 +250,26 @@ const optionsExpanded = ref<string[]>(['options'])
<NFormItem path="attempts" :label="videoRepair ? '修复链次数上限' : '每镜最多修复'"
><NInputNumber
v-model:value="attempts"
:disabled="operation.pending"
:disabled="pending"
:min="videoRepair ? 1 : 0"
:step="1"
:input-props="{ 'aria-label': '每镜最多修复次数' }"
/></NFormItem>
<NFormItem v-if="target?.kind === 'batch'" path="limit" label="本批镜头上限"
<NFormItem v-if="target?.kind === 'batch' && !singleShot" path="limit" label="本批镜头上限"
><NInputNumber
v-model:value="limit"
:disabled="operation.pending"
:disabled="pending"
:min="1"
:step="1"
:input-props="{ 'aria-label': '质量生成镜头上限' }"
/></NFormItem>
</div>
<NCheckbox
v-if="target?.kind === 'batch'"
v-model:checked="force"
:disabled="operation.pending"
class="mt-4"
>重做本集已有有效首帧(通过后替换主图)</NCheckbox
<NCheckbox v-if="target?.kind === 'batch'" v-model:checked="force" :disabled="pending" class="mt-4"
>重做当前范围已有有效首帧(通过后替换主图)</NCheckbox
>
<p v-if="target?.kind === 'batch'" class="mt-3 text-xs text-muted">
仅第 {{ target.episodeNo }} 集,最多
{{ limit ?? '—' }} 镜;非重做模式优先处理过期项,若全项目无过期项则补缺失首帧。
仅第 {{ target.episodeNo }} 集{{ singleShot ? `,指定镜头 ${target.shotId}` : '' }},最多
{{ singleShot ? 1 : (limit ?? '—') }} 镜;非重做模式处理符合条件的过期和缺失首帧。
</p>
<p v-if="videoRepair" class="mt-3 text-xs text-muted">
本次仅创建一个修复视频,不自动等待或复检。完成后请打开新候选的质量检查;修复约束沿用上次失败校验,不使用额外参数。
@@ -207,7 +288,7 @@ const optionsExpanded = ref<string[]>(['options'])
<NFormItem v-if="target?.kind === 'batch'" path="concurrency" label="批量并发"
><NInputNumber
v-model:value="concurrency"
:disabled="operation.pending"
:disabled="pending"
:min="1"
:step="1"
:input-props="{ 'aria-label': '质量生成并发' }"
@@ -215,14 +296,14 @@ const optionsExpanded = ref<string[]>(['options'])
<NFormItem v-if="generating" path="width" label="宽度(可选)"
><NInputNumber
v-model:value="width"
:disabled="operation.pending"
:disabled="pending"
:min="1"
:input-props="{ 'aria-label': '质量生成宽度' }"
/></NFormItem>
<NFormItem v-if="generating" path="height" label="高度(可选)"
><NInputNumber
v-model:value="height"
:disabled="operation.pending"
:disabled="pending"
:min="1"
:input-props="{ 'aria-label': '质量生成高度' }"
/></NFormItem>
@@ -230,12 +311,39 @@ const optionsExpanded = ref<string[]>(['options'])
<NFormItem class="mt-4 block" path="texts" label="额外允许的画面文字(一行一项,可留空)"
><NInput
v-model:value="texts"
:disabled="operation.pending"
:disabled="pending"
type="textarea"
:autosize="{ minRows: 2, maxRows: 5 }"
:input-props="{ 'aria-label': '额外允许的画面文字' }"
/></NFormItem>
<ModelCapabilities :shot-id="target && target.kind !== 'batch' ? target.shotId : undefined" />
<!-- 以下是复用现有模型目录的单次质量生成配置模块 -->
<GenerationModelControls
v-if="target?.kind === 'batch' && modelQuery.data.value?.profile"
v-model:provider="provider"
v-model:options="generationOptions"
type="image"
:catalog="modelQuery.data.value.catalog"
:aspect-ratio="modelQuery.data.value.profile.aspectRatio"
:disabled="pending"
/>
<NAlert v-if="modelQuery.error.value" type="error" :show-icon="false">{{
modelQuery.error.value
}}</NAlert>
<NAlert
v-if="target?.kind === 'batch' && !modelReady && !modelQuery.error.value"
type="warning"
:show-icon="false"
>
{{
modelQuery.loading.value
? '正在读取项目模型配置,请稍候。'
: '请先保存有效的项目图片模型配置,再选择本次模型。'
}}
</NAlert>
<ModelCapabilities
:shot-id="target?.shotId"
:provider="target?.kind === 'batch' ? provider : undefined"
/>
</NCollapseItem>
</NCollapse>
<NAlert type="warning" :show-icon="false" class="mt-4">
@@ -258,17 +366,30 @@ const optionsExpanded = ref<string[]>(['options'])
: '仅校验,不修改主资产。'
}}</template>
</NAlert>
<NCheckbox v-model:checked="acknowledged" :disabled="operation.pending" class="mt-4"
<NCheckbox v-model:checked="acknowledged" :disabled="pending" class="mt-4"
>我已确认费用、处理范围,且同项目没有其他生成任务。</NCheckbox
>
</AppForm>
<p v-if="operation.pending" role="status" class="mt-3 text-xs text-muted">
{{ operation.label }}进行中,请勿重复提交。
</p>
<p v-if="pending" role="status" class="mt-3 text-xs text-muted">{{ operation.label }}进行中,请勿重复提交。</p>
<NAlert v-if="session.error" role="alert" type="error" :show-icon="false" class="mt-4">{{
session.error
}}</NAlert>
<!-- 以下是持久化任务进度与原目标最终回执模块 -->
<WorkflowExecutionPanel
v-if="execution.executionId.value"
title="首帧质量后台任务"
:execution="execution.query.data.value"
:loading="execution.query.loading.value"
:error="execution.query.error.value"
@refresh="execution.query.refresh"
@dismiss="execution.dismiss"
/>
<KeyframeValidationHistory
v-if="target?.kind === 'keyframe'"
:project-id="projectId"
:shot-id="target.shotId"
:keyframe-id="target.assetId"
/>
<QualityResult v-if="session.receipt" :receipt="session.receipt" @locate="emit('locate', $event)" />
<NCollapse v-else-if="saved" class="mt-4" :default-expanded-names="['saved']"
><NCollapseItem name="saved" :title="`本会话最近校验 · ${saved.passed ? '通过' : '未通过'}`"
@@ -280,16 +401,17 @@ const optionsExpanded = ref<string[]>(['options'])
></NCollapse
>
<p v-if="target?.kind !== 'batch'" class="mt-3 text-xs text-muted">
校验回执保留在当前会话,可导出;素材列表不提供历史质量结果,刷新浏览器后需重新校验。
本会话回执可导出;首帧已有校验可在历史中只读查看,后台质量任务刷新后继续恢复。
</p>
<template #footer>
<NButton @click="open = false">关闭</NButton>
<NButton
type="primary"
:loading="operation.pending"
:loading="pending"
:disabled="blocked || !acknowledged || !repairAvailable"
@click="formRef?.validate(submit)"
>{{ label }}</NButton>
>{{ label }}</NButton
>
</template>
</AppDialog>
</template>
@@ -6,7 +6,9 @@ import type { QualityReceipt } from '../quality.types'
/** 摘要、失败与完整逐轮信息默认直接显示,不用完成请求冒充质量通过。 */
const props = defineProps<{ receipt: QualityReceipt }>()
/** 逐镜结果定位事件。 */
const emit = defineEmits<{ locate: [shotId: string] }>()
/** 完整最终回执的视觉结论。 */
const passed = computed(() =>
props.receipt.kind === 'batch'
? props.receipt.result.targetCount > 0 && props.receipt.result.passed === props.receipt.result.targetCount
@@ -14,6 +16,7 @@ const passed = computed(() =>
? false
: props.receipt.result.passed
)
/** 当前失败问题列表。 */
const issues = computed(() => {
const value = props.receipt
return value.kind === 'batch' || value.kind === 'video-repair'
@@ -22,6 +25,7 @@ const issues = computed(() => {
? (value.result.attempts.at(-1)?.issues ?? [])
: value.result.issues
})
/** 视频专项检查详情。 */
const videoChecks = computed(() => {
if (props.receipt.kind !== 'video') return []
const result = props.receipt.result
@@ -43,6 +47,7 @@ function exportResult() {
</script>
<template>
<!-- 以下是最终校验结论与逐镜执行结果模块 -->
<section class="quality-result" aria-label="质量检查结果">
<div class="flex flex-wrap items-center justify-between gap-3">
<strong :class="receipt.kind === 'video-repair' ? '' : passed ? 'text-success' : 'text-danger'">{{
@@ -67,7 +72,9 @@ function exportResult() {
<NButton text size="small" @click="emit('locate', item.shotId)">定位镜头</NButton>
<code class="text-xs text-muted">{{ item.shotId }}</code>
<span :class="item.success ? 'text-success' : 'text-danger'">{{
item.success ? '已通过' : item.error || '未通过'
item.success
? '已通过'
: item.error || (item.status === 'repair_failed' ? '达到修复上限仍未通过' : '调用失败')
}}</span>
</div>
</template>
@@ -32,6 +32,8 @@ import type {
import KeyframeDialog from './KeyframeDialog.vue'
import KeyframeCard from './KeyframeCard.vue'
import QualityDialog from './QualityDialog.vue'
import VideoQualityDiagnostics from './VideoQualityDiagnostics.vue'
import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
import ActionMenu from '../../../components/ui/ActionMenu.vue'
import { AppDialog } from '../../../components/ui'
import ModelCapabilities from './ModelCapabilities.vue'
@@ -47,25 +49,37 @@ import GenerationModelControls from '../../generation-config/components/Generati
/** 单镜头生产面板只负责正式资产,不修改上游导演设计与即时状态。 */
const props = defineProps<{
/** 当前正式项目 ID。 */
projectId: string
/** 当前正式镜头。 */
shot: DesignedShot
/** 当前剧集编号,用于限制单镜头质量生成。 */
episodeNo?: number
/** 视频提示词就绪项。 */
promptReadiness?: PromptReadinessItem
/** 首帧就绪项。 */
keyframeReadiness?: KeyframeReadinessItem
/** 视频就绪项。 */
videoReadiness?: VideoReadinessItem
/** 是否从深链接打开首帧生成。 */
openKeyframe?: boolean
/** 页面上游状态是否阻断操作。 */
disabled: boolean
}>()
const emit = defineEmits<{ changed: [] }>()
/** 通知父页面刷新及观察已启动的质量任务。 */
const emit = defineEmits<{ changed: []; qualityStarted: [executionId: string] }>()
const key = computed(() => props.shot.shotId)
/** 仅当前镜头存在后台首帧或视频任务时临时轮询,终态后自动停止。 */
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
}>>
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
@@ -173,6 +187,17 @@ function openQuality(kind: 'keyframe' | 'video', assetId: string) {
}
qualityOpen.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
}
const confirmingKeyframe = ref('')
const confirmingVideo = ref('')
const inspecting = ref(false)
@@ -458,6 +483,15 @@ async function inspectSpecs() {
/>
</div>
<p v-else class="mt-4 text-xs text-muted">尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。</p>
<!-- 以下是当前主首帧的只读视觉校验历史模块 -->
<KeyframeValidationHistory
v-if="currentKeyframe"
:key="currentKeyframe.id"
:project-id="projectId"
:shot-id="shot.shotId"
:keyframe-id="currentKeyframe.id"
class="mt-3"
/>
<NAlert
v-if="currentKeyframe && keyframePassed(currentKeyframe.id) === false"
type="error"
@@ -470,6 +504,9 @@ async function inspectSpecs() {
视频质量链状态暂时无法读取;视频资产仍可查看。请稍后刷新。
</NAlert>
<div class="production-stage-actions">
<NButton :disabled="!episodeNo || !canGenerateKeyframe" @click="openShotKeyframeQuality"
>本镜首帧质量重跑</NButton
>
<NButton v-if="keyframeCandidates.length" @click="candidatesOpen = true">
管理候选({{ keyframeCandidates.length }})
</NButton>
@@ -597,6 +634,8 @@ async function inspectSpecs() {
。请检查候选视频和校验结果,调整提示词或参考资产后再重新生成。
</template>
</NAlert>
<!-- 以下是当前镜头只读视频质量详情与失败归因模块 -->
<VideoQualityDiagnostics :key="shot.shotId" :shot-id="shot.shotId" class="mt-3" />
<div v-if="videos.length" class="video-grid mt-4">
<article v-for="item in videos" :key="item.id" class="video-record">
<video
@@ -795,6 +834,7 @@ async function inspectSpecs() {
:target="qualityTarget"
:disabled="assetBlocked"
@changed="refreshAll"
@started="emit('qualityStarted', $event)"
/>
<AppDialog
v-model:open="candidatesOpen"
@@ -0,0 +1,114 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { NAlert, NTag } from 'naive-ui'
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
import { useQuery } from '../../../composables/useQuery'
import { formatDate } from '../../../lib/format'
import { videoDiagnosticsApi } from '../diagnostics-api'
import { videoQualityStatusLabel } from '../model'
import type { VideoQualityRollbackTarget } from '../diagnostics.types'
/** 视频诊断始终绑定当前正式镜头。 */
const props = defineProps<{ /** 正式镜头 ID。 */ shotId: string }>()
/** 仅用户展开后查询,关闭后取消旧请求。 */
const open = ref(false)
/** 镜头和展开状态共同决定查询目标。 */
const key = computed(() => (open.value ? props.shotId : ''))
/** 切换镜头时取消查询,先读取链状态,耗尽时再查询独立归因。 */
const query = useQuery(key, async (shotId, signal) => {
if (!shotId) return null
const detail = await videoDiagnosticsApi.qualityDetail(shotId, signal)
if (detail.shotId !== shotId || !Array.isArray(detail.chain)) throw new Error('质量记录与当前镜头不匹配,请刷新。')
const analysis =
detail.status === 'exhausted'
? await videoDiagnosticsApi.exhaustionAnalysis(shotId, signal)
: detail.exhaustionAnalysis
if (analysis && analysis.shotId !== shotId) throw new Error('失败归因与当前镜头不匹配,请刷新。')
return { detail, analysis }
})
/** 当前请求返回的权威质量链。 */
const detail = computed(() => query.data.value?.detail)
/** 当前链对应的后端确定性归因。 */
const analysis = computed(() => query.data.value?.analysis)
/**
* 将后端回退层级转成业务标签,未知值保持原文。
* @param target 后端建议回退层级
* @returns 中文标签
*/
function rollbackLabel(target: VideoQualityRollbackTarget) {
const labels: Record<VideoQualityRollbackTarget, string> = {
identity_reference: '主体身份母版',
subject_reference: '形态参考图',
keyframe: '主首帧',
motion_plan: '运动计划',
video_prompt: '视频提示词',
provider: '视频模型'
}
return labels[target] ?? target
}
</script>
<template>
<!-- 以下是只读视频质量详情与自动修复失败归因模块 -->
<ReadonlyInspection
v-model:open="open"
title="视频质量详情"
description="读取已有校验链和失败归因,不重新校验或生成视频。"
:loading="query.loading.value"
:error="query.error.value"
@refresh="query.refresh"
>
<template v-if="detail">
<p>
<strong>{{ videoQualityStatusLabel(detail.status) }}</strong> · 修复 {{ detail.repairAttempt }} /
{{ detail.maxRepairAttempts ?? '未设置' }} · 候选 {{ detail.chain.length }}
</p>
<p v-if="!detail.chain.length" class="mt-2 text-muted">当前镜头尚无质量链记录。</p>
<article v-for="item in detail.chain" :key="item.videoId" class="surface-inset mt-3 p-3">
<div class="flex flex-wrap items-center gap-2">
<code>{{ item.videoId }}</code>
<NTag size="small" :bordered="false">第 {{ item.repairAttempt }} 代</NTag>
<span
>{{ item.providerStatus }} ·
{{
item.validationPassed === true
? '校验通过'
: item.validationPassed === false
? '校验未通过'
: '尚未校验'
}}</span
>
<span class="text-muted">{{ formatDate(item.updatedAt) }}</span>
</div>
<ul v-if="item.issues.length" class="mt-2 space-y-1">
<li
v-for="(issue, index) in item.issues"
:key="index"
:class="issue.severity === 'error' ? 'text-danger' : 'text-muted'"
>
{{ issue.frameLabel ? `${issue.frameLabel} · ` : '' }}{{ issue.description }}
</li>
</ul>
</article>
<NAlert
v-if="analysis"
class="mt-3"
:type="analysis.requiresManualReview ? 'warning' : 'info'"
:show-icon="false"
>
{{ analysis.summary }}
<p v-if="analysis.recommendedRollback.length" class="mt-1">
建议检查:{{ analysis.recommendedRollback.map(rollbackLabel).join('、') }}
</p>
</NAlert>
<article v-for="issue in analysis?.persistentIssues ?? []" :key="issue.type" class="mt-3">
<strong>{{ issue.type }} · 出现 {{ issue.occurrences }} 次</strong>
<p>{{ issue.suspectedCause }}</p>
<ul class="text-muted">
<li v-for="description in issue.descriptions" :key="description">{{ description }}</li>
</ul>
</article>
</template>
</ReadonlyInspection>
</template>
@@ -0,0 +1,28 @@
import { request } from '../../lib/http'
import type { VideoQualityDetail, VideoQualityExhaustionAnalysis } from './diagnostics.types'
/** 视频诊断只读取持久化记录,不触发视觉模型或 Provider。 */
export const videoDiagnosticsApi = {
/**
* 查询指定镜头的完整视频质量链。
* @param shotId 正式镜头 ID
* @param signal 取消信号
* @returns 包含问题详情的质量链
*/
qualityDetail: (shotId: string, signal?: AbortSignal) =>
request<VideoQualityDetail>(
`/storyboard-shots/${encodeURIComponent(shotId)}/videos/quality-status?detail=true`,
{ signal }
),
/**
* 查询自动修复耗尽后的确定性失败归因。
* @param shotId 正式镜头 ID
* @param signal 取消信号
* @returns 后端实际失败归因和建议回退层级
*/
exhaustionAnalysis: (shotId: string, signal?: AbortSignal) =>
request<VideoQualityExhaustionAnalysis>(
`/storyboard-shots/${encodeURIComponent(shotId)}/videos/quality-exhaustion-analysis`,
{ signal }
)
}
@@ -0,0 +1,70 @@
import type { QualityIssue } from './quality.types'
import type { ShotVideoQualityStatus } from './types'
/** 修复耗尽后后端建议回退的上游层级。 */
export type VideoQualityRollbackTarget =
| 'identity_reference'
| 'subject_reference'
| 'keyframe'
| 'motion_plan'
| 'video_prompt'
| 'provider'
/** 多轮视频中反复出现的质量问题,以后端实际归因为准。 */
export interface PersistentVideoQualityIssue {
/** 原始问题类型。 */
type: string
/** 累计出现次数。 */
occurrences: number
/** 出现该问题的候选代数。 */
generations: number[]
/** 实际失败描述。 */
descriptions: string[]
/** 后端疑似原因。 */
suspectedCause: string
/** 后端建议回退层级。 */
recommendedRollback: VideoQualityRollbackTarget[]
}
/** 确定性失败归因结果,查询不会重新执行模型。 */
export interface VideoQualityExhaustionAnalysis {
/** 正式镜头 ID。 */
shotId: string
/** 当前链是否耗尽。 */
exhausted: boolean
/** 质量链候选数量。 */
generations: number
/** 未通过的候选数量。 */
failedGenerations: number
/** 后端判定的持续问题。 */
persistentIssues: PersistentVideoQualityIssue[]
/** 建议回退层级集合。 */
recommendedRollback: VideoQualityRollbackTarget[]
/** 是否需要人工检查。 */
requiresManualReview: boolean
/** 后端摘要。 */
summary: string
}
/** 已有公开质量状态中的候选基础字段。 */
type VideoQualityChainBase = ShotVideoQualityStatus['chain'][number]
/** 单个候选的持久化质量记录。 */
export interface VideoQualityChainItem extends VideoQualityChainBase {
/** 本次视觉校验的问题详情。 */
issues: QualityIssue[]
/** 错误数量。 */
errorCount: number
/** 警告数量。 */
warningCount: number
}
/** 请求 detail=true 时的完整质量链。 */
export interface VideoQualityDetail extends Omit<ShotVideoQualityStatus, 'issues' | 'chain'> {
/** 最近一次质量问题。 */
issues: QualityIssue[]
/** 当前失败链的实际记录。 */
chain: VideoQualityChainItem[]
/** 耗尽后的确定性归因,未耗尽时为空。 */
exhaustionAnalysis: VideoQualityExhaustionAnalysis | null
}
+30 -4
View File
@@ -3,7 +3,8 @@ import type {
ImageProviderCapability,
KeyframeRepair,
KeyframeValidation,
QualityBatchResult,
KeyframeQualityStart,
KeyframeValidationHistoryItem,
QualityInput,
ShotProviderCapability,
VideoValidation,
@@ -19,9 +20,16 @@ export const qualityApi = {
),
providers: (signal?: AbortSignal) =>
request<ImageProviderCapability[]>('/image-providers/capabilities', { signal }),
capability: (shotId: string, signal?: AbortSignal) =>
/**
* 只读检查本次选择模型的实际参考图规划能力。
* @param shotId 正式镜头 ID
* @param signal 取消信号
* @param provider 本次明确选择的模型
* @returns 后端实际能力和参考图规划
*/
capability: (shotId: string, signal?: AbortSignal, provider?: string) =>
request<ShotProviderCapability>(
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability`,
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability${provider ? `?provider=${encodeURIComponent(provider)}` : ''}`,
{ signal }
),
validateKeyframe: (shotId: string, assetId: string, allowedTexts: string[]) =>
@@ -43,8 +51,26 @@ export const qualityApi = {
`/storyboard-shots/${encodeURIComponent(shotId)}/videos/${encodeURIComponent(assetId)}/validate`,
{ method: 'POST', body: { allowedTexts }, timeoutMs: 0 }
),
/**
* 只读查询指定首帧的已有校验历史。
* @param shotId 正式镜头 ID
* @param keyframeId 指定首帧 ID
* @param signal 取消信号
* @returns 后端保存的校验记录列表
*/
keyframeHistory: (shotId: string, keyframeId: string, signal?: AbortSignal) =>
request<KeyframeValidationHistoryItem[]>(
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/validations`,
{ signal }
),
/**
* 启动后台首帧质量生成,不把任务开始当作视觉通过。
* @param projectId 正式项目 ID
* @param input 已确认的镜头、模型和费用范围
* @returns 真实后台任务观察句柄
*/
generate: (projectId: string, input: QualityInput) =>
request<QualityBatchResult>(`/projects/${encodeURIComponent(projectId)}/keyframes/generate-quality`, {
request<KeyframeQualityStart>(`/projects/${encodeURIComponent(projectId)}/keyframes/generate-quality`, {
method: 'POST',
body: input,
timeoutMs: 0
+52 -12
View File
@@ -1,7 +1,14 @@
import { reactive } from 'vue'
import { validOptionalSize } from './model'
import type { KeyframeReadiness } from './types'
import type { QualityInput, QualityReceipt, QualityTarget, VisualValidation, VideoValidation } from './quality.types'
import type {
QualityBatchResult,
QualityInput,
QualityReceipt,
QualityTarget,
VisualValidation,
VideoValidation
} from './quality.types'
/** 未返回的操作不显示上次成功结论;网络失败不会自动重发。 */
const sessions = reactive<
@@ -13,7 +20,7 @@ export function qualityKey(projectId: string, target: QualityTarget | null) {
return JSON.stringify([
projectId,
target?.kind,
target && ('assetId' in target ? [target.shotId, target.assetId] : target.episodeNo)
target && ('assetId' in target ? [target.shotId, target.assetId] : [target.episodeNo, target.shotId])
])
}
@@ -44,21 +51,56 @@ export function validQualityInput(input: QualityInput) {
)
}
/** 与后端保持同一优先级:全项目有过期项时先筛过期,再按当前集筛选。 */
/**
* 按真实后端就绪结果、剧集与指定镜头过滤,过期与缺失项均保留。
* @param readiness 后端就绪列表
* @param input 已确认的批次参数
* @returns 实际候选镜头
*/
export function qualityTargets(readiness: KeyframeReadiness, input: QualityInput) {
return readiness.items
.filter(
item =>
item.status === 'ready' &&
(input.force ||
(readiness.stalePrimaryKeyframe > 0
? item.primaryKeyframeStale === true
: !item.primaryKeyframeId)) &&
item.episodeNo === input.episodeNo
item.episodeNo === input.episodeNo &&
(!input.shotId || item.shotId === input.shotId)
)
.slice(0, input.limit)
}
/**
* 解析数据库 JSON 校验结论;原始模型文字不能代替真实结构化结果。
* @param output 历史任务输出
* @returns 完整视觉结论或空值
*/
export function parseKeyframeValidationOutput(output: unknown): VisualValidation | null {
try {
const value: unknown = typeof output === 'string' ? JSON.parse(output) : output
return isVisualValidation(value) ? value : null
} catch {
return null
}
}
/**
* 区分最终逐镜回执与 202 句柄,防止后台开始被显示为完成。
* @param value 后端任务最终结果
* @returns 是否具有完整计数和逐镜结果
*/
export function isQualityBatchResult(value: unknown): value is QualityBatchResult {
if (!value || typeof value !== 'object') return false
const item = value as QualityBatchResult
return (
Array.isArray(item.results) &&
[item.targetCount, item.selected, item.passed, item.repairFailed, item.failed].every(
number => Number.isSafeInteger(number) && number >= 0
) &&
item.results.length === item.targetCount &&
item.passed + item.repairFailed + item.failed === item.targetCount &&
item.results.every(result => typeof result.shotId === 'string' && typeof result.success === 'boolean')
)
}
/** 最小响应校验,避免畸形响应或仅 HTTP 200 被显示成视觉通过。 */
export function isVisualValidation(value: unknown): value is VisualValidation {
if (!value || typeof value !== 'object') return false
@@ -90,11 +132,9 @@ export function sessionVideoValidation(projectId: string, shotId: string, assetI
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
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
+63 -1
View File
@@ -1,7 +1,12 @@
/** 校验入口绑定正式镜头与资产 ID;批量默认只处理当前集。 */
export type QualityTarget =
| { kind: 'keyframe' | 'video'; shotId: string; assetId: string; title: string }
| { kind: 'batch'; episodeNo: number; title: string }
| {
kind: 'batch'
/** 当前剧集 */ episodeNo: number
/** 指定单镜头 */ shotId?: string
/** 显示标题 */ title: string
}
/** 质量操作与普通生成独立,不复用生产面板的覆盖、并发或范围。 */
export type QualityAction = 'validate' | 'repair' | 'batch'
@@ -122,13 +127,27 @@ export interface QualityBatchResult {
/** 首帧质量生成配置;limit 强制由前端填写,避免无意执行全项目。 */
export interface QualityInput {
/** 本批并发数 */
concurrency: number
/** 每镜修复次数上限 */
maxRepairAttempts: number
/** 是否重做有效首帧 */
force: boolean
/** 固定本批剧集 */
episodeNo: number
/** 本批镜头上限 */
limit: number
/** 指定镜头,单镜头重跑固定 limit=1 */
shotId?: string
/** 图片供应方 */
provider?: string
/** 首次生成与修复共享模型参数 */
generationOptions?: import('../generation-config/types').GenerationOptions
/** 允许的画面文字 */
allowedTexts?: string[]
/** 输出宽度 */
width?: number
/** 输出高度 */
height?: number
}
@@ -141,10 +160,23 @@ export interface ImageProviderCapability {
/** 只读能力检查不切换模型;无法满足参考图数量时阻止生图。 */
export interface ShotProviderCapability {
/** 本次检查的图片模型。 */
provider: string
/** 镜头完整业务参考图候选数量。 */
referenceCount: number
/** 模型声明的实际输入上限。 */
maxReferenceImages: number | null
/** 后端规划将输入模型的图片数量。 */
plannedReferenceCount?: number
/** 转为文字约束的参考图数量。 */
omittedReferenceCount?: number
/** 是否需要参考图规划。 */
requiresPlanning?: boolean
/** 后端实际规划策略。 */
strategy?: string
/** 规划后是否满足模型能力。 */
valid: boolean
/** 后端实际能力或参考图规划说明。 */
message?: string
}
@@ -160,3 +192,33 @@ export type QualityReceipt =
export type VideoValidationCheck =
| { enabled: false; reason: string }
| { enabled: true; passed: boolean; summary: string; applicable?: boolean; [key: string]: unknown }
/** 首帧质量后台任务启动回执,不包含最终校验结论。 */
export interface KeyframeQualityStart {
/** 后台任务编号 */
executionId: string
/** 原项目编号 */
projectId: string
/** 后台已启动 */
status: 'running'
/** 本批镜头数 */
total: number
}
/** 已保存的只读首帧校验任务记录。 */
export interface KeyframeValidationHistoryItem {
/** 校验任务编号 */
id: string
/** 任务状态,保留后端原值 */
status: string
/** 数据库保存的 JSON 输出 */
output: string | Record<string, unknown> | null
/** 调用错误 */
error: string | null
/** 开始时间 */
startedAt: string | null
/** 结束时间 */
finishedAt: string | null
/** 创建时间 */
createdAt: string
}
+77 -6
View File
@@ -1,3 +1,5 @@
import type { GenerationOptions, ResolvedGenerationConfig } from '../generation-config/types'
/** 项目生产链的就绪状态;进行中只会出现在视频阶段。 */
export type ProductionReadinessStatus = 'ready' | 'skipped' | 'in_progress' | 'blocked'
@@ -420,6 +422,8 @@ export interface ProductionSession {
/** 串联生产回执;completed 由后端核对全部当前有效主资产后给出。 */
export interface ProductionPipelineResult {
projectId: string
/** 稳定身份母版生成的实际汇总。 */
stableIdentityAnchorResult?: Pick<PipelineBatchResult, 'total' | 'generated' | 'failed'>
visualPromptResult?: PipelineBatchResult
subjectImageResult?: PipelineBatchResult
videoPromptResult?: PipelineBatchResult
@@ -459,7 +463,7 @@ export interface VideoInputKeyframe {
export type ProviderInputRecoveryStatus = 'not_required' | 'required' | 'variant_ready' | 'exhausted'
/** 项目当前制作阶段,与剧本创作状态分别展示。 */
export type ProductionStage = 'subject_images' | 'keyframes' | 'videos' | 'completed'
export type ProductionStatusStage = 'subject_images' | 'keyframes' | 'videos' | 'completed'
/** 主体参考图的公开就绪明细,阻塞原因由后端提供。 */
export interface SubjectImageReadinessItem {
@@ -487,14 +491,20 @@ export interface ProductionPlanStage {
export interface ProductionPlan {
projectId: string
providers: { image: string; video: string }
generationConfig?: { image?: Record<string, unknown> }
/** 实际解析后的图片模型与参数。 */
generationConfig?: { image?: ResolvedGenerationConfig }
completed: boolean
canStart: boolean
canAutoRun: boolean
entryReadiness?: { ready: boolean; reason?: string | null }
characterIdentity?: ProductionPlanStage
stableIdentityAnchors?: ProductionPlanStage
stage: ProductionStage
/** 角色身份实际就绪汇总。 */
characterIdentity?: ProductionCharacterIdentityPlan
/** 稳定身份母版阶段与真实逐项计划。 */
stableIdentityAnchors?: ProductionPlanStage & {
/** 稳定主体的逐项就绪结果。 */
items?: ProductionStableIdentityItem[]
}
stage: ProductionStatusStage
hasManualBlockers: boolean
manualBlocked: number
subjectImages: ProductionPlanStage
@@ -502,6 +512,8 @@ export interface ProductionPlan {
videoPrompts: ProductionPlanStage
videos: ProductionPlanStage
details: {
/** 稳定身份母版的逐项计划。 */
stableIdentityAnchors?: ProductionStableIdentityItem[]
subjectImages: SubjectImageReadinessItem[]
keyframes: KeyframeReadinessItem[]
videoPrompts: PromptReadinessItem[]
@@ -513,7 +525,7 @@ export interface ProductionPlan {
export interface ProjectProductionStatus {
projectId: string
completed: boolean
stage: ProductionStage
stage: ProductionStatusStage
subjectImages: {
total: number
current: number
@@ -619,3 +631,62 @@ export interface EpisodeAssemblyResult {
durationSeconds: number
videoUrl: string
}
/** 后端允许恢复或正常停止的生产阶段。 */
export type ProductionStage = 'subjectImages' | 'keyframes' | 'videoPrompts'
/** 无消耗生产计划与实际启动共用的模型配置。 */
export interface ProductionPlanInput {
/** 本轮图片模型供应方。 */
imageProvider?: string
/** 主体图片与首帧共用的图片生成参数。 */
imageGenerationOptions?: GenerationOptions
/** 本轮视频模型供应方。 */
videoProvider?: string
}
/** 后端生产启动范围;上限必须是大于零的整数。 */
export interface ProductionStartInput extends ProductionPlanInput {
/** 从具备前置资产的阶段继续。 */
startFrom?: ProductionStage
/** 完成此阶段后正常停止;省略则允许提交视频。 */
stopAfter?: ProductionStage
/** 本轮稳定身份母版上限。 */
stableIdentityAnchorLimit?: number
/** 本轮主体图上限。 */
subjectImageLimit?: number
/** 本轮首帧上限。 */
keyframeLimit?: number
/** 本轮视频提示词上限。 */
videoPromptLimit?: number
}
/** 生产计划中的角色身份汇总,字段遵循后端实际返回。 */
export interface ProductionCharacterIdentityPlan {
/** 角色数量。 */
total: number
/** 已锁定身份数量。 */
ready: number
/** 待处理数量。 */
pending: number
/** 生产流程可自动处理数量。 */
autoResolvable: number
/** 需要人工选角数量。 */
manualBlocked: number
}
/** 后端稳定身份母版计划的单个主体。 */
export interface ProductionStableIdentityItem {
/** 数据库主体 ID。 */
subjectId: string
/** 主体引用标识。 */
subjectRef: string
/** 主体名称。 */
subjectName: string
/** 主体模块。 */
module: string
/** 已就绪、待生成、上游可补齐或人工阻塞。 */
status: 'skipped' | 'ready' | 'upstream' | 'blocked'
/** 后端提供的就绪或阻塞原因。 */
reason: string
}
+132 -29
View File
@@ -6,16 +6,26 @@ import { hasRunningImages } from '../subject-images/model'
import { getOperation, runOperation } from '../workflows/operations'
import { useWorkflowExecution } from '../workflows/execution'
import { hasRunningWorkflow } from '../workflows/selectors'
import { errorMessage } from '../../lib/http'
import { ApiError, errorMessage } from '../../lib/http'
import { generationConfigApi } from '../generation-config/api'
import { productionApi } from './api'
import { getProductionSession } from './model'
import type { ProductionStartInput, ProductionStage } from './types'
/** 使用后端计划区分可自动补齐和人工阻塞,保留项目归属及活动任务检查。 */
export async function checkPipeline(projectId: string) {
/**
* 使用后端计划区分可自动补齐和人工阻塞,保留项目归属及活动任务检查。
* @param projectId 当前项目 ID
* @param scope 已选择的生产范围
* @returns 无消耗计划、实际状态与同源请求参数
*/
export async function checkPipeline(projectId: string, scope: ProductionStartInput = {}) {
const profile = await generationConfigApi.profile(projectId)
const providers = profile
? { imageProvider: profile.imageProvider, videoProvider: profile.videoProvider }
? {
imageProvider: profile.imageProvider,
videoProvider: profile.videoProvider,
imageGenerationOptions: { ...profile.imageOptions }
}
: undefined
const [project, checkpoints, forms, plan, status] = await Promise.all([
projectsApi.detail(projectId),
@@ -32,6 +42,8 @@ export async function checkPipeline(projectId: string) {
)
throw new Error('预检返回了其他项目的数据,请重新读取。')
const issues: string[] = []
if (plan.entryReadiness && !plan.entryReadiness.ready)
issues.push(plan.entryReadiness.reason || '项目尚未满足生产入口条件。')
if (!profile) issues.push('尚未配置项目画布与生成模型,请先在批量生产工具中保存配置。')
const shotIds = new Set(plan.details.keyframes.map(item => item.shotId))
if (
@@ -68,23 +80,56 @@ export async function checkPipeline(projectId: string) {
status,
profile,
shotCount: plan.keyframes.total,
input: { ...scope, ...providers } as ProductionStartInput,
checkedAt: new Date().toISOString()
}
}
/** 预检不付费;确认后再次预检并锁住本浏览器项目,长请求不自动重发。 */
/**
* 预检不付费;确认后再次预检并锁住本浏览器项目,长请求不自动重发。
* @returns 生产范围、预检状态及一次性提交操作
*/
export function useAdvancedProduction() {
const context = useProjectContext()
/** 当前项目 ID。 */
const id = computed(() => context.project.value?.id ?? '')
/** 项目级操作锁。 */
const operation = computed(() => getOperation(id.value))
/** 项目生产回执。 */
const session = computed(() => getProductionSession(id.value))
const execution = useWorkflowExecution(id, 'production')
/** 正在读取预检。 */
const checking = ref(false)
/** 预检错误或已有任务说明。 */
const error = ref('')
/** 默认使用无视频测试模式,只有用户明确切换后才允许提交高费用视频任务。 */
const safeMode = ref(true)
/** 本轮有限首帧数量,保留原安全模式字段。 */
const testKeyframeLimit = ref<number | null>(1)
/** 恢复起点;留空从默认入口开始。 */
const startFrom = ref<ProductionStage | null>(null)
/** 显式结束阶段;安全模式下为空时默认在视频提示词后停止。 */
const stopAfter = ref<ProductionStage | null>(null)
/** 本轮稳定身份母版上限。 */
const stableIdentityAnchorLimit = ref<number | null>(1)
/** 本轮主体图片上限。 */
const subjectImageLimit = ref<number | null>(1)
/** 本轮视频提示词上限。 */
const videoPromptLimit = ref<number | null>(1)
/** 可供界面和确认描述共用的生产范围。 */
const scope = computed<ProductionStartInput>(() => ({
...(startFrom.value ? { startFrom: startFrom.value } : {}),
...(stopAfter.value || safeMode.value ? { stopAfter: stopAfter.value ?? 'videoPrompts' } : {}),
stableIdentityAnchorLimit: stableIdentityAnchorLimit.value ?? 0,
subjectImageLimit: subjectImageLimit.value ?? 0,
keyframeLimit: testKeyframeLimit.value ?? 0,
videoPromptLimit: videoPromptLimit.value ?? 0
}))
/** 阶段顺序与后端正整数约束。 */
const scopeError = computed(() => validateProductionScope(scope.value))
/** 已读取的预检与其不可变请求快照。 */
const check = ref<Awaited<ReturnType<typeof checkPipeline>> | null>(null)
/** 当前项目不可提交条件。 */
const blocked = computed(
() =>
!id.value ||
@@ -106,15 +151,27 @@ export function useAdvancedProduction() {
checking.value = false
})
watch(
[scope, safeMode],
() => {
version++
check.value = null
checking.value = false
error.value = ''
},
{ deep: true, flush: 'sync' }
)
/** 只读取无消耗计划,保存此次范围与模型参数。 */
async function preflight() {
if (blocked.value || checking.value) return
if (blocked.value || checking.value || scopeError.value) return
const current = ++version
const projectId = id.value
checking.value = true
check.value = null
error.value = ''
try {
const result = await checkPipeline(projectId)
const result = await checkPipeline(projectId, scope.value)
if (current === version && id.value === projectId) check.value = result
} catch (cause) {
if (current === version) error.value = errorMessage(cause)
@@ -123,9 +180,11 @@ export function useAdvancedProduction() {
}
}
/** 确认后校验参数快照并提交一次;冲突时观察现有任务。 */
async function start() {
if (
blocked.value ||
!!scopeError.value ||
checking.value ||
!check.value ||
check.value.projectId !== id.value ||
@@ -134,36 +193,49 @@ export function useAdvancedProduction() {
return
const projectId = id.value
const target = getProductionSession(projectId)
const confirmedInput = JSON.stringify(check.value.input)
const confirmedVersion = version
let submitted = false
await runOperation(projectId, '高级串联生产', async () => {
const result = await checkPipeline(projectId)
const result = await checkPipeline(projectId, scope.value)
if (
confirmedVersion !== version ||
disposed ||
id.value !== projectId ||
context.project.value?.status !== 'completed' ||
context.error.value
)
return
if (JSON.stringify(result.input) !== confirmedInput) {
check.value = null
throw new Error('项目模型或图片参数已变化,请重新预检并确认费用。')
}
check.value = result
if (result.issues.length) throw new Error('提交前预检发现条件变化,未启动生产。请处理下方问题。')
target.pipelineReceipt = null
submitted = true
const started = await productionApi.startPipeline(projectId, {
...(result.profile
? {
imageProvider: result.profile.imageProvider,
videoProvider: result.profile.videoProvider
}
: {}),
...(safeMode.value
? {
stopAfter: 'videoPrompts' as const,
...(testKeyframeLimit.value ? { keyframeLimit: testKeyframeLimit.value } : {})
}
: {})
})
let started
try {
started = await productionApi.startPipeline(projectId, result.input)
} catch (cause) {
if (
cause instanceof ApiError &&
cause.status === 409 &&
cause.details &&
typeof cause.details === 'object' &&
'executionId' in cause.details &&
typeof cause.details.executionId === 'string' &&
cause.details.executionId
) {
if (!disposed && id.value === projectId)
error.value = '已有任务:已附着当前生产后台任务,请等待其结束。'
await execution.track(cause.details.executionId, projectId)
return
}
throw cause
}
if (!started.executionId) throw new Error('后端未返回 Production executionId,请勿重复提交。')
await execution.track(started.executionId)
await execution.track(started.executionId, projectId)
})
if (!disposed && id.value === projectId) {
if (submitted) check.value = null
@@ -194,17 +266,48 @@ export function useAdvancedProduction() {
blocked,
safeMode,
testKeyframeLimit,
startFrom,
stopAfter,
stableIdentityAnchorLimit,
subjectImageLimit,
videoPromptLimit,
scope,
scopeError,
preflight,
start
}
}
/** WorkflowExecution.result 只在完成后转成串联生产回执,运行中绝不伪造完成状态。 */
function targetPipelineReceipt(
projectId: string,
result: object,
session: ReturnType<typeof getProductionSession>
) {
/**
* 完成任务结果只在项目归属正确时保存为回执。
* @param projectId 当前项目 ID
* @param result 后端真实完成结果
* @param session 当前项目回执容器
*/
function targetPipelineReceipt(projectId: string, result: object, session: ReturnType<typeof getProductionSession>) {
if (!projectId || !('projectId' in result) || result.projectId !== projectId) return
session.pipelineReceipt = result as import('./types').ProductionPipelineResult
}
/**
* 验证后端阶段枚举、顺序和本轮生成上限。
* @param input 本轮启动范围
* @returns 可直接展示的阻断原因;空字符串表示有效
*/
export function validateProductionScope(input: ProductionStartInput): string {
const stages: ProductionStage[] = ['subjectImages', 'keyframes', 'videoPrompts']
if (
(input.startFrom && !stages.includes(input.startFrom)) ||
(input.stopAfter && !stages.includes(input.stopAfter))
)
return '请选择有效的生产阶段。'
if (input.startFrom && input.stopAfter && stages.indexOf(input.startFrom) > stages.indexOf(input.stopAfter))
return '结束阶段不能早于起始阶段。'
if (
[input.stableIdentityAnchorLimit, input.subjectImageLimit, input.keyframeLimit, input.videoPromptLimit].some(
value => value !== undefined && (!Number.isInteger(value) || value <= 0)
)
)
return '所有生成上限必须是大于 0 的整数。'
return ''
}
+87 -17
View File
@@ -1,7 +1,9 @@
import type { KeyframeBatchResult } from './types'
import type { PromptBatchResult } from '../storyboard/types'
import { computed, ref, watch } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { useProjectContext } from '../projects/context'
import { mergeDesignedShots } from '../storyboard/model'
import { currentEpisodeSource, getStoryboardSession, mergeDesignedShots } from '../storyboard/model'
import { storyboardApi } from '../storyboard/api'
import { breakdownSnapshot } from '../workflows/selectors'
import { getOperation, runOperation } from '../workflows/operations'
@@ -17,22 +19,37 @@ export type ProductionCommand = 'prompts' | 'keyframes' | 'videos' | 'retry-vide
/** 镜头生产页的查询、筛选、就绪状态与批量操作。 */
export function useProduction() {
const context = useProjectContext()
/** 当前工作区的响应式状态或派生业务条件。 */
const id = computed(() => context.project.value?.id ?? '')
/** 当前工作区的响应式状态或派生业务条件。 */
const selectedEpisode = ref<number>()
/** 当前工作区的响应式状态或派生业务条件。 */
const selectedShot = ref('')
/** 当前工作区的响应式状态或派生业务条件。 */
const concurrency = ref(2)
/** 当前工作区的响应式状态或派生业务条件。 */
const force = ref(false)
/** 当前工作区的响应式状态或派生业务条件。 */
const keyframeLimit = ref<number | ''>('')
/** 当前工作区的响应式状态或派生业务条件。 */
const keyframeWidth = ref<number | ''>('')
/** 当前工作区的响应式状态或派生业务条件。 */
const keyframeHeight = ref<number | ''>('')
/** 当前工作区的响应式状态或派生业务条件。 */
const promptLimit = ref<number | null>(1)
/** 当前工作区的响应式状态或派生业务条件。 */
const videoLimit = ref<number | null>(1)
/** 当前工作区的响应式状态或派生业务条件。 */
const videoRepairAttempts = ref<number | null>(2)
/** 当前工作区的响应式状态或派生业务条件。 */
const videoInputMode = ref<VideoInputMode | 'all'>('all')
/** 当前工作区的响应式状态或派生业务条件。 */
const snapshot = computed(() => breakdownSnapshot(context.checkpoints.value))
/** 当前工作区的响应式状态或派生业务条件。 */
const sourceEpisodes = computed(
() => snapshot.value?.storyboardEpisodeShots ?? snapshot.value?.breakdownResult?.storyboardEpisodeShots ?? []
)
/** 当前工作区的响应式状态或派生业务条件。 */
const episodeOptions = computed(() => {
const entries = new Map(context.project.value?.episodes.map(episode => [episode.episode, episode.title]) ?? [])
for (const episode of sourceEpisodes.value) {
@@ -42,12 +59,14 @@ export function useProduction() {
.map(([episodeNo, title]) => ({ episodeNo, title }))
.toSorted((a, b) => a.episodeNo - b.episodeNo)
})
/** 当前工作区的响应式状态或派生业务条件。 */
const episodeNo = computed(
() =>
episodeOptions.value.find(item => item.episodeNo === selectedEpisode.value)?.episodeNo ??
episodeOptions.value[0]?.episodeNo ??
0
)
/** 当前工作区的响应式状态或派生业务条件。 */
const queryKey = computed(() => JSON.stringify([id.value, episodeNo.value, force.value]))
/** 生产页已有刷新按钮,就绪状态改为手动更新。 */
const query = usePolling(
@@ -80,23 +99,48 @@ export function useProduction() {
},
false
)
const source = computed(() => sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value))
/** 当前工作区的响应式状态或派生业务条件。 */
/** 重生成后不拿旧剧情快照补充新的正式镜头。 */
const source = computed(() =>
currentEpisodeSource(
id.value,
episodeNo.value,
sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value)
)
)
/** 未取得重生成后的正文时,只展示正式镜头编号,不填充旧剧情或时长。 */
const episodeSourceUnavailable = computed(
() => !!getStoryboardSession(id.value).invalidatedEpisodeSources[episodeNo.value]
)
/** 当前工作区的响应式状态或派生业务条件。 */
const shots = computed(() => mergeDesignedShots(query.data.value?.directions ?? null, null, source.value))
/** 当前工作区的响应式状态或派生业务条件。 */
const shot = computed(() => shots.value.find(item => item.shotId === selectedShot.value) ?? shots.value[0])
/** 当前工作区的响应式状态或派生业务条件。 */
const promptItem = computed(() => query.data.value?.prompts.items.find(item => item.shotId === shot.value?.shotId))
/** 当前工作区的响应式状态或派生业务条件。 */
const keyframeItem = computed(() =>
query.data.value?.keyframes.items.find(item => item.shotId === shot.value?.shotId)
)
/** 当前工作区的响应式状态或派生业务条件。 */
const videoItem = computed(() => query.data.value?.videos.items.find(item => item.shotId === shot.value?.shotId))
/** 当前工作区的响应式状态或派生业务条件。 */
const videoStatusItem = computed(() =>
query.data.value?.videoStatus.items.find(item => item.shotId === shot.value?.shotId)
)
/** 当前工作区的响应式状态或派生业务条件。 */
const operation = computed(() => getOperation(id.value))
/** 当前工作区的响应式状态或派生业务条件。 */
const session = computed(() => getProductionSession(id.value))
/** 普通首帧后台观察器,刷新页面后恢复真实执行状态。 */
const keyframeExecution = useWorkflowExecution(id, 'keyframe-generation')
const promptExecution = useWorkflowExecution(id, 'video-prompt')
const videoExecution = useWorkflowExecution(id, 'video-quality')
/** 当前工作区的响应式状态或派生业务条件。 */
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
/** 当前工作区的响应式状态或派生业务条件。 */
const promptValid = computed(() => Number.isSafeInteger(promptLimit.value) && (promptLimit.value ?? 0) > 0)
/** 当前工作区的响应式状态或派生业务条件。 */
const keyframeValid = computed(
() =>
(keyframeLimit.value === '' || (Number.isSafeInteger(keyframeLimit.value) && keyframeLimit.value > 0)) &&
@@ -110,6 +154,7 @@ export function useProduction() {
Number.isSafeInteger(videoRepairAttempts.value) &&
(videoRepairAttempts.value ?? 0) > 0
)
/** 当前工作区的响应式状态或派生业务条件。 */
const blocked = computed(
() =>
operation.value.pending ||
@@ -128,13 +173,39 @@ export function useProduction() {
if ((status === 'completed' || status === 'failed') && status !== previous) void query.refresh()
}
)
/** 观察后台状态变化并同步正式资产。 */
watch(
() => promptExecution.query.data.value?.status,
(status, previous) => {
const record = promptExecution.query.data.value
if (status === 'completed' && record?.projectId === id.value && record.result) {
const result = record.result as unknown as PromptBatchResult
if (typeof result.total === 'number' && Array.isArray(result.failures)) {
getProductionSession(record.projectId).receipt = {
kind: 'prompts',
title: '项目视频提示词',
result
}
}
}
if ((status === 'completed' || status === 'failed') && status !== previous) void query.refresh()
}
)
/** 普通首帧任务完成后才展示后端回执;失败仍刷新已经保存的资产。 */
watch(
() => keyframeExecution.query.data.value,
record => {
if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return
if (record.status === 'completed' && record.result) {
const result = record.result as unknown as KeyframeBatchResult
if (typeof result.total !== 'number' || !Array.isArray(result.failures)) return
getProductionSession(record.projectId).receipt = { kind: 'keyframes', title: '项目首帧生成', result }
}
void query.refresh()
}
)
/** 批量操作只向就绪镜头提交;最终资产状态由轮询查询确认。 */
async function run(command: ProductionCommand) {
if (
@@ -172,21 +243,18 @@ export function useProduction() {
episodeNo: episodeNo.value,
limit: promptLimit.value ?? undefined
})
await promptExecution.track(started.executionId)
await promptExecution.track(started.executionId, projectId)
} else if (command === 'keyframes') {
target.receipt = {
kind: 'keyframes',
title: labels[command],
result: await productionApi.generateKeyframes(projectId, {
...input,
// 有 stale 时由后端优先处理全部 stale;否则只补当前剧集,避免误跑整个项目。
...(force.value || staleKeyframes > 0 ? {} : { episodeNo: episodeNo.value }),
...(keyframeLimit.value === '' ? {} : { limit: keyframeLimit.value }),
...(keyframeWidth.value === '' || keyframeHeight.value === ''
? {}
: { width: keyframeWidth.value, height: keyframeHeight.value })
})
}
const started = await productionApi.generateKeyframes(projectId, {
...input,
// 有 stale 时由后端优先处理全部 stale;否则只补当前剧集,避免误跑整个项目。
...(force.value || staleKeyframes > 0 ? {} : { episodeNo: episodeNo.value }),
...(keyframeLimit.value === '' ? {} : { limit: keyframeLimit.value }),
...(keyframeWidth.value === '' || keyframeHeight.value === ''
? {}
: { width: keyframeWidth.value, height: keyframeHeight.value })
})
await keyframeExecution.track(started.executionId, projectId)
} else if (command === 'videos') {
const started = await productionApi.startQualityVideoExecution(projectId, {
...input,
@@ -195,7 +263,7 @@ export function useProduction() {
...(videoInputMode.value === 'all' ? {} : { inputMode: videoInputMode.value }),
maxRepairAttempts: videoRepairAttempts.value ?? 0
})
await videoExecution.track(started.executionId)
await videoExecution.track(started.executionId, projectId)
} else {
target.receipt = {
kind: 'retry',
@@ -220,6 +288,7 @@ export function useProduction() {
videoItem,
videoStatusItem,
query,
episodeSourceUnavailable,
operation,
session,
concurrency,
@@ -237,6 +306,7 @@ export function useProduction() {
batchValid,
blocked,
run,
keyframeExecution,
promptExecution,
videoExecution
}
+95 -25
View File
@@ -1,4 +1,6 @@
import { computed, onScopeDispose } from 'vue'
import { computed, onScopeDispose, watch } from 'vue'
import { useWorkflowExecution } from '../workflows/execution'
import { isQualityBatchResult } from './quality'
import { projectsApi } from '../projects/api'
import { hasRunningWorkflow } from '../workflows/selectors'
import { getOperation, runOperation } from '../workflows/operations'
@@ -26,22 +28,82 @@ function validAttempts(attempts: RepairAttempt[]) {
)
}
/** 统一质量操作:只读预检 → 显式付费请求 → 按原目标保存回执,不自动重试。 */
/**
* 只读预检后显式启动质量操作,按原目标保存回执与后台状态。
* @param props 当前项目、目标和阻断状态
* @param visible 弹窗是否仍可见
* @param changed 原项目资产刷新通知
* @param started 后台启动编号通知
* @returns 质量会话、任务状态与执行入口
*/
export function useQuality(
props: { projectId: string; target: QualityTarget | null; disabled: boolean },
visible: () => boolean,
changed: () => void
changed: () => void,
started: (executionId: string) => void = () => {}
) {
/** 原项目与目标共同隔离结果。 */
const key = computed(() => qualityKey(props.projectId, props.target))
/** 当前目标的会话回执。 */
const session = computed(() => qualitySession(key.value))
/** 当前项目的短操作锁。 */
const operation = computed(() => getOperation(props.projectId))
const blocked = computed(() => props.disabled || operation.value.pending || !props.target || !props.projectId)
/** 按项目恢复后台句柄,关闭弹窗仍继续观察。 */
const execution = useWorkflowExecution(
computed(() => props.projectId),
'keyframe-quality'
)
/** 已结束任务只写入其原始范围的回执。 */
const handled = new Set<string>()
/** 后台任务阻止重复启动。 */
const blocked = computed(
() => props.disabled || operation.value.pending || execution.active.value || !props.target || !props.projectId
)
/** 完成后由 metadata 恢复原目标;当前目标变化不改变任务归属。 */
watch(
() => execution.query.data.value,
record => {
if (
!record ||
record.projectId !== props.projectId ||
record.workflowName !== 'keyframe-quality' ||
!['completed', 'failed'].includes(record.status) ||
handled.has(record.id)
)
return
handled.add(record.id)
const metadata = record.metadata
const episodeNo = metadata?.episodeNo
if (typeof episodeNo !== 'number') return
const target: QualityTarget = {
kind: 'batch',
episodeNo,
title: '',
...(typeof metadata?.shotId === 'string' ? { shotId: metadata.shotId } : {})
}
const original = qualitySession(qualityKey(record.projectId, target))
if (record.status === 'failed') original.error = record.error || '首帧质量后台任务失败,请核对已完成资产。'
else if (
isQualityBatchResult(record.result) &&
record.result.results.every(item => !target.shotId || item.shotId === target.shotId) &&
(typeof metadata?.limit !== 'number' || record.result.targetCount <= metadata.limit)
)
original.receipt = { kind: 'batch', result: record.result }
else original.error = '后台最终回执不完整或范围不匹配,请核对资产,不要重复生成。'
changed()
}
)
let disposed = false
onScopeDispose(() => {
disposed = true
})
/** 确认之后重新读取后端状态;打开弹窗和查看结果不会调用此函数。 */
/**
* 确认之后重读状态并只提交一次,固定原目标与费用范围。
* @param action 已确认的质量操作
* @param input 已确认的参数
* @returns 操作结束通知,后台生成由持久化任务继续跟踪
*/
async function run(action: QualityAction, input: QualityInput) {
if (blocked.value || !visible() || !props.target || !validQualityInput(input)) return
const target = { ...props.target }
@@ -50,10 +112,20 @@ export function useQuality(
(target.kind === 'video' && action === 'repair' && input.maxRepairAttempts <= 0)
)
return
if (target.kind === 'batch' && input.episodeNo !== target.episodeNo) return
if (
target.kind === 'batch' &&
(input.episodeNo !== target.episodeNo ||
input.shotId !== target.shotId ||
(target.shotId && input.limit !== 1))
)
return
const projectId = props.projectId
// 固定本次确认的参数,预检期间的表单变化不能扩大已确认的生成范围。
input = { ...input, allowedTexts: input.allowedTexts?.slice() }
input = {
...input,
allowedTexts: input.allowedTexts?.slice(),
generationOptions: input.generationOptions ? { ...input.generationOptions } : undefined
}
const originalKey = key.value
const receiptTarget = qualitySession(originalKey)
receiptTarget.receipt = null
@@ -90,11 +162,13 @@ export function useQuality(
if (!targets.length)
throw new Error(
readiness.stalePrimaryKeyframe > 0
? '当前集没有可更新的过期首帧;后端优先处理全项目过期项,请切换剧集。'
? '当前范围没有可执行的首帧质量镜头,请刷新就绪状态。'
: '当前集没有符合条件的镜头;请补齐设计与参考图,或明确选择重做有效首帧。'
)
// 逐镜只读检查已选的小批量;任何模型能力不足都不启动本批付费流水线。
const capabilities = await Promise.all(targets.map(item => qualityApi.capability(item.shotId)))
const capabilities = await Promise.all(
targets.map(item => qualityApi.capability(item.shotId, undefined, input.provider))
)
const invalid = capabilities.find(item => item.valid !== true)
if (invalid) throw new Error(invalid.message || '当前图片模型不支持所需参考图。')
const assets = await Promise.all(targets.map(item => productionApi.listKeyframes(item.shotId)))
@@ -112,22 +186,18 @@ export function useQuality(
const result = await qualityApi.generate(projectId, input)
if (
!result ||
!Array.isArray(result.results) ||
![result.targetCount, result.passed, result.repairFailed, result.failed, result.selected].every(
value => Number.isSafeInteger(value) && value >= 0
) ||
result.targetCount > input.limit ||
result.results.length !== result.targetCount ||
result.passed + result.repairFailed + result.failed !== result.targetCount ||
result.results.some(
item =>
!readiness.items.some(
shot => shot.shotId === item.shotId && shot.episodeNo === input.episodeNo
) || typeof item.success !== 'boolean'
)
result.projectId !== projectId ||
typeof result.executionId !== 'string' ||
!result.executionId ||
result.status !== 'running' ||
!Number.isSafeInteger(result.total) ||
result.total < 0 ||
result.total > input.limit
)
throw new Error('质量流水线回执不完整,请先核对资产,不要重复提交。')
receipt = { kind: 'batch', result }
throw new Error('后台启动回执不完整,请刷新状态,不要重复提交。')
await execution.track(result.executionId, projectId)
if (!disposed && props.projectId === projectId) started(result.executionId)
return
} else {
if (!readiness.items.some(item => item.shotId === target.shotId))
throw new Error('指定镜头不属于当前项目,未提交质量任务。')
@@ -245,5 +315,5 @@ export function useQuality(
// 已提交请求即使切换页面也归原会话;只刷新仍在查看的原项目。
if (!disposed && props.projectId === projectId) changed()
}
return { key, session, operation, blocked, run }
return { key, session, operation, execution, blocked, run }
}