feat: 接入分镜单集重生成接口

接入后端正式单集 Storyboard Shot 重生成能力,补齐校验回执、旧 Shot 缓存失效与页面刷新逻辑。
This commit is contained in:
GouJ authored and GitHub committed 2026-09-08 20:09:37 +08:00
1 parent b4e1e6873c
commit 6dc3a93348
8 files changed
+159 -10

No files matched your search

+31 -4
View File
@@ -6,8 +6,8 @@ import { getOperation, runOperation } from '../workflows/operations'
import { storyboardApi } from './api'
import { getStoryboardSession, mergeDesignedShots, storyboardPrerequisites } from './model'
/** 分镜页只提供正式项目级生成命令,不暴露后端测试路由。 */
export type StoryboardCommand = 'direction-all' | 'visual-all' | 'prompts'
/** 分镜页只提供正式主流程命令,不暴露后端测试路由。 */
export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all' | 'prompts'
/** 分镜查询、依赖判断与操作入口;不修改后端 graph。 */
export function useStoryboard() {
@@ -61,14 +61,19 @@ export function useStoryboard() {
false
)
const data = query.data
const source = computed(() => sourceEpisodes.value.find(item => item.episodeNo === episodeNo.value))
const session = computed(() => getStoryboardSession(id.value))
/** 单集重生成返回的是最新镜头正文,优先于不会随局部覆盖更新的历史 Breakdown 快照。 */
const source = computed(
() =>
session.value.regeneratedEpisodes[episodeNo.value] ??
sourceEpisodes.value.find(item => item.episodeNo === 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 session = computed(() => getStoryboardSession(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(
@@ -86,7 +91,11 @@ export function useStoryboard() {
data.value.directions.directionCount === data.value.directions.shotCount &&
data.value.directions.coverage === 1
)
const hasCurrentEpisodeShots = computed(
() => Math.max(data.value?.directions.shotCount ?? 0, data.value?.visualStates.shotCount ?? 0) > 0
)
const allowed = computed<Record<StoryboardCommand, boolean>>(() => ({
'shots-current': !blocked.value && episodeNo.value > 0 && hasCurrentEpisodeShots.value,
'direction-all': !blocked.value && prerequisites.value.directionProject && batchValid.value,
'visual-all': !blocked.value && prerequisites.value.visualProject && batchValid.value && repairsValid.value,
prompts: !blocked.value && shots.value.length > 0 && batchValid.value
@@ -98,8 +107,10 @@ export function useStoryboard() {
const projectId = id.value
const batch = { concurrency: concurrency.value, force: force.value }
const repairs = maxRepairAttempts.value
const targetEpisode = episodeNo.value
const target = getStoryboardSession(projectId)
const titles: Record<StoryboardCommand, string> = {
'shots-current': `第 ${targetEpisode} 集镜头`,
'direction-all': '项目导演设计',
'visual-all': '项目即时状态',
prompts: '项目视频提示词'
@@ -107,6 +118,21 @@ 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',
@@ -160,6 +186,7 @@ export function useStoryboard() {
repairsValid,
blocked,
directionComplete,
hasCurrentEpisodeShots,
run
}
}