feat(short-drama-agent-front): 补齐后端生产与质量功能
This commit is contained in:
1 parent
967c4ebea1
commit
470b52e26d
52 files changed
+3754
-1075
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { NAlert, NButton } from 'naive-ui'
|
||||
|
||||
/** 只读诊断模块的展示参数。 */
|
||||
interface Props {
|
||||
/** 模块标题,同时用作无障碍名称。 */
|
||||
title: string
|
||||
/** 查询说明。 */
|
||||
description?: string
|
||||
/** 当前是否正在读取。 */
|
||||
loading?: boolean
|
||||
/** 当前查询错误。 */
|
||||
error?: string
|
||||
}
|
||||
/** 多个历史和诊断入口共用折叠、刷新与错误展示。 */
|
||||
defineProps<Props>()
|
||||
/** 展开状态由调用方决定,只在展开后读取诊断。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 显式刷新只发出读取事件,不产生任何生成或修复操作。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是只读诊断的标题、展开与手动刷新模块 -->
|
||||
<section class="workspace-panel text-xs leading-6" :aria-label="title">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<strong>{{ title }}</strong>
|
||||
<div class="flex items-center gap-3">
|
||||
<NButton text size="small" :aria-label="`${open ? '收起' : '查看'}${title}`" @click="open = !open">
|
||||
{{ open ? '收起' : '查看' }}
|
||||
</NButton>
|
||||
<NButton
|
||||
v-if="open"
|
||||
text
|
||||
size="small"
|
||||
:loading="loading"
|
||||
:aria-label="`刷新${title}`"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
刷新
|
||||
</NButton>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="description" class="mt-1 text-muted">{{ description }}</p>
|
||||
<!-- 以下是读取状态、错误与实际诊断结果模块 -->
|
||||
<div v-if="open" class="mt-3">
|
||||
<NAlert v-if="error" type="error" :show-icon="false" role="alert">{{ error }}</NAlert>
|
||||
<p v-if="loading" class="text-muted" role="status">正在读取后端记录…</p>
|
||||
<slot v-else />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 ''
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { getOperation } from '../workflows/operations'
|
||||
import { projectAccessKey, projectSectionFromPath, type ProjectAccess } from './access'
|
||||
import { useProjectStageAccess } from './useProjectStageAccess'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import { clearEpisodeSourceInvalidations, invalidateEpisodeSource } from '../storyboard/model'
|
||||
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
|
||||
/** 项目标题只保留名称;下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
|
||||
@@ -23,6 +24,39 @@ const context = useProjectData(id)
|
||||
provide(projectContextKey, context)
|
||||
const operation = computed(() => getOperation(id.value))
|
||||
const createDramaExecution = useWorkflowExecution(id, 'create-drama')
|
||||
/** 项目内跨页面继续观察首帧后台任务,维持活动锁并在真实终态后释放。 */
|
||||
useWorkflowExecution(id, 'keyframe-quality')
|
||||
/** 既有生成入口在跨页面时继续观察,保持项目活动锁。 */
|
||||
for (const workflowName of [
|
||||
'storyboard-direction',
|
||||
'storyboard-visual-state',
|
||||
'video-prompt',
|
||||
'keyframe-generation',
|
||||
'video-quality'
|
||||
]) {
|
||||
useWorkflowExecution(id, workflowName)
|
||||
}
|
||||
/** 即使直接刷新到生产页,也按真实重生成任务恢复旧剧情快照的失效标记。 */
|
||||
const breakdownExecution = useWorkflowExecution(id, 'breakdown')
|
||||
/** 只有后端确认有效的新分镜才废弃旧正文,不推测未完成或失败任务。 */
|
||||
watchEffect(() => {
|
||||
const record = breakdownExecution.query.data.value
|
||||
if (!record || record.projectId !== id.value || record.status !== 'completed') return
|
||||
if (record.metadata?.action !== 'regenerate-storyboard-episode') {
|
||||
if (record.metadata?.action === 'start') clearEpisodeSourceInvalidations(record.projectId)
|
||||
return
|
||||
}
|
||||
const number = record.metadata.episodeNo
|
||||
const validation = record.result?.storyboardShotValidation
|
||||
if (
|
||||
typeof number === 'number' &&
|
||||
validation &&
|
||||
typeof validation === 'object' &&
|
||||
'valid' in validation &&
|
||||
validation.valid === true
|
||||
)
|
||||
invalidateEpisodeSource(record.projectId, number)
|
||||
})
|
||||
watchEffect(() => {
|
||||
const status = createDramaExecution.query.data.value?.status
|
||||
if ((status === 'completed' || status === 'failed') && context.project.value?.status === 'generating') {
|
||||
@@ -135,7 +169,7 @@ onScopeDispose(() => {
|
||||
></NAlert
|
||||
>
|
||||
<NAlert v-if="operation.pending" :show-icon="false" role="status"
|
||||
>{{ operation.label }}。可切换页面查看结果,请勿重复提交。</NAlert
|
||||
>{{ operation.label || '后台制作任务执行中' }}。可切换页面查看结果,请勿重复提交。</NAlert
|
||||
>
|
||||
<NAlert v-if="operationGuide" type="error" :show-icon="false" class="operation-guide">
|
||||
<div class="operation-guide-content">
|
||||
@@ -178,11 +212,7 @@ onScopeDispose(() => {
|
||||
>刷新项目状态</NButton
|
||||
>
|
||||
</EmptyState>
|
||||
<NSpin
|
||||
v-else-if="context.loading.value"
|
||||
class="workspace-loading"
|
||||
description="正在读取项目内容…"
|
||||
/>
|
||||
<NSpin v-else-if="context.loading.value" class="workspace-loading" description="正在读取项目内容…" />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -5,17 +5,7 @@ import { integerRule } from '../../lib/form-rules'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import ActionMenu from '../../components/ui/ActionMenu.vue'
|
||||
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import {
|
||||
NScrollbar,
|
||||
NAlert,
|
||||
NButton,
|
||||
NCheckbox,
|
||||
NInputNumber,
|
||||
NProgress,
|
||||
NSelect,
|
||||
NTab,
|
||||
NTabs
|
||||
} from 'naive-ui'
|
||||
import { NScrollbar, NAlert, NButton, NCheckbox, NInputNumber, NProgress, NSelect, NTab, NTabs } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ArrowLeft, RefreshCw } from '@lucide/vue'
|
||||
import { EmptyState } from '../../components/ui'
|
||||
@@ -25,6 +15,9 @@ import GenerationReceipt from './components/GenerationReceipt.vue'
|
||||
import ShotDesign from './components/ShotDesign.vue'
|
||||
import ShotTools from './components/ShotTools.vue'
|
||||
import BeatShotDirectory from './components/BeatShotDirectory.vue'
|
||||
import SubjectCoverageAudit from './components/SubjectCoverageAudit.vue'
|
||||
import type { SubjectCoverageIssue } from './coverage.types'
|
||||
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useStoryboard } from './useStoryboard'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
|
||||
@@ -43,6 +36,7 @@ const {
|
||||
shot,
|
||||
query,
|
||||
data,
|
||||
episodeSourceUnavailable,
|
||||
prerequisites,
|
||||
session,
|
||||
operation,
|
||||
@@ -54,6 +48,7 @@ const {
|
||||
directionComplete,
|
||||
visualStateComplete,
|
||||
hasCurrentEpisodeShots,
|
||||
executions,
|
||||
run
|
||||
} = useStoryboard()
|
||||
const productionReady = computed(() => directionComplete.value && visualStateComplete.value)
|
||||
@@ -90,6 +85,51 @@ function exportEpisode() {
|
||||
}
|
||||
/** 回执到达后打开诊断区;平时留出镜头检查空间。 */
|
||||
const toolsOpen = ref(false)
|
||||
/** 覆盖审计只保存剧集与镜头坐标,正式 ID 从当前查询结果中定位。 */
|
||||
const auditLocation = ref<SubjectCoverageIssue | null>(null)
|
||||
/** 覆盖定位失败时保留明确反馈,不猜测其它镜头。 */
|
||||
const auditLocationError = ref('')
|
||||
|
||||
/**
|
||||
* 切换到引用遗漏发生的剧集,等待正式镜头数据后定位。
|
||||
* @param issue 后端实际覆盖问题
|
||||
*/
|
||||
function locateCoverageIssue(issue: SubjectCoverageIssue) {
|
||||
if (!episodeOptions.value.some(episode => episode.episodeNo === issue.episodeNo)) {
|
||||
auditLocationError.value = '审计中的剧集不在当前项目,请刷新分镜与审计结果。'
|
||||
return
|
||||
}
|
||||
auditLocation.value = issue
|
||||
auditLocationError.value = ''
|
||||
selectedEpisode.value = issue.episodeNo
|
||||
}
|
||||
|
||||
/** 当前集查询完成后按唯一坐标匹配正式镜头;目标缺失时不切到其他镜头。 */
|
||||
watch(
|
||||
[episodeNo, shots, () => query.loading.value, auditLocation],
|
||||
() => {
|
||||
const issue = auditLocation.value
|
||||
if (
|
||||
!issue ||
|
||||
query.loading.value ||
|
||||
episodeNo.value !== issue.episodeNo ||
|
||||
data.value?.directions.episodeNo !== issue.episodeNo
|
||||
)
|
||||
return
|
||||
if (issue.shotNo !== null) {
|
||||
const target = shots.value.find(item => item.beatNo === issue.beatNo && item.shotNo === issue.shotNo)
|
||||
if (!target) {
|
||||
auditLocationError.value = '目标镜头已变化,请刷新后重新检查主体引用。'
|
||||
auditLocation.value = null
|
||||
return
|
||||
}
|
||||
selectedShot.value = target.shotId
|
||||
}
|
||||
toolsOpen.value = false
|
||||
auditLocation.value = null
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
watch(
|
||||
() => session.value.receipt,
|
||||
receipt => {
|
||||
@@ -105,6 +145,9 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<template>
|
||||
<WorkspacePage split compact class="storyboard-workspace-page">
|
||||
<template #notice>
|
||||
<NAlert v-if="episodeSourceUnavailable" type="info" :show-icon="false">
|
||||
本集镜头已重新生成。新标题和剧情详情尚未提供,当前只显示正式镜头编号;请按实际生成规格核对内容。
|
||||
</NAlert>
|
||||
<NAlert v-if="stageComplete" type="success" :show-icon="false">
|
||||
分镜设计已经准备完成,可以继续生成首帧、视频提示词和视频。
|
||||
<RouterLink :to="`/projects/${id}/production`" class="text-button ml-2">继续镜头生产 →</RouterLink>
|
||||
@@ -226,109 +269,124 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
</div>
|
||||
<div class="workspace-overview-panel">
|
||||
<div class="overview-content workspace-section-stack">
|
||||
<!-- 以下是零费用主体引用覆盖检查模块 -->
|
||||
<SubjectCoverageAudit :project-id="id" @locate="locateCoverageIssue" />
|
||||
<NAlert v-if="auditLocationError" type="warning" :show-icon="false">{{
|
||||
auditLocationError
|
||||
}}</NAlert>
|
||||
<h3 class="mb-3 text-sm font-semibold">生成与恢复</h3>
|
||||
<div class="generation-row">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">
|
||||
<span class="mr-2 font-mono text-xs text-muted">00</span
|
||||
>本集镜头拆解
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
只重新拆解当前选择的第
|
||||
{{ episodeNo }}
|
||||
集,其它剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:label="`重生成第 ${episodeNo} 集镜头`"
|
||||
:disabled="!allowed['shots-current']"
|
||||
acknowledgement
|
||||
:description="`将删除并重建第 ${episodeNo} 集的正式镜头。该集已有导演设计、即时状态、首帧、提示词和视频结果会随旧镜头一并失效,且无法撤销;其它剧集保持不变。`"
|
||||
@confirm="run('shots-current')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!hasCurrentEpisodeShots" class="mt-3 text-[11px] text-muted">
|
||||
当前集还没有可用镜头,请先完成剧本拆解。
|
||||
<div class="generation-row">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">
|
||||
<span class="mr-2 font-mono text-xs text-muted">00</span>本集镜头拆解
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
只重新拆解当前选择的第
|
||||
{{ episodeNo }}
|
||||
集,其它剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
|
||||
</p>
|
||||
<div class="generation-row">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">
|
||||
<span class="mr-2 font-mono text-xs text-muted">01</span
|
||||
>导演摄影设计
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
景别、机位、运镜与构图。正式项目生成默认跳过已完整剧集,覆盖模式会重新生成全部剧集。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部导演设计' : '补齐项目导演设计'"
|
||||
:disabled="!allowed['direction-all']"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '重新生成项目全部剧集的导演设计,覆盖已有结果。'
|
||||
: '对整个项目生成导演设计,跳过已完整保存的剧集,可用于重试失败或未完成的剧集。'
|
||||
"
|
||||
@confirm="run('direction-all')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="generation-row">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">
|
||||
<span class="mr-2 font-mono text-xs text-muted">02</span
|
||||
>即时视觉状态
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
表情、姿态、位置、环境与连续性。每集需要完整导演设计;批量中缺少前置设计的剧集会单独报错。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部即时状态' : '补齐项目即时状态'"
|
||||
:disabled="!allowed['visual-all']"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '重新生成整个项目的即时状态,覆盖已有结果。每集必须先有完整导演设计。'
|
||||
: '补齐项目即时状态,跳过完整剧集;未完成导演设计的剧集会返回失败原因。'
|
||||
"
|
||||
@confirm="run('visual-all')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-4 text-[11px] leading-6 text-muted">
|
||||
修改或覆盖前面的设计后,已有状态和视频提示词不会自动更新;请按顺序重新生成后续内容。自动修复次数仅用于
|
||||
VisualState。
|
||||
</p>
|
||||
<section>
|
||||
<h3 class="text-sm font-semibold">视频提示词批量操作</h3>
|
||||
<p class="my-3 text-xs leading-6 text-muted">
|
||||
生成前会检查镜头设计和主体参考图是否齐全。这里只生成提示词;首帧、视频任务、状态检查与失败重试已整理到
|
||||
<RouterLink
|
||||
:to="`/projects/${id}/production`"
|
||||
class="text-button mx-1"
|
||||
>镜头生产</RouterLink
|
||||
>。
|
||||
</p>
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部视频提示词' : '补齐项目视频提示词'"
|
||||
:disabled="!allowed.prompts"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '调用模型重新生成全项目镜头的视频提示词,覆盖已有正文。'
|
||||
: '调用模型生成缺少视频提示词的镜头,已有提示词直接跳过。参考图缺失会返回失败。'
|
||||
"
|
||||
@confirm="run('prompts')" />
|
||||
</section>
|
||||
<GenerationReceipt
|
||||
v-if="session.receipt"
|
||||
:receipt="session.receipt"
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:label="`重生成第 ${episodeNo} 集镜头`"
|
||||
:disabled="!allowed['shots-current']"
|
||||
acknowledgement
|
||||
:description="`将删除并重建第 ${episodeNo} 集的正式镜头。该集已有导演设计、即时状态、首帧、提示词和视频结果会随旧镜头一并失效,且无法撤销;其它剧集保持不变。`"
|
||||
@confirm="run('shots-current')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!hasCurrentEpisodeShots" class="mt-3 text-[11px] text-muted">
|
||||
当前集还没有可用镜头,请先完成剧本拆解。
|
||||
</p>
|
||||
<div class="generation-row">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">
|
||||
<span class="mr-2 font-mono text-xs text-muted">01</span>导演摄影设计
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
景别、机位、运镜与构图。正式项目生成默认跳过已完整剧集,覆盖模式会重新生成全部剧集。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部导演设计' : '补齐项目导演设计'"
|
||||
:disabled="!allowed['direction-all']"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '重新生成项目全部剧集的导演设计,覆盖已有结果。'
|
||||
: '对整个项目生成导演设计,跳过已完整保存的剧集,可用于重试失败或未完成的剧集。'
|
||||
"
|
||||
@confirm="run('direction-all')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="generation-row">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">
|
||||
<span class="mr-2 font-mono text-xs text-muted">02</span>即时视觉状态
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
表情、姿态、位置、环境与连续性。每集需要完整导演设计;批量中缺少前置设计的剧集会单独报错。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部即时状态' : '补齐项目即时状态'"
|
||||
:disabled="!allowed['visual-all']"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '重新生成整个项目的即时状态,覆盖已有结果。每集必须先有完整导演设计。'
|
||||
: '补齐项目即时状态,跳过完整剧集;未完成导演设计的剧集会返回失败原因。'
|
||||
"
|
||||
@confirm="run('visual-all')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-4 text-[11px] leading-6 text-muted">
|
||||
修改或覆盖前面的设计后,已有状态和视频提示词不会自动更新;请按顺序重新生成后续内容。自动修复次数仅用于
|
||||
VisualState。
|
||||
</p>
|
||||
<section>
|
||||
<h3 class="text-sm font-semibold">视频提示词批量操作</h3>
|
||||
<p class="my-3 text-xs leading-6 text-muted">
|
||||
生成前会检查镜头设计和主体参考图是否齐全。这里只生成提示词;首帧、视频任务、状态检查与失败重试已整理到
|
||||
<RouterLink :to="`/projects/${id}/production`" class="text-button mx-1"
|
||||
>镜头生产</RouterLink
|
||||
>。
|
||||
</p>
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成全部视频提示词' : '补齐项目视频提示词'"
|
||||
:disabled="!allowed.prompts"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '调用模型重新生成全项目镜头的视频提示词,覆盖已有正文。'
|
||||
: '调用模型生成缺少视频提示词的镜头,已有提示词直接跳过。参考图缺失会返回失败。'
|
||||
"
|
||||
@confirm="run('prompts')"
|
||||
/>
|
||||
</section>
|
||||
<!-- 以下是正式分镜后台执行状态模块 -->
|
||||
<WorkflowExecutionPanel
|
||||
v-for="entry in executions.filter(
|
||||
item =>
|
||||
item.observer.executionId.value &&
|
||||
(item.title !== '单集镜头重生成' ||
|
||||
item.observer.query.data.value?.metadata?.action ===
|
||||
'regenerate-storyboard-episode')
|
||||
)"
|
||||
:key="entry.title"
|
||||
:title="entry.title"
|
||||
:execution="entry.observer.query.data.value"
|
||||
:loading="entry.observer.query.loading.value"
|
||||
:error="entry.observer.query.error.value"
|
||||
@refresh="entry.observer.query.refresh"
|
||||
@dismiss="entry.observer.dismiss"
|
||||
/>
|
||||
<GenerationReceipt v-if="session.receipt" :receipt="session.receipt" />
|
||||
</div>
|
||||
</div>
|
||||
</WorkspaceTools>
|
||||
@@ -360,9 +418,9 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
>
|
||||
<strong>Production 前置设计未完成。</strong>
|
||||
当前导演设计 {{ data.directions.directionCount }}/{{ data.directions.shotCount }},即时视觉状态
|
||||
{{ data.visualStates.visualStateCount }}/{{ data.visualStates.shotCount }}。请先补齐后再进入镜头生产,避免
|
||||
后续镜头制作无法开始。
|
||||
</NAlert
|
||||
{{ data.visualStates.visualStateCount }}/{{
|
||||
data.visualStates.shotCount
|
||||
}}。请先补齐后再进入镜头生产,避免 后续镜头制作无法开始。 </NAlert
|
||||
><NAlert
|
||||
v-if="!prerequisites.directionEpisode || !prerequisites.visualEpisode"
|
||||
type="info"
|
||||
@@ -424,7 +482,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
视觉重点:{{ shot.visualFocus }}
|
||||
</p>
|
||||
<p class="mt-3 break-all font-mono text-[10px] text-muted">Shot ID · {{ shot.shotId }}</p>
|
||||
<p class="mt-1 text-[10px] text-muted">
|
||||
<p v-if="!episodeSourceUnavailable" class="mt-1 text-[10px] text-muted">
|
||||
标题与剧情描述取自最近可用 Breakdown 快照;以下设计与状态取自数据库。
|
||||
</p>
|
||||
</header>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
import { request } from '../../lib/http'
|
||||
import type {
|
||||
EpisodeDirections,
|
||||
EpisodeVisualStates,
|
||||
PromptBatchResult,
|
||||
ShotPromptResult,
|
||||
ShotReferences,
|
||||
StoryboardBatchInput,
|
||||
StoryboardBatchResult,
|
||||
StoryboardShotRegenerationResult,
|
||||
VisualStateBatchInput
|
||||
} from './types'
|
||||
import type { ShotGenerationSpec } from './generation-spec.types'
|
||||
@@ -24,9 +22,14 @@ function shotPath(id: string) {
|
||||
|
||||
/** Storyboard 正式路由契约;测试路由不暴露为前端生产入口。 */
|
||||
export const storyboardApi = {
|
||||
/** 强制重生成指定单集的镜头拆解;后端校验通过后才覆盖正式 Storyboard。 */
|
||||
/**
|
||||
* 后台重生成指定单集镜头,终态后再读取正式分镜。
|
||||
* @param id 正式项目 ID
|
||||
* @param episodeNo 目标剧集编号
|
||||
* @returns 真实后台任务观察句柄
|
||||
*/
|
||||
regenerateEpisodeShots: (id: string, episodeNo: number) =>
|
||||
request<StoryboardShotRegenerationResult>(`${projectPath(id)}/storyboard-shots/regenerate`, {
|
||||
request<WorkflowExecutionStart>(`${projectPath(id)}/storyboard-shots/regenerate`, {
|
||||
method: 'POST',
|
||||
body: { episodeNo },
|
||||
timeoutMs: 0
|
||||
@@ -35,14 +38,26 @@ export const storyboardApi = {
|
||||
request<EpisodeDirections>(`${projectPath(id)}/storyboard-directions?episodeNo=${episodeNo}`, { signal }),
|
||||
visualStates: (id: string, episodeNo: number, signal?: AbortSignal) =>
|
||||
request<EpisodeVisualStates>(`${projectPath(id)}/storyboard-visual-states?episodeNo=${episodeNo}`, { signal }),
|
||||
/**
|
||||
* 后台生成项目导演设计。
|
||||
* @param id 正式项目 ID
|
||||
* @param input 并发与覆盖范围
|
||||
* @returns 真实后台任务观察句柄
|
||||
*/
|
||||
generateDirections: (id: string, input: StoryboardBatchInput) =>
|
||||
request<StoryboardBatchResult>(`${projectPath(id)}/storyboard-directions/generate`, {
|
||||
request<WorkflowExecutionStart>(`${projectPath(id)}/storyboard-directions/generate`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 后台生成项目即时状态。
|
||||
* @param id 正式项目 ID
|
||||
* @param input 并发、覆盖与有限修复配置
|
||||
* @returns 真实后台任务观察句柄
|
||||
*/
|
||||
generateVisualStates: (id: string, input: VisualStateBatchInput) =>
|
||||
request<StoryboardBatchResult>(`${projectPath(id)}/storyboard-visual-states/generate`, {
|
||||
request<WorkflowExecutionStart>(`${projectPath(id)}/storyboard-visual-states/generate`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
@@ -59,8 +74,14 @@ export const storyboardApi = {
|
||||
body: { force },
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 后台批量生成项目视频提示词。
|
||||
* @param id 正式项目 ID
|
||||
* @param input 并发与覆盖参数
|
||||
* @returns 真实后台任务观察句柄
|
||||
*/
|
||||
generatePrompts: (id: string, input: StoryboardBatchInput) =>
|
||||
request<PromptBatchResult>(`${projectPath(id)}/video-prompts/generate`, {
|
||||
request<WorkflowExecutionStart>(`${projectPath(id)}/video-prompts/generate`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { NAlert, NButton } from 'naive-ui'
|
||||
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { auditSubjectCoverage } from '../coverage-api'
|
||||
import type { SubjectCoverageIssue } from '../coverage.types'
|
||||
|
||||
/** 审计范围始终是当前正式项目。 */
|
||||
const props = defineProps<{ /** 项目 ID。 */ projectId: string }>()
|
||||
/** 定位只交给当前分镜页处理,不自行拼接猜测的镜头 ID。 */
|
||||
const emit = defineEmits<{ locate: [issue: SubjectCoverageIssue] }>()
|
||||
/** 展开才会读取零费用审计结果。 */
|
||||
const open = ref(false)
|
||||
/** 项目或展开状态变化时清空旧审计。 */
|
||||
const key = computed(() => (open.value ? props.projectId : ''))
|
||||
/** 请求取消和迟到响应保护复用公共查询。 */
|
||||
const query = useQuery(key, async (projectId, signal) => {
|
||||
if (!projectId) return null
|
||||
const result = await auditSubjectCoverage(projectId, signal)
|
||||
if (result.projectId !== projectId || !Array.isArray(result.issues) || typeof result.valid !== 'boolean')
|
||||
throw new Error('覆盖检查返回了不匹配的项目或无效结果,请刷新。')
|
||||
return result
|
||||
})
|
||||
/** 当前后端实际审计汇总。 */
|
||||
const result = computed(() => query.data.value)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是零费用主体引用覆盖审计模块 -->
|
||||
<ReadonlyInspection
|
||||
v-model:open="open"
|
||||
title="主体引用覆盖检查"
|
||||
description="检查分镜文本与主体绑定是否一致,只读取数据,不自动生成或修改分镜。"
|
||||
:loading="query.loading.value"
|
||||
:error="query.error.value"
|
||||
@refresh="query.refresh"
|
||||
>
|
||||
<template v-if="result">
|
||||
<NAlert :type="result.valid ? 'success' : 'warning'" :show-icon="false">
|
||||
{{ result.valid ? '未发现主体引用遗漏' : `发现 ${result.issueCount} 项引用遗漏` }} ·
|
||||
{{ result.episodeCount }} 集 / {{ result.beatCount }} 个 Beat / {{ result.shotCount }} 镜
|
||||
</NAlert>
|
||||
<p class="mt-2 text-muted">
|
||||
检查主体 {{ result.subjectSummary.total }} · 人物 {{ result.subjectSummary.character }} / 场景
|
||||
{{ result.subjectSummary.scene }} / 道具 {{ result.subjectSummary.prop }}
|
||||
</p>
|
||||
<article
|
||||
v-for="(issue, index) in result.issues"
|
||||
:key="`${issue.level}:${issue.episodeNo}:${issue.beatNo}:${issue.shotNo}:${issue.subjectRef}:${index}`"
|
||||
class="surface-inset mt-3 p-3"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<strong
|
||||
>第 {{ issue.episodeNo }} 集 · Beat {{ issue.beatNo
|
||||
}}{{ issue.shotNo !== null ? ` · 镜头 ${issue.shotNo}` : '' }} · {{ issue.subjectName }}
|
||||
{{ issue.subjectRef }}</strong
|
||||
>
|
||||
<NButton text size="small" @click="emit('locate', issue)">{{
|
||||
issue.shotNo === null ? '查看所在剧集' : '定位镜头'
|
||||
}}</NButton>
|
||||
</div>
|
||||
<p>{{ issue.message }}</p>
|
||||
<p class="text-muted">
|
||||
原文匹配:{{ issue.matchedTerm }} ·
|
||||
{{
|
||||
issue.level === 'visual_state'
|
||||
? '即时状态'
|
||||
: issue.level === 'beat'
|
||||
? 'Beat 主体引用'
|
||||
: '镜头主体绑定'
|
||||
}}
|
||||
</p>
|
||||
</article>
|
||||
</template>
|
||||
</ReadonlyInspection>
|
||||
</template>
|
||||
@@ -0,0 +1,14 @@
|
||||
import { request } from '../../lib/http'
|
||||
import type { SubjectCoverageAudit } from './coverage.types'
|
||||
|
||||
/**
|
||||
* 只读检查正式分镜的主体引用覆盖,不调用任何 Agent。
|
||||
* @param projectId 当前正式项目 ID
|
||||
* @param signal 取消信号
|
||||
* @returns 后端实际覆盖审计结果
|
||||
*/
|
||||
export function auditSubjectCoverage(projectId: string, signal?: AbortSignal) {
|
||||
return request<SubjectCoverageAudit>(`/projects/${encodeURIComponent(projectId)}/storyboard/subject-coverage`, {
|
||||
signal
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/** 主体引用覆盖检查中的单个遗漏,不推测正式 Shot ID。 */
|
||||
export interface SubjectCoverageIssue {
|
||||
/** 遗漏发生的层级。 */
|
||||
level: 'beat' | 'shot' | 'visual_state'
|
||||
/** 正式剧集编号。 */
|
||||
episodeNo: number
|
||||
/** Beat 编号。 */
|
||||
beatNo: number
|
||||
/** 镜头编号,Beat 层级为空。 */
|
||||
shotNo: number | null
|
||||
/** 漏引用的主体 Ref。 */
|
||||
subjectRef: string
|
||||
/** 主体名称。 */
|
||||
subjectName: string
|
||||
/** 主体模块。 */
|
||||
module: string
|
||||
/** 原文中匹配的用语。 */
|
||||
matchedTerm: string
|
||||
/** 后端问题描述。 */
|
||||
message: string
|
||||
}
|
||||
|
||||
/** 零费用主体引用覆盖审计的实际汇总。 */
|
||||
export interface SubjectCoverageAudit {
|
||||
/** 当前项目正式 ID。 */
|
||||
projectId: string
|
||||
/** 后端是否判定引用覆盖完整。 */
|
||||
valid: boolean
|
||||
/** 审计的剧集数量。 */
|
||||
episodeCount: number
|
||||
/** 审计的 Beat 数量。 */
|
||||
beatCount: number
|
||||
/** 审计的镜头数量。 */
|
||||
shotCount: number
|
||||
/** 遗漏问题数量。 */
|
||||
issueCount: number
|
||||
/** 后端用于本次审计的主体快照。 */
|
||||
subjectSnapshot: {
|
||||
/** 正式主体 ID。 */
|
||||
id: string
|
||||
/** 主体引用。 */
|
||||
ref: string
|
||||
/** 主体名称。 */
|
||||
name: string
|
||||
/** 主体模块。 */
|
||||
module: string
|
||||
}[]
|
||||
/** 本次审计的各类型主体数量。 */
|
||||
subjectSummary: {
|
||||
/** 主体总数。 */
|
||||
total: number
|
||||
/** 人物数量。 */
|
||||
character: number
|
||||
/** 场景数量。 */
|
||||
scene: number
|
||||
/** 道具数量。 */
|
||||
prop: number
|
||||
}
|
||||
/** 真实引用遗漏列表。 */
|
||||
issues: SubjectCoverageIssue[]
|
||||
}
|
||||
@@ -7,9 +7,89 @@ import type { DesignedShot, EpisodeDirections, EpisodeVisualStates, StoryboardSe
|
||||
/** 仅保存本会话回执和已返回的 Prompt,切换路由不丢失长请求结果。 */
|
||||
const sessions = reactive<Record<string, StoryboardSession>>({})
|
||||
|
||||
/**
|
||||
* 恢复整个项目已失效的剧集集合,兼容隐私模式或损坏的浏览器缓存。
|
||||
* @param projectId 正式项目 ID
|
||||
* @returns 只包含正整数剧集编号的失效标记
|
||||
*/
|
||||
function savedEpisodeInvalidations(projectId: string): Record<number, boolean> {
|
||||
try {
|
||||
if (typeof localStorage === 'undefined') return {}
|
||||
const value: unknown = JSON.parse(
|
||||
localStorage.getItem(`short-drama:storyboard-invalidated:${projectId}`) ?? '[]'
|
||||
)
|
||||
if (!Array.isArray(value)) return {}
|
||||
return Object.fromEntries(
|
||||
value
|
||||
.filter(number => typeof number === 'number' && Number.isSafeInteger(number) && number > 0)
|
||||
.map(number => [number, true])
|
||||
)
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取指定项目的独立回执容器。 */
|
||||
export function getStoryboardSession(id: string): StoryboardSession {
|
||||
return (sessions[id] ??= { receipt: null, prompts: {}, regeneratedEpisodes: {} })
|
||||
return (sessions[id] ??= {
|
||||
receipt: null,
|
||||
prompts: {},
|
||||
regeneratedEpisodes: {},
|
||||
invalidatedEpisodeSources: savedEpisodeInvalidations(id)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据真实有效终态废弃旧正文,并持久化全部剧集,隐藏任务不影响恢复。
|
||||
* @param projectId 正式项目 ID
|
||||
* @param episodeNo 已有效重生成的剧集编号
|
||||
*/
|
||||
export function invalidateEpisodeSource(projectId: string, episodeNo: number) {
|
||||
if (!Number.isSafeInteger(episodeNo) || episodeNo <= 0) return
|
||||
const session = getStoryboardSession(projectId)
|
||||
delete session.regeneratedEpisodes[episodeNo]
|
||||
session.invalidatedEpisodeSources = {
|
||||
...savedEpisodeInvalidations(projectId),
|
||||
...session.invalidatedEpisodeSources,
|
||||
[episodeNo]: true
|
||||
}
|
||||
try {
|
||||
if (typeof localStorage !== 'undefined')
|
||||
localStorage.setItem(
|
||||
`short-drama:storyboard-invalidated:${projectId}`,
|
||||
JSON.stringify(Object.keys(session.invalidatedEpisodeSources).map(Number))
|
||||
)
|
||||
} catch {
|
||||
/* 浏览器禁止存储时仍保留当前会话保护。 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅可信完整重新拆解完成后清除旧失效集合。
|
||||
* @param projectId 正式项目 ID
|
||||
*/
|
||||
export function clearEpisodeSourceInvalidations(projectId: string) {
|
||||
getStoryboardSession(projectId).invalidatedEpisodeSources = {}
|
||||
try {
|
||||
if (typeof localStorage !== 'undefined')
|
||||
localStorage.removeItem(`short-drama:storyboard-invalidated:${projectId}`)
|
||||
} catch {
|
||||
/* 当前会话已经清除,存储限制不会触发业务请求。 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重生成后不向新 Shot ID 回填旧 checkpoint 的标题、剧情或时长。
|
||||
* @param projectId 当前正式项目 ID
|
||||
* @param episodeNo 当前剧集编号
|
||||
* @param fallback 未失效的原始分集快照
|
||||
* @returns 实际正文或缺省;缺省时仅展示正式镜头编号
|
||||
*/
|
||||
export function currentEpisodeSource(projectId: string, episodeNo: number, fallback?: EpisodeShots) {
|
||||
const session = getStoryboardSession(projectId)
|
||||
return (
|
||||
session.regeneratedEpisodes[episodeNo] ?? (session.invalidatedEpisodeSources[episodeNo] ? undefined : fallback)
|
||||
)
|
||||
}
|
||||
|
||||
/** 后端生成服务只读取最新 Breakdown;不能用历史可恢复快照冒充当前生成前置条件。 */
|
||||
|
||||
@@ -181,13 +181,25 @@ export interface DesignedShot {
|
||||
|
||||
/** 生成回执按操作区分,切换剧集时仍保留原始目标信息。 */
|
||||
export type StoryboardReceipt =
|
||||
| { kind: 'shots'; title: string; result: StoryboardShotRegenerationResult }
|
||||
| {
|
||||
kind: 'shots'
|
||||
title: string
|
||||
result: Pick<
|
||||
StoryboardShotRegenerationResult,
|
||||
'episodeNo' | 'storyboardShotSummary' | 'storyboardShotValidation'
|
||||
>
|
||||
}
|
||||
| { kind: 'batch'; title: string; result: StoryboardBatchResult }
|
||||
| { kind: 'prompts'; title: string; result: PromptBatchResult }
|
||||
|
||||
/** 当前浏览器会话保存回执,不将其当作持久化运行状态。 */
|
||||
export interface StoryboardSession {
|
||||
/** 当前真实操作回执。 */
|
||||
receipt: StoryboardReceipt | null
|
||||
/** 按正式镜头缓存的实际视频提示词。 */
|
||||
prompts: Record<string, ShotPromptResult>
|
||||
/** 已实际返回的重生成分集正文,缺少正文时不构造缓存。 */
|
||||
regeneratedEpisodes: Record<number, EpisodeShots>
|
||||
/** 已重生成且旧 checkpoint 正文不再可信的剧集。 */
|
||||
invalidatedEpisodeSources: Record<number, boolean>
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import type { StoryboardBatchResult, PromptBatchResult, StoryboardShotRegenerationResult } from './types'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownSnapshot } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { storyboardApi } from './api'
|
||||
import { getStoryboardSession, mergeDesignedShots, storyboardPrerequisites } from './model'
|
||||
import {
|
||||
currentEpisodeSource,
|
||||
getStoryboardSession,
|
||||
invalidateEpisodeSource,
|
||||
mergeDesignedShots,
|
||||
storyboardPrerequisites
|
||||
} from './model'
|
||||
|
||||
/** 分镜页只提供正式主流程命令,不暴露后端测试路由。 */
|
||||
export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all' | 'prompts'
|
||||
@@ -12,16 +20,25 @@ export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all'
|
||||
/** 分镜查询、依赖判断与操作入口;不修改后端 graph。 */
|
||||
export function useStoryboard() {
|
||||
const context = useProjectContext()
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const id = computed(() => context.project.value?.id ?? '')
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const selectedEpisode = ref<number>()
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const selectedShot = ref('')
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const concurrency = ref(2)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const maxRepairAttempts = ref(2)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const force = ref(false)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
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) {
|
||||
@@ -31,12 +48,14 @@ export function useStoryboard() {
|
||||
.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]))
|
||||
/** 分镜页仅在进入、切换剧集或显式刷新时读取。 */
|
||||
const query = useQuery(queryKey, async (key, signal) => {
|
||||
@@ -57,21 +76,33 @@ export function useStoryboard() {
|
||||
return { directions, visualStates }
|
||||
})
|
||||
const data = query.data
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const session = computed(() => getStoryboardSession(id.value))
|
||||
/** 单集重生成返回的是最新镜头正文,优先于不会随局部覆盖更新的历史 Breakdown 快照。 */
|
||||
const source = computed(
|
||||
() =>
|
||||
session.value.regeneratedEpisodes[episodeNo.value] ??
|
||||
const source = computed(() =>
|
||||
currentEpisodeSource(
|
||||
id.value,
|
||||
episodeNo.value,
|
||||
sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value)
|
||||
)
|
||||
)
|
||||
/** 重生成接口未返回新正文时,明确标记辅助剧情信息不可用。 */
|
||||
const episodeSourceUnavailable = computed(() => !!session.value.invalidatedEpisodeSources[episodeNo.value])
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const shots = computed(() =>
|
||||
mergeDesignedShots(data.value?.directions ?? null, data.value?.visualStates ?? null, source.value)
|
||||
)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const shot = computed(() => shots.value.find(item => item.shotId === selectedShot.value) ?? shots.value[0])
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const prerequisites = computed(() => storyboardPrerequisites(context.checkpoints.value, episodeNo.value))
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const operation = computed(() => getOperation(id.value))
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const repairsValid = computed(() => Number.isSafeInteger(maxRepairAttempts.value) && maxRepairAttempts.value >= 0)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const blocked = computed(
|
||||
() =>
|
||||
operation.value.pending ||
|
||||
@@ -81,18 +112,21 @@ export function useStoryboard() {
|
||||
context.project.value?.status !== 'completed' ||
|
||||
prerequisites.value.breakdownRunning
|
||||
)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const directionComplete = computed(
|
||||
() =>
|
||||
!!data.value?.directions.shotCount &&
|
||||
data.value.directions.directionCount === data.value.directions.shotCount &&
|
||||
data.value.directions.coverage === 1
|
||||
)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const visualStateComplete = computed(
|
||||
() =>
|
||||
!!data.value?.visualStates.shotCount &&
|
||||
data.value.visualStates.visualStateCount === data.value.visualStates.shotCount &&
|
||||
data.value.visualStates.coverage === 1
|
||||
)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const hasCurrentEpisodeShots = computed(
|
||||
() => Math.max(data.value?.directions.shotCount ?? 0, data.value?.visualStates.shotCount ?? 0) > 0
|
||||
)
|
||||
@@ -103,6 +137,54 @@ export function useStoryboard() {
|
||||
prompts: !blocked.value && shots.value.length > 0 && batchValid.value
|
||||
}))
|
||||
|
||||
/** 正式后台任务观察器;重生成使用后端 breakdown 名称并通过 metadata 区分。 */
|
||||
const executions = [
|
||||
{ title: '单集镜头重生成', observer: useWorkflowExecution(id, 'breakdown') },
|
||||
{ title: '项目导演设计', observer: useWorkflowExecution(id, 'storyboard-direction') },
|
||||
{ title: '项目即时状态', observer: useWorkflowExecution(id, 'storyboard-visual-state') },
|
||||
{ title: '项目视频提示词', observer: useWorkflowExecution(id, 'video-prompt') }
|
||||
]
|
||||
/** 真实终态结果才发布回执;刷新恢复也按后端 metadata 归属。 */
|
||||
for (const [index, entry] of executions.entries()) {
|
||||
watch(
|
||||
() => entry.observer.query.data.value,
|
||||
record => {
|
||||
if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return
|
||||
const target = getStoryboardSession(record.projectId)
|
||||
if (index === 0 && record.metadata?.action !== 'regenerate-storyboard-episode') return
|
||||
if (record.status === 'completed' && record.result) {
|
||||
if (index === 0) {
|
||||
const result = record.result as unknown as StoryboardShotRegenerationResult
|
||||
const number = record.metadata?.episodeNo
|
||||
if (
|
||||
typeof number !== 'number' ||
|
||||
result.episodeNo !== number ||
|
||||
!result.storyboardShotValidation ||
|
||||
!result.storyboardShotSummary
|
||||
)
|
||||
return
|
||||
target.receipt = { kind: 'shots', title: `第 ${number} 集镜头`, result }
|
||||
if (result.storyboardShotValidation.valid) {
|
||||
delete target.regeneratedEpisodes[number]
|
||||
invalidateEpisodeSource(record.projectId, number)
|
||||
target.prompts = {}
|
||||
if (episodeNo.value === number) selectedShot.value = ''
|
||||
}
|
||||
} else if (index === 3) {
|
||||
const result = record.result as unknown as PromptBatchResult
|
||||
if (typeof result.failed !== 'number') return
|
||||
target.receipt = { kind: 'prompts', title: entry.title, result }
|
||||
} else {
|
||||
const result = record.result as unknown as StoryboardBatchResult
|
||||
if (result.projectId !== record.projectId || !Array.isArray(result.episodes)) return
|
||||
target.receipt = { kind: 'batch', title: entry.title, result }
|
||||
}
|
||||
}
|
||||
void Promise.all([query.refresh(), context.refresh(), context.refreshStageReadiness()])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/** 捕获提交时的目标与配置,切换剧集不改变正在运行的请求或回执。 */
|
||||
async function run(command: StoryboardCommand) {
|
||||
if (!allowed.value[command]) return
|
||||
@@ -119,48 +201,22 @@ export function useStoryboard() {
|
||||
}
|
||||
target.receipt = null
|
||||
await runOperation(projectId, `生成${titles[command]}`, async () => {
|
||||
switch (command) {
|
||||
case 'shots-current': {
|
||||
const result = await storyboardApi.regenerateEpisodeShots(projectId, targetEpisode)
|
||||
if (result.projectId !== projectId || result.episodeNo !== targetEpisode) {
|
||||
throw new Error('镜头重生成返回了不匹配的项目或剧集,请刷新后重试。')
|
||||
}
|
||||
target.receipt = { kind: 'shots', title: titles[command], result }
|
||||
if (!result.storyboardShotValidation.valid) {
|
||||
throw new Error('本集镜头校验未通过,后端未覆盖正式 Storyboard。')
|
||||
}
|
||||
target.regeneratedEpisodes[targetEpisode] = result.episodeShot
|
||||
// 新镜头会获得新的数据库 ID,废弃所有按旧 Shot ID 缓存的提示词。
|
||||
target.prompts = {}
|
||||
if (episodeNo.value === targetEpisode) selectedShot.value = ''
|
||||
break
|
||||
}
|
||||
case 'direction-all':
|
||||
target.receipt = {
|
||||
kind: 'batch',
|
||||
title: titles[command],
|
||||
result: await storyboardApi.generateDirections(projectId, batch)
|
||||
}
|
||||
break
|
||||
case 'visual-all':
|
||||
target.receipt = {
|
||||
kind: 'batch',
|
||||
title: titles[command],
|
||||
result: await storyboardApi.generateVisualStates(projectId, {
|
||||
...batch,
|
||||
maxRepairAttempts: repairs
|
||||
})
|
||||
}
|
||||
break
|
||||
case 'prompts':
|
||||
// 断网时也可能已部分覆盖,先清空缓存,避免继续展示可能失效的正文。
|
||||
target.prompts = {}
|
||||
target.receipt = {
|
||||
kind: 'prompts',
|
||||
title: titles[command],
|
||||
result: await storyboardApi.generatePrompts(projectId, batch)
|
||||
}
|
||||
break
|
||||
if (command === 'shots-current') {
|
||||
const started = await storyboardApi.regenerateEpisodeShots(projectId, targetEpisode)
|
||||
await executions[0]!.observer.track(started.executionId, projectId)
|
||||
} else if (command === 'direction-all') {
|
||||
const started = await storyboardApi.generateDirections(projectId, batch)
|
||||
await executions[1]!.observer.track(started.executionId, projectId)
|
||||
} else if (command === 'visual-all') {
|
||||
const started = await storyboardApi.generateVisualStates(projectId, {
|
||||
...batch,
|
||||
maxRepairAttempts: repairs
|
||||
})
|
||||
await executions[2]!.observer.track(started.executionId, projectId)
|
||||
} else {
|
||||
target.prompts = {}
|
||||
const started = await storyboardApi.generatePrompts(projectId, batch)
|
||||
await executions[3]!.observer.track(started.executionId, projectId)
|
||||
}
|
||||
})
|
||||
await Promise.all([query.refresh(), context.refreshStageReadiness()])
|
||||
@@ -177,6 +233,7 @@ export function useStoryboard() {
|
||||
query,
|
||||
data,
|
||||
source,
|
||||
episodeSourceUnavailable,
|
||||
prerequisites,
|
||||
session,
|
||||
operation,
|
||||
@@ -190,6 +247,7 @@ export function useStoryboard() {
|
||||
directionComplete,
|
||||
visualStateComplete,
|
||||
hasCurrentEpisodeShots,
|
||||
executions,
|
||||
run
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import { castingStatusLabel, currentAnchor } from './model'
|
||||
import { useSubjectIdentity } from './useSubjectIdentity'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import StableAnchorQualityDialog from './components/StableAnchorQualityDialog.vue'
|
||||
import IdentityEditor from './components/IdentityEditor.vue'
|
||||
import IdentityGallery from './components/IdentityGallery.vue'
|
||||
import IdentityImageDialog from './components/IdentityImageDialog.vue'
|
||||
@@ -78,11 +79,17 @@ const {
|
||||
generateImage,
|
||||
generateCastingCandidate,
|
||||
confirmStableAnchor,
|
||||
confirmCasting
|
||||
confirmCasting,
|
||||
validateImage,
|
||||
generateStableAnchorQuality,
|
||||
validationResult,
|
||||
qualityResult
|
||||
} = useSubjectIdentity()
|
||||
const search = ref('')
|
||||
const module = ref('all')
|
||||
const identityBatchModule = ref<'all' | 'character' | 'scene' | 'prop'>('all')
|
||||
/** 单主体稳定母版质量生成弹窗开关。 */
|
||||
const qualityOpen = ref(false)
|
||||
const imageOpen = ref(false)
|
||||
const castingOpen = ref(false)
|
||||
const pendingSelection = ref('')
|
||||
@@ -122,6 +129,7 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
watch(selectedId, () => {
|
||||
qualityOpen.value = false
|
||||
imageOpen.value = false
|
||||
castingOpen.value = false
|
||||
pendingSelection.value = ''
|
||||
@@ -308,7 +316,9 @@ watch(
|
||||
<template #notice>
|
||||
<NAlert v-if="stageComplete" type="success" :show-icon="false">
|
||||
所有需要确认的角色身份已经准备好,可以继续制作主体形态图片。
|
||||
<RouterLink :to="`/projects/${projectId}/subject-images`" class="text-button ml-2">继续形态图片 →</RouterLink>
|
||||
<RouterLink :to="`/projects/${projectId}/subject-images`" class="text-button ml-2"
|
||||
>继续形态图片 →</RouterLink
|
||||
>
|
||||
</NAlert>
|
||||
</template>
|
||||
<template #header>
|
||||
@@ -345,287 +355,253 @@ watch(
|
||||
<div class="workspace-overview-panel">
|
||||
<div class="overview-content workspace-section-stack dialog-flat-stack">
|
||||
<h3 class="text-sm font-semibold">角色选角总览与批量操作</h3>
|
||||
<NAlert type="info" :show-icon="false" class="text-xs">
|
||||
人物需要依次完成身份描述、选角候选、确认角色母版并锁定,之后才能用于镜头制作。未明确人物背景时,AI 默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-if="styleQuery.data.value && !hasStyle"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
|
||||
>
|
||||
先创建项目视觉风格,才能 AI 生成身份或身份图片。<RouterLink
|
||||
:to="`/projects/${projectId}/visual-style`"
|
||||
class="text-button ml-2"
|
||||
>设置视觉风格 →</RouterLink
|
||||
></NAlert
|
||||
>
|
||||
<section v-if="casting" class="workspace-panel" aria-label="角色选角流程">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="production-step"><UserCheck :size="17" /></span>
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">角色选角</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
只处理 Character。每张候选都根据当前身份描述独立生成,不复用旧母版;确认选择后才会设为角色母版并锁定身份。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<span class="font-mono text-xs text-muted"
|
||||
>{{ casting.ready }} / {{ casting.total }} 已完成</span
|
||||
>
|
||||
</div>
|
||||
<dl class="casting-stats mt-4">
|
||||
<div>
|
||||
<dt>缺身份文本</dt>
|
||||
<dd>{{ casting.missingIdentity }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>缺候选图</dt>
|
||||
<dd>{{ casting.missingAnchor }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>待确认演员</dt>
|
||||
<dd>{{ casting.candidatePending }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>母版未锁定</dt>
|
||||
<dd>{{ casting.unlocked }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>选角完成</dt>
|
||||
<dd>{{ casting.ready }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<AppForm
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:disabled="operation.pending"
|
||||
validate-on-change
|
||||
>
|
||||
<div class="form-controls mt-5 flex flex-wrap gap-4 pt-4">
|
||||
<NFormItem class="w-28" path="concurrency" label="并发数">
|
||||
<NInputNumber
|
||||
:input-props="{ 'aria-label': '并发数' }"
|
||||
:disabled="operation.pending"
|
||||
:value="
|
||||
typeof concurrency === 'number' ? concurrency : null
|
||||
"
|
||||
@update:value="concurrency = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber>
|
||||
</NFormItem>
|
||||
<NFormItem class="w-28" path="candidateLimit" label="本批上限">
|
||||
<NInputNumber
|
||||
:input-props="{ 'aria-label': '本批上限' }"
|
||||
:disabled="operation.pending"
|
||||
:value="
|
||||
typeof candidateLimit === 'number'
|
||||
? candidateLimit
|
||||
: null
|
||||
"
|
||||
@update:value="candidateLimit = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber>
|
||||
</NFormItem>
|
||||
<NCheckbox
|
||||
v-model:checked="force"
|
||||
:disabled="operation.pending"
|
||||
class="control-row-checkbox text-xs"
|
||||
>覆盖未锁定身份文本
|
||||
</NCheckbox>
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成角色身份文本' : '补齐角色身份文本'"
|
||||
:disabled="
|
||||
blocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
dirty ||
|
||||
!casting.total
|
||||
"
|
||||
acknowledgement
|
||||
description="只生成 Character Identity 文本,不生成图片。已锁定角色始终跳过;覆盖文本不会自动更新已有候选图。"
|
||||
@confirm="generateProject(true)"
|
||||
/>
|
||||
<ConfirmAction
|
||||
label="生成选角候选"
|
||||
:disabled="
|
||||
castingBlocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
!casting.missingAnchor
|
||||
"
|
||||
acknowledgement
|
||||
description="最多按本批上限为缺少 Anchor 的 Character 调用 图片模型,各自独立生成一张停用的 primary 候选,不复用旧身份母版。已有候选、已有母版或已完成选角的角色不会重复处理。"
|
||||
@confirm="generateCastingCandidates"
|
||||
/>
|
||||
</div>
|
||||
</AppForm>
|
||||
<div class="casting-list" role="group" aria-label="角色选角进度">
|
||||
<NButton
|
||||
v-for="item in casting.items"
|
||||
:key="item.subjectId"
|
||||
@click="select(item.subjectId)"
|
||||
class="casting-item"
|
||||
:class="{ selected: selectedId === item.subjectId }"
|
||||
:aria-pressed="selectedId === item.subjectId"
|
||||
><span class="casting-item-identity">
|
||||
<span class="casting-item-name">{{ item.subjectName }}</span>
|
||||
<span class="casting-item-ref">{{
|
||||
item.subjectRef
|
||||
}}</span> </span
|
||||
><StatusBadge
|
||||
class="casting-item-status"
|
||||
:status="item.status"
|
||||
:label="castingStatusLabel(item.status)"
|
||||
/></NButton>
|
||||
</div>
|
||||
</section>
|
||||
<section class="workspace-panel" aria-label="场景与道具身份母版">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">场景与道具稳定母版</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
为已有身份描述但缺少有效母版的场景或道具小批量生图。成功后会自动设为身份母版并锁定。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<ConfirmAction
|
||||
label="生成场景母版"
|
||||
:disabled="
|
||||
blocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
dirty ||
|
||||
!subjects.length
|
||||
"
|
||||
acknowledgement
|
||||
:description="`最多处理 ${candidateLimit} 个场景,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`"
|
||||
@confirm="generateStableAnchors('scene')"
|
||||
/>
|
||||
<ConfirmAction
|
||||
label="生成道具母版"
|
||||
:disabled="
|
||||
blocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
dirty ||
|
||||
!subjects.length
|
||||
"
|
||||
acknowledgement
|
||||
:description="`最多处理 ${candidateLimit} 个道具,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`"
|
||||
@confirm="generateStableAnchors('prop')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<NCollapse class="workspace-panel" :default-expanded-names="['details']"
|
||||
><NCollapseItem name="details"
|
||||
><template #header>高级:全部主体身份文本</template>
|
||||
<p class="mt-3 text-xs leading-6 text-muted">
|
||||
同时处理 Character、Scene 和
|
||||
Prop;角色选角建议优先使用上方专用入口。已锁定身份始终跳过。
|
||||
<NAlert type="info" :show-icon="false" class="text-xs">
|
||||
人物需要依次完成身份描述、选角候选、确认角色母版并锁定,之后才能用于镜头制作。未明确人物背景时,AI
|
||||
默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。
|
||||
</NAlert>
|
||||
<NAlert v-if="styleQuery.data.value && !hasStyle" type="info" :show-icon="false">
|
||||
先创建项目视觉风格,才能 AI 生成身份或身份图片。<RouterLink
|
||||
:to="`/projects/${projectId}/visual-style`"
|
||||
class="text-button ml-2"
|
||||
>设置视觉风格 →</RouterLink
|
||||
></NAlert
|
||||
>
|
||||
<section v-if="casting" class="workspace-panel" aria-label="角色选角流程">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="production-step"><UserCheck :size="17" /></span>
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">角色选角</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
只处理
|
||||
Character。每张候选都根据当前身份描述独立生成,不复用旧母版;确认选择后才会设为角色母版并锁定身份。
|
||||
</p>
|
||||
<NSelect
|
||||
v-model:value="identityBatchModule"
|
||||
class="mt-4 w-48"
|
||||
aria-label="身份文本批处理范围"
|
||||
:options="[
|
||||
{ label: String('全部类型'), value: 'all' },
|
||||
{ label: String('仅人物'), value: 'character' },
|
||||
{ label: String('仅场景'), value: 'scene' },
|
||||
{ label: String('仅道具'), value: 'prop' }
|
||||
]" />
|
||||
<ConfirmAction
|
||||
class="mt-4"
|
||||
:label="force ? '重生成全部未锁定身份' : '补齐全部主体身份文本'"
|
||||
:disabled="
|
||||
blocked || !hasStyle || !batchValid || dirty || !subjects.length
|
||||
"
|
||||
acknowledgement
|
||||
description="生成全项目主体身份描述与提示词,不生成图片。覆盖不会自动更新旧身份图、形态图、首帧或视频。"
|
||||
@confirm="
|
||||
identityBatchModule === 'character'
|
||||
? generateProject(true)
|
||||
: generateProject(
|
||||
false,
|
||||
identityBatchModule === 'scene' ||
|
||||
identityBatchModule === 'prop'
|
||||
? identityBatchModule
|
||||
: undefined
|
||||
)
|
||||
" /></NCollapseItem
|
||||
></NCollapse>
|
||||
<section
|
||||
v-if="session.receipt"
|
||||
class="workspace-panel"
|
||||
aria-label="身份文本批量回执"
|
||||
>
|
||||
<div class="flex justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">
|
||||
{{ session.receipt.title }} · 本次回执
|
||||
</h3>
|
||||
<NButton @click="exportReceipt" text size="small">导出诊断</NButton>
|
||||
</div>
|
||||
<p
|
||||
v-if="session.receipt.kind === 'identities'"
|
||||
class="mt-3 text-xs text-muted"
|
||||
>
|
||||
共 {{ session.receipt.result.total }} 个主体 · 目标
|
||||
{{ session.receipt.result.targetCount }} · 生成
|
||||
{{ session.receipt.result.generated }} · 跳过
|
||||
{{ session.receipt.result.skipped }}(含锁定
|
||||
{{ session.receipt.result.skippedLocked }})· 失败
|
||||
{{ session.receipt.result.failed }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="session.receipt.kind === 'casting'"
|
||||
class="mt-3 text-xs text-muted"
|
||||
>
|
||||
共 {{ session.receipt.result.totalCharacters }} 个角色 · 缺候选
|
||||
{{ session.receipt.result.missingAnchor }} · 本批目标
|
||||
{{ session.receipt.result.targetCount }} · 已生成
|
||||
{{ session.receipt.result.generated }} · 失败
|
||||
{{ session.receipt.result.failed }}
|
||||
</p>
|
||||
<p v-else class="mt-3 text-xs text-muted">
|
||||
共 {{ session.receipt.result.total }} 个{{
|
||||
session.receipt.result.module === 'scene' ? '场景' : '道具'
|
||||
}}
|
||||
· 符合条件 {{ session.receipt.result.eligibleCount }} · 本批目标
|
||||
{{ session.receipt.result.targetCount }} · 已生成并锁定
|
||||
{{ session.receipt.result.generated }} · 失败
|
||||
{{ session.receipt.result.failed }}
|
||||
</p>
|
||||
<NAlert
|
||||
v-if="session.receipt.result.failed"
|
||||
role="alert"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
>
|
||||
本次存在部分失败,成功结果不会回滚。请检查逐角色原因后再重试。
|
||||
</NAlert>
|
||||
<ul class="mt-3 space-y-2 text-xs text-danger">
|
||||
<li
|
||||
v-for="failure in session.receipt.result.failures"
|
||||
:key="failure.subjectId"
|
||||
>
|
||||
{{ failure.subjectRef }} · {{ failure.subjectId }}:{{
|
||||
failure.error
|
||||
}}
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-3 text-[11px] text-muted">
|
||||
回执仅保留于当前浏览器会话;最终状态以刷新后的正式记录为准。
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
<span class="font-mono text-xs text-muted"
|
||||
>{{ casting.ready }} / {{ casting.total }} 已完成</span
|
||||
>
|
||||
</div>
|
||||
<dl class="casting-stats mt-4">
|
||||
<div>
|
||||
<dt>缺身份文本</dt>
|
||||
<dd>{{ casting.missingIdentity }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>缺候选图</dt>
|
||||
<dd>{{ casting.missingAnchor }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>待确认演员</dt>
|
||||
<dd>{{ casting.candidatePending }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>母版未锁定</dt>
|
||||
<dd>{{ casting.unlocked }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>选角完成</dt>
|
||||
<dd>{{ casting.ready }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<AppForm
|
||||
:model="formModel"
|
||||
:rules="rules"
|
||||
:disabled="operation.pending"
|
||||
validate-on-change
|
||||
>
|
||||
<div class="form-controls mt-5 flex flex-wrap gap-4 pt-4">
|
||||
<NFormItem class="w-28" path="concurrency" label="并发数">
|
||||
<NInputNumber
|
||||
:input-props="{ 'aria-label': '并发数' }"
|
||||
:disabled="operation.pending"
|
||||
:value="typeof concurrency === 'number' ? concurrency : null"
|
||||
@update:value="concurrency = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber>
|
||||
</NFormItem>
|
||||
<NFormItem class="w-28" path="candidateLimit" label="本批上限">
|
||||
<NInputNumber
|
||||
:input-props="{ 'aria-label': '本批上限' }"
|
||||
:disabled="operation.pending"
|
||||
:value="typeof candidateLimit === 'number' ? candidateLimit : null"
|
||||
@update:value="candidateLimit = $event ?? 0"
|
||||
:min="1"
|
||||
:step="1"
|
||||
></NInputNumber>
|
||||
</NFormItem>
|
||||
<NCheckbox
|
||||
v-model:checked="force"
|
||||
:disabled="operation.pending"
|
||||
class="control-row-checkbox text-xs"
|
||||
>覆盖未锁定身份文本
|
||||
</NCheckbox>
|
||||
<ConfirmAction
|
||||
:label="force ? '重生成角色身份文本' : '补齐角色身份文本'"
|
||||
:disabled="
|
||||
blocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
dirty ||
|
||||
!casting.total
|
||||
"
|
||||
acknowledgement
|
||||
description="只生成 Character Identity 文本,不生成图片。已锁定角色始终跳过;覆盖文本不会自动更新已有候选图。"
|
||||
@confirm="generateProject(true)"
|
||||
/>
|
||||
<ConfirmAction
|
||||
label="生成选角候选"
|
||||
:disabled="
|
||||
castingBlocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
!casting.missingAnchor
|
||||
"
|
||||
acknowledgement
|
||||
description="最多按本批上限为缺少 Anchor 的 Character 调用 图片模型,各自独立生成一张停用的 primary 候选,不复用旧身份母版。已有候选、已有母版或已完成选角的角色不会重复处理。"
|
||||
@confirm="generateCastingCandidates"
|
||||
/>
|
||||
</div>
|
||||
</AppForm>
|
||||
<div class="casting-list" role="group" aria-label="角色选角进度">
|
||||
<NButton
|
||||
v-for="item in casting.items"
|
||||
:key="item.subjectId"
|
||||
@click="select(item.subjectId)"
|
||||
class="casting-item"
|
||||
:class="{ selected: selectedId === item.subjectId }"
|
||||
:aria-pressed="selectedId === item.subjectId"
|
||||
><span class="casting-item-identity">
|
||||
<span class="casting-item-name">{{ item.subjectName }}</span>
|
||||
<span class="casting-item-ref">{{ item.subjectRef }}</span> </span
|
||||
><StatusBadge
|
||||
class="casting-item-status"
|
||||
:status="item.status"
|
||||
:label="castingStatusLabel(item.status)"
|
||||
/></NButton>
|
||||
</div>
|
||||
</section>
|
||||
<section class="workspace-panel" aria-label="场景与道具身份母版">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold">场景与道具稳定母版</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
为已有身份描述但缺少有效母版的场景或道具小批量生图。成功后会自动设为身份母版并锁定。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<ConfirmAction
|
||||
label="生成场景母版"
|
||||
:disabled="
|
||||
blocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
dirty ||
|
||||
!subjects.length
|
||||
"
|
||||
acknowledgement
|
||||
:description="`最多处理 ${candidateLimit} 个场景,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`"
|
||||
@confirm="generateStableAnchors('scene')"
|
||||
/>
|
||||
<ConfirmAction
|
||||
label="生成道具母版"
|
||||
:disabled="
|
||||
blocked || !hasStyle || !batchValid || dirty || !subjects.length
|
||||
"
|
||||
acknowledgement
|
||||
:description="`最多处理 ${candidateLimit} 个道具,生成成功后自动设为身份母版并锁定。可能产生图片模型费用。`"
|
||||
@confirm="generateStableAnchors('prop')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<NCollapse class="workspace-panel" :default-expanded-names="['details']"
|
||||
><NCollapseItem name="details"
|
||||
><template #header>高级:全部主体身份文本</template>
|
||||
<p class="mt-3 text-xs leading-6 text-muted">
|
||||
同时处理 Character、Scene 和
|
||||
Prop;角色选角建议优先使用上方专用入口。已锁定身份始终跳过。
|
||||
</p>
|
||||
<NSelect
|
||||
v-model:value="identityBatchModule"
|
||||
class="mt-4 w-48"
|
||||
aria-label="身份文本批处理范围"
|
||||
:options="[
|
||||
{ label: String('全部类型'), value: 'all' },
|
||||
{ label: String('仅人物'), value: 'character' },
|
||||
{ label: String('仅场景'), value: 'scene' },
|
||||
{ label: String('仅道具'), value: 'prop' }
|
||||
]" />
|
||||
<ConfirmAction
|
||||
class="mt-4"
|
||||
:label="force ? '重生成全部未锁定身份' : '补齐全部主体身份文本'"
|
||||
:disabled="blocked || !hasStyle || !batchValid || dirty || !subjects.length"
|
||||
acknowledgement
|
||||
description="生成全项目主体身份描述与提示词,不生成图片。覆盖不会自动更新旧身份图、形态图、首帧或视频。"
|
||||
@confirm="
|
||||
identityBatchModule === 'character'
|
||||
? generateProject(true)
|
||||
: generateProject(
|
||||
false,
|
||||
identityBatchModule === 'scene' ||
|
||||
identityBatchModule === 'prop'
|
||||
? identityBatchModule
|
||||
: undefined
|
||||
)
|
||||
" /></NCollapseItem
|
||||
></NCollapse>
|
||||
<section v-if="session.receipt" class="workspace-panel" aria-label="身份文本批量回执">
|
||||
<div class="flex justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">{{ session.receipt.title }} · 本次回执</h3>
|
||||
<NButton @click="exportReceipt" text size="small">导出诊断</NButton>
|
||||
</div>
|
||||
<p v-if="session.receipt.kind === 'identities'" class="mt-3 text-xs text-muted">
|
||||
共 {{ session.receipt.result.total }} 个主体 · 目标
|
||||
{{ session.receipt.result.targetCount }} · 生成
|
||||
{{ session.receipt.result.generated }} · 跳过
|
||||
{{ session.receipt.result.skipped }}(含锁定
|
||||
{{ session.receipt.result.skippedLocked }})· 失败
|
||||
{{ session.receipt.result.failed }}
|
||||
</p>
|
||||
<p v-else-if="session.receipt.kind === 'casting'" class="mt-3 text-xs text-muted">
|
||||
共 {{ session.receipt.result.totalCharacters }} 个角色 · 缺候选
|
||||
{{ session.receipt.result.missingAnchor }} · 本批目标
|
||||
{{ session.receipt.result.targetCount }} · 已生成
|
||||
{{ session.receipt.result.generated }} · 失败
|
||||
{{ session.receipt.result.failed }}
|
||||
</p>
|
||||
<p v-else class="mt-3 text-xs text-muted">
|
||||
共 {{ session.receipt.result.total }} 个{{
|
||||
session.receipt.result.module === 'scene' ? '场景' : '道具'
|
||||
}}
|
||||
· 符合条件 {{ session.receipt.result.eligibleCount }} · 本批目标
|
||||
{{ session.receipt.result.targetCount }} · 已生成并锁定
|
||||
{{ session.receipt.result.generated }} · 失败
|
||||
{{ session.receipt.result.failed }}
|
||||
</p>
|
||||
<NAlert
|
||||
v-if="session.receipt.result.failed"
|
||||
role="alert"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
>
|
||||
本次存在部分失败,成功结果不会回滚。请检查逐角色原因后再重试。
|
||||
</NAlert>
|
||||
<ul class="mt-3 space-y-2 text-xs text-danger">
|
||||
<li v-for="failure in session.receipt.result.failures" :key="failure.subjectId">
|
||||
{{ failure.subjectRef }} · {{ failure.subjectId }}:{{ failure.error }}
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-3 text-[11px] text-muted">
|
||||
回执仅保留于当前浏览器会话;最终状态以刷新后的正式记录为准。
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</WorkspaceTools>
|
||||
</div>
|
||||
@@ -803,6 +779,30 @@ watch(
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是场景与道具单主体母版质量生成模块 -->
|
||||
<NButton
|
||||
v-if="subject.module === 'scene' || subject.module === 'prop'"
|
||||
class="mt-4"
|
||||
:disabled="!canGenerateImage"
|
||||
@click="qualityOpen = true"
|
||||
>生成稳定母版并校验质量</NButton
|
||||
>
|
||||
<NAlert v-if="qualityResult" :type="qualityResult.passed ? 'success' : 'warning'" class="mt-3">
|
||||
{{
|
||||
qualityResult.passed
|
||||
? '质量闭环通过,母版与锁定已确认'
|
||||
: '质量闭环未通过,候选仍保留在图库'
|
||||
}}
|
||||
· 已修复 {{ qualityResult.repairAttempts }} 次
|
||||
<p v-if="qualityResult.stopReason">停止原因:{{ qualityResult.stopReason }}</p>
|
||||
<pre class="whitespace-pre-wrap break-all text-xs">{{
|
||||
JSON.stringify(qualityResult.attempts, null, 2)
|
||||
}}</pre>
|
||||
</NAlert>
|
||||
<!-- 以下是已完成主体的候选生成与真实输入预览入口模块 -->
|
||||
<NButton class="mt-4" :disabled="!canGenerateImage" @click="imageOpen = true">
|
||||
{{ subject.module === 'character' ? '生成辅助参考图' : '生成母版候选' }}
|
||||
</NButton>
|
||||
<IdentityGallery
|
||||
id="identity-reference-gallery"
|
||||
:key="selectedId"
|
||||
@@ -811,6 +811,8 @@ watch(
|
||||
:module="subject.module"
|
||||
:identity-locked="!!identity?.isLocked"
|
||||
:disabled="detailBlocked || (subject.module === 'character' && !!castingQuery.error.value)"
|
||||
:validation-result="validationResult"
|
||||
@validate="validateImage"
|
||||
@anchor="chooseAnchor"
|
||||
/>
|
||||
</template>
|
||||
@@ -842,22 +844,30 @@ watch(
|
||||
>前往剧本拆解</RouterLink
|
||||
></EmptyState
|
||||
>
|
||||
<NAlert
|
||||
v-if="activeIdentityGeneration"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
class="mb-4 text-xs"
|
||||
>
|
||||
{{ subject?.name }} 的身份图片正在生成({{ activeIdentityGeneration.provider || '图片模型' }}),刷新页面不会重复提交,请等待当前任务完成。
|
||||
<NAlert v-if="activeIdentityGeneration" type="info" :show-icon="false" class="mb-4 text-xs">
|
||||
{{ subject?.name }} 的身份图片正在生成({{
|
||||
activeIdentityGeneration.provider || '图片模型'
|
||||
}}),刷新页面不会重复提交,请等待当前任务完成。
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-else-if="latestIdentityFailure"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
class="mb-4 text-xs"
|
||||
>
|
||||
最近一次身份图片生成失败:{{ latestIdentityFailure.error || '未返回具体错误' }}。可以调整模型参数后重新生成。
|
||||
<NAlert v-else-if="latestIdentityFailure" type="error" :show-icon="false" class="mb-4 text-xs">
|
||||
最近一次身份图片生成失败:{{
|
||||
latestIdentityFailure.error || '未返回具体错误'
|
||||
}}。可以调整模型参数后重新生成。
|
||||
</NAlert>
|
||||
<StableAnchorQualityDialog
|
||||
v-if="
|
||||
subject &&
|
||||
(subject.module === 'scene' || subject.module === 'prop') &&
|
||||
profileQuery.data.value?.profile &&
|
||||
generationModelsQuery.data.value
|
||||
"
|
||||
v-model:open="qualityOpen"
|
||||
:subject-id="subject.id"
|
||||
:subject-name="subject.name"
|
||||
:catalog="generationModelsQuery.data.value"
|
||||
:profile="profileQuery.data.value.profile"
|
||||
:disabled="!canGenerateImage"
|
||||
@generate="generateStableAnchorQuality" />
|
||||
<IdentityImageDialog
|
||||
v-if="subject && profileQuery.data.value?.profile && generationModelsQuery.data.value"
|
||||
v-model:open="imageOpen"
|
||||
@@ -870,7 +880,9 @@ watch(
|
||||
:disabled="!canGenerateImage"
|
||||
@generate="submitIdentityImage" />
|
||||
<CastingCandidateDialog
|
||||
v-if="subject?.module === 'character' && profileQuery.data.value?.profile && generationModelsQuery.data.value"
|
||||
v-if="
|
||||
subject?.module === 'character' && profileQuery.data.value?.profile && generationModelsQuery.data.value
|
||||
"
|
||||
v-model:open="castingOpen"
|
||||
:subject-id="subject.id"
|
||||
:subject-name="subject.name"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { request } from '../../lib/http'
|
||||
import type {
|
||||
IdentityImagePreview,
|
||||
IdentityValidationResult,
|
||||
StableAnchorQualityInput,
|
||||
StableAnchorQualityResult,
|
||||
CastingBatchResult,
|
||||
CharacterCastingReadiness,
|
||||
ConfirmCastingResult,
|
||||
@@ -71,14 +75,54 @@ export const subjectIdentityApi = {
|
||||
request<IdentityImage[]>(`${identityPath(subjectId)}/images`, { signal }),
|
||||
generateImage: (subjectId: string, input: GenerateIdentityImageInput) =>
|
||||
request<IdentityImage>(`${identityPath(subjectId)}/images`, { method: 'POST', body: input, timeoutMs: 0 }),
|
||||
/**
|
||||
* 读取与实际生图同源的输入预览,道具可能执行已确认的结构模型编译。
|
||||
* @param subjectId 正式主体 ID
|
||||
* @param input 与实际生图相同的参数
|
||||
* @param signal 只读预览取消信号,可能付费的道具不传
|
||||
* @returns 后端真实输入与最终参数
|
||||
*/
|
||||
previewImage: (subjectId: string, input: GenerateIdentityImageInput, signal?: AbortSignal) =>
|
||||
request<IdentityImagePreview>(`${identityPath(subjectId)}/images/preview`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
signal,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 明确确认后对指定身份图片执行视觉校验。
|
||||
* @param subjectId 正式主体 ID
|
||||
* @param imageId 此主体的正式图片 ID
|
||||
* @returns 真实视觉校验回执
|
||||
*/
|
||||
validateImage: (subjectId: string, imageId: string) =>
|
||||
request<IdentityValidationResult>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/validate`, {
|
||||
method: 'POST',
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 为单个场景或道具执行有限预算的稳定母版质量闭环。
|
||||
* @param subjectId 正式主体 ID
|
||||
* @param input 已确认的模型与修复预算
|
||||
* @returns 候选、各轮质量和实际母版确认回执
|
||||
*/
|
||||
generateStableAnchorQuality: (subjectId: string, input: StableAnchorQualityInput) =>
|
||||
request<StableAnchorQualityResult>(`${identityPath(subjectId)}/stable-anchor/generate-quality`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
setAnchor: (subjectId: string, imageId: string) =>
|
||||
request<IdentityImage>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/anchor`, {
|
||||
method: 'PUT'
|
||||
}),
|
||||
confirmStableAnchor: (subjectId: string, imageId: string) =>
|
||||
request<ConfirmCastingResult>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/stable-anchor`, {
|
||||
method: 'PUT'
|
||||
}),
|
||||
request<ConfirmCastingResult>(
|
||||
`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/stable-anchor`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
),
|
||||
confirmCasting: (subjectId: string, imageId: string) =>
|
||||
request<ConfirmCastingResult>(`${identityPath(subjectId)}/images/${encodeURIComponent(imageId)}/casting`, {
|
||||
method: 'PUT'
|
||||
|
||||
@@ -1,28 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { NScrollbar, NAlert, NButton, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { AssetImage, StatusBadge } from '../../../components/ui'
|
||||
import { referenceImageUrl } from '../../../lib/assets'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { canBeAnchor, currentAnchor, identityViewLabels } from '../model'
|
||||
import type { IdentityImage } from '../types'
|
||||
import type { IdentityImage, IdentityValidationResult } from '../types'
|
||||
|
||||
/** 身份图库区分权威母版、primary 候选和辅助视图,保留后端原始状态。 */
|
||||
const props = defineProps<{
|
||||
/** 指定图片本次校验回执。 */
|
||||
validationResult?: IdentityValidationResult | null
|
||||
images: IdentityImage[]
|
||||
subjectName: string
|
||||
module: string
|
||||
identityLocked: boolean
|
||||
disabled: boolean
|
||||
}>()
|
||||
const emit = defineEmits<{ anchor: [imageId: string] }>()
|
||||
/** 用户确认的图片操作。 */
|
||||
const emit = defineEmits<{ anchor: [imageId: string]; validate: [imageId: string] }>()
|
||||
/** selectedId 的当前界面状态与输入绑定。 */
|
||||
const selectedId = ref('')
|
||||
/** confirming 的当前界面状态与输入绑定。 */
|
||||
const confirming = ref(false)
|
||||
/** anchor 的当前界面状态与输入绑定。 */
|
||||
const anchor = computed(() => currentAnchor(props.images))
|
||||
/** selected 的当前界面状态与输入绑定。 */
|
||||
const selected = computed(
|
||||
() => props.images.find(image => image.id === selectedId.value) ?? anchor.value ?? props.images[0]
|
||||
)
|
||||
/** character 的当前界面状态与输入绑定。 */
|
||||
const character = computed(() => props.module === 'character')
|
||||
/** canSelect 的当前界面状态与输入绑定。 */
|
||||
const canSelect = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
@@ -30,7 +40,9 @@ const canSelect = computed(
|
||||
canBeAnchor(selected.value) &&
|
||||
(!selected.value.isAnchor || (character.value && !props.identityLocked))
|
||||
)
|
||||
/** imageUrl 的当前界面状态与输入绑定。 */
|
||||
const imageUrl = computed(() => referenceImageUrl(selected.value?.imageUrl ?? ''))
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
watch(
|
||||
() => selected.value?.id,
|
||||
() => {
|
||||
@@ -133,6 +145,25 @@ function chooseAnchor() {
|
||||
>{{ selected.provider }} · {{ selected.model }} · {{ formatDate(selected.createdAt) }}</span
|
||||
>
|
||||
</div>
|
||||
<!-- 以下是指定身份图片质量校验模块 -->
|
||||
<ConfirmAction
|
||||
:key="selected.id"
|
||||
label="校验此身份图片"
|
||||
:description="`将校验图片 ${selected.id},会调用视觉模型并可能产生费用,不会切换母版。`"
|
||||
:disabled="disabled || selected.status !== 'completed' || !selected.imageUrl"
|
||||
acknowledgement
|
||||
@confirm="emit('validate', selected.id)"
|
||||
/>
|
||||
<NAlert
|
||||
v-if="validationResult?.imageId === selected.id"
|
||||
:type="validationResult.passed ? 'success' : 'warning'"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ validationResult.passed ? '本次校验通过' : '本次校验未通过' }}:{{ validationResult.summary }}</p>
|
||||
<p v-for="(issue, index) in validationResult.issues" :key="index">
|
||||
{{ issue.severity }} · {{ issue.type }}:{{ issue.description }}
|
||||
</p>
|
||||
</NAlert>
|
||||
<p v-if="selected.viewType !== 'primary'" class="mt-2 text-xs text-muted">
|
||||
辅助视图不能直接设为母版;它会继承当前身份母版,不适合用来更换演员。
|
||||
</p>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { fieldRule } from '../../../lib/form-rules'
|
||||
import { NAlert, NButton, NCheckbox, NInput, NSelect } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
import { subjectIdentityApi } from '../api'
|
||||
import type { IdentityImagePreview } from '../types'
|
||||
import { currentAnchor, identityViewLabels } from '../model'
|
||||
import type { GenerateIdentityImageInput, IdentityImage, IdentityViewType } from '../types'
|
||||
|
||||
@@ -20,32 +24,46 @@ const props = defineProps<{
|
||||
catalog: GenerationModelCatalog
|
||||
profile: CreativeProfile
|
||||
}>()
|
||||
/** open 的当前界面状态与输入绑定。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** emit 的当前界面状态与输入绑定。 */
|
||||
const emit = defineEmits<{ generate: [input: GenerateIdentityImageInput] }>()
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
const viewType = ref<IdentityViewType>('primary')
|
||||
/** referenceImageId 的当前界面状态与输入绑定。 */
|
||||
const referenceImageId = ref('')
|
||||
/** prompt 的当前界面状态与输入绑定。 */
|
||||
const prompt = ref('')
|
||||
/** provider 的当前界面状态与输入绑定。 */
|
||||
const provider = ref('')
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
/** acknowledged 的当前界面状态与输入绑定。 */
|
||||
const acknowledged = ref(false)
|
||||
/** anchor 的当前界面状态与输入绑定。 */
|
||||
const anchor = computed(() => currentAnchor(props.images))
|
||||
/** allowedViews 的当前界面状态与输入绑定。 */
|
||||
const allowedViews = computed(() =>
|
||||
props.module === 'character'
|
||||
? Object.entries(identityViewLabels).filter(([value]) => value !== 'primary')
|
||||
: [['primary', identityViewLabels.primary]]
|
||||
)
|
||||
/** references 的当前界面状态与输入绑定。 */
|
||||
const references = computed(() => props.images.filter(image => image.status === 'completed' && image.imageUrl))
|
||||
/** valid 的当前界面状态与输入绑定。 */
|
||||
const valid = computed(
|
||||
() => Boolean(provider.value) && (!referenceImageId.value || references.value.some(image => image.id === referenceImageId.value))
|
||||
() =>
|
||||
Boolean(provider.value) &&
|
||||
(!referenceImageId.value || references.value.some(image => image.id === referenceImageId.value))
|
||||
)
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
watch(
|
||||
() => [open.value, props.subjectId],
|
||||
() => {
|
||||
viewType.value = props.module === 'character' ? 'front' : 'primary'
|
||||
referenceImageId.value = ''
|
||||
prompt.value = ''
|
||||
const selected = props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
generationOptions.value = {
|
||||
@@ -53,7 +71,10 @@ watch(
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
const sizeSchema = selected?.generationOptions.find(item => item.key === 'size')
|
||||
if (sizeSchema?.options?.length && !sizeSchema.options.some(option => option.value === generationOptions.value.size)) {
|
||||
if (
|
||||
sizeSchema?.options?.length &&
|
||||
!sizeSchema.options.some(option => option.value === generationOptions.value.size)
|
||||
) {
|
||||
generationOptions.value.size = selected?.defaults.size ?? sizeSchema.options[0]?.value ?? ''
|
||||
}
|
||||
acknowledged.value = false
|
||||
@@ -61,18 +82,78 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 预览与正式生图共享的最终请求参数。 */
|
||||
const generationInput = computed<GenerateIdentityImageInput>(() => ({
|
||||
viewType: props.module === 'character' ? viewType.value : 'primary',
|
||||
...(referenceImageId.value ? { referenceImageId: referenceImageId.value } : {}),
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: { ...generationOptions.value }
|
||||
}))
|
||||
/** 当前参数的预览结果。 */
|
||||
const preview = ref<IdentityImagePreview | null>(null)
|
||||
/** 预览读取状态。 */
|
||||
const previewLoading = ref(false)
|
||||
/** 道具预览可能付费,保持项目锁直到真实请求结束,不能因关闭弹窗提前释放。 */
|
||||
const paidPreviewPending = ref(false)
|
||||
/** 预览读取错误。 */
|
||||
const previewError = ref('')
|
||||
/** 用于取消迟到预览的请求控制器。 */
|
||||
let previewController: AbortController | undefined
|
||||
/** 参数、主体或弹窗变化时清除旧结果和费用确认。 */
|
||||
/** 监听界面目标变化并重置关联确认状态。 */
|
||||
watch(
|
||||
() => [props.subjectId, open.value, JSON.stringify(generationInput.value), JSON.stringify(props.images)],
|
||||
() => {
|
||||
previewController?.abort()
|
||||
preview.value = null
|
||||
previewError.value = ''
|
||||
previewLoading.value = false
|
||||
acknowledged.value = false
|
||||
}
|
||||
)
|
||||
/** 卸载时取消未完成的只读请求。 */
|
||||
onBeforeUnmount(() => previewController?.abort())
|
||||
/** 读取当前参数的真实预览;道具后端可能编译结构模型,禁止当作免费读取。 */
|
||||
async function loadPreview() {
|
||||
if (props.disabled || !valid.value || previewLoading.value || paidPreviewPending.value) return
|
||||
previewController?.abort()
|
||||
const controller = new AbortController()
|
||||
previewController = controller
|
||||
const subjectId = props.subjectId
|
||||
const projectId = props.profile.projectId
|
||||
const paid = props.module === 'prop'
|
||||
const input = { ...generationInput.value, generationOptions: { ...generationInput.value.generationOptions } }
|
||||
previewLoading.value = true
|
||||
previewError.value = ''
|
||||
paidPreviewPending.value = paid
|
||||
/** 道具请求不传取消信号,取消客户端展示不能取消后端结构模型的工作。 */
|
||||
const inspect = async () => {
|
||||
const result = await subjectIdentityApi.previewImage(subjectId, input, paid ? undefined : controller.signal)
|
||||
if (!controller.signal.aborted && previewController === controller && subjectId === props.subjectId)
|
||||
preview.value = result
|
||||
}
|
||||
try {
|
||||
if (paid) {
|
||||
const ok = await runOperation(projectId, '预览道具结构输入', inspect)
|
||||
if (!ok && !controller.signal.aborted && subjectId === props.subjectId)
|
||||
previewError.value = getOperation(projectId).error
|
||||
} else await inspect()
|
||||
} catch (error) {
|
||||
if (!controller.signal.aborted)
|
||||
previewError.value = error instanceof Error ? error.message : '身份输入预览读取失败'
|
||||
} finally {
|
||||
paidPreviewPending.value = false
|
||||
if (previewController === controller) previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交生图参数;省略空参考 ID 以保留后端自动选择逻辑。 */
|
||||
function submit() {
|
||||
if (props.disabled || !valid.value || !acknowledged.value) return
|
||||
const effectiveViewType: IdentityViewType = props.module === 'character' ? viewType.value : 'primary'
|
||||
emit('generate', {
|
||||
viewType: effectiveViewType,
|
||||
...(referenceImageId.value ? { referenceImageId: referenceImageId.value } : {}),
|
||||
...(prompt.value.trim() ? { prompt: prompt.value.trim() } : {}),
|
||||
provider: provider.value,
|
||||
generationOptions: generationOptions.value
|
||||
})
|
||||
if (props.disabled || paidPreviewPending.value || !valid.value || !acknowledged.value) return
|
||||
emit('generate', generationInput.value)
|
||||
}
|
||||
/** formModel 的当前界面状态与输入绑定。 */
|
||||
const formModel = computed(() => ({
|
||||
prompt: prompt.value,
|
||||
viewType: viewType.value,
|
||||
@@ -88,7 +169,7 @@ const rules = {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppDialog v-model:open="open" title="生成身份参考图" :description="subjectName">
|
||||
<AppDialog v-model:open="open" title="生成身份参考图" :description="subjectName" :busy="paidPreviewPending">
|
||||
<AppForm
|
||||
ref="formRef"
|
||||
:model="formModel"
|
||||
@@ -162,6 +243,34 @@ const rules = {
|
||||
@update:provider="provider = $event"
|
||||
@update:options="generationOptions = $event"
|
||||
/>
|
||||
<!-- 以下是真实生图输入预览模块 -->
|
||||
<ConfirmAction
|
||||
v-if="module === 'prop'"
|
||||
label="预览道具真实输入"
|
||||
description="缺少有效结构缓存时可能调用文本模型并产生费用;不会生成身份图片。确认后读取本次最终参数。"
|
||||
:disabled="disabled || !valid || previewLoading"
|
||||
acknowledgement
|
||||
@confirm="loadPreview"
|
||||
/>
|
||||
<NButton v-else :disabled="disabled || !valid" :loading="previewLoading" @click="loadPreview"
|
||||
>预览本次真实输入</NButton
|
||||
>
|
||||
<NAlert v-if="previewError" type="error">{{ previewError }}</NAlert>
|
||||
<div v-if="preview" class="text-xs space-y-3">
|
||||
<p>实际供应方:{{ preview.provider }} · 模型:{{ preview.model }}</p>
|
||||
<p class="whitespace-pre-wrap">最终提示词:{{ preview.providerPrompt }}</p>
|
||||
<pre class="whitespace-pre-wrap break-all">{{
|
||||
JSON.stringify(
|
||||
{
|
||||
referenceImages: preview.referenceImages,
|
||||
referencePlan: preview.referencePlan,
|
||||
generationConfig: preview.generationConfig
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
}}</pre>
|
||||
</div>
|
||||
<NCheckbox
|
||||
id="identity-image-cost"
|
||||
v-model:checked="acknowledged"
|
||||
@@ -170,10 +279,14 @@ const rules = {
|
||||
>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton
|
||||
><NButton :disabled="disabled || !valid || !acknowledged" type="primary" @click="formRef?.validate(submit)">
|
||||
确认生成身份图
|
||||
</NButton>
|
||||
<NButton @click="open = false">取消</NButton
|
||||
><NButton
|
||||
:disabled="disabled || paidPreviewPending || !valid || !acknowledged"
|
||||
type="primary"
|
||||
@click="formRef?.validate(submit)"
|
||||
>
|
||||
确认生成身份图
|
||||
</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
@@ -0,0 +1,109 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NAlert, NButton, NCheckbox, NInputNumber } from 'naive-ui'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import GenerationModelControls from '../../generation-config/components/GenerationModelControls.vue'
|
||||
import type { CreativeProfile, GenerationModelCatalog, GenerationOptions } from '../../generation-config/types'
|
||||
import type { StableAnchorQualityInput } from '../types'
|
||||
|
||||
/** 单主体稳定母版质量生成配置。 */
|
||||
const props = defineProps<{
|
||||
/** 正式主体 ID。 */
|
||||
subjectId: string
|
||||
/** 主体名称。 */
|
||||
subjectName: string
|
||||
/** 模型目录。 */
|
||||
catalog: GenerationModelCatalog
|
||||
/** 项目生成配置。 */
|
||||
profile: CreativeProfile
|
||||
/** 当前是否阻断提交。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 质量弹窗开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 已确认费用的生成事件。 */
|
||||
const emit = defineEmits<{ generate: [input: StableAnchorQualityInput] }>()
|
||||
/** 本次供应方。 */
|
||||
const provider = ref('')
|
||||
/** 本次图片参数。 */
|
||||
const options = ref<GenerationOptions>({})
|
||||
/** 最多修复次数。 */
|
||||
const maxRepairAttempts = ref(0)
|
||||
/** 明确费用确认。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 有限预算和供应方是否可用。 */
|
||||
const valid = computed(
|
||||
() =>
|
||||
!!provider.value &&
|
||||
Number.isInteger(maxRepairAttempts.value) &&
|
||||
maxRepairAttempts.value >= 0 &&
|
||||
maxRepairAttempts.value <= 3
|
||||
)
|
||||
/** 每次重新打开或切主体初始化项目参数。 */
|
||||
watch(
|
||||
() => [open.value, props.subjectId],
|
||||
() => {
|
||||
const selected =
|
||||
props.catalog.images.find(item => item.provider === props.profile.imageProvider && item.enabled) ??
|
||||
props.catalog.images.find(item => item.enabled)
|
||||
provider.value = selected?.provider ?? ''
|
||||
options.value = {
|
||||
...selected?.defaults,
|
||||
...(selected?.provider === props.profile.imageProvider ? props.profile.imageOptions : {})
|
||||
}
|
||||
maxRepairAttempts.value = 0
|
||||
acknowledged.value = false
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/** 改变预算或模型后必须再次确认。 */
|
||||
watch(
|
||||
() => [provider.value, JSON.stringify(options.value), maxRepairAttempts.value],
|
||||
() => {
|
||||
acknowledged.value = false
|
||||
}
|
||||
)
|
||||
/** 提交有限预算的模型生成参数。 */
|
||||
function submit() {
|
||||
if (props.disabled || !valid.value || !acknowledged.value) return
|
||||
emit('generate', {
|
||||
provider: provider.value,
|
||||
generationOptions: { ...options.value },
|
||||
maxRepairAttempts: maxRepairAttempts.value
|
||||
})
|
||||
open.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是单主体母版质量生成费用确认模块 -->
|
||||
<AppDialog v-model:open="open" title="生成稳定母版并校验质量" :description="subjectName">
|
||||
<div class="dialog-form-stack">
|
||||
<NAlert type="warning" :show-icon="false"
|
||||
>最多生成
|
||||
{{ maxRepairAttempts + 1 }}
|
||||
张候选,并逐张调用视觉校验;道具还可能调用结构编译模型,均可能产生费用。只有真实通过后,后端才会切换母版并锁定身份。</NAlert
|
||||
>
|
||||
<GenerationModelControls
|
||||
type="image"
|
||||
:catalog="catalog"
|
||||
:provider="provider"
|
||||
:options="options"
|
||||
:aspect-ratio="profile.aspectRatio"
|
||||
:disabled="disabled"
|
||||
@update:provider="provider = $event"
|
||||
@update:options="options = $event"
|
||||
/>
|
||||
<label
|
||||
>最多修复次数(0–3)<NInputNumber v-model:value="maxRepairAttempts" :min="0" :max="3" :precision="0"
|
||||
/></label>
|
||||
<NCheckbox v-model:checked="acknowledged">我已确认本次候选数量、模型费用,且后台没有同项目任务。</NCheckbox>
|
||||
</div>
|
||||
<template #footer
|
||||
><NButton @click="open = false">取消</NButton
|
||||
><NButton type="primary" :disabled="disabled || !valid || !acknowledged" @click="submit"
|
||||
>确认生成并校验</NButton
|
||||
></template
|
||||
>
|
||||
</AppDialog>
|
||||
</template>
|
||||
@@ -167,3 +167,81 @@ export type IdentityReceipt =
|
||||
| { kind: 'identities'; title: string; result: IdentityBatchResult }
|
||||
| { kind: 'casting'; title: string; result: CastingBatchResult }
|
||||
| { kind: 'stable-anchors'; title: string; result: StableAnchorBatchResult }
|
||||
|
||||
/** 最终身份图片 Provider 输入,直接对应身份预览接口。 */
|
||||
export interface IdentityImagePreview {
|
||||
/** 实际供应方。 */
|
||||
provider: string
|
||||
/** 实际模型。 */
|
||||
model: string
|
||||
/** 最终提示词。 */
|
||||
providerPrompt: string
|
||||
/** 实际引用图片地址。 */
|
||||
referenceImages: string[]
|
||||
/** 后端参考图选择计划。 */
|
||||
referencePlan: Record<string, unknown>
|
||||
/** 后端解析后的生成配置。 */
|
||||
generationConfig: Record<string, unknown>
|
||||
}
|
||||
|
||||
/** 指定身份图片的视觉校验回执。 */
|
||||
export interface IdentityValidationResult {
|
||||
/** 正式主体 ID。 */
|
||||
subjectId: string
|
||||
/** 被校验的图片 ID。 */
|
||||
imageId: string
|
||||
/** 是否通过本次校验。 */
|
||||
passed: boolean
|
||||
/** 校验总结。 */
|
||||
summary: string
|
||||
/** 具体问题。 */
|
||||
issues: Array<{
|
||||
/** 问题类型。 */
|
||||
type: string
|
||||
/** 严重程度。 */
|
||||
severity: string
|
||||
/** 问题描述。 */
|
||||
description: string
|
||||
}>
|
||||
}
|
||||
|
||||
/** 有限预算的单主体稳定母版生成参数。 */
|
||||
export interface StableAnchorQualityInput {
|
||||
/** 最大修复次数,页面限制为 0 到 3。 */
|
||||
maxRepairAttempts: number
|
||||
/** 本次供应方。 */
|
||||
provider: string
|
||||
/** 本次图片生成参数。 */
|
||||
generationOptions: Record<string, string | number | boolean>
|
||||
}
|
||||
|
||||
/** 单主体质量闭环的真实终态回执。 */
|
||||
export interface StableAnchorQualityResult {
|
||||
/** 最终是否通过。 */
|
||||
passed: boolean
|
||||
/** 最后一张候选图片 ID。 */
|
||||
imageId?: string
|
||||
/** 实际修复次数。 */
|
||||
repairAttempts: number
|
||||
/** 后端停止原因。 */
|
||||
stopReason?: string
|
||||
/** 重复错误签名。 */
|
||||
repeatedErrorSignature?: string
|
||||
/** 每轮结果。 */
|
||||
attempts: Array<{
|
||||
/** 从零开始的轮次。 */
|
||||
attempt: number
|
||||
/** 本轮图片 ID。 */
|
||||
imageId: string
|
||||
/** 本轮是否通过。 */
|
||||
passed: boolean
|
||||
/** 原始诊断问题。 */
|
||||
issues: unknown[]
|
||||
/** 结构问题类型。 */
|
||||
structuralIssueTypes?: string[]
|
||||
/** 错误签名。 */
|
||||
errorSignature?: string
|
||||
}>
|
||||
/** 通过后原子确认的母版与锁定回执。 */
|
||||
confirmed?: ConfirmCastingResult
|
||||
}
|
||||
@@ -10,6 +10,9 @@ import { useProjectContext } from '../projects/context'
|
||||
import { subjectIdentityApi } from './api'
|
||||
import { canBeAnchor, getIdentitySession, groupIdentitySubjects, mergeCastingSubjects } from './model'
|
||||
import type {
|
||||
IdentityValidationResult,
|
||||
StableAnchorQualityInput,
|
||||
StableAnchorQualityResult,
|
||||
GenerateCastingCandidateInput,
|
||||
GenerateIdentityImageInput,
|
||||
IdentityImage,
|
||||
@@ -82,7 +85,9 @@ export function useSubjectIdentity() {
|
||||
)
|
||||
const subject = computed(() => subjects.value.find(item => item.id === selectedId.value))
|
||||
const selectionKey = computed(() => subject.value?.id ?? '')
|
||||
const detailRef = {} as { current?: ReturnType<typeof usePolling<{ identity: SubjectIdentity | null; images: IdentityImage[] }>> }
|
||||
const detailRef = {} as {
|
||||
current?: ReturnType<typeof usePolling<{ identity: SubjectIdentity | null; images: IdentityImage[] }>>
|
||||
}
|
||||
const detailPollInterval = computed(() =>
|
||||
detailRef.current?.data.value?.images.some(image => image.status === 'pending' || image.status === 'generating')
|
||||
? 4000
|
||||
@@ -163,6 +168,72 @@ export function useSubjectIdentity() {
|
||||
editorRevision.value++
|
||||
})
|
||||
|
||||
/** 校验结果以正式主体 ID 保存,切换主体不会串回执。 */
|
||||
const validationResults = ref<Record<string, IdentityValidationResult>>({})
|
||||
/** 质量闭环结果以正式主体 ID 保存。 */
|
||||
const qualityResults = ref<Record<string, StableAnchorQualityResult>>({})
|
||||
/** 当前主体的指定图片校验结果。 */
|
||||
const validationResult = computed(() => validationResults.value[selectedId.value] ?? null)
|
||||
/** 当前主体的质量闭环回执。 */
|
||||
const qualityResult = computed(() => qualityResults.value[selectedId.value] ?? null)
|
||||
/**
|
||||
* 校验当前主体的正式图片,费用确认由图库负责。
|
||||
* @param imageId 指定正式身份图片 ID
|
||||
*/
|
||||
async function validateImage(imageId: string) {
|
||||
const image = images.value.find(item => item.id === imageId)
|
||||
if (detailBlocked.value || !subject.value || image?.status !== 'completed' || !image.imageUrl) return
|
||||
const id = subject.value.id
|
||||
const project = projectId.value
|
||||
delete validationResults.value[id]
|
||||
await runOperation(project, '校验身份参考图质量', async () => {
|
||||
const result = await subjectIdentityApi.validateImage(id, imageId)
|
||||
if (result.subjectId !== id || result.imageId !== imageId) throw new Error('身份校验回执与提交目标不匹配')
|
||||
validationResults.value[id] = result
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 为场景或道具执行有限预算质量闭环,仅按真实回执确认锁定。
|
||||
* @param input 模型、参数和修复次数
|
||||
*/
|
||||
async function generateStableAnchorQuality(input: StableAnchorQualityInput) {
|
||||
if (
|
||||
!canGenerateImage.value ||
|
||||
!subject.value ||
|
||||
!identity.value ||
|
||||
!['scene', 'prop'].includes(subject.value.module)
|
||||
)
|
||||
return
|
||||
if (!Number.isInteger(input.maxRepairAttempts) || input.maxRepairAttempts < 0 || input.maxRepairAttempts > 3)
|
||||
return
|
||||
const id = subject.value.id
|
||||
const identityId = identity.value.id
|
||||
const project = projectId.value
|
||||
delete qualityResults.value[id]
|
||||
await runOperation(project, '生成稳定身份母版并校验质量', async () => {
|
||||
const result = await subjectIdentityApi.generateStableAnchorQuality(id, input)
|
||||
if (
|
||||
result.passed &&
|
||||
(!result.confirmed ||
|
||||
result.confirmed.subjectId !== id ||
|
||||
result.confirmed.identityId !== identityId ||
|
||||
!result.confirmed.isLocked ||
|
||||
!result.confirmed.anchor.isAnchor ||
|
||||
result.confirmed.anchor.id !== result.imageId)
|
||||
)
|
||||
throw new Error('质量生成的母版与锁定回执未确认,请刷新核对')
|
||||
qualityResults.value[id] = result
|
||||
})
|
||||
if (projectId.value === project) {
|
||||
await Promise.all([
|
||||
catalog.refresh(),
|
||||
castingQuery.refresh(),
|
||||
projectContext.refreshStageReadiness(),
|
||||
...(selectedId.value === id ? [detail.refresh()] : [])
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
/** 长请求跨主体切换后只更新原项目的操作回执,不用旧响应覆盖新主体。 */
|
||||
async function writeIdentity(label: string, action: (id: string) => Promise<SubjectIdentity>) {
|
||||
if (detailBlocked.value || !subject.value) return
|
||||
@@ -447,6 +518,10 @@ export function useSubjectIdentity() {
|
||||
generateCastingCandidate,
|
||||
setAnchor,
|
||||
confirmStableAnchor,
|
||||
confirmCasting
|
||||
confirmCasting,
|
||||
validateImage,
|
||||
generateStableAnchorQuality,
|
||||
validationResult,
|
||||
qualityResult
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,29 @@ const statusType = computed(() =>
|
||||
)
|
||||
const finished = computed(() => ['completed', 'failed'].includes(props.execution?.status ?? ''))
|
||||
const videoQuality = computed(() => props.execution?.workflowName === 'video-quality')
|
||||
/** 首帧质量后台任务使用独立的通过与修复失败统计,不套用普通生图字段。 */
|
||||
const keyframeQuality = computed(() => props.execution?.workflowName === 'keyframe-quality')
|
||||
/** 只接受后端完整的质量计数,畸形或缺失结果不显示全成功。 */
|
||||
const keyframeCounts = computed(() => {
|
||||
const fields = ['targetCount', 'passed', 'repairFailed', 'failed'] as const
|
||||
if (
|
||||
!fields.every(
|
||||
field =>
|
||||
typeof result.value[field] === 'number' &&
|
||||
Number.isSafeInteger(result.value[field]) &&
|
||||
Number(result.value[field]) >= 0
|
||||
)
|
||||
)
|
||||
return null
|
||||
const counts = {
|
||||
targetCount: Number(result.value.targetCount),
|
||||
passed: Number(result.value.passed),
|
||||
repairFailed: Number(result.value.repairFailed),
|
||||
failed: Number(result.value.failed)
|
||||
}
|
||||
return counts.passed + counts.repairFailed + counts.failed === counts.targetCount ? counts : null
|
||||
})
|
||||
/** 范围描述保留指定镜头或剧集,不把小批量误显示为全项目。 */
|
||||
const scopeLabel = computed(() => {
|
||||
const metadata = props.execution?.metadata
|
||||
if (!metadata) return ''
|
||||
@@ -32,6 +55,7 @@ const scopeLabel = computed(() => {
|
||||
: metadata.inputModeFilter === 'omni_reference'
|
||||
? '全模态参考'
|
||||
: '全部推荐模式'
|
||||
if (keyframeQuality.value && typeof metadata.shotId === 'string') return `${episode} · 单镜头`
|
||||
return videoQuality.value ? `${episode} · ${mode}` : episode
|
||||
})
|
||||
const inputPlanCounts = computed(() => {
|
||||
@@ -78,8 +102,8 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
aria-label="隐藏制作任务记录"
|
||||
title="隐藏制作任务记录"
|
||||
@click="emit('dismiss')"
|
||||
><X :size="15" /></NButton
|
||||
>
|
||||
><X :size="15"
|
||||
/></NButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -101,12 +125,19 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</p>
|
||||
<NAlert v-if="execution.status === 'running'" type="info" :show-icon="false" class="mt-3">
|
||||
{{
|
||||
videoQuality
|
||||
? '系统会继续生成、检查并按需修复。'
|
||||
: '系统会继续处理剩余内容并保存已完成结果。'
|
||||
videoQuality ? '系统会继续生成、检查并按需修复。' : '系统会继续处理剩余内容并保存已完成结果。'
|
||||
}}可以离开或刷新页面,返回后会继续显示本次任务进度,请勿重复提交。
|
||||
</NAlert>
|
||||
<NAlert v-else-if="execution.status === 'completed'" type="success" :show-icon="false" class="mt-3">
|
||||
<NAlert
|
||||
v-else-if="execution.status === 'completed'"
|
||||
:type="
|
||||
keyframeQuality && (!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
|
||||
? 'warning'
|
||||
: 'success'
|
||||
"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>本轮任务已结束,页面正在重新读取镜头资产状态。</p>
|
||||
<p v-if="videoQuality" class="mt-2 text-xs">
|
||||
目标 {{ result.targetCount ?? execution.total }} · 通过 {{ result.passed ?? 0 }} · 修复耗尽
|
||||
@@ -117,7 +148,14 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
输入规划:首帧模式 {{ inputPlanCounts.firstFrame }} · 全模态参考
|
||||
{{ inputPlanCounts.omniReference }}
|
||||
</p>
|
||||
<p v-else class="mt-2 text-xs">
|
||||
<p v-else-if="keyframeQuality" class="mt-2 text-xs">
|
||||
<template v-if="keyframeCounts"
|
||||
>目标 {{ keyframeCounts.targetCount }} · 通过 {{ keyframeCounts.passed }} · 修复未通过
|
||||
{{ keyframeCounts.repairFailed }} · 调用失败 {{ keyframeCounts.failed }}</template
|
||||
>
|
||||
<template v-else>后端首帧质量统计不完整,请查看任务详情并刷新核对。</template>
|
||||
</p>
|
||||
<p v-else-if="!videoQuality" class="mt-2 text-xs">
|
||||
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
|
||||
{{ result.skipped ?? 0 }} · 阻塞 {{ result.blocked ?? 0 }} · 失败 {{ result.failed ?? 0 }}
|
||||
</p>
|
||||
@@ -125,7 +163,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<NAlert v-else-if="execution.status === 'failed'" type="error" :show-icon="false" class="mt-3">
|
||||
<p>{{ execution.error || '制作任务执行失败。' }}</p>
|
||||
<p class="mt-2 text-xs">
|
||||
请先刷新下方视频状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。
|
||||
请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。
|
||||
</p>
|
||||
</NAlert>
|
||||
<details class="mt-3 text-[10px] text-muted">
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
import { computed, ref, watch, type Ref } from 'vue'
|
||||
import { computed, onScopeDispose, reactive, ref, watch, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { workflowExecutionApi } from './execution-api'
|
||||
|
||||
const storagePrefix = 'short-drama:workflow-execution'
|
||||
|
||||
/** 同项目观察器共享真实后台句柄与活动状态,防止绕过弹窗重复付费启动。 */
|
||||
interface ExecutionActivity {
|
||||
/** 任务所属项目。 */
|
||||
projectId: string
|
||||
/** 后端实际任务编号。 */
|
||||
id: string
|
||||
/** 尚未取得终态时保持活动锁。 */
|
||||
active: boolean
|
||||
/** 同一任务取得终态后,任何迟到记录都不能使它重新活动。 */
|
||||
terminal: boolean
|
||||
}
|
||||
/** 活动状态按项目和工作流共同隔离。 */
|
||||
const executionActivity = reactive<Record<string, ExecutionActivity>>({})
|
||||
|
||||
/**
|
||||
* 检查项目是否仍有已跟踪且未结束的后台任务。
|
||||
* @param projectId 正式项目 ID
|
||||
* @returns 是否存在活动后台任务
|
||||
*/
|
||||
export function hasActiveWorkflowExecution(projectId: string) {
|
||||
return Object.values(executionActivity).some(record => record.projectId === projectId && record.active)
|
||||
}
|
||||
|
||||
/** 任务阶段短标签;未知后端阶段保留原值,避免静默隐藏新能力。 */
|
||||
export function executionStageLabel(stage: string | null) {
|
||||
if (!stage) return '等待后端开始'
|
||||
@@ -19,6 +42,11 @@ export function executionStageLabel(stage: string | null) {
|
||||
resumeGeneration: '恢复分集剧本生成',
|
||||
resumeRewrite: '恢复剧本改写',
|
||||
breakdown: '拆解剧本',
|
||||
storyboardRegenerate: '重生成单集镜头',
|
||||
storyboardDirection: '生成导演设计',
|
||||
storyboardVisualState: '生成即时状态',
|
||||
keyframe_generation: '生成普通首帧',
|
||||
videoPrompt: '生成视频提示词',
|
||||
breakdownRetry: '重试失败拆解任务',
|
||||
breakdownResumeShots: '补齐分镜镜头',
|
||||
breakdownResumeStoryboard: '修复分镜绑定',
|
||||
@@ -34,6 +62,7 @@ export function executionStageLabel(stage: string | null) {
|
||||
finalize: '收尾生产状态',
|
||||
manualReview: '等待人工处理',
|
||||
video_prompt: '生成视频提示词',
|
||||
keyframe_quality: '首帧质量生成',
|
||||
submitting: '提交视频候选',
|
||||
generating: '生成视频',
|
||||
validating: '质量校验',
|
||||
@@ -64,6 +93,11 @@ function savedExecutionId(projectId: string, workflowName: string) {
|
||||
|
||||
/** 跟踪一个项目最近的持久化任务;刷新页面后从本地句柄恢复,状态仍从后端读取。 */
|
||||
export function useWorkflowExecution(projectId: Ref<string>, workflowName: string) {
|
||||
/** 卸载后仍保存原项目返回的句柄,但不再更新已销毁的观察器。 */
|
||||
let disposed = false
|
||||
onScopeDispose(() => {
|
||||
disposed = true
|
||||
})
|
||||
const executionId = ref('')
|
||||
const terminal = ref(false)
|
||||
watch(
|
||||
@@ -71,13 +105,48 @@ export function useWorkflowExecution(projectId: Ref<string>, workflowName: strin
|
||||
value => {
|
||||
executionId.value = savedExecutionId(value, workflowName)
|
||||
terminal.value = false
|
||||
if (executionId.value && executionActivity[storageKey(value, workflowName)]?.id !== executionId.value)
|
||||
executionActivity[storageKey(value, workflowName)] = {
|
||||
projectId: value,
|
||||
id: executionId.value,
|
||||
active: true,
|
||||
terminal: false
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/** 同页面其它入口跟踪了任务时,同步句柄并读取同一后台状态。 */
|
||||
watch(
|
||||
() => executionActivity[storageKey(projectId.value, workflowName)]?.id,
|
||||
id => {
|
||||
if (id && id !== executionId.value) {
|
||||
terminal.value = false
|
||||
executionId.value = id
|
||||
}
|
||||
}
|
||||
)
|
||||
const key = computed(() => executionId.value)
|
||||
const query = usePolling(
|
||||
key,
|
||||
(id, signal) => (id ? workflowExecutionApi.get(id, signal) : Promise.resolve(null)),
|
||||
async (id, signal) => {
|
||||
if (!id) return null
|
||||
const targetProjectId = projectId.value
|
||||
const record = await workflowExecutionApi.get(id, signal)
|
||||
if (record.projectId !== targetProjectId || record.workflowName !== workflowName || record.id !== id)
|
||||
throw new Error('后台任务与当前项目或工作流不匹配,请刷新核对。')
|
||||
const activity = executionActivity[storageKey(targetProjectId, workflowName)]
|
||||
if (
|
||||
!signal.aborted &&
|
||||
!disposed &&
|
||||
projectId.value === targetProjectId &&
|
||||
activity?.id === id &&
|
||||
!activity.terminal
|
||||
) {
|
||||
activity.terminal = ['completed', 'failed'].includes(record.status)
|
||||
activity.active = !activity.terminal
|
||||
}
|
||||
return record
|
||||
},
|
||||
computed(() => (executionId.value && !terminal.value ? 1_500 : false))
|
||||
)
|
||||
watch(
|
||||
@@ -86,16 +155,31 @@ export function useWorkflowExecution(projectId: Ref<string>, workflowName: strin
|
||||
terminal.value = status === 'completed' || status === 'failed'
|
||||
}
|
||||
)
|
||||
const active = computed(
|
||||
() =>
|
||||
!!executionId.value &&
|
||||
(!query.data.value || ['pending', 'running'].includes(query.data.value.status))
|
||||
)
|
||||
const active = computed(() => {
|
||||
const activity = executionActivity[storageKey(projectId.value, workflowName)]
|
||||
return activity?.id === executionId.value
|
||||
? activity.active
|
||||
: !!executionId.value && (!query.data.value || ['pending', 'running'].includes(query.data.value.status))
|
||||
})
|
||||
|
||||
/** 保存后端返回的真实 executionId,随后立即读取一次权威状态。 */
|
||||
async function track(id: string) {
|
||||
if (!id || !projectId.value) return
|
||||
if (typeof localStorage !== 'undefined') localStorage.setItem(storageKey(projectId.value, workflowName), id)
|
||||
/**
|
||||
* 保存任务原项目的真实句柄,只有仍查看该项目时才读取权威状态。
|
||||
* @param id 后端任务编号
|
||||
* @param targetProjectId 启动请求时固定的原项目 ID
|
||||
* @returns 保存句柄与可用观察器刷新完成
|
||||
*/
|
||||
async function track(id: string, targetProjectId = projectId.value) {
|
||||
if (typeof id !== 'string' || !id.trim()) throw new Error('后端未返回有效任务编号,请刷新状态,勿重复提交。')
|
||||
if (!targetProjectId) return
|
||||
if (typeof localStorage !== 'undefined') localStorage.setItem(storageKey(targetProjectId, workflowName), id)
|
||||
if (executionActivity[storageKey(targetProjectId, workflowName)]?.id !== id)
|
||||
executionActivity[storageKey(targetProjectId, workflowName)] = {
|
||||
projectId: targetProjectId,
|
||||
id,
|
||||
active: true,
|
||||
terminal: false
|
||||
}
|
||||
if (disposed || projectId.value !== targetProjectId) return
|
||||
terminal.value = false
|
||||
executionId.value = id
|
||||
await query.refresh()
|
||||
@@ -103,6 +187,8 @@ export function useWorkflowExecution(projectId: Ref<string>, workflowName: strin
|
||||
|
||||
/** 只隐藏当前观察记录,不取消后端任务。 */
|
||||
function dismiss() {
|
||||
if (active.value) return
|
||||
delete executionActivity[storageKey(projectId.value, workflowName)]
|
||||
if (projectId.value && typeof localStorage !== 'undefined')
|
||||
localStorage.removeItem(storageKey(projectId.value, workflowName))
|
||||
executionId.value = ''
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { reactive } from 'vue'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { hasActiveWorkflowExecution } from './execution'
|
||||
|
||||
/** 当前浏览器会话中的操作状态;切换路由不会丢失长请求。 */
|
||||
export interface Operation {
|
||||
@@ -22,7 +23,23 @@ const operations = reactive<Record<string, Operation>>({})
|
||||
|
||||
/** 取得项目操作状态,不向浏览器持久化虚假的后台运行状态。 */
|
||||
export function getOperation(projectId: string): Operation {
|
||||
return (operations[projectId] ??= { pending: false, label: '', error: '', notice: '', recovery: null })
|
||||
if (operations[projectId]) return operations[projectId]
|
||||
/** 当前 HTTP 操作锁与持久化后台活动锁合并,后台结束前不能重复启动付费操作。 */
|
||||
let requestPending = false
|
||||
return (operations[projectId] = {
|
||||
/** 当前项目是否有短请求或后台任务仍在执行。 */
|
||||
get pending() {
|
||||
return requestPending || hasActiveWorkflowExecution(projectId)
|
||||
},
|
||||
/** 更新短请求锁;后台锁只由后端真实终态释放。 */
|
||||
set pending(value: boolean) {
|
||||
requestPending = value
|
||||
},
|
||||
label: '',
|
||||
error: '',
|
||||
notice: '',
|
||||
recovery: null
|
||||
})
|
||||
}
|
||||
|
||||
/** 只提交一次;断网不自动重试,后台是否已执行由刷新后的 checkpoint 确认。 */
|
||||
|
||||
Reference in new issue
Block a user