feat: 实现剧本创作与拆解前端工作台
This commit is contained in:
1 parent
edc003443f
commit
2ee6f049f6
56 files changed
+7597
-2
No files matched your search
@@ -0,0 +1,401 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import {
|
||||
TabsRoot,
|
||||
TabsList,
|
||||
TabsTrigger,
|
||||
TabsContent,
|
||||
CheckboxRoot,
|
||||
CheckboxIndicator,
|
||||
ProgressRoot,
|
||||
ProgressIndicator
|
||||
} from 'reka-ui'
|
||||
import { Check, Download, Layers, LoaderCircle, ArrowRight } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownApi } from './api'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview } from './types'
|
||||
import { breakdownSnapshot, recoveryOptions, workflowCheckpoints } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import HistoryPanel from '../workflows/HistoryPanel.vue'
|
||||
import SubjectList from './components/SubjectList.vue'
|
||||
import StoryboardList from './components/StoryboardList.vue'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { downloadText, nodeLabel } from '../../lib/format'
|
||||
|
||||
/** 拆解工作区:先预览真实分组,再启动;恢复操作根据 checkpoint 分阶段展示。 */
|
||||
const { project, checkpoints, refresh, error } = useProjectContext()
|
||||
const groupSize = ref(3)
|
||||
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
|
||||
const preview = ref<BreakdownPreview | null>(null)
|
||||
const previewBusy = ref(false)
|
||||
const previewError = ref('')
|
||||
const tab = ref('character')
|
||||
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
|
||||
{ value: 'character', label: '人物', description: '人物身份、外观与形态' },
|
||||
{ value: 'scene', label: '场景', description: '故事空间与环境特征' },
|
||||
{ value: 'prop', label: '道具', description: '关键物件与视觉描述' }
|
||||
]
|
||||
const records = computed(() => workflowCheckpoints(checkpoints.value, 'breakdown'))
|
||||
const snapshot = computed(() => breakdownSnapshot(checkpoints.value))
|
||||
const result = computed(() => snapshot.value?.breakdownResult ?? snapshot.value)
|
||||
const subjects = computed(() => result.value?.subjectCandidates ?? [])
|
||||
const forms = computed(() => result.value?.subjectForms ?? [])
|
||||
const plans = computed(() => result.value?.storyboardPlans ?? [])
|
||||
const shots = computed(() => result.value?.storyboardEpisodeShots ?? [])
|
||||
const summary = computed(() => snapshot.value?.taskSummary)
|
||||
const validation = computed(() => result.value?.storyboardShotValidation ?? snapshot.value?.storyboardShotValidation)
|
||||
const operation = computed(() => getOperation(project.value!.id))
|
||||
const recovery = computed(() => recoveryOptions(checkpoints.value))
|
||||
const execution = computed(() => snapshot.value?.workflowExecution)
|
||||
const taskStopped = computed(() => execution.value?.status === 'failed' || execution.value?.status === 'completed')
|
||||
const showRecovery = computed(
|
||||
() => records.value.length > 0 && (execution.value?.status !== 'completed' || validation.value?.valid === false)
|
||||
)
|
||||
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 canStart = computed(
|
||||
() =>
|
||||
!!project.value?.episodes.length &&
|
||||
project.value.status !== 'generating' &&
|
||||
!!preview.value &&
|
||||
configValid.value &&
|
||||
!operation.value.pending &&
|
||||
!error.value &&
|
||||
(!records.value.length || taskStopped.value)
|
||||
)
|
||||
let previewController: AbortController | undefined
|
||||
let previewVersion = 0
|
||||
|
||||
/** 输入变化立即废弃旧预览,防止按新配置启动旧的任务清单。 */
|
||||
function invalidatePreview() {
|
||||
previewVersion++
|
||||
previewController?.abort()
|
||||
preview.value = null
|
||||
previewBusy.value = false
|
||||
previewError.value = ''
|
||||
}
|
||||
watch(
|
||||
[
|
||||
groupSize,
|
||||
() => modules.value.join(','),
|
||||
() => project.value?.episodes.map(item => item.episode + ':' + item.content).join('|')
|
||||
],
|
||||
invalidatePreview
|
||||
)
|
||||
onScopeDispose(invalidatePreview)
|
||||
|
||||
/** Reka Checkbox 的不确定值不视为选择。 */
|
||||
function toggleModule(module: BreakdownModule, checked: boolean | 'indeterminate') {
|
||||
if (checked === true && !modules.value.includes(module)) modules.value.push(module)
|
||||
else modules.value = modules.value.filter(item => item !== module)
|
||||
}
|
||||
|
||||
/** 获取服务器生成的任务分组,不在浏览器伪造任务 ID。 */
|
||||
async function loadPreview() {
|
||||
if (!configValid.value || !project.value || previewBusy.value) return
|
||||
invalidatePreview()
|
||||
const version = previewVersion
|
||||
previewController = new AbortController()
|
||||
previewBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.preview(project.value.id, input.value, previewController.signal)
|
||||
if (version === previewVersion) preview.value = data
|
||||
} catch (cause) {
|
||||
if (version === previewVersion) previewError.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === previewVersion) previewBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 长请求不随路由切换取消,返回后刷新 checkpoint 与正式项目数据。 */
|
||||
async function run(action: BreakdownAction) {
|
||||
if (!project.value || operation.value.pending || error.value) return
|
||||
if (action === 'start' && !canStart.value) return
|
||||
const labels: Record<BreakdownAction, string> = {
|
||||
start: '正在拆解剧本',
|
||||
retry: '正在重试失败抽取',
|
||||
'resume-shots': '正在补齐镜头',
|
||||
'resume-storyboard': '正在修复分镜绑定'
|
||||
}
|
||||
const id = project.value.id
|
||||
await runOperation(id, labels[action], () =>
|
||||
breakdownApi.run(id, action, action === 'start' ? input.value : undefined)
|
||||
)
|
||||
await refresh()
|
||||
}
|
||||
|
||||
/** 导出所见的后端结果;阶段性数据也明确标记为 snapshot。 */
|
||||
function exportResult() {
|
||||
if (!snapshot.value) return
|
||||
downloadText(
|
||||
`breakdown-${project.value?.id}-snapshot.json`,
|
||||
JSON.stringify(snapshot.value, null, 2),
|
||||
'application/json'
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mt-6">
|
||||
<div v-if="!project?.episodes.length" class="panel">
|
||||
<EmptyState
|
||||
title="还没有可拆解的剧集"
|
||||
description="先完成剧本创作。拆解会读取数据库中的正式剧集,不需要上传 checkpoint。"
|
||||
><RouterLink class="button button-primary" :to="`/projects/${project?.id}/create-drama`"
|
||||
>前往剧本创作<ArrowRight :size="14" /></RouterLink
|
||||
></EmptyState>
|
||||
</div>
|
||||
<template v-else>
|
||||
<section class="panel p-5 lg:p-6">
|
||||
<div class="mb-5 flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 class="flex items-center gap-2 font-semibold"><Layers :size="17" />拆解设置</h2>
|
||||
<p class="mt-2 text-xs leading-5 text-muted">
|
||||
读取已保存的
|
||||
{{ project.episodes.length }} 集剧本。每个分组分别抽取所选模块,再生成主体与分镜。
|
||||
</p>
|
||||
</div>
|
||||
<span class="tag">来源:正式剧集</span>
|
||||
</div>
|
||||
<div class="breakdown-config">
|
||||
<div>
|
||||
<label class="field-label" for="group-size">每组集数</label>
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
id="group-size"
|
||||
v-model.number="groupSize"
|
||||
type="number"
|
||||
class="input w-24"
|
||||
min="1"
|
||||
step="1"
|
||||
:disabled="operation.pending"
|
||||
/><span class="text-sm text-muted">集 / 组</span>
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="flex flex-wrap gap-5 border-0 p-0">
|
||||
<legend class="field-label mb-3">抽取模块</legend>
|
||||
<label
|
||||
v-for="option in moduleOptions"
|
||||
:key="option.value"
|
||||
class="flex cursor-pointer items-start gap-2.5"
|
||||
><CheckboxRoot
|
||||
:model-value="modules.includes(option.value)"
|
||||
:disabled="operation.pending"
|
||||
class="checkbox mt-0.5"
|
||||
:aria-label="option.label"
|
||||
@update:model-value="toggleModule(option.value, $event)"
|
||||
><CheckboxIndicator><Check :size="12" /></CheckboxIndicator></CheckboxRoot
|
||||
><span
|
||||
><span class="block text-sm font-medium">{{ option.label }}</span
|
||||
><span class="mt-1 block text-[11px] text-muted">{{ option.description }}</span></span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
<button
|
||||
class="button button-secondary self-end"
|
||||
:disabled="!configValid || previewBusy || operation.pending || !!error"
|
||||
@click="loadPreview"
|
||||
>
|
||||
<LoaderCircle v-if="previewBusy" :size="14" class="animate-spin" />预览分组
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="!configValid" class="mt-4 text-xs text-danger">
|
||||
每组集数必须是正整数,并至少选择一个抽取模块。
|
||||
</p>
|
||||
<p v-if="previewError" class="alert alert-error mt-4" role="alert">{{ previewError }}</p>
|
||||
<div v-if="preview" class="group-preview">
|
||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<p class="text-sm">
|
||||
<strong>{{ preview.groupCount }}</strong> 个分组 <span class="mx-2 text-faint">/</span>
|
||||
<strong>{{ preview.estimatedTaskCount }}</strong> 个抽取任务
|
||||
</p>
|
||||
<ConfirmAction
|
||||
:label="records.length ? '重新拆解' : '开始拆解'"
|
||||
:description="
|
||||
records.length
|
||||
? '这会重新运行整个 Breakdown,可能替换已保存的主体与分镜。只想恢复失败阶段时,请使用下方对应恢复操作。'
|
||||
: '将按当前预览配置启动完整的 Breakdown 工作流。抽取结束后仍需完成主体整理、分镜生成与入库。'
|
||||
"
|
||||
:acknowledgement="records.length > 0"
|
||||
primary
|
||||
:disabled="!canStart"
|
||||
@confirm="run('start')"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<div v-for="group in preview.groups" :key="group.groupId" class="group-chip">
|
||||
<span class="text-muted">{{ String(group.groupNo).padStart(2, '0') }}</span
|
||||
><span>第 {{ group.startEpisodeNo }}–{{ group.endEpisodeNo }} 集</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="project.status === 'generating'" class="mt-4 text-xs text-danger">
|
||||
剧本仍在生成,暂不允许启动拆解,避免读取到不完整的剧集。
|
||||
</p>
|
||||
<p v-if="records.length && !taskStopped" class="mt-4 text-xs leading-5 text-muted">
|
||||
后端尚无明确的完成或失败记录。为避免重复执行,已禁用整条重新拆解;如进程已中断,请先核实后台,再选择对应恢复操作。
|
||||
</p>
|
||||
</section>
|
||||
<section v-if="snapshot" class="mt-5">
|
||||
<div class="mb-3 flex flex-wrap items-center justify-between gap-3">
|
||||
<h2 class="text-sm font-medium">
|
||||
最近可用拆解快照
|
||||
<span class="ml-2 text-xs font-normal text-muted">{{
|
||||
nodeLabel(records.at(-1)?.metadata?.nodeName)
|
||||
}}</span>
|
||||
</h2>
|
||||
<StatusBadge
|
||||
:status="execution?.status || 'unknown'"
|
||||
:label="
|
||||
execution?.status === 'completed'
|
||||
? '工作流已完成'
|
||||
: execution?.status === 'failed'
|
||||
? '工作流失败'
|
||||
: '阶段快照 · 执行状态待确认'
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="summary" class="flex flex-wrap items-center gap-x-6 gap-y-2 text-xs text-muted">
|
||||
<span
|
||||
>抽取完成 <strong class="text-ink">{{ summary.completed }} / {{ summary.total }}</strong></span
|
||||
><span>失败 {{ summary.failed }}</span
|
||||
><span>主体 {{ subjects.length }}</span
|
||||
><span>分镜剧集 {{ shots.length }} / {{ plans.length }}</span>
|
||||
</div>
|
||||
<ProgressRoot
|
||||
v-if="summary?.total"
|
||||
class="progress-track mt-3"
|
||||
:model-value="summary.completed"
|
||||
:max="summary.total"
|
||||
aria-label="已完成抽取任务"
|
||||
><ProgressIndicator
|
||||
class="progress-fill"
|
||||
:style="{ width: Math.min(100, (summary.completed / summary.total) * 100) + '%' }"
|
||||
/></ProgressRoot>
|
||||
<p v-if="execution?.errorMessage" class="alert alert-error mt-4" role="alert">
|
||||
{{ execution.errorMessage }}
|
||||
</p>
|
||||
<div v-if="validation && !validation.valid" class="alert alert-error mt-4">
|
||||
<p class="font-medium">分镜校验未通过</p>
|
||||
<ul class="mt-2 list-inside list-disc space-y-1">
|
||||
<li v-for="(issue, index) in validation.issues" :key="index">
|
||||
第 {{ issue.episodeNo }} 集<span v-if="issue.beatNo"> / Beat {{ issue.beatNo }}</span
|
||||
><span v-if="issue.shotNo"> / Shot {{ issue.shotNo }}</span
|
||||
>:{{ issue.message }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="showRecovery" class="recovery-strip mt-4">
|
||||
<div>
|
||||
<p class="text-sm font-medium">从中断处继续</p>
|
||||
<p class="mt-1 text-xs leading-5 text-muted">
|
||||
抽取失败、镜头缺失、主体绑定异常分别处理。禁用表示近期 checkpoint 不具备所需数据。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
label="重试失败抽取"
|
||||
description="只重试 character / scene / prop 抽取任务中的失败项。不能用于镜头阶段失败。"
|
||||
acknowledgement
|
||||
:disabled="!recovery.retry || operation.pending || !!error"
|
||||
@confirm="run('retry')"
|
||||
/><ConfirmAction
|
||||
label="补齐缺失镜头"
|
||||
description="复用已完成剧集的镜头,仅生成尚未完成的 Episode Shot,再进行校验与入库。"
|
||||
acknowledgement
|
||||
:disabled="!recovery.shots || operation.pending || !!error"
|
||||
@confirm="run('resume-shots')"
|
||||
/><ConfirmAction
|
||||
label="修复分镜绑定"
|
||||
description="复用已有镜头,修复 SubjectRef 与视觉 Form 绑定,再校验并保存。"
|
||||
acknowledgement
|
||||
:disabled="!recovery.storyboard || operation.pending || !!error"
|
||||
@confirm="run('resume-storyboard')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<TabsRoot v-model="tab" class="mt-7">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<TabsList class="tabs-list" aria-label="拆解结果"
|
||||
><TabsTrigger
|
||||
v-for="option in moduleOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
class="tab-trigger"
|
||||
>{{ option.label
|
||||
}}<span>{{
|
||||
subjects.filter(item => item.module === option.value).length
|
||||
}}</span></TabsTrigger
|
||||
><TabsTrigger value="storyboard" class="tab-trigger">分镜</TabsTrigger
|
||||
><TabsTrigger value="tasks" class="tab-trigger">任务明细</TabsTrigger></TabsList
|
||||
><button class="text-button" :disabled="!snapshot" @click="exportResult">
|
||||
<Download :size="14" />导出 JSON
|
||||
</button>
|
||||
</div>
|
||||
<div class="content-with-history panel mt-4">
|
||||
<main class="min-w-0">
|
||||
<TabsContent v-for="option in moduleOptions" :key="option.value" :value="option.value"
|
||||
><SubjectList
|
||||
:subjects="subjects.filter(item => item.module === option.value)"
|
||||
:forms="forms" /></TabsContent
|
||||
><TabsContent value="storyboard"
|
||||
><StoryboardList :plans="plans" :episodes="shots" /></TabsContent
|
||||
><TabsContent value="tasks" class="p-5"
|
||||
><div v-if="snapshot?.tasks?.length" class="table-scroll">
|
||||
<table class="project-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>分组</th>
|
||||
<th>模块</th>
|
||||
<th>状态</th>
|
||||
<th>尝试</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="task in snapshot.tasks" :key="task.taskId"
|
||||
><tr>
|
||||
<td>
|
||||
第 {{ task.group.startEpisodeNo }}–{{ task.group.endEpisodeNo }} 集
|
||||
</td>
|
||||
<td>
|
||||
{{ moduleOptions.find(item => item.value === task.module)?.label }}
|
||||
</td>
|
||||
<td>
|
||||
<StatusBadge
|
||||
:status="task.status"
|
||||
:label="
|
||||
{
|
||||
pending: '等待中',
|
||||
running: '执行中',
|
||||
completed: '完成',
|
||||
failed: '失败'
|
||||
}[task.status]
|
||||
"
|
||||
/>
|
||||
</td>
|
||||
<td>{{ task.attempt }}</td>
|
||||
</tr>
|
||||
<tr v-if="task.errorMessage">
|
||||
<td colspan="4" class="text-danger">{{ task.errorMessage }}</td>
|
||||
</tr></template
|
||||
>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<EmptyState
|
||||
v-else
|
||||
title="尚无抽取任务记录"
|
||||
description="启动拆解后,任务会在后端保存 checkpoint 时更新。预览中的任务尚未执行。"
|
||||
/></TabsContent>
|
||||
</main>
|
||||
<HistoryPanel :checkpoints="checkpoints" workflow="breakdown" />
|
||||
</div>
|
||||
</TabsRoot>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
import { optionalResource, request } from '../../lib/http'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownPreview, BreakdownState } from './types'
|
||||
|
||||
/** Breakdown API;预览为 GET,启动和恢复为等待完成的长 POST。 */
|
||||
export const breakdownApi = {
|
||||
preview: (id: string, input: BreakdownInput, signal?: AbortSignal) => {
|
||||
const query = new URLSearchParams({ groupSize: String(input.groupSize), modules: input.modules.join(',') })
|
||||
return request<BreakdownPreview>(`/projects/${encodeURIComponent(id)}/breakdown-preview?${query}`, { signal })
|
||||
},
|
||||
latest: (id: string, signal?: AbortSignal) =>
|
||||
optionalResource(request<BreakdownState>(`/projects/${encodeURIComponent(id)}/breakdown/latest`, { signal })),
|
||||
run: (id: string, action: BreakdownAction, input?: BreakdownInput) =>
|
||||
request<BreakdownState>(`/projects/${encodeURIComponent(id)}/breakdown/${action}`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
timeoutMs: 0
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { Clock3 } from '@lucide/vue'
|
||||
import { EmptyState } from '../../../components/ui'
|
||||
import type { EpisodePlan, EpisodeShots } from '../types'
|
||||
|
||||
/** Episode → Beat → Shot 的分层查看,不提前加入下一条 graph 的导演字段。 */
|
||||
const props = defineProps<{ plans: EpisodePlan[]; episodes: EpisodeShots[] }>()
|
||||
const selected = ref<number>()
|
||||
const plans = computed(() => (props.plans.length ? props.plans : props.episodes.map(item => item.episodePlan)))
|
||||
const plan = computed(() => plans.value.find(item => item.episodeNo === selected.value) ?? plans.value[0])
|
||||
const episode = computed(() => props.episodes.find(item => item.episodeNo === plan.value?.episodeNo))
|
||||
const purposeLabels: Record<string, string> = {
|
||||
establish: '建立场景',
|
||||
introduce: '引入',
|
||||
action: '行动',
|
||||
dialogue: '对白',
|
||||
reaction: '反应',
|
||||
reveal: '揭示',
|
||||
transition: '过渡',
|
||||
climax: '高潮',
|
||||
resolution: '收束',
|
||||
hook: '钩子'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="plan" class="p-5 lg:p-7">
|
||||
<div class="mb-5 flex flex-wrap items-center justify-between gap-3">
|
||||
<label class="flex items-center gap-3 text-sm"
|
||||
>选择剧集<select v-model="selected" class="input w-auto" aria-label="选择分镜剧集">
|
||||
<option v-if="selected === undefined" :value="undefined">
|
||||
第 {{ plan.episodeNo }} 集 · {{ plan.episodeTitle }}
|
||||
</option>
|
||||
<option v-for="item in plans" :key="item.episodeNo" :value="item.episodeNo">
|
||||
第 {{ item.episodeNo }} 集 · {{ item.episodeTitle }}
|
||||
</option>
|
||||
</select></label
|
||||
><span class="text-xs text-muted"
|
||||
>{{ plan.beats.length }} 个节拍 ·
|
||||
{{ episode?.beatShots.reduce((sum, beat) => sum + beat.shots.length, 0) ?? 0 }} 个镜头</span
|
||||
>
|
||||
</div>
|
||||
<div class="mb-7 border-l-2 border-accent pl-4">
|
||||
<p class="font-medium">{{ plan.storyGoal }}</p>
|
||||
<p class="mt-2 text-sm leading-6 text-muted">{{ plan.emotionalArc }}</p>
|
||||
</div>
|
||||
<p v-if="!episode" class="alert mb-5">
|
||||
本集已完成节拍规划,镜头尚未生成。请等待进度更新,或在确认中断后使用“补齐缺失镜头”。
|
||||
</p>
|
||||
<section v-for="beat in plan.beats" :key="beat.beatNo" class="beat-section">
|
||||
<div class="beat-heading">
|
||||
<span class="beat-number">{{ String(beat.beatNo).padStart(2, '0') }}</span>
|
||||
<h3 class="text-sm font-semibold">{{ beat.title }}</h3>
|
||||
<span class="tag ml-auto">{{ purposeLabels[beat.purpose] || beat.purpose }}</span>
|
||||
</div>
|
||||
<p class="mb-4 mt-3 text-sm leading-6 text-muted">{{ beat.description }}</p>
|
||||
<div class="space-y-3">
|
||||
<article
|
||||
v-for="shot in episode?.beatShots.find(item => item.beatNo === beat.beatNo)?.shots ?? []"
|
||||
:key="shot.shotNo"
|
||||
class="shot-row"
|
||||
>
|
||||
<div class="shot-label">
|
||||
镜头 {{ String(shot.shotNo).padStart(2, '0')
|
||||
}}<span class="mt-2 flex items-center gap-1 text-[11px]"
|
||||
><Clock3 :size="11" />{{ shot.durationSeconds }}s</span
|
||||
>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h4 class="text-sm font-medium">{{ shot.title }}</h4>
|
||||
<p class="mt-2 text-sm leading-7">{{ shot.description }}</p>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">视觉重点 · {{ shot.visualFocus }}</p>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
<code v-for="ref in shot.subjectRefs" :key="ref" class="subject-ref">{{ ref }}</code>
|
||||
</div>
|
||||
<p v-if="shot.subjectBindings?.length" class="mt-2 text-xs leading-6 text-muted">
|
||||
{{
|
||||
shot.subjectBindings
|
||||
.map(binding => binding.subjectRef + ' · ' + binding.formName)
|
||||
.join(' / ')
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<EmptyState
|
||||
v-else
|
||||
title="分镜规划尚未生成"
|
||||
description="完成主体整理后,工作流会先规划每集的剧情节拍,再逐集生成镜头。"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,67 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { Search, ChevronDown } from '@lucide/vue'
|
||||
import { EmptyState } from '../../../components/ui'
|
||||
import type { SubjectCandidate, SubjectForm } from '../types'
|
||||
|
||||
/** 主体列表按稳定 ref 展示;形态以 profileId 关联。 */
|
||||
const props = defineProps<{ subjects: SubjectCandidate[]; forms: SubjectForm[] }>()
|
||||
const search = ref('')
|
||||
const filtered = computed(() =>
|
||||
props.subjects.filter(item =>
|
||||
`${item.name} ${item.ref} ${item.aliases?.join(' ') ?? ''}`
|
||||
.toLowerCase()
|
||||
.includes(search.value.trim().toLowerCase())
|
||||
)
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-5 lg:p-7">
|
||||
<div class="mb-5 flex items-center justify-between gap-3">
|
||||
<p class="text-sm text-muted">{{ subjects.length }} 个主体</p>
|
||||
<div class="search-field">
|
||||
<Search :size="14" /><input v-model="search" placeholder="搜索名称或引用" aria-label="搜索主体" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="filtered.length" class="divide-y divide-line">
|
||||
<article v-for="subject in filtered" :key="subject.profileId" class="py-5 first:pt-0">
|
||||
<div class="mb-3 flex flex-wrap items-center gap-3">
|
||||
<h3 class="font-semibold">{{ subject.name }}</h3>
|
||||
<code class="subject-ref">{{ subject.ref }}</code
|
||||
><span v-if="subject.aliases?.length" class="text-xs text-muted"
|
||||
>别名:{{ subject.aliases.join('、') }}</span
|
||||
>
|
||||
</div>
|
||||
<p class="text-sm leading-7">{{ subject.description }}</p>
|
||||
<details class="subject-details mt-4">
|
||||
<summary>
|
||||
<ChevronDown :size="14" />外观描述与形态
|
||||
<span class="ml-1 text-muted">{{
|
||||
forms.filter(form => form.profileId === subject.profileId).length
|
||||
}}</span>
|
||||
</summary>
|
||||
<p class="mt-3 whitespace-pre-wrap text-sm leading-7 text-muted">
|
||||
{{ subject.appearance_prompt || '暂无外观描述' }}
|
||||
</p>
|
||||
<div
|
||||
v-for="form in forms.filter(item => item.profileId === subject.profileId)"
|
||||
:key="form.formId"
|
||||
class="mt-3 border-l-2 border-line pl-4"
|
||||
>
|
||||
<p class="text-sm font-medium">
|
||||
{{ form.formName || form.name }}<span v-if="form.isDefault" class="tag ml-2">默认</span>
|
||||
</p>
|
||||
<p class="mt-2 text-sm leading-6 text-muted">{{ form.description }}</p>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">{{ form.appearancePrompt }}</p>
|
||||
</div>
|
||||
</details>
|
||||
</article>
|
||||
</div>
|
||||
<EmptyState
|
||||
v-else
|
||||
:title="subjects.length ? '没有匹配的主体' : '尚无主体结果'"
|
||||
description="主体会在抽取、合并与档案整理完成后出现在这里。若未启用该模块,则不会生成此类主体。"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,3 @@
|
||||
/** Breakdown 模块公共入口。 */
|
||||
export { breakdownApi } from './api'
|
||||
export type { BreakdownInput, BreakdownState, BreakdownModule } from './types'
|
||||
@@ -0,0 +1,154 @@
|
||||
/** 三种可配置的抽取模块,分镜并不是第四个模块。 */
|
||||
export type BreakdownModule = 'character' | 'scene' | 'prop'
|
||||
|
||||
/** 拆解分组,来自后端预览接口。 */
|
||||
export interface EpisodeGroup {
|
||||
groupId: string
|
||||
groupNo: number
|
||||
startEpisodeNo: number
|
||||
endEpisodeNo: number
|
||||
episodes: { episodeId: string; episodeNo: number; title: string }[]
|
||||
}
|
||||
|
||||
/** 抽取任务统计,不代表整个 Breakdown 工作流已完成。 */
|
||||
export interface TaskSummary {
|
||||
total: number
|
||||
pending: number
|
||||
running: number
|
||||
completed: number
|
||||
failed: number
|
||||
finished: number
|
||||
allFinished: boolean
|
||||
hasFailed: boolean
|
||||
}
|
||||
|
||||
/** 单个模块 × 分组的抽取任务。 */
|
||||
export interface BreakdownTask {
|
||||
taskId: string
|
||||
module: BreakdownModule
|
||||
group: EpisodeGroup
|
||||
status: 'pending' | 'running' | 'completed' | 'failed'
|
||||
attempt: number
|
||||
errorMessage?: string
|
||||
}
|
||||
|
||||
/** 传给预览与启动接口的相同配置。 */
|
||||
export interface BreakdownInput {
|
||||
groupSize: number
|
||||
modules: BreakdownModule[]
|
||||
}
|
||||
|
||||
/** 拆解启动前的服务器预览结果。 */
|
||||
export interface BreakdownPreview {
|
||||
episodeCount: number
|
||||
groupCount: number
|
||||
estimatedTaskCount: number
|
||||
groups: EpisodeGroup[]
|
||||
tasks: BreakdownTask[]
|
||||
modules: BreakdownModule[]
|
||||
groupSize: number
|
||||
}
|
||||
|
||||
/** 归一化主体;appearance_prompt 保留后端字段名。 */
|
||||
export interface SubjectCandidate {
|
||||
profileId: string
|
||||
name: string
|
||||
ref: string
|
||||
description: string
|
||||
module: BreakdownModule
|
||||
appearance_prompt: string
|
||||
aliases?: string[]
|
||||
}
|
||||
|
||||
/** 同一主体的不同视觉形态。 */
|
||||
export interface SubjectForm {
|
||||
formId: string
|
||||
profileId: string
|
||||
type: BreakdownModule
|
||||
name: string
|
||||
formName?: string
|
||||
isDefault: boolean
|
||||
description: string
|
||||
appearancePrompt: string
|
||||
}
|
||||
|
||||
/** 分镜规划中的叙事节拍。 */
|
||||
export interface StoryboardBeat {
|
||||
beatNo: number
|
||||
title: string
|
||||
purpose: string
|
||||
description: string
|
||||
visualFocus: string
|
||||
narrativeGoal: string
|
||||
emotionalTone: string
|
||||
estimatedDurationSeconds: number
|
||||
subjectRefs: string[]
|
||||
isKeyBeat: boolean
|
||||
}
|
||||
|
||||
/** 单集分镜规划。 */
|
||||
export interface EpisodePlan {
|
||||
episodeNo: number
|
||||
episodeTitle: string
|
||||
storyGoal: string
|
||||
centralConflict: string
|
||||
emotionalArc: string
|
||||
pacing: string
|
||||
endingHook: string
|
||||
beats: StoryboardBeat[]
|
||||
}
|
||||
|
||||
/** 最小连续镜头及其主体形态绑定。 */
|
||||
export interface StoryboardShot {
|
||||
shotNo: number
|
||||
title: string
|
||||
description: string
|
||||
visualFocus: string
|
||||
subjectRefs: string[]
|
||||
durationSeconds: number
|
||||
subjectBindings?: { subjectRef: string; profileId: string; formId: string; formName: string }[]
|
||||
}
|
||||
|
||||
/** 单集按 Beat 组织的镜头结果。 */
|
||||
export interface EpisodeShots {
|
||||
episodeNo: number
|
||||
episodePlan: EpisodePlan
|
||||
beatShots: { beatNo: number; shots: StoryboardShot[] }[]
|
||||
}
|
||||
|
||||
/** 分镜校验报告。 */
|
||||
export interface ShotValidation {
|
||||
valid: boolean
|
||||
issues: { episodeNo: number; beatNo?: number | null; shotNo?: number | null; message: string }[]
|
||||
}
|
||||
|
||||
/** Breakdown 的最终成果及阶段 checkpoint 共有的可展示字段。 */
|
||||
export interface BreakdownResult {
|
||||
subjectCandidates?: SubjectCandidate[]
|
||||
subjectForms?: SubjectForm[]
|
||||
storyboardPlans?: EpisodePlan[]
|
||||
storyboardEpisodeShots?: EpisodeShots[]
|
||||
storyboardShotValidation?: ShotValidation
|
||||
storyboardNeedsManualReview?: boolean
|
||||
}
|
||||
|
||||
/** 工作流执行结果与抽取任务状态独立。 */
|
||||
export interface WorkflowExecution {
|
||||
executionId: string
|
||||
status: 'running' | 'completed' | 'failed'
|
||||
errorMessage?: string
|
||||
startedAt: string
|
||||
completedAt?: string
|
||||
}
|
||||
|
||||
/** latest 和 checkpoint 的恢复状态;失败 checkpoint 可能只有 execution。 */
|
||||
export interface BreakdownState extends BreakdownResult {
|
||||
workflowExecution?: WorkflowExecution
|
||||
runConfig?: BreakdownInput & { episodeGroups: EpisodeGroup[] }
|
||||
taskSummary?: TaskSummary
|
||||
tasks?: BreakdownTask[]
|
||||
breakdownResult?: BreakdownResult
|
||||
}
|
||||
|
||||
/** 不同失败阶段的恢复端点,不能用 retry 替代所有恢复。 */
|
||||
export type BreakdownAction = 'start' | 'retry' | 'resume-shots' | 'resume-storyboard'
|
||||
Reference in new issue
Block a user