feat(short-drama-agent-front): 接入人工动作修订与视频版本权限
This commit is contained in:
1 parent
7a60db3ced
commit
fa76165960
38 files changed
+2003
-158
No files matched your search
@@ -27,6 +27,7 @@ import BeatShotDirectory from './components/BeatShotDirectory.vue'
|
||||
import SubjectCoverageAudit from './components/SubjectCoverageAudit.vue'
|
||||
import type { SubjectCoverageIssue } from './coverage.types'
|
||||
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import { useStoryboard } from './useStoryboard'
|
||||
import { storyboardApi, type StoryboardDurationAudit } from './api'
|
||||
|
||||
@@ -74,6 +75,8 @@ const {
|
||||
executions,
|
||||
run
|
||||
} = useStoryboard()
|
||||
/** 切换详情标签后仍观察起点视觉任务,重新进入项目时恢复真实终态。 */
|
||||
useWorkflowExecution(id, 'motion-plan-start-state-validation')
|
||||
const productionReady = computed(() => directionComplete.value && visualStateComplete.value)
|
||||
/** 分镜时长审计为只读预警,接口失败不能影响分镜设计。 */
|
||||
const durationAudit = ref<StoryboardDurationAudit | null>(null)
|
||||
@@ -552,11 +555,18 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
><NTab name="design">设计与状态</NTab><NTab name="tools">参考图与提示词</NTab
|
||||
><NTab name="motion">动作与视线</NTab></NTabs
|
||||
>
|
||||
<div v-if="detailTab === 'motion'" class="pt-5 space-y-6">
|
||||
<!-- 以下是统一标签内容起点与模块间距的动作和视线模块 -->
|
||||
<div
|
||||
v-if="detailTab === 'motion'"
|
||||
class="pt-6 workspace-section-stack workspace-section-stack-spacious"
|
||||
>
|
||||
<MotionPlanPanel
|
||||
:key="shot.shotId"
|
||||
:shot-id="shot.shotId"
|
||||
:revision="session.prompts[shot.shotId]?.updatedAt"
|
||||
:project-id="id"
|
||||
:disabled="blocked"
|
||||
@changed="query.refresh"
|
||||
/>
|
||||
<SpatialBindingsPanel
|
||||
:key="shot.shotId"
|
||||
|
||||
@@ -1,12 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton, NTag, NSpin } from 'naive-ui'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { WorkspaceSectionHeading, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import IssueHint from '../../../components/ui/IssueHint.vue'
|
||||
import { motionApi } from '../motion-api'
|
||||
import MotionRevisionEditor from './MotionRevisionEditor.vue'
|
||||
|
||||
/** 单镜头动作计划嵌入当前位置,切换镜头时取消旧读取。 */
|
||||
const props = defineProps<{ shotId: string; revision?: string }>()
|
||||
const props = defineProps<{
|
||||
/** 正式镜头。 */
|
||||
shotId: string
|
||||
/** 所属项目,旧只读引用可以缺省。 */
|
||||
projectId?: string
|
||||
/** 外层更新标记。 */
|
||||
revision?: string
|
||||
/** 是否阻止修改。 */
|
||||
disabled?: boolean
|
||||
}>()
|
||||
/** 激活后通知外层刷新资产与就绪检查。 */
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
/** 人工编辑只在用户明确打开后挂载。 */
|
||||
const editing = ref(false)
|
||||
/** 生效后刷新真实时间轴,不用草稿覆盖预览。 */
|
||||
async function changed() {
|
||||
await query.refresh()
|
||||
emit('changed')
|
||||
}
|
||||
/** 生成提示词后修改 revision,重新读取后端保存的动作时间轴。 */
|
||||
const key = computed(() => JSON.stringify([props.shotId, props.revision ?? '']))
|
||||
const query = useQuery(key, async (value, signal) => {
|
||||
@@ -34,10 +54,25 @@ const savedWarnings = computed(() =>
|
||||
|
||||
<template>
|
||||
<section class="motion-plan-panel" aria-label="镜头动作时间轴">
|
||||
<header class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-semibold">动作时间轴</h3>
|
||||
<NButton text size="small" :loading="query.loading.value" @click="query.refresh">刷新动作计划</NButton>
|
||||
</header>
|
||||
<!-- 以下是与参考图模块一致的标题、刷新与计划摘要模块 -->
|
||||
<WorkspaceSectionHeading title="动作时间轴">
|
||||
<template #actions>
|
||||
<WorkspaceRefreshButton label="刷新动作计划" :loading="query.loading.value" @refresh="query.refresh" />
|
||||
<NButton v-if="projectId" :disabled="disabled || !!query.error.value" @click="editing = true"
|
||||
>编辑动作修订</NButton
|
||||
>
|
||||
</template>
|
||||
<template v-if="query.data.value" #description>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<span v-if="query.data.value.source">{{
|
||||
query.data.value.source === 'manual' ? '人工生效版本' : 'AI 原始规划'
|
||||
}}</span>
|
||||
<span>{{ query.data.value.durationSeconds }} 秒 · {{ query.data.value.beats.length }} 个阶段</span>
|
||||
<NTag v-if="warnings.length" size="small" type="warning" :bordered="false">需人工复核</NTag>
|
||||
<IssueHint :messages="warnings" label="查看预警与建议" inline />
|
||||
</div>
|
||||
</template>
|
||||
</WorkspaceSectionHeading>
|
||||
<div
|
||||
v-if="query.loading.value && !query.data.value"
|
||||
class="flex items-center gap-2 py-5 text-xs text-muted"
|
||||
@@ -48,12 +83,7 @@ const savedWarnings = computed(() =>
|
||||
<div v-else-if="query.error.value" class="mt-3">
|
||||
<IssueHint :messages="[query.error.value]" type="error" inline />
|
||||
</div>
|
||||
<template v-if="query.data.value">
|
||||
<div class="mt-3 flex flex-wrap items-center gap-3 text-xs text-muted">
|
||||
<span>{{ query.data.value.durationSeconds }} 秒 · {{ query.data.value.beats.length }} 个阶段</span>
|
||||
<NTag v-if="warnings.length" size="small" type="warning" :bordered="false">需人工复核</NTag>
|
||||
<IssueHint :messages="warnings" label="查看预警与建议" inline />
|
||||
</div>
|
||||
<template v-if="query.data.value && !query.error.value">
|
||||
<p v-if="!query.data.value.motionPlanAvailable" class="mt-4 text-xs text-muted">
|
||||
尚无已保存动作计划,生成视频提示词后可在此查看。
|
||||
</p>
|
||||
@@ -96,13 +126,23 @@ const savedWarnings = computed(() =>
|
||||
<IssueHint :messages="savedWarnings" label="查看历史预警" inline />
|
||||
</div>
|
||||
</template>
|
||||
<!-- 以下是同一镜头的版本化动作编辑模块 -->
|
||||
<MotionRevisionEditor
|
||||
v-if="projectId"
|
||||
v-model:open="editing"
|
||||
:project-id="projectId"
|
||||
:shot-id="shotId"
|
||||
:disabled="disabled"
|
||||
@changed="changed"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@reference "../../../styles/styles.css";
|
||||
.motion-beats {
|
||||
@apply grid gap-3 list-none p-0;
|
||||
@apply grid list-none p-0;
|
||||
gap: var(--app-content-gap);
|
||||
}
|
||||
.motion-beat {
|
||||
@apply grid grid-cols-[104px_minmax(0,1fr)] gap-4 p-4 bg-(--app-subtle);
|
||||
|
||||
@@ -0,0 +1,510 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCheckbox, NInput, NInputNumber, NSelect, NTag } from 'naive-ui'
|
||||
import { AppDialog, AssetImage } from '../../../components/ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { useMotionRevision } from '../useMotionRevision'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
|
||||
/** 完整动作修订表单在分镜与生产工作区共用。 */
|
||||
const props = defineProps<{
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 正式镜头。 */
|
||||
shotId: string
|
||||
/** 上游请求是否阻断。 */
|
||||
disabled?: boolean
|
||||
}>()
|
||||
/** 关闭不取消已启动的后台视觉任务。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 生效后通知外层刷新,不自动生成视频提示词。 */
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
/** 修订状态与显式请求入口。 */
|
||||
const state = useMotionRevision(props, open, () => emit('changed'))
|
||||
/** 模板直接使用草稿和交互状态。 */
|
||||
const {
|
||||
draft,
|
||||
reason,
|
||||
acknowledged,
|
||||
selectedId,
|
||||
preview,
|
||||
error,
|
||||
notice,
|
||||
saved,
|
||||
pending,
|
||||
blocked,
|
||||
formBlocked,
|
||||
canActivate,
|
||||
invalidated,
|
||||
record
|
||||
} = state
|
||||
/** 版本选项包含来源、创建时间及真实生效标记。 */
|
||||
const options = computed(() =>
|
||||
(state.context.data.value?.history.revisions ?? []).map(item => ({
|
||||
label: `${item.isActive ? '生效 · ' : ''}${item.source === 'manual' ? '人工修订' : 'AI 原始'} · ${formatDate(item.createdAt)} · ${item.revisionId}`,
|
||||
value: item.revisionId
|
||||
}))
|
||||
)
|
||||
/** 结构错误与非阻断预警分别展示,不将预警当作通过资格。 */
|
||||
const previewMessages = computed(() => [
|
||||
...(preview.value?.schemaIssues ?? []).map(item => `${item.path}:${item.message}`),
|
||||
...(preview.value?.timelineIssues ?? []).map(item => item.message),
|
||||
...(preview.value?.actionDensityIssues ?? []).map(item => item.message)
|
||||
])
|
||||
/** 任务返回问题可能是视觉问题或门禁说明,按实际描述展示。 */
|
||||
const taskIssues = computed(() =>
|
||||
Array.isArray(record.value?.result?.issues)
|
||||
? record.value!.result!.issues.flatMap(item => {
|
||||
if (typeof item === 'string') return [item]
|
||||
if (item && typeof item === 'object' && 'description' in item && typeof item.description === 'string')
|
||||
return [item.description]
|
||||
return []
|
||||
})
|
||||
: []
|
||||
)
|
||||
/** 完成状态与通过语义分别显示。 */
|
||||
const taskLabel = computed(() =>
|
||||
!record.value
|
||||
? ''
|
||||
: record.value.status === 'failed'
|
||||
? '视觉任务失败'
|
||||
: record.value.status !== 'completed'
|
||||
? '正在执行起点视觉校验'
|
||||
: canActivate.value
|
||||
? '视觉校验通过,证据有效'
|
||||
: record.value.result?.passed === true
|
||||
? '历史校验通过,当前证据不可用'
|
||||
: '视觉校验未通过'
|
||||
)
|
||||
/**
|
||||
* 增加用户主动填写的完整阶段,最多五段。
|
||||
* @returns 是否已新增
|
||||
*/
|
||||
function addBeat() {
|
||||
if (blocked.value || draft.value.beats.length >= 5) return false
|
||||
draft.value.beats.push({
|
||||
startSecond: draft.value.beats.at(-1)?.endSecond ?? 0,
|
||||
endSecond: state.context.data.value?.preview.durationSeconds ?? 1,
|
||||
action: '',
|
||||
cameraMotion: '',
|
||||
physicalContinuity: '',
|
||||
subjectRefs: [],
|
||||
closingState: ''
|
||||
})
|
||||
return true
|
||||
}
|
||||
/**
|
||||
* 主体引用只按用户输入拆分,不推导其它主体。
|
||||
* @param index 阶段位置
|
||||
* @param value 逗号或换行分隔的引用
|
||||
*/
|
||||
function updateRefs(index: number, value: string) {
|
||||
const beat = draft.value.beats[index]
|
||||
if (beat)
|
||||
beat.subjectRefs = value
|
||||
.split(/[,,\n]/)
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是完整动作规划与历史版本编辑模块 -->
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
title="人工动作修订"
|
||||
description="免费预检查并保存后,确认模型费用、执行起点视觉校验,再激活修订。"
|
||||
wide
|
||||
>
|
||||
<div class="motion-revision-layout">
|
||||
<ContextNotice v-if="state.context.error.value || error" type="error" :show-icon="false">{{
|
||||
state.context.error.value || error
|
||||
}}</ContextNotice>
|
||||
<!-- 以下是集中展示版本与本次主首帧的上下文模块 -->
|
||||
<section class="motion-revision-context" aria-label="修订版本与主首帧">
|
||||
<div class="motion-revision-section-heading">
|
||||
<div>
|
||||
<h3>修订版本</h3>
|
||||
<p class="motion-revision-description">
|
||||
{{ state.context.data.value?.preview.durationSeconds ?? '—' }} 秒 · 保存不生效、不调用模型
|
||||
</p>
|
||||
</div>
|
||||
<NButton :loading="state.context.loading.value" @click="state.context.refresh"
|
||||
>刷新版本与主首帧</NButton
|
||||
>
|
||||
</div>
|
||||
<label v-if="options.length" class="motion-revision-field">
|
||||
<span>编辑来源</span>
|
||||
<NSelect
|
||||
:value="selectedId || null"
|
||||
:options="options"
|
||||
:disabled="formBlocked"
|
||||
aria-label="动作修订版本"
|
||||
@update:value="state.select($event)"
|
||||
/>
|
||||
</label>
|
||||
<p v-else class="motion-revision-description">尚未初始化版本历史,首次保存会封存原始 AI 规划。</p>
|
||||
<div class="motion-revision-source">
|
||||
<div v-if="state.context.data.value?.primary?.imageUrl" class="motion-revision-thumbnail">
|
||||
<AssetImage
|
||||
:src="state.context.data.value.primary.imageUrl"
|
||||
alt="本次起点视觉校验的主首帧"
|
||||
object-fit="contain"
|
||||
:preview="true"
|
||||
/>
|
||||
</div>
|
||||
<dl class="motion-revision-source-details">
|
||||
<div>
|
||||
<dt>当前主首帧</dt>
|
||||
<dd>{{ state.context.data.value?.primary?.id ?? '尚无有效主首帧' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>当前生效版本</dt>
|
||||
<dd>{{ state.context.data.value?.history.activeRevisionId ?? 'AI 原始规划' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 以下是完整阶段表单模块,长文本独占一行,短字段共用两列 -->
|
||||
<section
|
||||
v-for="(beat, index) in draft.beats"
|
||||
:key="index"
|
||||
class="workspace-panel motion-revision-section"
|
||||
:aria-label="`动作阶段 ${index + 1}`"
|
||||
>
|
||||
<div class="motion-revision-section-heading">
|
||||
<h3>阶段 {{ index + 1 }}</h3>
|
||||
<NButton
|
||||
quaternary
|
||||
:disabled="blocked || draft.beats.length <= 1"
|
||||
@click="draft.beats.splice(index, 1)"
|
||||
>删除阶段</NButton
|
||||
>
|
||||
</div>
|
||||
<div class="motion-revision-fields">
|
||||
<label class="motion-revision-field"
|
||||
><span>开始秒数</span>
|
||||
<NInputNumber
|
||||
v-model:value="beat.startSecond"
|
||||
:disabled="formBlocked"
|
||||
:min="0"
|
||||
:input-props="{ 'aria-label': `阶段 ${index + 1} 开始秒数` }"
|
||||
/>
|
||||
</label>
|
||||
<label class="motion-revision-field"
|
||||
><span>结束秒数</span>
|
||||
<NInputNumber
|
||||
v-model:value="beat.endSecond"
|
||||
:disabled="formBlocked"
|
||||
:min="0"
|
||||
:input-props="{ 'aria-label': `阶段 ${index + 1} 结束秒数` }"
|
||||
/>
|
||||
</label>
|
||||
<label class="motion-revision-field motion-revision-field-wide"
|
||||
><span>动作</span>
|
||||
<NInput
|
||||
v-model:value="beat.action"
|
||||
:disabled="formBlocked"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||
:aria-label="`阶段 ${index + 1} 动作`"
|
||||
/>
|
||||
</label>
|
||||
<label class="motion-revision-field"
|
||||
><span>运镜</span>
|
||||
<NInput
|
||||
v-model:value="beat.cameraMotion"
|
||||
:disabled="formBlocked"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
:aria-label="`阶段 ${index + 1} 运镜`"
|
||||
/>
|
||||
</label>
|
||||
<label class="motion-revision-field"
|
||||
><span>主体引用(逗号分隔)</span>
|
||||
<NInput
|
||||
:value="beat.subjectRefs.join(', ')"
|
||||
:disabled="formBlocked"
|
||||
:aria-label="`阶段 ${index + 1} 主体引用`"
|
||||
@update:value="updateRefs(index, $event)"
|
||||
/>
|
||||
</label>
|
||||
<label class="motion-revision-field motion-revision-field-wide"
|
||||
><span>物理连续性</span>
|
||||
<NInput
|
||||
v-model:value="beat.physicalContinuity"
|
||||
:disabled="formBlocked"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||
:aria-label="`阶段 ${index + 1} 连续性`"
|
||||
/>
|
||||
</label>
|
||||
<label class="motion-revision-field motion-revision-field-wide"
|
||||
><span>收尾状态</span>
|
||||
<NInput
|
||||
v-model:value="beat.closingState"
|
||||
:disabled="formBlocked"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||
:aria-label="`阶段 ${index + 1} 收尾状态`"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
<div class="motion-revision-section-action">
|
||||
<NButton :disabled="blocked || draft.beats.length >= 5" @click="addBeat">添加动作阶段</NButton>
|
||||
<span class="motion-revision-description">{{ draft.beats.length }} / 5 个阶段</span>
|
||||
</div>
|
||||
<!-- 以下是整体约束与修改原因模块,标签和删除按钮分别对齐 -->
|
||||
<section class="workspace-panel motion-revision-section" aria-label="整体动作约束">
|
||||
<div class="motion-revision-section-heading">
|
||||
<h3>整体约束</h3>
|
||||
<span class="motion-revision-description">{{ draft.globalMotionConstraints.length }} / 8 项</span>
|
||||
</div>
|
||||
<div class="motion-revision-constraints">
|
||||
<div
|
||||
v-for="(_, index) in draft.globalMotionConstraints"
|
||||
:key="index"
|
||||
class="motion-revision-constraint-row"
|
||||
>
|
||||
<label class="motion-revision-field"
|
||||
><span>约束 {{ index + 1 }}</span>
|
||||
<NInput
|
||||
v-model:value="draft.globalMotionConstraints[index]"
|
||||
:disabled="formBlocked"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 1, maxRows: 4 }"
|
||||
:aria-label="`整体约束 ${index + 1}`"
|
||||
/>
|
||||
</label>
|
||||
<NButton
|
||||
quaternary
|
||||
:disabled="blocked || draft.globalMotionConstraints.length <= 1"
|
||||
@click="draft.globalMotionConstraints.splice(index, 1)"
|
||||
>删除</NButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<NButton
|
||||
:disabled="blocked || draft.globalMotionConstraints.length >= 8"
|
||||
@click="draft.globalMotionConstraints.push('')"
|
||||
>添加整体约束</NButton
|
||||
>
|
||||
</div>
|
||||
<label class="motion-revision-field"
|
||||
><span>修改原因</span>
|
||||
<NInput v-model:value="reason" :disabled="formBlocked" aria-label="动作修订原因" />
|
||||
</label>
|
||||
</section>
|
||||
<!-- 以下是免费预检查结果模块,与收费校验证据分开 -->
|
||||
<section v-if="preview" class="motion-revision-feedback" aria-label="免费预检查结果">
|
||||
<h3>预检查结果</h3>
|
||||
<p>{{ preview.valid ? '结构检查通过,仍须视觉校验;尚不可激活。' : '结构检查未通过,请修改草稿。' }}</p>
|
||||
<p v-for="(message, index) in previewMessages" :key="index">{{ message }}</p>
|
||||
</section>
|
||||
<!-- 以下是收费视觉校验与激活模块,费用说明和操作成组排列 -->
|
||||
<section class="workspace-panel motion-revision-section" aria-label="动作起点视觉校验">
|
||||
<h3>起点视觉校验</h3>
|
||||
<p class="motion-revision-description">
|
||||
起点视觉校验会调用服务端已配置的视觉模型并消耗额度。仅校验所选已保存修订与当前主首帧,不生成图片或视频。
|
||||
</p>
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="blocked || !saved"
|
||||
>我已确认本次起点视觉校验的模型费用和修订范围。</NCheckbox
|
||||
>
|
||||
<div class="motion-revision-validation-actions">
|
||||
<NButton
|
||||
:disabled="blocked || !saved || !acknowledged || !state.context.data.value?.primary"
|
||||
@click="state.validate"
|
||||
>启动起点视觉校验</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="record"
|
||||
:loading="state.execution.query.loading.value"
|
||||
@click="state.execution.query.refresh"
|
||||
>刷新视觉任务</NButton
|
||||
>
|
||||
<NButton type="primary" :disabled="!canActivate" @click="state.activate">激活此修订</NButton>
|
||||
</div>
|
||||
<div v-if="record || state.execution.query.error.value" class="motion-revision-feedback">
|
||||
<p v-if="record" role="status">{{ taskLabel }} · {{ record.id }}</p>
|
||||
<p v-if="state.execution.query.error.value" class="text-danger">
|
||||
{{ state.execution.query.error.value }}
|
||||
</p>
|
||||
<p v-if="record?.error" class="text-danger">{{ record.error }}</p>
|
||||
<p v-if="record?.result?.summary">{{ record.result.summary }}</p>
|
||||
<p v-for="(issue, index) in taskIssues" :key="index">{{ issue }}</p>
|
||||
<NTag v-if="invalidated && record" type="warning" :bordered="false"
|
||||
>草稿或输入已变化,请重新校验</NTag
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
<ContextNotice v-if="notice" type="info" :show-icon="false">{{ notice }}</ContextNotice>
|
||||
</div>
|
||||
<!-- 以下是固定底栏的免费操作与关闭入口模块 -->
|
||||
<template #footer>
|
||||
<div class="motion-revision-footer">
|
||||
<div class="motion-revision-save-actions">
|
||||
<NButton :disabled="blocked" :loading="pending" @click="state.precheck">免费预检查</NButton>
|
||||
<NButton :disabled="blocked || preview?.valid !== true" @click="state.save">保存为新修订</NButton>
|
||||
</div>
|
||||
<NButton @click="open = false">关闭</NButton>
|
||||
</div>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 弹窗内独立控制字段与区块间距,不影响其它页面的公共面板。 */
|
||||
.motion-revision-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--app-content-gap) * 2);
|
||||
}
|
||||
.motion-revision-layout > .workspace-panel {
|
||||
margin: 0;
|
||||
}
|
||||
.motion-revision-context,
|
||||
.motion-revision-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
.motion-revision-section-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
.motion-revision-layout h3 {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.motion-revision-description {
|
||||
margin: 0;
|
||||
color: var(--app-muted);
|
||||
font-size: 12px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.motion-revision-section-heading .motion-revision-description {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.motion-revision-source {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
.motion-revision-thumbnail {
|
||||
width: 88px;
|
||||
flex: 0 0 88px;
|
||||
}
|
||||
.motion-revision-thumbnail :deep(.asset-image) {
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
.motion-revision-source-details {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.motion-revision-source-details dt {
|
||||
color: var(--app-muted);
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.motion-revision-source-details dd {
|
||||
margin: 4px 0 0;
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.motion-revision-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
.motion-revision-field {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
align-content: start;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.motion-revision-field-wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.motion-revision-field :deep(.n-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
.motion-revision-constraints {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
.motion-revision-constraint-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: end;
|
||||
gap: 12px;
|
||||
}
|
||||
.motion-revision-section-action,
|
||||
.motion-revision-validation-actions,
|
||||
.motion-revision-save-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
.motion-revision-feedback {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: 8px;
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 12px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.motion-revision-feedback p {
|
||||
margin: 0;
|
||||
}
|
||||
.motion-revision-footer {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
/* 仅此弹窗的底栏铺满宽度,使免费操作和关闭按钮分别对齐两侧。 */
|
||||
:global(.app-dialog .dialog-footer:has(> .motion-revision-footer)) {
|
||||
width: 100%;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.motion-revision-fields {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.motion-revision-layout > .workspace-panel {
|
||||
padding: 16px;
|
||||
}
|
||||
.motion-revision-source {
|
||||
align-items: flex-start;
|
||||
}
|
||||
.motion-revision-thumbnail {
|
||||
width: 64px;
|
||||
flex-basis: 64px;
|
||||
}
|
||||
.motion-revision-footer {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.motion-revision-save-actions {
|
||||
flex: 1;
|
||||
}
|
||||
.motion-revision-validation-actions {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { WorkspaceSectionHeading } from '../../../components/ui'
|
||||
import { NTag } from 'naive-ui'
|
||||
import { directionLabel } from '../model'
|
||||
import type { DesignedShot } from '../types'
|
||||
@@ -8,11 +9,12 @@ defineProps<{ shot: DesignedShot }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-7">
|
||||
<div class="workspace-section-stack workspace-section-stack-spacious">
|
||||
<section>
|
||||
<h3 class="mb-4 text-sm font-semibold">导演摄影设计</h3>
|
||||
<!-- 以下是统一的导演设计模块标题 -->
|
||||
<WorkspaceSectionHeading title="导演摄影设计" />
|
||||
<template v-if="shot.direction"
|
||||
><div class="mb-5 flex flex-wrap gap-2">
|
||||
><div class="mt-4 mb-5 flex flex-wrap gap-2">
|
||||
<NTag
|
||||
v-for="field in [
|
||||
{ key: 'shotSize', label: '景别' },
|
||||
@@ -36,12 +38,13 @@ defineProps<{ shot: DesignedShot }>()
|
||||
<dd>{{ shot.direction.visualIntent }}</dd>
|
||||
</dl></template
|
||||
>
|
||||
<p v-else class="text-sm text-muted">此镜头尚无已保存的导演设计。</p>
|
||||
<p v-else class="mt-4 text-sm text-muted">此镜头尚无已保存的导演设计。</p>
|
||||
</section>
|
||||
<section class="pt-6">
|
||||
<h3 class="mb-4 text-sm font-semibold">画面状态</h3>
|
||||
<section>
|
||||
<!-- 以下是统一的画面状态模块标题 -->
|
||||
<WorkspaceSectionHeading title="画面状态" />
|
||||
<template v-if="shot.visualState"
|
||||
><dl class="detail-grid">
|
||||
><dl class="detail-grid mt-4">
|
||||
<dt>时间</dt>
|
||||
<dd>{{ shot.visualState.timeOfDay || '未指定' }}</dd>
|
||||
<dt>天气</dt>
|
||||
@@ -78,7 +81,7 @@ defineProps<{ shot: DesignedShot }>()
|
||||
</dl>
|
||||
</article></template
|
||||
>
|
||||
<p v-else class="text-sm leading-6 text-muted">此镜头还没有画面状态,请先完成镜头设计。</p>
|
||||
<p v-else class="mt-4 text-sm leading-6 text-muted">此镜头还没有画面状态,请先完成镜头设计。</p>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -3,9 +3,9 @@ import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
|
||||
import { NScrollbar, NButton, NCheckbox } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { Download, ExternalLink, RefreshCw } from '@lucide/vue'
|
||||
import { Download, ExternalLink } from '@lucide/vue'
|
||||
import IssueHint from '../../../components/ui/IssueHint.vue'
|
||||
import { AssetImage } from '../../../components/ui'
|
||||
import { AssetImage, WorkspaceSectionHeading, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import { storyboardApi } from '../api'
|
||||
import { getStoryboardSession, referenceImageUrl } from '../model'
|
||||
import type { DesignedShot, ShotReferences } from '../types'
|
||||
@@ -130,17 +130,22 @@ function exportResult(kind: 'spec' | 'prompt') {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-7">
|
||||
<div class="workspace-section-stack workspace-section-stack-spacious">
|
||||
<section>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-semibold">主体参考图</h3>
|
||||
<NButton :disabled="busy.references || locked" :loading="busy.references" @click="load('references')"
|
||||
><RefreshCw :size="13" :class="{ 'animate-spin': busy.references }" />刷新参考图</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
自动读取镜头当前绑定形态的主参考图,不生成新图。切换镜头会同步刷新,参考图缺失会影响后续生成。
|
||||
</p>
|
||||
<!-- 以下是统一的参考图模块标题、说明与刷新操作模块 -->
|
||||
<WorkspaceSectionHeading
|
||||
title="主体参考图"
|
||||
description="自动读取镜头当前绑定形态的主参考图,不生成新图。切换镜头会同步刷新,参考图缺失会影响后续生成。"
|
||||
>
|
||||
<template #actions>
|
||||
<WorkspaceRefreshButton
|
||||
label="刷新参考图"
|
||||
:disabled="busy.references || locked"
|
||||
:loading="busy.references"
|
||||
@refresh="load('references')"
|
||||
/>
|
||||
</template>
|
||||
</WorkspaceSectionHeading>
|
||||
<FeedbackMessage v-if="errors.references" :message="errors.references" />
|
||||
<template v-if="references">
|
||||
<div class="reference-grid mt-4">
|
||||
@@ -182,20 +187,21 @@ function exportResult(kind: 'spec' | 'prompt') {
|
||||
</p>
|
||||
</template>
|
||||
</section>
|
||||
<section class="pt-6">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-semibold">镜头生成规格</h3>
|
||||
<NButton
|
||||
:disabled="locked || busy.spec || !shot.direction || !shot.visualState"
|
||||
:loading="busy.spec"
|
||||
@click="load('spec')"
|
||||
>{{ busy.spec ? '编译中…' : '读取生成规格' }}</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
后端合并主体稳定身份、具体形态、摄影设计与即时状态,编译为 GenerationSpec,不调用模型。需要本镜头已有
|
||||
Direction 和 VisualState。
|
||||
</p>
|
||||
<section>
|
||||
<!-- 以下是统一的生成规格模块标题与读取操作模块 -->
|
||||
<WorkspaceSectionHeading
|
||||
title="镜头生成规格"
|
||||
description="后端合并主体稳定身份、具体形态、摄影设计与即时状态,编译为 GenerationSpec,不调用模型。需要本镜头已有 Direction 和 VisualState。"
|
||||
>
|
||||
<template #actions>
|
||||
<NButton
|
||||
:disabled="locked || busy.spec || !shot.direction || !shot.visualState"
|
||||
:loading="busy.spec"
|
||||
@click="load('spec')"
|
||||
>{{ busy.spec ? '编译中…' : '读取生成规格' }}</NButton
|
||||
>
|
||||
</template>
|
||||
</WorkspaceSectionHeading>
|
||||
<FeedbackMessage v-if="errors.spec" :message="errors.spec" />
|
||||
<template v-if="spec"
|
||||
><div class="mt-4 flex items-center justify-between">
|
||||
@@ -208,12 +214,12 @@ function exportResult(kind: 'spec' | 'prompt') {
|
||||
</NScrollbar>
|
||||
</template>
|
||||
</section>
|
||||
<section class="pt-6">
|
||||
<h3 class="text-sm font-semibold">视频提示词</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
已有提示词可直接复用,没有则依据 GenerationSpec 与参考图调用模型生成。此处只处理
|
||||
Prompt;首帧和实际视频任务请到“镜头生产”。
|
||||
</p>
|
||||
<section>
|
||||
<!-- 以下是统一的视频提示词模块标题与说明模块 -->
|
||||
<WorkspaceSectionHeading
|
||||
title="视频提示词"
|
||||
description="已有提示词可直接复用,没有则依据 GenerationSpec 与参考图调用模型生成。此处只处理 Prompt;首帧和实际视频任务请到“镜头生产”。"
|
||||
/>
|
||||
<div class="mt-4 flex flex-wrap items-center gap-4">
|
||||
<ConfirmAction
|
||||
:label="force ? '重新生成提示词' : '生成提示词'"
|
||||
@@ -256,7 +262,8 @@ function exportResult(kind: 'spec' | 'prompt') {
|
||||
@apply py-3 px-[15px] rounded-none bg-(--app-subtle) text-ink text-xs leading-[1.8] wrap-anywhere;
|
||||
}
|
||||
.reference-grid {
|
||||
@apply grid grid-cols-[repeat(auto-fill,_minmax(150px,_1fr))] gap-3.5;
|
||||
@apply grid grid-cols-[repeat(auto-fill,_minmax(150px,_1fr))];
|
||||
gap: var(--app-content-gap);
|
||||
}
|
||||
.reference-card {
|
||||
@apply bg-(--app-subtle) rounded-none overflow-hidden;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { NButton, NInput, NSelect, NPopconfirm } from 'naive-ui'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { useFeedbackMessage } from '../../../composables/useFeedbackMessage'
|
||||
import { useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
import { WorkspaceSectionHeading, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import IssueHint from '../../../components/ui/IssueHint.vue'
|
||||
import { runOperation, getOperation } from '../../workflows/operations'
|
||||
import { storyboardApi } from '../api'
|
||||
@@ -181,15 +182,20 @@ async function inspectGaze() {
|
||||
|
||||
<template>
|
||||
<section class="spatial-bindings-panel" aria-label="人工确认视线目标">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-semibold">视线目标</h3>
|
||||
<NButton text size="small" :loading="query.loading.value" :disabled="dirty || saving" @click="query.refresh"
|
||||
>刷新绑定</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
明确“朝向目标方向”或“注视具体目标”,保存后重新核对相关提示词和首帧。
|
||||
</p>
|
||||
<!-- 以下是统一的视线模块标题、说明与刷新操作模块 -->
|
||||
<WorkspaceSectionHeading
|
||||
title="视线目标"
|
||||
description="明确“朝向目标方向”或“注视具体目标”,保存后重新核对相关提示词和首帧。"
|
||||
>
|
||||
<template #actions>
|
||||
<WorkspaceRefreshButton
|
||||
label="刷新绑定"
|
||||
:loading="query.loading.value"
|
||||
:disabled="dirty || saving"
|
||||
@refresh="query.refresh"
|
||||
/>
|
||||
</template>
|
||||
</WorkspaceSectionHeading>
|
||||
<IssueHint :messages="query.error.value ? [query.error.value] : []" type="error" />
|
||||
<div class="mt-4 grid gap-4">
|
||||
<section v-for="(binding, index) in draft" :key="index" class="spatial-binding-row">
|
||||
|
||||
@@ -1,8 +1,84 @@
|
||||
import type { MotionPlan, MotionRevision, MotionRevisionHistory, MotionRevisionPreview } from './motion-revision'
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
import { request } from '../../lib/http'
|
||||
import type { MotionPlanAudit, MotionPlanPreview } from './motion.types'
|
||||
|
||||
/** 动作时间轴入口只读,不生成提示词,也不改变镜头时长。 */
|
||||
/** 动作查询与修订入口;只有明确启动视觉校验会调用模型。 */
|
||||
export const motionApi = {
|
||||
/**
|
||||
* 查询真实修订历史。
|
||||
* @param shotId 镜头 ID
|
||||
* @param signal 取消信号
|
||||
* @returns 版本历史与生效指针
|
||||
*/
|
||||
revisions: (shotId: string, signal?: AbortSignal) =>
|
||||
request<MotionRevisionHistory>(`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions`, {
|
||||
signal
|
||||
}),
|
||||
/**
|
||||
* 免费检查完整草稿,不激活版本。
|
||||
* @param shotId 镜头 ID
|
||||
* @param motionPlan 完整规划
|
||||
* @returns 结构检查与预警
|
||||
*/
|
||||
previewRevision: (shotId: string, motionPlan: MotionPlan) =>
|
||||
request<MotionRevisionPreview>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions/preview`,
|
||||
{ method: 'POST', body: { motionPlan } }
|
||||
),
|
||||
/**
|
||||
* 保存不可变修订,不调用模型。
|
||||
* @param shotId 镜头 ID
|
||||
* @param input 完整规划、父版本与原因
|
||||
* @returns 未生效修订
|
||||
*/
|
||||
saveRevision: (
|
||||
shotId: string,
|
||||
input: { motionPlan: MotionPlan; parentRevisionId: string | null; reason: string | null }
|
||||
) =>
|
||||
request<MotionRevision>(`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions`, {
|
||||
method: 'POST',
|
||||
body: input
|
||||
}),
|
||||
/**
|
||||
* 明确确认费用后启动服务端视觉模型,不接收请求级模型配置。
|
||||
* @param shotId 镜头 ID
|
||||
* @param revisionId 校验版本
|
||||
* @param input 当前主首帧及当前生效指针
|
||||
* @returns 持久化任务句柄
|
||||
*/
|
||||
validateRevision: (
|
||||
shotId: string,
|
||||
revisionId: string,
|
||||
input: { primaryKeyframeId: string; expectedRevisionId: string | null }
|
||||
) =>
|
||||
request<WorkflowExecutionStart & { willCallModel: true }>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions/${encodeURIComponent(revisionId)}/start-state-validation/start`,
|
||||
{ method: 'POST', body: input }
|
||||
),
|
||||
/**
|
||||
* 使用当前有效视觉证据激活已保存版本。
|
||||
* @param shotId 镜头 ID
|
||||
* @param revisionId 目标版本
|
||||
* @param input 当前指针与校验任务 ID
|
||||
* @returns 生效状态及提示词失效标记
|
||||
*/
|
||||
activateRevision: (
|
||||
shotId: string,
|
||||
revisionId: string,
|
||||
input: { expectedRevisionId: string | null; validationExecutionId: string }
|
||||
) =>
|
||||
request<{
|
||||
shotId: string
|
||||
activeRevisionId: string
|
||||
motionPlanFingerprint: string
|
||||
changed: boolean
|
||||
videoPromptStale: boolean
|
||||
}>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/revisions/${encodeURIComponent(revisionId)}/active`,
|
||||
{ method: 'PUT', body: input }
|
||||
),
|
||||
|
||||
/**
|
||||
* 读取单镜头已保存的动作计划和实时复核建议。
|
||||
* @param shotId 正式镜头 ID
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
import type { MotionBeat, MotionIssue } from './motion.types'
|
||||
import type { ShotKeyframe } from '../production/types'
|
||||
import type { WorkflowExecution } from '../workflows/execution.types'
|
||||
|
||||
/** 可编辑的完整动作规划,与后端 schema 一致。 */
|
||||
export interface MotionPlan {
|
||||
/** 一至五个动作阶段。 */
|
||||
beats: MotionBeat[]
|
||||
/** 一至八条整体运动约束。 */
|
||||
globalMotionConstraints: string[]
|
||||
}
|
||||
/** 不可变动作修订,生效状态由后端返回。 */
|
||||
export interface MotionRevision {
|
||||
/** 修订 ID。 */
|
||||
revisionId: string
|
||||
/** 所属镜头。 */
|
||||
shotId: string
|
||||
/** 修订来源。 */
|
||||
source: 'ai_original' | 'manual'
|
||||
/** 实际父版本。 */
|
||||
parentRevisionId: string | null
|
||||
/** 修改原因。 */
|
||||
reason: string | null
|
||||
/** 完整规划快照。 */
|
||||
motionPlan: MotionPlan
|
||||
/** 镜头时长。 */
|
||||
durationSeconds: number
|
||||
/** 服务端内容指纹。 */
|
||||
fingerprint: string
|
||||
/** ISO 创建时间。 */
|
||||
createdAt: string
|
||||
/** 是否生效。 */
|
||||
isActive: boolean
|
||||
}
|
||||
/** 空历史与空生效指针均为合法状态。 */
|
||||
export interface MotionRevisionHistory {
|
||||
/** 镜头 ID。 */
|
||||
shotId: string
|
||||
/** 原始封存版本。 */
|
||||
originalRevisionId: string | null
|
||||
/** 当前生效版本。 */
|
||||
activeRevisionId: string | null
|
||||
/** 所有版本。 */
|
||||
revisions: MotionRevision[]
|
||||
}
|
||||
/** 免费预检查不授予激活权限。 */
|
||||
export interface MotionRevisionPreview {
|
||||
/** 镜头 ID。 */
|
||||
shotId: string
|
||||
/** 仅结构合法。 */
|
||||
valid: boolean
|
||||
/** 通过结构检查后的指纹。 */
|
||||
motionPlanFingerprint: string | null
|
||||
/** 结构错误位置与原因。 */
|
||||
schemaIssues: { path: string; message: string }[]
|
||||
/** 时间预警。 */
|
||||
timelineIssues: MotionIssue[]
|
||||
/** 密度预警。 */
|
||||
actionDensityIssues: MotionIssue[]
|
||||
/** 必须进一步视觉校验。 */
|
||||
requiresStartStateValidation: true
|
||||
/** 预检查不能激活。 */
|
||||
canActivate: false
|
||||
/** 不调用模型。 */
|
||||
willCallModel: false
|
||||
/** 不修改资产。 */
|
||||
willModifyAssets: false
|
||||
}
|
||||
/** 起点视觉校验的实际问题结构。 */
|
||||
export interface MotionValidationIssue {
|
||||
/** 起点冲突种类。 */
|
||||
type: 'state_replay' | 'keyframe_conflict' | 'subject_spawn_risk'
|
||||
/** 警告或错误。 */
|
||||
severity: 'warning' | 'error'
|
||||
/** 问题说明。 */
|
||||
description: string
|
||||
/** 涉及主体。 */
|
||||
subjectRef?: string
|
||||
}
|
||||
/** 任务完成后的视觉证据;完成不代表通过。 */
|
||||
export interface MotionValidationResult {
|
||||
/** 镜头 ID。 */
|
||||
shotId: string
|
||||
/** 被校验版本。 */
|
||||
revisionId: string
|
||||
/** 被校验内容指纹。 */
|
||||
fingerprint: string
|
||||
/** 主首帧 ID。 */
|
||||
primaryKeyframeId: string
|
||||
/** 主首帧图片地址。 */
|
||||
primaryKeyframeImageUrl: string
|
||||
/** 校验启动时的生效指针。 */
|
||||
expectedRevisionId: string | null
|
||||
/** 后端最终通过标记。 */
|
||||
passed: boolean
|
||||
/** 是否失效。 */
|
||||
stale: boolean
|
||||
/** 汇总问题。 */
|
||||
issues: MotionValidationIssue[]
|
||||
/** 汇总说明。 */
|
||||
summary: string
|
||||
/** 模型校验结论。 */
|
||||
validation: {
|
||||
/** 是否通过视觉检查。 */
|
||||
passed: boolean
|
||||
/** 是否重演首帧状态。 */
|
||||
stateReplayDetected: boolean
|
||||
/** 模型问题。 */
|
||||
issues: MotionValidationIssue[]
|
||||
/** 模型说明。 */
|
||||
summary: string
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 只接受完整且仍绑定当前修订、主首帧和生效版本的已通过证据。
|
||||
* @param execution 持久化任务
|
||||
* @param revision 已保存修订
|
||||
* @param primary 当前主首帧
|
||||
* @param activeRevisionId 当前生效版本
|
||||
* @returns 是否允许请求激活
|
||||
*/
|
||||
export function motionEvidenceCurrent(
|
||||
execution: WorkflowExecution | null,
|
||||
revision: MotionRevision | null,
|
||||
primary: ShotKeyframe | null,
|
||||
activeRevisionId: string | null
|
||||
): boolean {
|
||||
const result = execution?.result
|
||||
const validation = result?.validation as MotionValidationResult['validation'] | undefined
|
||||
return !!(
|
||||
execution?.status === 'completed' &&
|
||||
execution.workflowName === 'motion-plan-start-state-validation' &&
|
||||
revision &&
|
||||
primary?.imageUrl &&
|
||||
primary.status === 'completed' &&
|
||||
primary.isPrimary &&
|
||||
primary.source !== 'provider_variant' &&
|
||||
result?.passed === true &&
|
||||
result.stale === false &&
|
||||
validation?.passed === true &&
|
||||
result.shotId === revision.shotId &&
|
||||
result.revisionId === revision.revisionId &&
|
||||
result.fingerprint === revision.fingerprint &&
|
||||
result.primaryKeyframeId === primary.id &&
|
||||
result.primaryKeyframeImageUrl === primary.imageUrl &&
|
||||
result.expectedRevisionId === activeRevisionId
|
||||
)
|
||||
}
|
||||
@@ -19,6 +19,12 @@ export interface MotionBeat {
|
||||
|
||||
/** 单镜头动作时间轴详情,实时审计与历史生成记录分别保存。 */
|
||||
export interface MotionPlanPreview {
|
||||
/** 当前生效规划来源。 */
|
||||
source?: 'ai_original' | 'manual' | null
|
||||
/** 当前生效修订,历史镜头可为空。 */
|
||||
activeRevisionId?: string | null
|
||||
/** 生效规划内容指纹。 */
|
||||
motionPlanFingerprint?: string | null
|
||||
shotId: string
|
||||
episodeNo: number
|
||||
beatNo: number
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
import { computed, ref, watch, onScopeDispose, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { motionApi } from './motion-api'
|
||||
import { productionApi } from '../production/api'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { ApiError, errorMessage } from '../../lib/http'
|
||||
import { motionEvidenceCurrent, type MotionPlan, type MotionRevisionPreview } from './motion-revision'
|
||||
|
||||
/**
|
||||
* 管理一个镜头的完整草稿、免费预检、保存和付费视觉任务;切镜后丢弃迟到 UI 更新。
|
||||
* @param props 当前镜头与项目
|
||||
* @param open 编辑面板可见状态
|
||||
* @param changed 激活成功后通知外层刷新资产和就绪状态
|
||||
* @returns 表单状态与明确操作入口
|
||||
*/
|
||||
export function useMotionRevision(
|
||||
props: { projectId: string; shotId: string; disabled?: boolean },
|
||||
open: Ref<boolean>,
|
||||
changed: () => void
|
||||
) {
|
||||
/** 任务观察按项目隔离,真实状态来自持久化接口。 */
|
||||
const project = computed(() => props.projectId)
|
||||
const execution = useWorkflowExecution(project, 'motion-plan-start-state-validation')
|
||||
/** 原目标身份同时用于废弃迟到响应。 */
|
||||
const identity = computed(() => JSON.stringify([props.projectId, props.shotId]))
|
||||
/** 面板关闭后不发起普通查询;活动任务仍由任务观察器恢复。 */
|
||||
const key = computed(() => (open.value ? identity.value : ''))
|
||||
/** 查询期间显示已有后端数据,但出错时禁用所有写入。 */
|
||||
const context = usePolling(
|
||||
key,
|
||||
async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [, shotId] = JSON.parse(value) as [string, string]
|
||||
const [history, preview, keyframes] = await Promise.all([
|
||||
motionApi.revisions(shotId, signal),
|
||||
motionApi.preview(shotId, signal),
|
||||
productionApi.listKeyframes(shotId, signal)
|
||||
])
|
||||
if (
|
||||
history.shotId !== shotId ||
|
||||
preview.shotId !== shotId ||
|
||||
keyframes.some(item => item.shotId !== shotId)
|
||||
)
|
||||
throw new Error('动作修订或首帧与当前镜头不匹配。')
|
||||
return {
|
||||
history,
|
||||
preview,
|
||||
primary:
|
||||
keyframes.find(
|
||||
item => item.isPrimary && item.status === 'completed' && item.source !== 'provider_variant'
|
||||
) ?? null
|
||||
}
|
||||
},
|
||||
computed(() => (open.value ? 5000 : false))
|
||||
)
|
||||
/** 当前选择的已保存版本;空值表示从历史 AI 预览开始。 */
|
||||
const selectedId = ref('')
|
||||
/** 全字段动作草稿,不允许自动生成占位阶段。 */
|
||||
const draft = ref<MotionPlan>({ beats: [], globalMotionConstraints: [] })
|
||||
/** 人工修改原因。 */
|
||||
const reason = ref('')
|
||||
/** 只保留当前草稿的免费预检查。 */
|
||||
const preview = ref<MotionRevisionPreview | null>(null)
|
||||
/** 明确确认视觉模型费用。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 草稿或输入变化后不再认可旧视觉证据。 */
|
||||
const invalidated = ref(false)
|
||||
/** 本次请求错误独立于只读查询。 */
|
||||
const error = ref('')
|
||||
/** 激活成功的提示词更新说明。 */
|
||||
const notice = ref('')
|
||||
/** 拷贝历史时不误判为用户修改。 */
|
||||
let copying = false
|
||||
/** 卸载后不更新当前界面。 */
|
||||
let disposed = false
|
||||
onScopeDispose(() => {
|
||||
disposed = true
|
||||
})
|
||||
/** 当前后端保存版本,不以草稿代替不可变修订。 */
|
||||
const revision = computed(
|
||||
() => context.data.value?.history.revisions.find(item => item.revisionId === selectedId.value) ?? null
|
||||
)
|
||||
/** 草稿与所选修订内容保持一致才可校验或激活。 */
|
||||
const saved = computed(
|
||||
() => !!revision.value && JSON.stringify(draft.value) === JSON.stringify(revision.value.motionPlan)
|
||||
)
|
||||
/** 项目已有请求或后台任务时禁止重复发起。 */
|
||||
const pending = computed(() => getOperation(props.projectId).pending)
|
||||
/** 自动核对输入期间允许继续填写草稿,不让定时查询打断输入焦点。 */
|
||||
const formBlocked = computed(
|
||||
() => !!props.disabled || pending.value || !!context.error.value || !context.data.value
|
||||
)
|
||||
/** 后端查询缺失或失败时不使用旧数据提交。 */
|
||||
const blocked = computed(
|
||||
() => !!props.disabled || pending.value || context.loading.value || !!context.error.value || !context.data.value
|
||||
)
|
||||
/** 当前任务只展示本镜头记录,其他镜头任务不充当证据。 */
|
||||
const record = computed(() => {
|
||||
const item = execution.query.data.value
|
||||
return item?.metadata?.shotId === props.shotId || item?.result?.shotId === props.shotId ? item : null
|
||||
})
|
||||
/** 完成、通过、未失效且所有绑定匹配才开放激活。 */
|
||||
const evidenceValid = computed(
|
||||
() =>
|
||||
saved.value &&
|
||||
!invalidated.value &&
|
||||
motionEvidenceCurrent(
|
||||
record.value,
|
||||
revision.value,
|
||||
context.data.value?.primary ?? null,
|
||||
context.data.value?.history.activeRevisionId ?? null
|
||||
)
|
||||
)
|
||||
/** 查询与请求进行中临时禁用提交,不把有效证据误显示为失效。 */
|
||||
const canActivate = computed(() => !blocked.value && evidenceValid.value)
|
||||
/** 当前版本和主首帧输入变化也撤销费用确认及旧证据。 */
|
||||
const binding = computed(() =>
|
||||
JSON.stringify([
|
||||
context.data.value?.history.activeRevisionId ?? null,
|
||||
context.data.value?.primary?.id ?? null,
|
||||
context.data.value?.primary?.imageUrl ?? null
|
||||
])
|
||||
)
|
||||
watch(binding, (_value, old) => {
|
||||
if (old && old !== '[null,null,null]') invalidated.value = true
|
||||
acknowledged.value = false
|
||||
})
|
||||
watch(
|
||||
draft,
|
||||
() => {
|
||||
preview.value = null
|
||||
acknowledged.value = false
|
||||
if (!copying) invalidated.value = true
|
||||
},
|
||||
{ deep: true, flush: 'sync' }
|
||||
)
|
||||
watch([identity, open], () => {
|
||||
selectedId.value = ''
|
||||
draft.value = { beats: [], globalMotionConstraints: [] }
|
||||
preview.value = null
|
||||
reason.value = ''
|
||||
error.value = ''
|
||||
notice.value = ''
|
||||
acknowledged.value = false
|
||||
})
|
||||
/**
|
||||
* 复制所选版本或真实 AI 规划;改变来源后须重新取得视觉证据。
|
||||
* @param id 所选版本 ID,空值使用预览
|
||||
* @param initial 首次恢复允许核对已持久化任务
|
||||
*/
|
||||
function select(id: string, initial = false) {
|
||||
const value = context.data.value
|
||||
if (!value) return
|
||||
const source =
|
||||
value.history.revisions.find(item => item.revisionId === id)?.motionPlan ??
|
||||
(id ? null : { beats: value.preview.beats, globalMotionConstraints: value.preview.globalMotionConstraints })
|
||||
if (!source) return
|
||||
copying = true
|
||||
selectedId.value = id
|
||||
draft.value = JSON.parse(JSON.stringify(source)) as MotionPlan
|
||||
copying = false
|
||||
preview.value = null
|
||||
reason.value = ''
|
||||
acknowledged.value = false
|
||||
invalidated.value = !initial
|
||||
notice.value = ''
|
||||
}
|
||||
watch(
|
||||
() => context.data.value,
|
||||
value => {
|
||||
if (value && !selectedId.value && draft.value.beats.length === 0)
|
||||
select(
|
||||
value.history.activeRevisionId ??
|
||||
value.history.originalRevisionId ??
|
||||
value.history.revisions.at(-1)?.revisionId ??
|
||||
'',
|
||||
true
|
||||
)
|
||||
}
|
||||
)
|
||||
/** 刷新或重开时恢复同镜头的真实任务版本;用户修改后不恢复旧资格。 */
|
||||
watch([() => context.data.value, record], ([value, task]) => {
|
||||
const id = task?.metadata?.revisionId
|
||||
if (
|
||||
value &&
|
||||
typeof id === 'string' &&
|
||||
!invalidated.value &&
|
||||
!preview.value &&
|
||||
value.history.revisions.some(item => item.revisionId === id) &&
|
||||
selectedId.value !== id &&
|
||||
(saved.value || draft.value.beats.length === 0)
|
||||
)
|
||||
select(id, true)
|
||||
})
|
||||
/**
|
||||
* 发起一次明确操作;冲突后刷新绑定,成功也校验响应目标。
|
||||
* @param label 操作说明
|
||||
* @param action 固定原镜头操作
|
||||
*/
|
||||
async function perform(label: string, action: () => Promise<void>) {
|
||||
if (blocked.value) return
|
||||
const target = identity.value
|
||||
error.value = ''
|
||||
notice.value = ''
|
||||
await runOperation(props.projectId, label, async () => {
|
||||
try {
|
||||
await action()
|
||||
} catch (cause) {
|
||||
if (!disposed && identity.value === target) {
|
||||
error.value = errorMessage(cause)
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
invalidated.value = true
|
||||
acknowledged.value = false
|
||||
await context.refresh()
|
||||
changed()
|
||||
}
|
||||
}
|
||||
throw cause
|
||||
}
|
||||
})
|
||||
}
|
||||
/** 免费检查本次完整草稿;编辑或切镜后丢弃迟到回执。 */
|
||||
async function precheck() {
|
||||
const shotId = props.shotId
|
||||
const plan = JSON.parse(JSON.stringify(draft.value)) as MotionPlan
|
||||
const signature = JSON.stringify(plan)
|
||||
await perform('免费检查动作修订', async () => {
|
||||
const result = await motionApi.previewRevision(shotId, plan)
|
||||
if (!disposed && props.shotId === shotId && signature === JSON.stringify(draft.value)) {
|
||||
if (result.shotId !== shotId) throw new Error('预检查回执与镜头不匹配。')
|
||||
preview.value = result
|
||||
}
|
||||
})
|
||||
}
|
||||
/** 保存必须先获得当前草稿的结构通过结果,不激活或调用模型。 */
|
||||
async function save() {
|
||||
if (preview.value?.valid !== true) return
|
||||
const target = identity.value
|
||||
const shotId = props.shotId
|
||||
const plan = JSON.parse(JSON.stringify(draft.value)) as MotionPlan
|
||||
const parentRevisionId = selectedId.value || null
|
||||
await perform('保存动作修订', async () => {
|
||||
const result = await motionApi.saveRevision(shotId, {
|
||||
motionPlan: plan,
|
||||
parentRevisionId,
|
||||
reason: reason.value.trim() || null
|
||||
})
|
||||
if (result.shotId !== shotId || result.source !== 'manual' || result.isActive || !result.revisionId)
|
||||
throw new Error('保存回执不是当前镜头的未生效人工版本。')
|
||||
if (disposed || identity.value !== target) return
|
||||
await context.refresh()
|
||||
select(result.revisionId)
|
||||
notice.value = '修订已保存,尚未生效;请确认模型费用后校验。'
|
||||
})
|
||||
}
|
||||
/** 用户确认费用后重新读取首帧与生效指针,再启动视觉模型。 */
|
||||
async function validate() {
|
||||
if (!acknowledged.value || !saved.value || !revision.value || !context.data.value?.primary) return
|
||||
const target = identity.value
|
||||
const selected = revision.value
|
||||
const originalProjectId = props.projectId
|
||||
const expectedBinding = binding.value
|
||||
acknowledged.value = false
|
||||
await perform('校验动作修订起点', async () => {
|
||||
await context.refresh()
|
||||
if (
|
||||
disposed ||
|
||||
identity.value !== target ||
|
||||
context.error.value ||
|
||||
expectedBinding !== binding.value ||
|
||||
!saved.value
|
||||
)
|
||||
throw new Error('主首帧或生效版本已变化,请刷新并重新确认费用。')
|
||||
const primary = context.data.value?.primary
|
||||
if (!primary?.imageUrl) throw new Error('尚无有效主首帧,不能启动视觉校验。')
|
||||
const result = await motionApi.validateRevision(selected.shotId, selected.revisionId, {
|
||||
primaryKeyframeId: primary.id,
|
||||
expectedRevisionId: context.data.value!.history.activeRevisionId
|
||||
})
|
||||
if (!result.executionId || result.willCallModel !== true)
|
||||
throw new Error('未返回有效视觉校验任务,请刷新,勿重复提交。')
|
||||
if (!disposed && identity.value === target) invalidated.value = false
|
||||
await execution.track(result.executionId, originalProjectId)
|
||||
})
|
||||
}
|
||||
/** 激活前再次刷新并核对全部证据,成功后通知两个工作区同步。 */
|
||||
async function activate() {
|
||||
if (!canActivate.value || !revision.value || !record.value) return
|
||||
const target = identity.value
|
||||
const selected = revision.value
|
||||
const taskId = record.value.id
|
||||
await perform('激活动作修订', async () => {
|
||||
await context.refresh()
|
||||
if (
|
||||
disposed ||
|
||||
identity.value !== target ||
|
||||
context.error.value ||
|
||||
!saved.value ||
|
||||
invalidated.value ||
|
||||
!motionEvidenceCurrent(
|
||||
record.value,
|
||||
selected,
|
||||
context.data.value?.primary ?? null,
|
||||
context.data.value?.history.activeRevisionId ?? null
|
||||
)
|
||||
)
|
||||
throw new Error('视觉证据已失效,请重新校验当前修订。')
|
||||
const result = await motionApi.activateRevision(props.shotId, selected.revisionId, {
|
||||
expectedRevisionId: context.data.value!.history.activeRevisionId,
|
||||
validationExecutionId: taskId
|
||||
})
|
||||
if (
|
||||
result.shotId !== selected.shotId ||
|
||||
result.activeRevisionId !== selected.revisionId ||
|
||||
result.motionPlanFingerprint !== selected.fingerprint
|
||||
)
|
||||
throw new Error('激活回执与目标版本不匹配,请刷新核对。')
|
||||
if (disposed || identity.value !== target) return
|
||||
await context.refresh()
|
||||
changed()
|
||||
notice.value = result.videoPromptStale
|
||||
? '修订已生效。请重新生成视频提示词;旧视频候选仍保留,未自动提交生成任务。'
|
||||
: '此版本已生效。'
|
||||
})
|
||||
}
|
||||
return {
|
||||
context,
|
||||
selectedId,
|
||||
draft,
|
||||
reason,
|
||||
preview,
|
||||
acknowledged,
|
||||
error,
|
||||
notice,
|
||||
revision,
|
||||
saved,
|
||||
pending,
|
||||
blocked,
|
||||
formBlocked,
|
||||
record,
|
||||
execution,
|
||||
canActivate,
|
||||
evidenceValid,
|
||||
invalidated,
|
||||
select,
|
||||
precheck,
|
||||
save,
|
||||
validate,
|
||||
activate
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user