feat: 同步动作与首帧编辑能力并统一工作区反馈

接入动作时间轴、密度审计、人工视线目标和后台首帧编辑;独立读取已保存提示词,并在首帧晋升前重新核对持久化质量状态。
统一 NMessage 结果反馈、局部 loading 和业务说明间距,保留真实长任务进度与部分失败语义。
验证:pnpm check(49 个文件、393 项测试)、pnpm build;当前环境无法完成 localhost 浏览器验收及真实后端联调。
This commit is contained in:
GouJ committed 2026-10-12 20:05:03 +08:00
1 parent 83482a70c5
commit 7a60db3ced
76 files changed
+2485 -457

No files matched your search

+81 -20
View File
@@ -1,11 +1,15 @@
<script setup lang="ts">
import { isOperationRunning } from '../workflows/operations'
import ContextNotice from '../../components/ui/ContextNotice.vue'
import AppForm from '../../components/ui/AppForm.vue'
import { NFormItem } from 'naive-ui'
import { integerRule } from '../../lib/form-rules'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import ActionMenu from '../../components/ui/ActionMenu.vue'
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
import { NScrollbar, NAlert, NButton, NCheckbox, NInputNumber, NProgress, NSelect, NTab, NTabs } from 'naive-ui'
import { NScrollbar, NButton, NCheckbox, NInputNumber, NProgress, NSelect, NTab, NTabs } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { ArrowLeft } from '@lucide/vue'
import { EmptyState } from '../../components/ui'
@@ -13,6 +17,11 @@ import { downloadText } from '../../lib/format'
import ConfirmAction from '../workflows/ConfirmAction.vue'
import GenerationReceipt from './components/GenerationReceipt.vue'
import ShotDesign from './components/ShotDesign.vue'
import MotionPlanPanel from './components/MotionPlanPanel.vue'
import MotionAuditPanel from './components/MotionAuditPanel.vue'
import SpatialBindingsPanel from './components/SpatialBindingsPanel.vue'
import type { MotionPlanAudit } from './motion.types'
import { useActionMessage } from '../../components/ui/useActionMessage'
import ShotTools from './components/ShotTools.vue'
import BeatShotDirectory from './components/BeatShotDirectory.vue'
import SubjectCoverageAudit from './components/SubjectCoverageAudit.vue'
@@ -22,6 +31,22 @@ import { useStoryboard } from './useStoryboard'
import { storyboardApi, type StoryboardDurationAudit } from './api'
const detailTab = ref('design')
/** 动作审计只能定位当前项目正式列表中的镜头。 */
const feedback = useActionMessage()
/**
* 按后端正式镜头坐标定位动作预警。
* @param item 后端返回的真实镜头及剧集
*/
function locateMotion(item: MotionPlanAudit['items'][number]) {
if (!episodeOptions.value.some(episode => episode.episodeNo === item.episodeNo)) {
feedback?.warning('审计中的剧集已不在当前项目列表,请刷新分镜。')
return
}
selectedEpisode.value = item.episodeNo
selectedShot.value = item.shotId
detailTab.value = 'motion'
toolsOpen.value = false
}
/** 分镜工作区按单集查看正式数据,生成配置与镜头检查分开。 */
const {
@@ -167,10 +192,10 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<template>
<WorkspacePage split compact mobile-scroll class="storyboard-workspace-page compact-shot-workspace">
<template #notice>
<NAlert v-if="episodeSourceUnavailable" type="info" :show-icon="false">
<ContextNotice v-if="episodeSourceUnavailable" type="info" :show-icon="false">
本集镜头已重新生成。新标题和剧情详情尚未提供,当前只显示正式镜头编号;请按实际生成规格核对内容。
</NAlert>
<NAlert v-if="currentEpisodeDurationIssues.length" type="warning" :show-icon="false">
</ContextNotice>
<ContextNotice v-if="currentEpisodeDurationIssues.length" type="warning" :show-icon="false">
<div class="text-sm font-medium">
本集有 {{ currentEpisodeDurationIssues.length }} 条分镜时长建议(不阻断生成)
</div>
@@ -178,7 +203,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
Beat {{ issue.beatNo }}<span v-if="issue.shotNo"> · Shot {{ issue.shotNo }}</span
>:{{ issue.message }}
</div>
</NAlert>
</ContextNotice>
<span v-if="durationAuditError" class="text-xs text-muted">{{ durationAuditError }}</span>
</template>
<template #header
@@ -213,6 +238,8 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</div>
<WorkspaceTools
:pending="operation.pending"
:pending-label="operation.label"
v-model:open="toolsOpen"
title="分镜生成配置与回执"
label="生成与恢复"
@@ -290,9 +317,10 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<div class="overview-content workspace-section-stack">
<!-- 以下是零费用主体引用覆盖检查模块 -->
<SubjectCoverageAudit :project-id="id" @locate="locateCoverageIssue" />
<NAlert v-if="auditLocationError" type="warning" :show-icon="false">{{
<MotionAuditPanel :project-id="id" @locate="locateMotion" />
<ContextNotice v-if="auditLocationError" type="warning" :show-icon="false">{{
auditLocationError
}}</NAlert>
}}</ContextNotice>
<h3 class="mb-3 text-sm font-semibold">生成与恢复</h3>
<div class="generation-row">
<div>
@@ -302,15 +330,21 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<p class="mt-2 text-xs leading-6 text-muted">
只重新拆解当前选择的第
{{ episodeNo }}
集,其它剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
集,其他剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
:loading="
isOperationRunning(operation, `生成第 ${episodeNo} 集镜头`) ||
(!!executions[0]?.observer.active.value &&
executions[0]?.observer.query.data.value?.metadata?.episodeNo ===
episodeNo)
"
:label="`重生成第 ${episodeNo} 集镜头`"
:disabled="!allowed['shots-current']"
acknowledgement
:description="`将删除并重建第 ${episodeNo} 集的正式镜头。该集已有导演设计、即时状态、首帧、提示词和视频结果会随旧镜头一并失效,且无法撤销;其它剧集保持不变。`"
:description="`将删除并重建第 ${episodeNo} 集的正式镜头。该集已有导演设计、即时状态、首帧、提示词和视频结果会随旧镜头一并失效,且无法撤销;其他剧集保持不变。`"
@confirm="run('shots-current')"
/>
</div>
@@ -329,6 +363,10 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
:loading="
isOperationRunning(operation, '生成项目导演设计') ||
!!executions[1]?.observer.active.value
"
:label="force ? '重生成全部导演设计' : '补齐项目导演设计'"
:disabled="!allowed['direction-all']"
acknowledgement
@@ -352,6 +390,10 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
:loading="
isOperationRunning(operation, '生成项目即时状态') ||
!!executions[2]?.observer.active.value
"
:label="force ? '重生成全部即时状态' : '补齐项目即时状态'"
:disabled="!allowed['visual-all']"
acknowledgement
@@ -377,6 +419,10 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
>。
</p>
<ConfirmAction
:loading="
isOperationRunning(operation, '生成项目视频提示词') ||
!!executions[3]?.observer.active.value
"
:label="force ? '重生成全部视频提示词' : '补齐项目视频提示词'"
:disabled="!allowed.prompts"
acknowledgement
@@ -420,7 +466,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
"
class="workspace-feedback"
>
<NAlert v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mt-4"
<ContextNotice v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mt-4"
>{{ query.error.value }} 当前保留上次成功读取的数据,暂停生成操作。<NButton
@click="query.refresh"
text
@@ -428,34 +474,34 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
class="ml-3"
>
重试查询
</NButton></NAlert
><NAlert
</NButton></ContextNotice
><ContextNotice
v-if="data && data.directions.shotCount && !productionReady"
type="warning"
:show-icon="false"
class="mt-4"
>
<strong>Production 前置设计未完成。</strong>
<strong>镜头生产前置设计未完成。</strong>
当前导演设计 {{ data.directions.directionCount }}/{{ data.directions.shotCount }},即时视觉状态
{{ data.visualStates.visualStateCount }}/{{
data.visualStates.shotCount
}}。请先补齐后再进入镜头生产,避免 后续镜头制作无法开始。 </NAlert
><NAlert
}}。请先补齐后再进入镜头生产,避免 后续镜头制作受阻。 </ContextNotice
><ContextNotice
v-if="!prerequisites.directionEpisode || !prerequisites.visualEpisode"
type="info"
:show-icon="false"
class="mt-4"
>
最新 Breakdown
缺少本集生成所需的镜头、主体或形态数据。已保存设计仍可查看;请先在拆解页完成或恢复相应阶段。 </NAlert
><NAlert
最新剧本拆解
缺少本集生成所需的镜头、主体或形态数据。已保存设计仍可查看;请先在拆解页完成或恢复相应阶段。 </ContextNotice
><ContextNotice
v-else-if="data && !directionComplete && data.directions.shotCount"
type="info"
:show-icon="false"
class="mt-4"
>
本集导演设计尚未补齐,请先完成第 01 步,再生成本集即时状态。
</NAlert>
</ContextNotice>
</NScrollbar>
<div v-if="!data && query.loading.value" class="panel p-8 text-sm text-muted" role="status">
正在读取正式分镜数据……
@@ -503,8 +549,23 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</header>
<div>
<NTabs v-model:value="detailTab" type="line" size="small" aria-label="镜头详情"
><NTab name="design">设计与状态</NTab><NTab name="tools">参考图与生成规格</NTab></NTabs
><NTab name="design">设计与状态</NTab><NTab name="tools">参考图与提示词</NTab
><NTab name="motion">动作与视线</NTab></NTabs
>
<div v-if="detailTab === 'motion'" class="pt-5 space-y-6">
<MotionPlanPanel
:key="shot.shotId"
:shot-id="shot.shotId"
:revision="session.prompts[shot.shotId]?.updatedAt"
/>
<SpatialBindingsPanel
:key="shot.shotId"
:project-id="id"
:shot-id="shot.shotId"
:disabled="blocked"
@changed="query.refresh"
/>
</div>
<div v-if="detailTab === 'design'" class="pt-6"><ShotDesign :shot="shot" /></div>
<div v-if="detailTab === 'tools'" class="pt-6">
<ShotTools
@@ -1,5 +1,7 @@
<script setup lang="ts">
import { NScrollbar, NAlert, NButton, NTable } from 'naive-ui'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import { NScrollbar, NButton, NTable } from 'naive-ui'
import { computed } from 'vue'
import { Download } from '@lucide/vue'
import { downloadText } from '../../../lib/format'
@@ -25,9 +27,9 @@ function exportReceipt() {
<h3 class="text-sm font-semibold">{{ receipt.title }} · 本次回执</h3>
<NButton @click="exportReceipt" text size="small"><Download :size="13" />导出诊断</NButton>
</div>
<NAlert v-if="failed" role="alert" type="error" :show-icon="false" class="mt-3">
<ContextNotice v-if="failed" role="alert" type="error" :show-icon="false" class="mt-3">
本次存在失败、校验未通过或未保存项。关闭“批量覆盖已有结果”后再补齐,可跳过已完整保存项。
</NAlert>
</ContextNotice>
<template v-if="receipt.kind === 'shots'">
<p class="my-4 text-xs text-muted">
第 {{ receipt.result.episodeNo }} 集 · {{ receipt.result.storyboardShotSummary.beatCount }} 个 Beat ·
@@ -35,9 +37,14 @@ function exportReceipt() {
{{ receipt.result.storyboardShotSummary.totalDurationSeconds }} 秒 · 形态绑定覆盖率
{{ Math.round(receipt.result.storyboardShotSummary.bindingCoverage * 100) }}%
</p>
<NAlert v-if="receipt.result.storyboardShotValidation.valid" type="success" :show-icon="false" class="mt-3">
<ContextNotice
v-if="receipt.result.storyboardShotValidation.valid"
type="success"
:show-icon="false"
class="mt-3"
>
本集新镜头已保存。该集下游结果已随旧镜头清除,请依次重新生成导演设计、即时状态、首帧、提示词和视频。
</NAlert>
</ContextNotice>
<ul v-else class="mt-3 space-y-2 text-xs text-danger">
<li v-for="(issue, index) in receipt.result.storyboardShotValidation.issues" :key="index">
Beat {{ issue.beatNo ?? '—' }} / Shot {{ issue.shotNo ?? '—' }}:{{ issue.message }}
@@ -0,0 +1,95 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton, NTag } from 'naive-ui'
import { motionApi } from '../motion-api'
import type { MotionPlanAudit } from '../motion.types'
import { errorMessage } from '../../../lib/http'
import { useFeedbackMessage } from '../../../composables/useFeedbackMessage'
import IssueHint from '../../../components/ui/IssueHint.vue'
/** 项目审计按需读取,避免遍历全部镜头逐个请求。 */
const props = defineProps<{ projectId: string }>()
const emit = defineEmits<{ locate: [item: MotionPlanAudit['items'][number]] }>()
const result = ref<MotionPlanAudit | null>(null)
const loading = ref(false)
const error = ref('')
useFeedbackMessage(error)
/** 项目切换或卸载时取消迟到结果。 */
let controller: AbortController | undefined
watch(
() => props.projectId,
() => {
controller?.abort()
result.value = null
error.value = ''
loading.value = false
}
)
onScopeDispose(() => controller?.abort())
/** 只显示存在预警或缺少计划的镜头,完整数目保留在摘要。 */
const attentionItems = computed(
() =>
result.value?.items.filter(
item => !item.motionPlanAvailable || item.issues.length || item.actionDensityIssues.length
) ?? []
)
/** 读取真实审计结果,不触发生成或修复。 */
async function inspect() {
if (loading.value || !props.projectId) return
const projectId = props.projectId
controller = new AbortController()
const signal = controller.signal
loading.value = true
error.value = ''
try {
const data = await motionApi.audit(projectId, signal)
if (signal.aborted || projectId !== props.projectId) return
if (data.projectId !== projectId) throw new Error('动作审计与当前项目不匹配。')
result.value = data
} catch (cause) {
if (!signal.aborted && projectId === props.projectId) error.value = errorMessage(cause)
} finally {
if (!signal.aborted && projectId === props.projectId) loading.value = false
}
}
</script>
<template>
<section aria-label="项目动作时间轴审计">
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-semibold">动作时长与密度检查</h3>
<NButton :loading="loading" @click="inspect">{{ result ? '重新检查' : '检查已保存动作' }}</NButton>
</div>
<p class="mt-2 text-xs leading-6 text-muted">只检查已保存时间轴;预警供人工复核,不阻止生产。</p>
<IssueHint :messages="error ? [error] : []" type="error" />
<template v-if="result">
<div class="mt-3 flex flex-wrap gap-x-4 gap-y-2 text-xs">
<span>已审计 {{ result.auditedCount }} / {{ result.shotCount }} 镜</span
><span>缺少计划 {{ result.missingMotionPlanCount }}</span
><span>时间轴预警 {{ result.warningCount }}</span
><span>动作密度预警 {{ result.actionDensityWarningCount }}</span>
</div>
<div class="mt-3 grid gap-3">
<div
v-for="item in attentionItems"
:key="item.shotId"
class="flex flex-wrap items-center justify-between gap-3 bg-(--app-subtle) p-3"
>
<div class="flex flex-wrap items-center gap-3 text-xs">
<strong>第 {{ item.episodeNo }} 集 · 段落 {{ item.beatNo }} · 镜头 {{ item.shotNo }}</strong
><NTag size="small" :bordered="false">{{
item.motionPlanAvailable
? `${item.issues.length + item.actionDensityIssues.length} 项预警`
: '尚无动作计划'
}}</NTag
><IssueHint
:messages="[...item.issues, ...item.actionDensityIssues].map(issue => issue.message)"
inline
/>
</div>
<NButton text size="small" @click="emit('locate', item)">查看镜头</NButton>
</div>
</div>
</template>
</section>
</template>
@@ -0,0 +1,133 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NButton, NTag, NSpin } from 'naive-ui'
import { useQuery } from '../../../composables/useQuery'
import IssueHint from '../../../components/ui/IssueHint.vue'
import { motionApi } from '../motion-api'
/** 单镜头动作计划嵌入当前位置,切换镜头时取消旧读取。 */
const props = defineProps<{ shotId: string; revision?: string }>()
/** 生成提示词后修改 revision,重新读取后端保存的动作时间轴。 */
const key = computed(() => JSON.stringify([props.shotId, props.revision ?? '']))
const query = useQuery(key, async (value, signal) => {
const [shotId] = JSON.parse(value) as [string, string]
const result = await motionApi.preview(shotId, signal)
if (result.shotId !== shotId) throw new Error('动作时间轴与当前镜头不匹配,请重新读取。')
return result
})
/** 当前规则审计的预警及建议在需要时查看,不误报为质量阻塞。 */
const warnings = computed(() => [
...(query.data.value?.issues ?? []).map(item => item.message),
...(query.data.value?.actionDensityIssues ?? []).map(item => item.message),
...(query.data.value?.actionReviewSuggestions ?? []).flatMap(item =>
item.suggestions.map(text => `阶段 ${item.beatIndex + 1}:${text}`)
)
])
/** 只保留历史记录中的真实文本,缺失历史不能显示为已审计通过。 */
const savedWarnings = computed(() =>
(query.data.value?.savedActionDensityIssues ?? []).flatMap(value => {
if (!value || typeof value !== 'object' || !('message' in value) || typeof value.message !== 'string') return []
return [value.message]
})
)
</script>
<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>
<div
v-if="query.loading.value && !query.data.value"
class="flex items-center gap-2 py-5 text-xs text-muted"
role="status"
>
<NSpin :size="16" />正在读取已保存动作…
</div>
<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>
<p v-if="!query.data.value.motionPlanAvailable" class="mt-4 text-xs text-muted">
尚无已保存动作计划,生成视频提示词后可在此查看。
</p>
<ol v-else class="motion-beats mt-4">
<li v-for="(beat, index) in query.data.value.beats" :key="index" class="motion-beat">
<div class="motion-beat-time">
<strong>{{ beat.startSecond }}–{{ beat.endSecond }} 秒</strong><span>阶段 {{ index + 1 }}</span>
</div>
<div class="min-w-0 space-y-2">
<p class="text-sm leading-6 whitespace-pre-wrap">{{ beat.action || '未保存动作描述' }}</p>
<dl class="motion-beat-detail">
<template v-if="beat.cameraMotion"
><dt>运镜</dt>
<dd>{{ beat.cameraMotion }}</dd></template
>
<template v-if="beat.physicalContinuity"
><dt>连续性</dt>
<dd>{{ beat.physicalContinuity }}</dd></template
>
<template v-if="beat.closingState"
><dt>收尾状态</dt>
<dd>{{ beat.closingState }}</dd></template
>
</dl>
</div>
</li>
</ol>
<p v-if="query.data.value.globalMotionConstraints.length" class="mt-4 text-xs leading-6 text-muted">
整体约束:{{ query.data.value.globalMotionConstraints.join(';') }}
</p>
<div
v-if="query.data.value.motionPlanAvailable"
class="mt-4 flex flex-wrap items-center gap-3 text-xs text-muted"
>
<span>{{
query.data.value.savedActionDensityIssues === null
? '未保存生成时审计记录'
: `生成时保存 ${query.data.value.savedActionDensityIssues.length} 项预警`
}}</span>
<IssueHint :messages="savedWarnings" label="查看历史预警" inline />
</div>
</template>
</section>
</template>
<style>
@reference "../../../styles/styles.css";
.motion-beats {
@apply grid gap-3 list-none p-0;
}
.motion-beat {
@apply grid grid-cols-[104px_minmax(0,1fr)] gap-4 p-4 bg-(--app-subtle);
}
.motion-beat-time {
@apply flex flex-col gap-1 text-xs;
}
.motion-beat-time span {
@apply text-muted;
}
.motion-beat-detail {
@apply grid grid-cols-[60px_minmax(0,1fr)] gap-x-3 gap-y-1 text-xs leading-6;
}
.motion-beat-detail dt {
@apply text-muted;
}
.motion-beat-detail dd {
@apply m-0 break-words;
}
@media (max-width: 600px) {
.motion-beat {
@apply grid-cols-1 gap-3 p-3;
}
.motion-beat-time {
@apply flex-row flex-wrap items-center gap-3;
}
}
</style>
@@ -1,15 +1,19 @@
<script setup lang="ts">
import { NScrollbar, NAlert, NButton, NCheckbox } from 'naive-ui'
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 IssueHint from '../../../components/ui/IssueHint.vue'
import { AssetImage } from '../../../components/ui'
import { storyboardApi } from '../api'
import { getStoryboardSession, referenceImageUrl } from '../model'
import type { DesignedShot, ShotReferences } from '../types'
import type { ShotGenerationSpec } from '../generation-spec.types'
import { useQuery } from '../../../composables/useQuery'
import { errorMessage } from '../../../lib/http'
import { downloadText } from '../../../lib/format'
import { runOperation } from '../../workflows/operations'
import { getOperation, runOperation } from '../../workflows/operations'
import ConfirmAction from '../../workflows/ConfirmAction.vue'
/** 镜头级只读资源与显式 Prompt 生成;查询与耗费模型的操作分开。 */
@@ -19,7 +23,21 @@ const spec = ref<ShotGenerationSpec | null>(null)
const errors = ref({ references: '', spec: '' })
const busy = ref({ references: false, spec: false })
const force = ref(false)
const prompt = computed(() => getStoryboardSession(props.projectId).prompts[props.shot.shotId])
/** 进入镜头直接读取已保存正文,不借生成接口发起模型调用。 */
const promptQuery = useQuery(
computed(() => props.shot.shotId),
(shotId, signal) => storyboardApi.videoPrompt(shotId, signal)
)
const prompt = computed(
() =>
getStoryboardSession(props.projectId).prompts[props.shot.shotId] ??
(promptQuery.data.value?.shotId === props.shot.shotId ? promptQuery.data.value : null)
)
/** 当前单镜头生成按钮只反映本次生成请求。 */
const promptLoading = computed(() => {
const operation = getOperation(props.projectId)
return operation.pending && operation.label === `生成镜头 ${props.shot.shotNo} 视频提示词`
})
const locked = computed(() => props.disabled)
const controllers: Partial<Record<'references' | 'spec', AbortController>> = {}
let revision = 0
@@ -72,13 +90,13 @@ async function load(kind: 'references' | 'spec') {
}
}
/** 没有独立 GET Prompt 接口:force=false 会复用已有正文,否则仍会调用模型。 */
/** 显式生成或重生成才调用 POST;已保存正文通过 GET 独立读取。 */
async function generatePrompt() {
if (locked.value) return
const projectId = props.projectId
const shotId = props.shot.shotId
const overwrite = force.value
const ok = await runOperation(projectId, `读取/生成镜头 ${props.shot.shotNo} 提示词`, async () => {
const ok = await runOperation(projectId, `生成镜头 ${props.shot.shotNo} 视频提示词`, async () => {
const session = getStoryboardSession(projectId)
// 请求结果不确定时不要保留可能已被覆盖的旧正文。
delete session.prompts[shotId]
@@ -89,7 +107,6 @@ async function generatePrompt() {
})
if (!ok) {
// 单镜头错误由 runOperation 记录到项目操作状态;这里只处理可恢复的首帧前置问题。
const { getOperation } = await import('../../workflows/operations')
const operation = getOperation(projectId)
if (!/primary keyframe|主首帧/i.test(operation.error)) return
operation.recovery = {
@@ -117,16 +134,14 @@ function exportResult(kind: 'spec' | 'prompt') {
<section>
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-semibold">主体参考图</h3>
<NButton :disabled="busy.references || locked" @click="load('references')"
<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>
<NAlert v-if="errors.references" role="alert" type="error" :show-icon="false" class="mt-3">{{
errors.references
}}</NAlert>
<FeedbackMessage v-if="errors.references" :message="errors.references" />
<template v-if="references">
<div class="reference-grid mt-4">
<article v-for="item in references.references" :key="item.shotSubjectId" class="reference-card">
@@ -172,6 +187,7 @@ function exportResult(kind: 'spec' | 'prompt') {
<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
>
@@ -180,9 +196,7 @@ function exportResult(kind: 'spec' | 'prompt') {
后端合并主体稳定身份、具体形态、摄影设计与即时状态,编译为 GenerationSpec,不调用模型。需要本镜头已有
Direction 和 VisualState。
</p>
<NAlert v-if="errors.spec" role="alert" type="error" :show-icon="false" class="mt-3">{{
errors.spec
}}</NAlert>
<FeedbackMessage v-if="errors.spec" :message="errors.spec" />
<template v-if="spec"
><div class="mt-4 flex items-center justify-between">
<span class="text-xs text-muted"
@@ -202,27 +216,32 @@ function exportResult(kind: 'spec' | 'prompt') {
</p>
<div class="mt-4 flex flex-wrap items-center gap-4">
<ConfirmAction
label="读取/生成提示词"
:label="force ? '重新生成提示词' : '生成提示词'"
:loading="promptLoading"
:disabled="locked"
acknowledgement
:description="
force
? '将覆盖此镜头已保存的视频提示词,并调用模型重新生成。'
: '读取此镜头已有提示词;若不存在,将自动生成并保存。生成前会检查所需参考图是否齐全。'
: '调用文本模型生成缺失的视频提示词;已有正文会直接复用。'
"
@confirm="generatePrompt"
/><NCheckbox v-model:checked="force" :disabled="locked" class="flex items-center gap-2 text-xs"
>覆盖此镜头提示词</NCheckbox
>
</div>
<div v-if="prompt" class="mt-5">
<p v-if="promptQuery.loading.value && !prompt" class="mt-4 text-xs text-muted" role="status">
正在读取提示词…
</p>
<IssueHint :messages="promptQuery.error.value ? [promptQuery.error.value] : []" type="error" />
<div v-if="prompt?.videoPrompt" class="mt-5">
<div class="mb-3 flex items-center justify-between">
<span class="text-xs font-medium">本会话已读取的正文</span
<span class="text-xs font-medium">已保存的视频提示词</span
><NButton @click="exportResult('prompt')" text size="small"><Download :size="13" />导出</NButton>
</div>
<p class="whitespace-pre-wrap text-sm leading-7">{{ prompt.videoPrompt }}</p>
<template v-if="prompt.negativePrompt"
><h4 class="mb-2 mt-5 text-xs font-medium text-muted">Negative prompt</h4>
><h4 class="mb-2 mt-5 text-xs font-medium text-muted">Negative prompt(负向提示词)</h4>
<p class="whitespace-pre-wrap text-sm leading-6">{{ prompt.negativePrompt }}</p></template
>
</div>
@@ -0,0 +1,339 @@
<script setup lang="ts">
import { computed, ref, watch, onScopeDispose } from 'vue'
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 IssueHint from '../../../components/ui/IssueHint.vue'
import { runOperation, getOperation } from '../../workflows/operations'
import { storyboardApi } from '../api'
import { spatialApi, type GazeReadability, type SpatialBinding } from '../spatial-api'
import { errorMessage } from '../../../lib/http'
/** 人工目标绑定编辑器;保留所有已确认字段,切镜后隔离草稿与迟到响应。 */
const props = defineProps<{ projectId: string; shotId: string; disabled: boolean }>()
const emit = defineEmits<{ changed: [] }>()
const query = useQuery(
computed(() => props.shotId),
async (shotId, signal) => {
const [bindings, references] = await Promise.all([
spatialApi.bindings(shotId, signal),
storyboardApi.references(shotId, signal)
])
if (references.shotId !== shotId) throw new Error('视线绑定的主体列表与当前镜头不匹配。')
return { bindings, references }
}
)
/**
* 仅复制允许写入的业务字段,不能提交或伪造后端 evidence。
* @param binding 后端已保存或人工编辑的空间绑定
* @returns 可提交到正式接口的业务字段
*/
function writableBinding(binding: SpatialBinding): SpatialBinding {
const {
subjectRef,
relation,
gazeIntent,
targetDescription,
targetSubjectRef,
targetDepth,
targetScreenRegion,
targetUniqueness,
direction,
visibility
} = binding
return {
subjectRef,
relation,
gazeIntent,
targetDescription,
targetSubjectRef,
targetDepth,
targetScreenRegion,
targetUniqueness,
direction,
visibility
}
}
const draft = ref<SpatialBinding[]>([])
const saved = ref('[]')
watch(
() => props.shotId,
() => {
draft.value = []
saved.value = '[]'
}
)
watch(
() => query.data.value,
data => {
if (!data) return
draft.value = data.bindings.map(writableBinding)
saved.value = JSON.stringify(draft.value)
}
)
const dirty = computed(() => JSON.stringify(draft.value) !== saved.value)
const subjects = computed(() => {
const references = query.data.value?.references
const all = [...(references?.references ?? []), ...(references?.missing ?? [])]
return [
...new Map(
all.map(item => [
item.subjectRef,
{ label: `${item.subjectName}(${item.subjectRef})`, value: item.subjectRef }
])
).values()
]
})
const message = useActionMessage()
/** 局部保存的加载状态只显示在本镜头保存按钮。 */
const saving = computed(() => {
const op = getOperation(props.projectId)
return op.pending && op.label === `保存镜头 ${props.shotId} 视线目标`
})
/**
* 使用真实镜头主体创建一条待确认绑定。
* @returns 无可选主体时不创建草稿
*/
function add() {
const subjectRef = subjects.value[0]?.value
if (!subjectRef) return
draft.value.push({
subjectRef,
relation: 'gaze',
gazeIntent: 'target_locked',
targetDescription: '',
direction: 'unknown',
visibility: 'unknown'
})
}
/** 保存完整列表,后端负责最终主体归属检查。 */
async function save() {
if (props.disabled || !dirty.value || query.error.value || !query.data.value) return
const shotId = props.shotId
const projectId = props.projectId
if (
draft.value.some(
item => !subjects.value.some(subject => subject.value === item.subjectRef) || !item.targetDescription.trim()
)
) {
message?.warning('请选择本镜头主体并填写明确的注视目标。')
return
}
const input = draft.value.map(item =>
writableBinding({
...item,
targetDescription: item.targetDescription.trim(),
targetSubjectRef: item.targetSubjectRef || undefined,
targetScreenRegion: item.targetScreenRegion?.trim() || undefined
})
)
const ok = await runOperation(
projectId,
`保存镜头 ${shotId} 视线目标`,
async () => {
await spatialApi.replace(shotId, input)
},
{ content: '视线目标已保存,请重新核对相关提示词和首帧。', type: 'success' }
)
if (ok && props.shotId === shotId && props.projectId === projectId) {
await query.refresh()
gaze.value = null
emit('changed')
}
}
/** 只读审计由用户主动展开,不在缺少设计时反复编译。 */
const gaze = ref<GazeReadability | null>(null)
const gazeLoading = ref(false)
const gazeError = ref('')
useFeedbackMessage(gazeError)
let controller: AbortController | undefined
watch(
() => props.shotId,
() => {
controller?.abort()
gaze.value = null
gazeError.value = ''
gazeLoading.value = false
}
)
onScopeDispose(() => controller?.abort())
/** 查询当前编译约束,不改写摄影或画面状态。 */
async function inspectGaze() {
if (gazeLoading.value || dirty.value) return
const shotId = props.shotId
controller = new AbortController()
const signal = controller.signal
gazeLoading.value = true
gazeError.value = ''
try {
const data = await spatialApi.gaze(shotId, signal)
if (signal.aborted || props.shotId !== shotId) return
if (data.shotId !== shotId) throw new Error('视线检查与当前镜头不匹配。')
gaze.value = data
} catch (cause) {
if (!signal.aborted && props.shotId === shotId) gazeError.value = errorMessage(cause)
} finally {
if (!signal.aborted && props.shotId === shotId) gazeLoading.value = false
}
}
</script>
<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>
<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">
<div class="flex items-center justify-between gap-3">
<strong class="text-xs">目标 {{ index + 1 }}</strong
><NButton text size="small" :disabled="disabled" @click="draft.splice(index, 1)">移除</NButton>
</div>
<div class="spatial-binding-fields mt-3">
<label
>注视主体<NSelect v-model:value="binding.subjectRef" :options="subjects" :disabled="disabled"
/></label>
<label
>视线要求<NSelect
v-model:value="binding.gazeIntent"
:options="[
{ label: '朝向目标方向', value: 'directional' },
{ label: '注视具体目标', value: 'target_locked' }
]"
:disabled="disabled"
/></label>
<label class="spatial-binding-wide"
>目标说明<NInput
v-model:value="binding.targetDescription"
placeholder="例如:右侧唯一的枯树树桩"
:disabled="disabled"
/></label>
<label
>目标主体<NSelect
v-model:value="binding.targetSubjectRef"
clearable
:options="subjects"
placeholder="可选:本镜头目标主体"
:disabled="disabled"
/></label>
<label
>画面方向<NSelect
v-model:value="binding.direction"
:options="[
{ label: '左侧', value: 'left' },
{ label: '右侧', value: 'right' },
{ label: '上方', value: 'up' },
{ label: '下方', value: 'down' },
{ label: '未确认', value: 'unknown' }
]"
:disabled="disabled"
/></label>
<label
>目标是否入画<NSelect
v-model:value="binding.visibility"
:options="[
{ label: '画内', value: 'in_frame' },
{ label: '画外', value: 'off_screen' },
{ label: '未确认', value: 'unknown' }
]"
:disabled="disabled"
/></label>
<label
>目标景深<NSelect
v-model:value="binding.targetDepth"
clearable
:options="[
{ label: '前景', value: 'foreground' },
{ label: '中景', value: 'midground' },
{ label: '背景', value: 'background' }
]"
:disabled="disabled"
/></label>
<label
>目标唯一性<NSelect
v-model:value="binding.targetUniqueness"
clearable
:options="[
{ label: '唯一', value: 'unique' },
{ label: '存在歧义', value: 'ambiguous' },
{ label: '未确认', value: 'unknown' }
]"
:disabled="disabled"
/></label>
<label
>具体画面区域<NInput
v-model:value="binding.targetScreenRegion"
placeholder="可选:右下方树桩上部"
:disabled="disabled"
/></label>
</div>
</section>
</div>
<p v-if="query.data.value && !draft.length" class="mt-4 text-xs text-muted">
尚未手工确认目标;当前仍使用已保存设计推导的约束。
</p>
<div class="mt-4 flex flex-wrap items-center gap-3">
<NButton :disabled="disabled || !subjects.length || !!query.error.value" @click="add">添加目标</NButton>
<NPopconfirm
v-if="dirty && !draft.length"
positive-text="确认撤销"
negative-text="取消"
@positive-click="save"
><template #trigger
><NButton type="primary" :disabled="disabled" :loading="saving">撤销全部人工绑定</NButton></template
>撤销后将重新使用已保存设计推导的目标约束。</NPopconfirm
>
<NButton
v-else
type="primary"
:disabled="disabled || !dirty || !!query.error.value"
:loading="saving"
@click="save"
>保存全部绑定</NButton
>
<NButton :loading="gazeLoading" :disabled="dirty" @click="inspectGaze">检查当前视线约束</NButton>
</div>
<IssueHint :messages="gazeError ? [gazeError] : []" type="error" />
<div v-if="gaze" class="mt-4 space-y-3 text-xs leading-6">
<div class="flex flex-wrap items-center gap-3">
<span
>当前约束 {{ gaze.spatialTargetBindings.length }} 项 · 精确注视
{{ gaze.targetLockedCount }} 项</span
><IssueHint
:messages="gaze.specConsistencyIssues.flatMap(item => [item.message, item.suggestion])"
label="查看设计预警"
inline
/>
</div>
<p v-for="(binding, index) in gaze.spatialTargetBindings" :key="index">
{{ binding.subjectRef }} → {{ binding.targetDescription }} ·
{{ binding.gazeIntent === 'directional' ? '朝向目标方向' : '注视具体目标' }} ·
{{ binding.evidence.includes('confirmed_override') ? '人工确认' : '设计推导' }}
</p>
</div>
</section>
</template>
<style>
@reference "../../../styles/styles.css";
.spatial-binding-row {
@apply p-4 bg-(--app-subtle);
}
.spatial-binding-fields {
@apply grid grid-cols-[repeat(auto-fit,minmax(min(100%,200px),1fr))] gap-4;
}
.spatial-binding-fields > label {
@apply grid gap-2 text-xs min-w-0;
}
.spatial-binding-wide {
@apply col-span-full;
}
</style>
@@ -1,6 +1,8 @@
<script setup lang="ts">
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import { computed, ref } from 'vue'
import { NAlert, NButton } from 'naive-ui'
import { NButton } from 'naive-ui'
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
import { useQuery } from '../../../composables/useQuery'
import { auditSubjectCoverage } from '../coverage-api'
@@ -37,10 +39,10 @@ const result = computed(() => query.data.value)
@refresh="query.refresh"
>
<template v-if="result">
<NAlert :type="result.valid ? 'success' : 'warning'" :show-icon="false">
<ContextNotice :type="result.valid ? 'success' : 'warning'" :show-icon="false">
{{ result.valid ? '未发现主体引用遗漏' : `发现 ${result.issueCount} 项引用遗漏` }} ·
{{ result.episodeCount }} 集 / {{ result.beatCount }} 个 Beat / {{ result.shotCount }} 镜
</NAlert>
</ContextNotice>
<p class="mt-2 text-muted">
检查主体 {{ result.subjectSummary.total }} · 人物 {{ result.subjectSummary.character }} / 场景
{{ result.subjectSummary.scene }} / 道具 {{ result.subjectSummary.prop }}
+24
View File
@@ -0,0 +1,24 @@
import { request } from '../../lib/http'
import type { MotionPlanAudit, MotionPlanPreview } from './motion.types'
/** 动作时间轴入口只读,不生成提示词,也不改变镜头时长。 */
export const motionApi = {
/**
* 读取单镜头已保存的动作计划和实时复核建议。
* @param shotId 正式镜头 ID
* @param signal 查询取消信号
* @returns 后端实际动作时间轴
*/
preview: (shotId: string, signal?: AbortSignal) =>
request<MotionPlanPreview>(`/storyboard-shots/${encodeURIComponent(shotId)}/motion-plan/preview`, { signal }),
/**
* 按需读取项目动作时长与密度审计。
* @param projectId 正式项目 ID
* @param signal 查询取消信号
* @returns 项目审计和正式镜头坐标
*/
audit: (projectId: string, signal?: AbortSignal) =>
request<MotionPlanAudit>(`/projects/${encodeURIComponent(projectId)}/storyboard/motion-plan-duration-audit`, {
signal
})
}
+66
View File
@@ -0,0 +1,66 @@
/** 后端动作时间轴与密度审计的非阻断预警。 */
export interface MotionIssue {
code: string
severity: 'warning'
message: string
beatIndex?: number
}
/** 已保存动作阶段;时间和动作均来自后端,不在前端补造。 */
export interface MotionBeat {
startSecond: number
endSecond: number
action: string
cameraMotion: string
physicalContinuity: string
subjectRefs: string[]
closingState: string
}
/** 单镜头动作时间轴详情,实时审计与历史生成记录分别保存。 */
export interface MotionPlanPreview {
shotId: string
episodeNo: number
beatNo: number
shotNo: number
durationSeconds: number
motionPlanAvailable: boolean
beats: MotionBeat[]
globalMotionConstraints: string[]
issues: MotionIssue[]
actionDensityIssues: MotionIssue[]
actionReviewSuggestions: Array<{
beatIndex: number
code: string
suggestions: string[]
requiresManualReview: true
}>
savedActionDensityIssues: unknown[] | null
willCallModel: false
willModifyAssets: false
}
/** 项目动作审计按正式镜头 ID 返回,可安全定位至原剧集。 */
export interface MotionPlanAudit {
projectId: string
shotCount: number
auditedCount: number
missingMotionPlanCount: number
warningCount: number
actionDensityWarningCount: number
items: Array<
Pick<
MotionPlanPreview,
| 'shotId'
| 'episodeNo'
| 'beatNo'
| 'shotNo'
| 'durationSeconds'
| 'motionPlanAvailable'
| 'issues'
| 'actionDensityIssues'
>
>
willCallModel: false
willModifyAssets: false
}
+62
View File
@@ -0,0 +1,62 @@
import { request } from '../../lib/http'
/** 人工确认的视线目标;证据字段只由后端创建。 */
export interface SpatialBinding {
subjectRef: string
relation: 'gaze'
gazeIntent?: 'directional' | 'target_locked'
targetDescription: string
targetSubjectRef?: string
targetDepth?: 'foreground' | 'midground' | 'background'
targetScreenRegion?: string
targetUniqueness?: 'unique' | 'ambiguous' | 'unknown'
direction: 'left' | 'right' | 'up' | 'down' | 'unknown'
visibility: 'in_frame' | 'off_screen' | 'unknown'
}
/** 只读视线可读性检查保留编译来源,不代表取得重新构图权限。 */
export interface GazeReadability {
shotId: string
visualFocus: string
spatialTargetBindings: Array<SpatialBinding & { evidence: string[] }>
targetLockedCount: number
confirmedBindingsPresent: boolean
specConsistencyIssues: Array<{ message: string; suggestion: string }>
subjectGaze: Array<{ subjectRef: string; gaze: string; pose: string; transientState: string }>
canAutomaticallyReframe: false
willCallModel: false
willModifyData: false
}
/** 视线目标正式接口,写入只替换人工确认的绑定。 */
export const spatialApi = {
/**
* 读取已确认空间目标。
* @param shotId 正式镜头 ID
* @param signal 查询取消信号
* @returns 人工确认的目标列表
*/
bindings: (shotId: string, signal?: AbortSignal) =>
request<SpatialBinding[]>(`/storyboard-shots/${encodeURIComponent(shotId)}/spatial-target-bindings`, {
signal
}),
/**
* 保存当前镜头的完整人工确认列表;空列表撤销覆盖。
* @param shotId 正式镜头 ID
* @param bindings 已人工核对的完整列表
* @returns 后端保存后的目标列表
*/
replace: (shotId: string, bindings: SpatialBinding[]) =>
request<SpatialBinding[]>(`/storyboard-shots/${encodeURIComponent(shotId)}/spatial-target-bindings`, {
method: 'PUT',
body: { bindings }
}),
/**
* 检查当前已编译目标与设计的一致性。
* @param shotId 正式镜头 ID
* @param signal 查询取消信号
* @returns 只读视线检查结果
*/
gaze: (shotId: string, signal?: AbortSignal) =>
request<GazeReadability>(`/storyboard-shots/${encodeURIComponent(shotId)}/gaze-readability/preview`, { signal })
}