feat(short-drama-agent-front): 接入分阶段镜头生产与摄影修订
This commit is contained in:
1 parent
1e9ef33d1d
commit
87427d9d43
29 files changed
+2787
-136
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>分阶段生产 · 隔离验收</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./staged-production.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,299 @@
|
||||
import { createApp, computed, defineComponent, h, provide, ref } from 'vue'
|
||||
import { NButton, NConfigProvider, NGlobalStyle, NMessageProvider, zhCN, dateZhCN } from 'naive-ui'
|
||||
import { useTheme } from '../../src/composables/useTheme'
|
||||
import ActionMessageProvider from '../../src/components/ui/ActionMessageProvider.vue'
|
||||
import StoryboardPage from '../../src/features/storyboard/StoryboardPage.vue'
|
||||
import { projectContextKey, useProjectData } from '../../src/features/projects/context'
|
||||
import {
|
||||
directionsResult,
|
||||
visualStatesResult,
|
||||
storyboardCheckpoint
|
||||
} from '../../src/features/storyboard/testing/fixtures'
|
||||
import { preparationFixture } from '../features/storyboard-preparation/fixtures'
|
||||
import type { WorkflowExecution } from '../../src/features/workflows/execution.types'
|
||||
import { billingCatalog, billingProfile } from '../fixtures/billing'
|
||||
import '../../src/styles/styles.css'
|
||||
import '../../src/styles/admin.css'
|
||||
|
||||
/** 隔离场景,任何请求都不会进入本地真实 API。 */
|
||||
const scenario = new URLSearchParams(location.search).get('scenario') ?? 'direction'
|
||||
/** 固定隔离身份以验证刷新恢复,和正式项目完全分开。 */
|
||||
const projectId = `staged-browser-${scenario}`
|
||||
/** 显式显示模拟写入次数,便于 Chrome 验证没有自动生产。 */
|
||||
const calls = ref<Array<{ path: string; method: string; body: unknown }>>([])
|
||||
/** 当前正式模拟摄影,保留并发版本与原文。 */
|
||||
let directions = directionsResult(projectId)
|
||||
for (const row of directions.beats.flatMap(beat => beat.shots))
|
||||
row.direction = {
|
||||
...row.direction!,
|
||||
id: 'original-' + row.shotId,
|
||||
updatedAt: '2026-11-15T00:00:00.000Z',
|
||||
rawJson: '原摄影原文'
|
||||
}
|
||||
/** 尚无画面状态的镜头允许独立摄影修订。 */
|
||||
let visuals = visualStatesResult(projectId, 1, scenario === 'complete')
|
||||
/** 用于验证用户明确覆盖后的二次保护。 */
|
||||
let conflictNext = false
|
||||
/** 场景的正式质量确认。 */
|
||||
const approval = preparationFixture(projectId)
|
||||
/** 任务当前持久化投影,模拟停止后在途回执的保留。 */
|
||||
let task: WorkflowExecution = {
|
||||
id: 'mock-derived-task',
|
||||
projectId,
|
||||
workflowName: 'storyboard-direction',
|
||||
status: scenario === 'running' ? 'running' : 'completed',
|
||||
stage: scenario === 'running' ? 'storyboardDirection' : 'completed',
|
||||
current: 0,
|
||||
total: 2,
|
||||
currentResourceId: null,
|
||||
metadata: {
|
||||
derivedBatchVersion: 1,
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2'],
|
||||
claims: [{ state: 'submitted', episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] }]
|
||||
},
|
||||
result: null,
|
||||
error: null,
|
||||
startedAt: '2026-11-15T00:00:00Z',
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-15T00:00:00Z',
|
||||
updatedAt: '2026-11-15T00:00:00Z'
|
||||
}
|
||||
if (scenario === 'running') {
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem('staged-browser:task') ?? 'null')
|
||||
if (saved?.projectId === projectId) task = saved
|
||||
} catch {
|
||||
/* 隔离数据损坏不构造正式任务。 */
|
||||
}
|
||||
localStorage.setItem(`short-drama:workflow-execution:${projectId}:storyboard-direction`, task.id)
|
||||
}
|
||||
/**
|
||||
* 全量拦截当前页面请求,未知接口拒绝,不连接正式项目、模型或资产。
|
||||
* @param input 原接口地址
|
||||
* @param init 原请求方法与正文
|
||||
* @returns 与原正式路由同形状的隔离数据
|
||||
*/
|
||||
window.fetch = async (input, init) => {
|
||||
const path = String(input),
|
||||
method = init?.method ?? 'GET'
|
||||
const body = init?.body ? JSON.parse(String(init.body)) : undefined
|
||||
calls.value.push({ path, method, body })
|
||||
let data: unknown
|
||||
if (path.endsWith(`/projects/${projectId}`))
|
||||
data = {
|
||||
id: projectId,
|
||||
title: '隔离验收剧本',
|
||||
status: 'completed',
|
||||
episodes: [{ episode: 1, title: '来信', content: '隔离内容' }],
|
||||
characters: []
|
||||
}
|
||||
else if (path.endsWith('/stage-readiness'))
|
||||
data = {
|
||||
projectId,
|
||||
...Object.fromEntries(
|
||||
['script', 'breakdown', 'preparation', 'visualStyle', 'identity', 'subjectAssets', 'storyboard'].map(
|
||||
key => [key, { ready: true, reason: null }]
|
||||
)
|
||||
)
|
||||
}
|
||||
else if (path.includes('/checkpoints')) data = path.includes('view=summary') ? [] : [storyboardCheckpoint()]
|
||||
else if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
data = { ...approval.approval, valid: true, confirmation: approval.record }
|
||||
else if (path.endsWith('/storyboard-quality-confirmation/preflight'))
|
||||
data = {
|
||||
current: { ...approval.approval, valid: true, confirmation: approval.record },
|
||||
quality: approval.quality
|
||||
}
|
||||
else if (path.includes('/storyboard-directions?')) data = directions
|
||||
else if (path.includes('/storyboard-visual-states?')) data = visuals
|
||||
else if (path.endsWith('/storyboard/duration-audit')) data = { projectId, issues: [] }
|
||||
else if (path.endsWith('/duration-budget')) data = { projectId, episodes: [] }
|
||||
else if (path.endsWith('/production/entry-readiness'))
|
||||
data = {
|
||||
...approval.entry,
|
||||
derivedAssets: {
|
||||
...approval.entry.derivedAssets,
|
||||
shotCount: 2,
|
||||
directionCount: 2,
|
||||
visualStateCount: visuals.visualStateCount,
|
||||
staleDirectionCount: 0,
|
||||
staleVisualStateCount: 0
|
||||
}
|
||||
}
|
||||
else if (path.endsWith('/generation-models')) data = billingCatalog
|
||||
else if (path.endsWith('/creative-profile')) data = { ...billingProfile, projectId }
|
||||
else if (path.includes('/keyframe-review-draft')) data = null
|
||||
else if (path.endsWith('/storyboard-derived-reviews/confirm')) {
|
||||
if (conflictNext && body.preview === false) {
|
||||
conflictNext = false
|
||||
return new Response(
|
||||
JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影已由另一审核人更新,请重新核对。' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
}
|
||||
if (!body.preview)
|
||||
directions.beats[0]!.shots[0]!.direction = {
|
||||
...directions.beats[0]!.shots[0]!.direction!,
|
||||
...body.shots[0].direction
|
||||
}
|
||||
data = {
|
||||
projectId,
|
||||
phase: 'direction',
|
||||
preview: body.preview,
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
changed: !body.preview,
|
||||
shots: [
|
||||
{
|
||||
shotId: body.shots[0].shotId,
|
||||
directionId: 'original-shot-db-1-1',
|
||||
updatedAt: '2026-11-15T00:00:00.000Z',
|
||||
changed: !body.preview,
|
||||
alreadyApplied: false
|
||||
}
|
||||
]
|
||||
}
|
||||
} else if (
|
||||
path.endsWith('/storyboard-directions/generate') ||
|
||||
path.endsWith('/storyboard-visual-states/generate')
|
||||
) {
|
||||
const visual = path.includes('visual-states')
|
||||
if (visual) visuals = visualStatesResult(projectId, 1, true)
|
||||
else directions = directionsResult(projectId)
|
||||
task = {
|
||||
...task,
|
||||
id: 'mock-' + calls.value.length,
|
||||
workflowName: visual ? 'storyboard-visual-state' : 'storyboard-direction',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
metadata: { ...body, claims: [{ state: 'received' }] },
|
||||
result: {
|
||||
projectId,
|
||||
episodeCount: 1,
|
||||
completedEpisodes: 1,
|
||||
skippedEpisodes: 0,
|
||||
failedEpisodes: 0,
|
||||
episodes: [{ episodeNo: 1, status: 'completed' }]
|
||||
},
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
data = { executionId: task.id, projectId, status: 'running' }
|
||||
} else if (path.endsWith('/stop')) {
|
||||
task = {
|
||||
...task,
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true, retryAutomatically: false },
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
localStorage.setItem('staged-browser:task', JSON.stringify(task))
|
||||
setTimeout(() => {
|
||||
task = {
|
||||
...task,
|
||||
metadata: { ...task.metadata, claims: [{ state: 'received' }] },
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
localStorage.setItem('staged-browser:task', JSON.stringify(task))
|
||||
}, 1000)
|
||||
data = task
|
||||
} else if (path.includes('/workflow-executions/')) data = task
|
||||
else if (path.endsWith('/references')) data = { shotId: path.split('/').at(-2), references: [], missing: [] }
|
||||
else if (path.endsWith('/production/plan'))
|
||||
data = {
|
||||
projectId,
|
||||
configuration: { status: 'blocked', reason: '隔离项目尚未设置图片模型' },
|
||||
entryReadiness: { ready: false, reason: '仅所选镜头准备完成,项目未就绪' },
|
||||
stageReadiness: {
|
||||
referenceImages: { status: 'ready', reason: null },
|
||||
keyframes: { status: 'blocked', reason: '需要核对首帧预览' },
|
||||
videos: { status: 'blocked', reason: '尚无主视频' }
|
||||
},
|
||||
details: null
|
||||
}
|
||||
else if (path.endsWith('/production/status')) data = { projectId, completed: false }
|
||||
else return new Response(JSON.stringify({ message: '隔离页面拒绝未声明接口,不连接真实服务' }), { status: 403 })
|
||||
return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } })
|
||||
}
|
||||
/** 整页复用原上下文及分镜组件,只增加隔离控制栏。 */
|
||||
const Workspace = defineComponent({
|
||||
setup() {
|
||||
const id = ref(projectId)
|
||||
const context = useProjectData(id)
|
||||
provide(projectContextKey, context)
|
||||
return () => h(StoryboardPage)
|
||||
}
|
||||
})
|
||||
/** 主题只用于当前隔离页渲染,不更改用户存储偏好。 */
|
||||
const Preview = defineComponent({
|
||||
setup() {
|
||||
const theme = useTheme()
|
||||
const writes = computed(
|
||||
() => calls.value.filter(call => call.method === 'POST' && /generate|confirm|stop/.test(call.path)).length
|
||||
)
|
||||
return () =>
|
||||
h(
|
||||
NConfigProvider,
|
||||
{ locale: zhCN, dateLocale: dateZhCN, theme: theme.theme.value, themeOverrides: theme.overrides.value },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
NMessageProvider,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
ActionMessageProvider,
|
||||
{},
|
||||
{
|
||||
default: () => [
|
||||
h(NGlobalStyle),
|
||||
h(
|
||||
'header',
|
||||
{
|
||||
style: 'height:70px;padding:12px;display:flex;gap:12px;flex-wrap:wrap;overflow:auto'
|
||||
},
|
||||
[
|
||||
...Object.entries({
|
||||
direction: '独立摄影',
|
||||
complete: '已有结果',
|
||||
running: '停止与刷新'
|
||||
}).map(([key, label]) =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
location.href = `?scenario=${key}`
|
||||
}
|
||||
},
|
||||
() => label
|
||||
)
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
conflictNext = true
|
||||
}
|
||||
},
|
||||
() => '模拟一次并发冲突'
|
||||
),
|
||||
h(
|
||||
'span',
|
||||
{ role: 'status' },
|
||||
`模拟写入 ${writes.value} 次 · 真实模型请求 0 次`
|
||||
)
|
||||
]
|
||||
),
|
||||
h('div', { style: 'height:calc(100dvh - 70px);min-height:0' }, [
|
||||
h(Workspace)
|
||||
])
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
createApp(Preview).mount('#app')
|
||||
Reference in new issue
Block a user