feat(short-drama-agent-front): 新增拆解候选与质量修订

This commit is contained in:
GJ committed 2026-10-17 08:25:16 +08:00
1 parent 49ad08a63e
commit 3414cc8232
32 files changed
+2319 -454

No files matched your search

+69 -21
View File
@@ -9,7 +9,7 @@ import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue
import { NScrollbar, NButton, NCheckbox, NInputNumber, NProgress, NTab, NTable, NTabs } from 'naive-ui'
import { computed, h, onScopeDispose, ref, watch } from 'vue'
import { useActionMessage } from '../../components/ui/useActionMessage'
import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
import { Layers, LoaderCircle, Settings2 } from '@lucide/vue'
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
import { useProjectContext } from '../projects/context'
import { breakdownApi } from './api'
@@ -22,6 +22,8 @@ import { useWorkflowExecution } from '../workflows/execution'
import SubjectList from './components/SubjectList.vue'
import StoryboardList from './components/StoryboardList.vue'
import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
import BreakdownCandidatePanel from './components/BreakdownCandidatePanel.vue'
import StoryboardQualityRepair from './components/StoryboardQualityRepair.vue'
import type { DiagnosisLocation } from './diagnosis'
import { errorMessage } from '../../lib/http'
import { downloadText, nodeLabel } from '../../lib/format'
@@ -32,6 +34,8 @@ const groupSize = ref(3)
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
const preview = ref<BreakdownPreview | null>(null)
const previewBusy = ref(false)
/** 默认只生成候选,正式替换需单独确认。 */
const candidateOnly = ref(true)
const tab = ref('character')
const toolsOpen = ref(false)
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
@@ -40,6 +44,16 @@ const moduleOptions: { value: BreakdownModule; label: string; description: strin
{ value: 'prop', label: '道具', description: '关键物件与视觉描述' }
]
const records = computed(() => workflowCheckpoints(checkpoints.value, 'breakdown'))
/** 提交候选只读取最新原始记录,避免从旧快照恢复提交资格。 */
const latestCheckpoint = computed(() => records.value.at(-1))
/** 有旧结果后统一采用候选模式,不再从设置入口直接覆盖。 */
watch(
() => records.value.length,
count => {
if (count > 0) candidateOnly.value = true
},
{ immediate: true }
)
const snapshot = computed(() => breakdownSnapshot(checkpoints.value))
const result = computed(() => snapshot.value?.breakdownResult ?? snapshot.value)
const subjects = computed(() => result.value?.subjectCandidates ?? [])
@@ -100,8 +114,13 @@ const showRecovery = computed(
const configValid = computed(
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
)
const input = computed<BreakdownInput>(() => ({ groupSize: groupSize.value, modules: [...modules.value] }))
/** 后端就绪状态决定是否显示后续制作入口。 */
/** 预览配置与明确选择的生成模式共用一次启动快照。 */
const input = computed<BreakdownInput>(() => ({
groupSize: groupSize.value,
modules: [...modules.value],
candidateOnly: candidateOnly.value
}))
/** 后端就绪状态用于拆解完成反馈。 */
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
/** 拆解提示复用全局 NMessage,详细问题留在设置弹窗。 */
const actionMessage = useActionMessage()
@@ -173,6 +192,8 @@ function invalidatePreview() {
watch(
[
groupSize,
candidateOnly,
projectId,
() => modules.value.join(','),
() => project.value?.episodes.map(item => item.episode + ':' + item.content).join('|')
],
@@ -203,7 +224,10 @@ async function loadPreview() {
}
}
/** 长请求不随路由切换取消,返回后刷新 checkpoint 与正式项目数据。 */
/**
* 提交后台任务并观察真实状态,启动时固定当前候选模式。
* @param action 本次启动或恢复动作
*/
async function run(action: BreakdownAction) {
if (project.value?.status !== 'completed' || operation.value.pending || error.value) return
if (action === 'start' && !canStart.value) return
@@ -227,6 +251,11 @@ async function run(action: BreakdownAction) {
await refresh()
}
/** 刷新候选和正式阶段状态,不重放候选生成请求。 */
async function refreshCandidate() {
await Promise.all([refresh(), refreshStageReadiness()])
}
/** 导出当前拆解结果;阶段性数据也明确标记为 snapshot。 */
function exportResult() {
if (!snapshot.value) return
@@ -259,14 +288,16 @@ const rules = {
:status="execution?.status || 'unknown'"
:label="
execution?.status === 'completed'
? '工作流已完成'
? latestCheckpoint?.state.candidateOnly && !latestCheckpoint.state.storyboardPersisted
? '候选生成已完成'
: '工作流已完成'
: execution?.status === 'failed'
? '工作流失败'
: '执行状态待确认'
"
/>
</div>
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗 -->
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗;阶段切换使用侧栏 -->
<div v-if="project?.episodes.length" class="toolbar-actions">
<NButton
v-if="execution?.errorMessage || validation?.valid === false"
@@ -275,9 +306,7 @@ const rules = {
@click="toolsOpen = true"
>查看拆解问题</NButton
>
<RouterLink v-if="stageComplete" :to="`/projects/${projectId}/visual-style`" class="text-button"
>继续视觉风格 →</RouterLink
>
<WorkspaceTools
:pending="operation.pending"
:pending-label="operation.label"
@@ -364,6 +393,18 @@ const rules = {
</NButton>
</div>
</AppForm>
<!-- 以下是候选生成模式,已有拆解结果统一通过安全提交替换 -->
<div class="mt-4 space-y-2">
<NCheckbox
v-model:checked="candidateOnly"
:disabled="operation.pending || records.length > 0"
>
仅生成候选,确认后再提交正式结果
</NCheckbox>
<p class="text-xs leading-6 text-muted">
候选不会替换现有主体和分镜。重新拆解使用候选模式,完成后单独审核与提交。
</p>
</div>
<div v-if="preview" class="group-preview">
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<p class="text-sm">
@@ -376,10 +417,10 @@ const rules = {
isOperationRunning(operation, '正在拆解剧本') ||
backgroundExecution.active.value
"
:label="records.length ? '重新拆解' : '开始拆解'"
:label="candidateOnly ? '生成拆解候选' : '开始拆解'"
:description="
records.length
? '这会重新运行完整剧本拆解,可能替换已保存的主体与分镜。只想恢复失败阶段时,请使用下方对应恢复操作。'
candidateOnly
? '将按当前分组调用模型生成主体、形态与分镜候选,可能产生模型费用。现有正式数据会保留,候选需经独立确认后才提交。'
: '将按当前预览配置启动完整的 剧本拆解流程。抽取结束后仍需完成主体整理、分镜生成与入库。'
"
:acknowledgement="records.length > 0"
@@ -402,6 +443,20 @@ const rules = {
当前任务还没有明确的完成或失败记录。为避免重复执行,已暂停重新拆解;如任务已中断,请先刷新状态,再选择对应恢复操作。
</p>
</section>
<BreakdownCandidatePanel
:project-id="projectId"
:state="latestCheckpoint?.state"
:checkpoint-id="latestCheckpoint?.checkpointId"
:disabled="!!error || operation.pending || backgroundExecution.active.value"
@refresh="refreshCandidate"
/>
<StoryboardQualityRepair
v-if="toolsOpen && snapshot"
:project-id="projectId"
:checkpoint="latestCheckpoint"
:disabled="!!error || operation.pending || backgroundExecution.active.value"
@refresh="refreshCandidate"
/>
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
title="剧本拆解任务"
@@ -533,9 +588,7 @@ const rules = {
<EmptyState
title="还没有可拆解的剧集"
description="先完成剧本创作。拆解会读取数据库中的正式剧集,不需要上传 checkpoint。"
><RouterLink class="button button-primary" :to="`/projects/${project?.id}/create-drama`"
>前往剧本创作<ArrowRight :size="14" /></RouterLink
></EmptyState>
/>
</NScrollbar>
<template v-else>
<section class="breakdown-results-section">
@@ -593,7 +646,7 @@ const rules = {
:episodes="shots"
@diagnose="openShotDiagnosis"
>
<!-- 以下是跟随当前剧集的一行诊断摘要,抽屉独立于列表滚动 -->
<!-- 以下是跟随当前剧集的一行诊断摘要,诊断弹窗独立于列表滚动 -->
<template #diagnosis>
<StoryboardDiagnosis
ref="diagnosisPanel"
@@ -603,11 +656,6 @@ const rules = {
@locate="locateDiagnosisShot"
/>
</template>
<template #actions>
<RouterLink :to="`/projects/${project?.id}/storyboard`" class="text-button"
>进入分镜设计<ArrowRight :size="14"
/></RouterLink>
</template>
</StoryboardList>
</div>
<div v-if="tab === 'tasks'" class="breakdown-result-pad">