feat: 接入分镜导演设计与即时视觉状态工作台
增加单集和批量生成、修复诊断、正式镜头检查、参考图、生成规格与视频提示词。 补齐接口契约、竞态保护和确认交互测试,保持现有两条工作流。
This commit is contained in:
1 parent
2ee6f049f6
commit
bae69c3c62
22 files changed
+2211
-11
No files matched your search
@@ -0,0 +1,128 @@
|
||||
import { reactive } from 'vue'
|
||||
import type { EpisodeShots } from '../breakdown/types'
|
||||
import type { Checkpoint } from '../workflows/types'
|
||||
import { workflowCheckpoints } from '../workflows/selectors'
|
||||
import type { DesignedShot, EpisodeDirections, EpisodeVisualStates, StoryboardSession } from './types'
|
||||
|
||||
/** 仅保存本会话回执和已返回的 Prompt,切换路由不丢失长请求结果。 */
|
||||
const sessions = reactive<Record<string, StoryboardSession>>({})
|
||||
|
||||
/** 获取指定项目的独立回执容器。 */
|
||||
export function getStoryboardSession(id: string): StoryboardSession {
|
||||
return (sessions[id] ??= { receipt: null, prompts: {} })
|
||||
}
|
||||
|
||||
/** 后端生成服务只读取最新 Breakdown;不能用历史可恢复快照冒充当前生成前置条件。 */
|
||||
export function storyboardPrerequisites(checkpoints: Checkpoint[], episodeNo: number) {
|
||||
const latest = workflowCheckpoints(checkpoints, 'breakdown').at(-1)
|
||||
const state = latest?.state
|
||||
const directionEpisodes = state?.breakdownResult?.storyboardEpisodeShots ?? []
|
||||
const visualEpisodes = state?.storyboardEpisodeShots ?? []
|
||||
return {
|
||||
directionEpisode: directionEpisodes.some(item => item.episodeNo === episodeNo),
|
||||
directionProject: directionEpisodes.length > 0,
|
||||
visualEpisode:
|
||||
visualEpisodes.some(item => item.episodeNo === episodeNo) &&
|
||||
!!state?.subjectCandidates?.length &&
|
||||
!!state?.subjectForms?.length,
|
||||
visualProject: visualEpisodes.length > 0 && !!state?.subjectCandidates?.length && !!state?.subjectForms?.length,
|
||||
breakdownRunning: state?.workflowExecution?.status === 'running'
|
||||
}
|
||||
}
|
||||
|
||||
/** 以正式 Shot ID 关联设计和状态;checkpoint 仅补足标题与剧情描述。 */
|
||||
export function mergeDesignedShots(
|
||||
directions: EpisodeDirections | null,
|
||||
states: EpisodeVisualStates | null,
|
||||
source?: EpisodeShots
|
||||
): DesignedShot[] {
|
||||
const rows = new Map<string, DesignedShot>()
|
||||
for (const beat of directions?.beats ?? []) {
|
||||
for (const shot of beat.shots) {
|
||||
const detail = source?.beatShots
|
||||
.find(item => item.beatNo === beat.beatNo)
|
||||
?.shots.find(item => item.shotNo === shot.shotNo)
|
||||
rows.set(shot.shotId, {
|
||||
shotId: shot.shotId,
|
||||
shotNo: shot.shotNo,
|
||||
beatNo: beat.beatNo,
|
||||
title: detail?.title || `镜头 ${shot.shotNo}`,
|
||||
description: detail?.description || '',
|
||||
visualFocus: detail?.visualFocus || '',
|
||||
durationSeconds: detail?.durationSeconds,
|
||||
direction: shot.direction,
|
||||
visualState: null
|
||||
})
|
||||
}
|
||||
}
|
||||
for (const beat of states?.beats ?? []) {
|
||||
for (const shot of beat.shots) {
|
||||
const row = rows.get(shot.shotId)
|
||||
if (row) row.visualState = shot.visualState
|
||||
else
|
||||
rows.set(shot.shotId, {
|
||||
shotId: shot.shotId,
|
||||
shotNo: shot.shotNo,
|
||||
beatNo: beat.beatNo,
|
||||
title: `镜头 ${shot.shotNo}`,
|
||||
description: '',
|
||||
visualFocus: '',
|
||||
direction: null,
|
||||
visualState: shot.visualState
|
||||
})
|
||||
}
|
||||
}
|
||||
return [...rows.values()].toSorted((a, b) => a.beatNo - b.beatNo || a.shotNo - b.shotNo)
|
||||
}
|
||||
|
||||
/** 摄影枚举翻译;新枚举保留原值,避免静默丢失字段。 */
|
||||
export function directionLabel(value: string, field?: string): string {
|
||||
if (value === 'wide') return field === 'lensIntent' ? '广角' : '远景'
|
||||
const labels: Record<string, string> = {
|
||||
'extreme-wide': '大远景',
|
||||
full: '全景',
|
||||
medium: '中景',
|
||||
'medium-close-up': '近景',
|
||||
'close-up': '特写',
|
||||
'extreme-close-up': '大特写',
|
||||
'eye-level': '平视',
|
||||
'high-angle': '俯拍',
|
||||
'low-angle': '仰拍',
|
||||
overhead: '顶拍',
|
||||
'dutch-angle': '倾斜机位',
|
||||
static: '固定',
|
||||
pan: '水平摇镜',
|
||||
tilt: '垂直摇镜',
|
||||
'push-in': '推进',
|
||||
'pull-out': '拉远',
|
||||
tracking: '跟拍',
|
||||
dolly: '移动摄影',
|
||||
handheld: '手持',
|
||||
crane: '升降',
|
||||
'ultra-wide': '超广角',
|
||||
normal: '标准',
|
||||
portrait: '人像焦段',
|
||||
telephoto: '长焦',
|
||||
deep: '深景深',
|
||||
moderate: '中等景深',
|
||||
shallow: '浅景深'
|
||||
}
|
||||
return labels[value] ?? value
|
||||
}
|
||||
|
||||
/** 只开放 http(s) 与同源 /storage 路径,拦截模型/数据中的 javascript 或协议相对 URL。 */
|
||||
export function referenceImageUrl(value: string): string | null {
|
||||
const raw = value.trim()
|
||||
try {
|
||||
if (raw.startsWith('/storage/') && !raw.includes('\\')) {
|
||||
const api = import.meta.env.VITE_API_BASE_URL || '/api'
|
||||
const origin = /^https?:\/\//i.test(api) ? new URL(api).origin : window.location.origin
|
||||
const url = new URL(raw, origin)
|
||||
return url.pathname.startsWith('/storage/') ? url.href : null
|
||||
}
|
||||
const url = new URL(raw)
|
||||
return ['http:', 'https:'].includes(url.protocol) ? url.href : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user