feat(short-drama-agent-front): 新增拆解候选与质量修订
This commit is contained in:
1 parent
49ad08a63e
commit
3414cc8232
32 files changed
+2319
-454
No files matched your search
@@ -1,5 +1,20 @@
|
||||
# 接口数据同步说明
|
||||
|
||||
## 2026-10-17 候选拆解、质量规则与阶段续跑
|
||||
|
||||
依据同级后端 `dev@dc884f0f` 的正式路由、候选提交服务、质量策略 schema、人工修订服务与 Production Prepare 节点核对。本轮在前端项目根目录 `dev` 适配,保留工作区原有页面改动。
|
||||
|
||||
- 拆解启动默认显式传 `candidateOnly: true`;已有结果时使用候选模式。分组、模块、项目、剧本正文或生成模式变化都会撤销旧预览,启动与正式替换分开确认。
|
||||
- 新增 `commit-candidate` 入口,只发送 `{ confirmed: true }`。资格读取最新原始 Checkpoint,不从历史回退结果拼接;确认后再读取当前版本,变化时停止提交。后端继续在事务内校验最新候选、剧本正文指纹、审核状态和下游资产,不接受客户端上传主体或分镜数据。
|
||||
- 项目配置新增“质量规则”分类,对接 `quality-policy` GET/PUT。完整保留物理模式、三项动作许可、自定义规则和针对主体/资源的精确例外;切换表现方式不会自动放宽动作权限。保存与生成模型配置使用各自的接口和按钮。
|
||||
- 拆解设置新增 `storyboard-quality-repair-plan`、`storyboard-quality-repair-candidates` 与 `storyboard-quality-repair`。人工编辑完整必需动作、阶段时长、手部证据及身体/道具资源证据;候选来源发送真实镜头指纹和 Checkpoint ID。修改草稿撤销旧确认,版本变化要求重新读取。保存仅产生新快照,之后仍需恢复拆解及候选正式提交,不显示为已入库。
|
||||
- 指定 Production 续跑阶段的预检同步后端门禁:所有续跑均要求角色身份确认;首帧及视频提示词续跑要求主体参考图全部有效;视频提示词续跑额外要求全部已有有效首帧。`planned`/可生成不等同于已有有效资产,不影响默认从头运行时补齐上游的行为。
|
||||
- 页面沿用现有公共弹窗、模块留白和固定底栏,动作与资源编辑字段提供可见标签;393px 窄屏按单列显示。
|
||||
|
||||
验证:本地 Chrome 使用 `localhost:4312` 读取真实后端 `localhost:3412`,完成候选分组预览、费用确认取消、真实修复清单空结果、多行质量规则和精确例外必填验证;在 393px 视口检查表单、正文滚动和底栏。已有项目没有待提交候选或质量阻断镜头,候选版本变化拦截、完整证据编辑、无效动作引用阻断和人工修订提交使用临时隔离验收页验证;该页面已删除,不向真实后端写入,不触发模型生成。
|
||||
|
||||
代码校验:lint、format:check、typecheck、56 个测试文件/429 项测试、生产构建和差异检查均通过。使用本机已安装 pnpm 的 `--pm-on-fail=ignore` 参数执行脚本,避免自动下载项目声明的另一版包管理器;没有修改依赖或锁文件。
|
||||
|
||||
核对日期:2026-09-10。依据同级后端仓库 `short-drama-agent` 的 `HEAD=f0321c2`、`src/api/routes` 及实际资产 DTO/service 实现。本轮仅修改前端,沿用已完成页面和正式路由。
|
||||
|
||||
| 接口范围 | 精简后的公开数据 | 前端处理 |
|
||||
|
||||
@@ -18,6 +18,8 @@ withDefaults(
|
||||
}>(),
|
||||
{ description: '', busy: false, wide: false }
|
||||
)
|
||||
/** 关闭动画结束后通知调用方,便于在焦点陷阱释放后定位正文。 */
|
||||
const emit = defineEmits<{ closed: [] }>()
|
||||
/** 弹窗显隐状态,关闭行为由 Naive 管理。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 正文容器隔离子元素外边距,保留完整的自然内容高度。 */
|
||||
@@ -93,6 +95,7 @@ onBeforeUnmount(() => {
|
||||
:class="{ 'app-dialog-title-only': !description && !$slots.description }"
|
||||
role="dialog"
|
||||
:aria-label="title"
|
||||
@after-leave="emit('closed')"
|
||||
>
|
||||
<!-- 以下是固定标题与说明模块,无说明时标题与关闭按钮垂直居中对齐 -->
|
||||
<template #header>
|
||||
|
||||
@@ -9,7 +9,7 @@ import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue
|
||||
import { NScrollbar, NButton, NCheckbox, NInputNumber, NProgress, NTab, NTable, NTabs } from 'naive-ui'
|
||||
import { computed, h, onScopeDispose, ref, watch } from 'vue'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
|
||||
import { Layers, LoaderCircle, Settings2 } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownApi } from './api'
|
||||
@@ -22,6 +22,8 @@ import { useWorkflowExecution } from '../workflows/execution'
|
||||
import SubjectList from './components/SubjectList.vue'
|
||||
import StoryboardList from './components/StoryboardList.vue'
|
||||
import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
|
||||
import BreakdownCandidatePanel from './components/BreakdownCandidatePanel.vue'
|
||||
import StoryboardQualityRepair from './components/StoryboardQualityRepair.vue'
|
||||
import type { DiagnosisLocation } from './diagnosis'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { downloadText, nodeLabel } from '../../lib/format'
|
||||
@@ -32,6 +34,8 @@ const groupSize = ref(3)
|
||||
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
|
||||
const preview = ref<BreakdownPreview | null>(null)
|
||||
const previewBusy = ref(false)
|
||||
/** 默认只生成候选,正式替换需单独确认。 */
|
||||
const candidateOnly = ref(true)
|
||||
const tab = ref('character')
|
||||
const toolsOpen = ref(false)
|
||||
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
|
||||
@@ -40,6 +44,16 @@ const moduleOptions: { value: BreakdownModule; label: string; description: strin
|
||||
{ value: 'prop', label: '道具', description: '关键物件与视觉描述' }
|
||||
]
|
||||
const records = computed(() => workflowCheckpoints(checkpoints.value, 'breakdown'))
|
||||
/** 提交候选只读取最新原始记录,避免从旧快照恢复提交资格。 */
|
||||
const latestCheckpoint = computed(() => records.value.at(-1))
|
||||
/** 有旧结果后统一采用候选模式,不再从设置入口直接覆盖。 */
|
||||
watch(
|
||||
() => records.value.length,
|
||||
count => {
|
||||
if (count > 0) candidateOnly.value = true
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
const snapshot = computed(() => breakdownSnapshot(checkpoints.value))
|
||||
const result = computed(() => snapshot.value?.breakdownResult ?? snapshot.value)
|
||||
const subjects = computed(() => result.value?.subjectCandidates ?? [])
|
||||
@@ -100,8 +114,13 @@ const showRecovery = computed(
|
||||
const configValid = computed(
|
||||
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
|
||||
)
|
||||
const input = computed<BreakdownInput>(() => ({ groupSize: groupSize.value, modules: [...modules.value] }))
|
||||
/** 后端就绪状态决定是否显示后续制作入口。 */
|
||||
/** 预览配置与明确选择的生成模式共用一次启动快照。 */
|
||||
const input = computed<BreakdownInput>(() => ({
|
||||
groupSize: groupSize.value,
|
||||
modules: [...modules.value],
|
||||
candidateOnly: candidateOnly.value
|
||||
}))
|
||||
/** 后端就绪状态用于拆解完成反馈。 */
|
||||
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
|
||||
/** 拆解提示复用全局 NMessage,详细问题留在设置弹窗。 */
|
||||
const actionMessage = useActionMessage()
|
||||
@@ -173,6 +192,8 @@ function invalidatePreview() {
|
||||
watch(
|
||||
[
|
||||
groupSize,
|
||||
candidateOnly,
|
||||
projectId,
|
||||
() => modules.value.join(','),
|
||||
() => project.value?.episodes.map(item => item.episode + ':' + item.content).join('|')
|
||||
],
|
||||
@@ -203,7 +224,10 @@ async function loadPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 长请求不随路由切换取消,返回后刷新 checkpoint 与正式项目数据。 */
|
||||
/**
|
||||
* 提交后台任务并观察真实状态,启动时固定当前候选模式。
|
||||
* @param action 本次启动或恢复动作
|
||||
*/
|
||||
async function run(action: BreakdownAction) {
|
||||
if (project.value?.status !== 'completed' || operation.value.pending || error.value) return
|
||||
if (action === 'start' && !canStart.value) return
|
||||
@@ -227,6 +251,11 @@ async function run(action: BreakdownAction) {
|
||||
await refresh()
|
||||
}
|
||||
|
||||
/** 刷新候选和正式阶段状态,不重放候选生成请求。 */
|
||||
async function refreshCandidate() {
|
||||
await Promise.all([refresh(), refreshStageReadiness()])
|
||||
}
|
||||
|
||||
/** 导出当前拆解结果;阶段性数据也明确标记为 snapshot。 */
|
||||
function exportResult() {
|
||||
if (!snapshot.value) return
|
||||
@@ -259,14 +288,16 @@ const rules = {
|
||||
:status="execution?.status || 'unknown'"
|
||||
:label="
|
||||
execution?.status === 'completed'
|
||||
? '工作流已完成'
|
||||
? latestCheckpoint?.state.candidateOnly && !latestCheckpoint.state.storyboardPersisted
|
||||
? '候选生成已完成'
|
||||
: '工作流已完成'
|
||||
: execution?.status === 'failed'
|
||||
? '工作流失败'
|
||||
: '执行状态待确认'
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗 -->
|
||||
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗;阶段切换使用侧栏 -->
|
||||
<div v-if="project?.episodes.length" class="toolbar-actions">
|
||||
<NButton
|
||||
v-if="execution?.errorMessage || validation?.valid === false"
|
||||
@@ -275,9 +306,7 @@ const rules = {
|
||||
@click="toolsOpen = true"
|
||||
>查看拆解问题</NButton
|
||||
>
|
||||
<RouterLink v-if="stageComplete" :to="`/projects/${projectId}/visual-style`" class="text-button"
|
||||
>继续视觉风格 →</RouterLink
|
||||
>
|
||||
|
||||
<WorkspaceTools
|
||||
:pending="operation.pending"
|
||||
:pending-label="operation.label"
|
||||
@@ -364,6 +393,18 @@ const rules = {
|
||||
</NButton>
|
||||
</div>
|
||||
</AppForm>
|
||||
<!-- 以下是候选生成模式,已有拆解结果统一通过安全提交替换 -->
|
||||
<div class="mt-4 space-y-2">
|
||||
<NCheckbox
|
||||
v-model:checked="candidateOnly"
|
||||
:disabled="operation.pending || records.length > 0"
|
||||
>
|
||||
仅生成候选,确认后再提交正式结果
|
||||
</NCheckbox>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
候选不会替换现有主体和分镜。重新拆解使用候选模式,完成后单独审核与提交。
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="preview" class="group-preview">
|
||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<p class="text-sm">
|
||||
@@ -376,10 +417,10 @@ const rules = {
|
||||
isOperationRunning(operation, '正在拆解剧本') ||
|
||||
backgroundExecution.active.value
|
||||
"
|
||||
:label="records.length ? '重新拆解' : '开始拆解'"
|
||||
:label="candidateOnly ? '生成拆解候选' : '开始拆解'"
|
||||
:description="
|
||||
records.length
|
||||
? '这会重新运行完整剧本拆解,可能替换已保存的主体与分镜。只想恢复失败阶段时,请使用下方对应恢复操作。'
|
||||
candidateOnly
|
||||
? '将按当前分组调用模型生成主体、形态与分镜候选,可能产生模型费用。现有正式数据会保留,候选需经独立确认后才提交。'
|
||||
: '将按当前预览配置启动完整的 剧本拆解流程。抽取结束后仍需完成主体整理、分镜生成与入库。'
|
||||
"
|
||||
:acknowledgement="records.length > 0"
|
||||
@@ -402,6 +443,20 @@ const rules = {
|
||||
当前任务还没有明确的完成或失败记录。为避免重复执行,已暂停重新拆解;如任务已中断,请先刷新状态,再选择对应恢复操作。
|
||||
</p>
|
||||
</section>
|
||||
<BreakdownCandidatePanel
|
||||
:project-id="projectId"
|
||||
:state="latestCheckpoint?.state"
|
||||
:checkpoint-id="latestCheckpoint?.checkpointId"
|
||||
:disabled="!!error || operation.pending || backgroundExecution.active.value"
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<StoryboardQualityRepair
|
||||
v-if="toolsOpen && snapshot"
|
||||
:project-id="projectId"
|
||||
:checkpoint="latestCheckpoint"
|
||||
:disabled="!!error || operation.pending || backgroundExecution.active.value"
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<WorkflowExecutionPanel
|
||||
v-if="backgroundExecution.executionId.value"
|
||||
title="剧本拆解任务"
|
||||
@@ -533,9 +588,7 @@ const rules = {
|
||||
<EmptyState
|
||||
title="还没有可拆解的剧集"
|
||||
description="先完成剧本创作。拆解会读取数据库中的正式剧集,不需要上传 checkpoint。"
|
||||
><RouterLink class="button button-primary" :to="`/projects/${project?.id}/create-drama`"
|
||||
>前往剧本创作<ArrowRight :size="14" /></RouterLink
|
||||
></EmptyState>
|
||||
/>
|
||||
</NScrollbar>
|
||||
<template v-else>
|
||||
<section class="breakdown-results-section">
|
||||
@@ -593,7 +646,7 @@ const rules = {
|
||||
:episodes="shots"
|
||||
@diagnose="openShotDiagnosis"
|
||||
>
|
||||
<!-- 以下是跟随当前剧集的一行诊断摘要,抽屉独立于列表滚动 -->
|
||||
<!-- 以下是跟随当前剧集的一行诊断摘要,诊断弹窗独立于列表滚动 -->
|
||||
<template #diagnosis>
|
||||
<StoryboardDiagnosis
|
||||
ref="diagnosisPanel"
|
||||
@@ -603,11 +656,6 @@ const rules = {
|
||||
@locate="locateDiagnosisShot"
|
||||
/>
|
||||
</template>
|
||||
<template #actions>
|
||||
<RouterLink :to="`/projects/${project?.id}/storyboard`" class="text-button"
|
||||
>进入分镜设计<ArrowRight :size="14"
|
||||
/></RouterLink>
|
||||
</template>
|
||||
</StoryboardList>
|
||||
</div>
|
||||
<div v-if="tab === 'tasks'" class="breakdown-result-pad">
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
BreakdownInput,
|
||||
BreakdownPreview,
|
||||
BreakdownState,
|
||||
BreakdownCandidateCommit,
|
||||
StoryboardHandOccupancyDiagnostics,
|
||||
StoryboardHandRepairPreview,
|
||||
StoryboardHandRepairHistory,
|
||||
@@ -12,9 +13,57 @@ import type {
|
||||
LegacyActionDiagnosisResults
|
||||
} from './types'
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
import type {
|
||||
QualityRepairPlan,
|
||||
QualityRepairCandidates,
|
||||
QualityRepairInput,
|
||||
QualityRepairResult
|
||||
} from './repair.types'
|
||||
|
||||
/** Breakdown API;预览为 GET,启动和恢复为等待完成的长 POST。 */
|
||||
/** Breakdown API;预览为只读查询,启动和恢复返回可持续观察的后台任务。 */
|
||||
export const breakdownApi = {
|
||||
/**
|
||||
* 读取当前仍被质量审核阻断的镜头。
|
||||
* @param id 当前项目编号
|
||||
* @param signal 请求取消信号
|
||||
* @returns 版本化的修复清单
|
||||
*/
|
||||
qualityRepairPlan: (id: string, signal?: AbortSignal) =>
|
||||
request<QualityRepairPlan>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-quality-repair-plan`, {
|
||||
signal
|
||||
}),
|
||||
/**
|
||||
* 读取后端确认仍有效的局部修订候选。
|
||||
* @param id 当前项目编号
|
||||
* @param signal 请求取消信号
|
||||
* @returns 含镜头指纹的候选建议
|
||||
*/
|
||||
qualityRepairCandidates: (id: string, signal?: AbortSignal) =>
|
||||
request<QualityRepairCandidates>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-quality-repair-candidates`,
|
||||
{ signal }
|
||||
),
|
||||
/**
|
||||
* 人工修订单镜头动作规划,不触发模型或替换正式资产。
|
||||
* @param id 当前项目编号
|
||||
* @param input 完整动作字段与版本约束
|
||||
* @returns 修订后的检查点和恢复资格
|
||||
*/
|
||||
repairQualityShot: (id: string, input: QualityRepairInput) =>
|
||||
request<QualityRepairResult>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-quality-repair`, {
|
||||
method: 'POST',
|
||||
body: input
|
||||
}),
|
||||
/**
|
||||
* 明确确认后提交服务端最新候选,不上传或拼装正式资产。
|
||||
* @param id 当前项目编号
|
||||
* @returns 后端事务保存后的正式资产统计
|
||||
*/
|
||||
commitCandidate: (id: string) =>
|
||||
request<BreakdownCandidateCommit>(`/projects/${encodeURIComponent(id)}/breakdown/commit-candidate`, {
|
||||
method: 'POST',
|
||||
body: { confirmed: true }
|
||||
}),
|
||||
preview: (id: string, input: BreakdownInput, signal?: AbortSignal) => {
|
||||
const query = new URLSearchParams({ groupSize: String(input.groupSize), modules: input.modules.join(',') })
|
||||
return request<BreakdownPreview>(`/projects/${encodeURIComponent(id)}/breakdown-preview?${query}`, { signal })
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { BreakdownState } from './types'
|
||||
|
||||
/**
|
||||
* 仅用最新原始快照提示提交条件,实际替换权限仍由后端事务判断。
|
||||
* @param state 最新原始拆解快照,禁止传入历史回退拼接结果
|
||||
* @returns 提交前需要处理的问题,空字符串表示可以请求后端提交
|
||||
*/
|
||||
export function candidateCommitIssue(state: BreakdownState | null | undefined): string {
|
||||
if (state?.candidateOnly !== true) return '当前最新结果不是候选模式。'
|
||||
if (state.storyboardPersisted === true || state.candidateCommitted === true) return '这份候选已经提交。'
|
||||
if (state.workflowExecution?.status === 'running') return '候选拆解仍在执行。'
|
||||
if (state.storyboardShotValidation?.valid !== true) return '候选分镜尚未通过校验。'
|
||||
if (state.storyboardPendingQualityEpisodeNos?.length) return '仍有剧集未通过质量审核,请先修订。'
|
||||
if (!state.expectedEpisodeFingerprints || !state.runConfig?.sourceEpisodes?.length)
|
||||
return '候选缺少剧本版本信息,请重新生成候选。'
|
||||
const episodes = state.storyboardEpisodeShots ?? []
|
||||
const source = state.runConfig.sourceEpisodes
|
||||
if (
|
||||
!state.subjectCandidates?.length ||
|
||||
!Array.isArray(state.subjectForms) ||
|
||||
episodes.length !== source.length ||
|
||||
source.some(
|
||||
item =>
|
||||
!state.expectedEpisodeFingerprints?.[item.episodeNo] ||
|
||||
!episodes.some(
|
||||
episode => episode.episodeNo === item.episodeNo && episode.beatShots.some(beat => beat.shots.length)
|
||||
)
|
||||
)
|
||||
)
|
||||
return '候选主体或分镜不完整,请先完成拆解。'
|
||||
return ''
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import type { BreakdownState } from '../types'
|
||||
import { candidateCommitIssue } from '../candidate'
|
||||
import { breakdownApi } from '../api'
|
||||
import { runOperation, getOperation, isOperationRunning } from '../../workflows/operations'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import { projectsApi } from '../../projects/api'
|
||||
import { workflowCheckpoints } from '../../workflows/selectors'
|
||||
|
||||
/** 最新候选快照及独立提交入口。 */
|
||||
const props = defineProps<{
|
||||
/** 当前正式项目编号。 */
|
||||
projectId: string
|
||||
/** 服务端最新原始快照,不使用历史回退结果。 */
|
||||
state?: BreakdownState
|
||||
/** 当前快照版本,用于撤销旧确认。 */
|
||||
checkpointId?: string
|
||||
/** 项目存在活动任务或读取错误。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 提交后刷新正式资产和阶段状态。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 项目级操作锁与错误反馈沿用现有工作区。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 显式候选标记,历史通过记录不作为提交依据。 */
|
||||
const isCandidate = computed(() => props.state?.candidateOnly === true)
|
||||
/** 候选完成后是否已经提交。 */
|
||||
const committed = computed(() => props.state?.storyboardPersisted === true || props.state?.candidateCommitted === true)
|
||||
/** 本地可见的提交阻断原因。 */
|
||||
const issue = computed(() => candidateCommitIssue(props.state))
|
||||
/** 本轮候选的真实规模。 */
|
||||
const counts = computed(() => ({
|
||||
subjects: props.state?.subjectCandidates?.length ?? 0,
|
||||
episodes: props.state?.storyboardEpisodeShots?.length ?? 0,
|
||||
shots:
|
||||
props.state?.storyboardEpisodeShots?.reduce(
|
||||
(total, episode) => total + episode.beatShots.reduce((sum, beat) => sum + beat.shots.length, 0),
|
||||
0
|
||||
) ?? 0
|
||||
}))
|
||||
|
||||
/** 只提交一次,后端事务再次校验剧本版本、候选审核和下游资产。 */
|
||||
async function commit() {
|
||||
if (props.disabled || issue.value || operation.value.pending) return
|
||||
const id = props.projectId
|
||||
const checkpointId = props.checkpointId
|
||||
await runOperation(
|
||||
id,
|
||||
'正在提交拆解候选',
|
||||
async () => {
|
||||
const records = await projectsApi.checkpoints(id)
|
||||
const latest = workflowCheckpoints(records, 'breakdown').at(-1)
|
||||
if (
|
||||
!checkpointId ||
|
||||
!latest ||
|
||||
props.projectId !== id ||
|
||||
props.checkpointId !== checkpointId ||
|
||||
latest.checkpointId !== checkpointId
|
||||
)
|
||||
throw new Error('拆解候选版本已变化,请刷新后重新确认。')
|
||||
const nextIssue = candidateCommitIssue(latest.state)
|
||||
if (nextIssue) throw new Error(nextIssue)
|
||||
const receipt = await breakdownApi.commitCandidate(id)
|
||||
if (receipt.projectId !== id) throw new Error('候选提交回执的项目不一致,请刷新确认。')
|
||||
return receipt
|
||||
},
|
||||
receipt => ({
|
||||
type: 'success',
|
||||
content: `候选已提交:${receipt.subjectCount} 个主体、${receipt.episodeCount} 集、${receipt.shotCount} 个镜头。`
|
||||
})
|
||||
)
|
||||
if (props.projectId === id) emit('refresh')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是候选审核与正式提交模块,沿用设置区的模块间距和按钮层级 -->
|
||||
<section v-if="isCandidate" class="workspace-panel space-y-4" aria-label="拆解候选">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">{{ committed ? '候选已提交' : '待确认的拆解候选' }}</h3>
|
||||
<span class="text-xs text-muted"
|
||||
>主体 {{ counts.subjects }} · {{ counts.episodes }} 集 · {{ counts.shots }} 镜</span
|
||||
>
|
||||
</div>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
{{
|
||||
committed
|
||||
? '这份结果已写入正式主体、形态与分镜。'
|
||||
: '候选生成不替换正式数据。确认后由后端核对剧本版本、审核结果和下游资产,再统一提交。已有身份、参考图或镜头生产资产时会拒绝替换。'
|
||||
}}
|
||||
</p>
|
||||
<p v-if="!committed && issue" class="text-xs leading-6 text-muted" role="status">{{ issue }}</p>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<ConfirmAction
|
||||
v-if="!committed"
|
||||
:key="checkpointId"
|
||||
label="提交候选为正式结果"
|
||||
description="将使用服务端最新候选统一替换正式主体、形态与分镜。此操作不调用模型;已有下游资产、剧本变化或审核未通过时,后端会拒绝提交。"
|
||||
acknowledgement
|
||||
:disabled="disabled || !!issue || operation.pending"
|
||||
:loading="isOperationRunning(operation, '正在提交拆解候选')"
|
||||
@confirm="commit"
|
||||
/>
|
||||
<NButton text :disabled="operation.pending" @click="emit('refresh')">刷新候选状态</NButton>
|
||||
</div>
|
||||
<p
|
||||
v-if="operation.error && operation.label === '正在提交拆解候选'"
|
||||
role="alert"
|
||||
class="text-xs leading-6 text-danger"
|
||||
>
|
||||
{{ operation.error }}
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,291 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCheckbox, NFormItem, NInput, NInputNumber, NSelect } from 'naive-ui'
|
||||
import { actionResourceOptions } from '../../projects/quality-policy'
|
||||
import type { ShotActionDraft } from '../repair.types'
|
||||
|
||||
/** 单镜头动作及资源证据的结构化编辑器。 */
|
||||
defineProps<{
|
||||
/** 保存或后台操作期间只读。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 调用方持有独立草稿,编辑器不改动原始检查点。 */
|
||||
const draft = defineModel<ShotActionDraft>({ required: true })
|
||||
/** 动作引用选项随草稿编号更新,非法旧引用由提交校验提示。 */
|
||||
const actionOptions = computed(() =>
|
||||
draft.value.requiredActions
|
||||
.filter(item => item.id.trim())
|
||||
.map(item => ({ value: item.id, label: `${item.id} · ${item.description || '待填写描述'}` }))
|
||||
)
|
||||
/** 动作种类。 */
|
||||
const kindOptions = [
|
||||
{ value: 'action', label: '动作' },
|
||||
{ value: 'state', label: '状态' }
|
||||
]
|
||||
/** 动作复杂度。 */
|
||||
const complexityOptions = [
|
||||
{ value: 'low', label: '低' },
|
||||
{ value: 'medium', label: '中' },
|
||||
{ value: 'high', label: '高' }
|
||||
]
|
||||
/** 手部枚举。 */
|
||||
const handOptions = [
|
||||
{ value: 'left', label: '左手' },
|
||||
{ value: 'right', label: '右手' },
|
||||
{ value: 'both', label: '双手' }
|
||||
]
|
||||
/** 通用资源用途。 */
|
||||
const usageOptions = [
|
||||
{ value: 'support', label: '支撑' },
|
||||
{ value: 'hold', label: '持有' },
|
||||
{ value: 'move', label: '移动' },
|
||||
{ value: 'interact', label: '交互' },
|
||||
{ value: 'other', label: '其他' }
|
||||
]
|
||||
|
||||
/** 添加待人工填写的动作,不自动编造编号或描述。 */
|
||||
function addAction() {
|
||||
draft.value.requiredActions.push({ id: '', description: '', kind: 'action', mustPerformInShot: true })
|
||||
}
|
||||
/** 添加待人工填写的动作阶段。 */
|
||||
function addPhase() {
|
||||
draft.value.durationPlanning.phases.push({ action: '', actionIds: [], estimatedSeconds: 0 })
|
||||
}
|
||||
/**
|
||||
* 添加一项空资源证据,由用户明确选择对应动作和主体。
|
||||
* @param index 目标阶段序号
|
||||
* @param kind 手部或通用资源
|
||||
*/
|
||||
function addEvidence(index: number, kind: 'hand' | 'resource') {
|
||||
const phase = draft.value.durationPlanning.phases[index]
|
||||
if (!phase) return
|
||||
if (kind === 'hand')
|
||||
(phase.handOccupancy ??= []).push({ actionId: '', characterRef: '', hands: 'left', shareable: false })
|
||||
else
|
||||
(phase.resourceOccupancy ??= []).push({
|
||||
actionId: '',
|
||||
ownerRef: '',
|
||||
resource: 'left_hand',
|
||||
usage: 'hold',
|
||||
shareable: false
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是必需动作、阶段时长与完整资源证据编辑模块 -->
|
||||
<div class="shot-action-editor">
|
||||
<section class="space-y-4" aria-label="必需动作">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">必需动作</h3>
|
||||
<NButton size="small" :disabled="disabled" @click="addAction">添加动作</NButton>
|
||||
</div>
|
||||
<div v-for="(action, index) in draft.requiredActions" :key="index" class="action-fields">
|
||||
<NFormItem label="动作编号" :show-feedback="false"
|
||||
><NInput
|
||||
v-model:value="action.id"
|
||||
:aria-label="`动作 ${index + 1} 编号`"
|
||||
placeholder="动作编号"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="动作描述" :show-feedback="false"
|
||||
><NInput
|
||||
v-model:value="action.description"
|
||||
:aria-label="`动作 ${index + 1} 描述`"
|
||||
placeholder="具体动作描述"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="动作类型" :show-feedback="false"
|
||||
><NSelect
|
||||
v-model:value="action.kind"
|
||||
:aria-label="`动作 ${index + 1} 类型`"
|
||||
:options="kindOptions"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NCheckbox v-model:checked="action.mustPerformInShot" :disabled="disabled">本镜必须完成</NCheckbox>
|
||||
<NButton :disabled="disabled" @click="draft.requiredActions.splice(index, 1)">移除</NButton>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 以下是动作阶段编辑模块,同阶段动作视为同时发生 -->
|
||||
<section class="space-y-4" aria-label="动作阶段">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">动作阶段</h3>
|
||||
<NButton size="small" :disabled="disabled" @click="addPhase">添加阶段</NButton>
|
||||
</div>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
同阶段动作视为同时发生;需要释放资源后再执行的动作,请安排在不同阶段。已有证据会完整保留。
|
||||
</p>
|
||||
<section
|
||||
v-for="(phase, index) in draft.durationPlanning.phases"
|
||||
:key="index"
|
||||
class="action-phase space-y-4"
|
||||
:aria-label="`动作阶段 ${index + 1}`"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h4 class="text-sm">阶段 {{ index + 1 }}</h4>
|
||||
<NButton text :disabled="disabled" @click="draft.durationPlanning.phases.splice(index, 1)"
|
||||
>移除阶段</NButton
|
||||
>
|
||||
</div>
|
||||
<NFormItem label="阶段描述"
|
||||
><NInput v-model:value="phase.action" :aria-label="`阶段 ${index + 1} 描述`" :disabled="disabled"
|
||||
/></NFormItem>
|
||||
<div class="phase-fields">
|
||||
<NFormItem label="阶段动作"
|
||||
><NSelect
|
||||
v-model:value="phase.actionIds"
|
||||
multiple
|
||||
:options="actionOptions"
|
||||
:aria-label="`阶段 ${index + 1} 动作引用`"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="阶段时长(秒)"
|
||||
><NInputNumber
|
||||
:value="phase.estimatedSeconds"
|
||||
@update:value="phase.estimatedSeconds = $event ?? 0"
|
||||
:min="0.1"
|
||||
:aria-label="`阶段 ${index + 1} 时长`"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<NButton size="small" :disabled="disabled" @click="addEvidence(index, 'hand')">添加手部证据</NButton
|
||||
><NButton size="small" :disabled="disabled" @click="addEvidence(index, 'resource')"
|
||||
>添加资源证据</NButton
|
||||
>
|
||||
</div>
|
||||
<div
|
||||
v-for="(hand, handIndex) in phase.handOccupancy"
|
||||
:key="`hand-${handIndex}`"
|
||||
class="evidence-fields"
|
||||
>
|
||||
<NFormItem label="关联动作" :show-feedback="false"
|
||||
><NSelect
|
||||
v-model:value="hand.actionId"
|
||||
:options="actionOptions"
|
||||
aria-label="手部证据动作"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="主体引用" :show-feedback="false"
|
||||
><NInput
|
||||
v-model:value="hand.characterRef"
|
||||
placeholder="主体引用"
|
||||
aria-label="手部证据主体引用"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="手部" :show-feedback="false"
|
||||
><NSelect
|
||||
v-model:value="hand.hands"
|
||||
:options="handOptions"
|
||||
aria-label="使用的手"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NCheckbox v-model:checked="hand.shareable" :disabled="disabled">可共享</NCheckbox>
|
||||
<NButton :disabled="disabled" @click="phase.handOccupancy?.splice(handIndex, 1)">移除</NButton>
|
||||
</div>
|
||||
<div
|
||||
v-for="(resource, resourceIndex) in phase.resourceOccupancy"
|
||||
:key="`resource-${resourceIndex}`"
|
||||
class="evidence-fields"
|
||||
>
|
||||
<NFormItem label="关联动作" :show-feedback="false"
|
||||
><NSelect
|
||||
v-model:value="resource.actionId"
|
||||
:options="actionOptions"
|
||||
aria-label="资源证据动作"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="主体引用" :show-feedback="false"
|
||||
><NInput
|
||||
v-model:value="resource.ownerRef"
|
||||
placeholder="主体引用"
|
||||
aria-label="资源证据主体引用"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="占用资源" :show-feedback="false"
|
||||
><NSelect
|
||||
v-model:value="resource.resource"
|
||||
:options="actionResourceOptions"
|
||||
aria-label="占用资源"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="资源用途" :show-feedback="false"
|
||||
><NSelect
|
||||
v-model:value="resource.usage"
|
||||
:options="usageOptions"
|
||||
aria-label="资源用途"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NCheckbox v-model:checked="resource.shareable" :disabled="disabled">可共享</NCheckbox>
|
||||
<NButton :disabled="disabled" @click="phase.resourceOccupancy?.splice(resourceIndex, 1)"
|
||||
>移除</NButton
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
<!-- 以下是镜头整体时长依据模块 -->
|
||||
<section class="phase-fields" aria-label="整体时长规划">
|
||||
<NFormItem label="动作复杂度"
|
||||
><NSelect
|
||||
v-model:value="draft.durationPlanning.complexity"
|
||||
:options="complexityOptions"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="阶段衔接(秒)"
|
||||
><NInputNumber
|
||||
:value="draft.durationPlanning.transitionSeconds"
|
||||
@update:value="draft.durationPlanning.transitionSeconds = $event ?? 0"
|
||||
:min="0"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
<NFormItem label="建议总时长(秒)"
|
||||
><NInputNumber
|
||||
:value="draft.durationPlanning.recommendedDurationSeconds"
|
||||
@update:value="draft.durationPlanning.recommendedDurationSeconds = $event ?? 0"
|
||||
:min="0.1"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
</section>
|
||||
<NFormItem label="时长规划依据"
|
||||
><NInput
|
||||
v-model:value="draft.durationPlanning.reason"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 6 }"
|
||||
:disabled="disabled"
|
||||
/></NFormItem>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.shot-action-editor {
|
||||
display: grid;
|
||||
gap: 24px;
|
||||
}
|
||||
.action-fields,
|
||||
.evidence-fields {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: end;
|
||||
gap: 12px;
|
||||
}
|
||||
.action-fields > :deep(.n-form-item),
|
||||
.evidence-fields > :deep(.n-form-item) {
|
||||
flex: 1 1 140px;
|
||||
min-width: 0;
|
||||
}
|
||||
.phase-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
.action-phase {
|
||||
background: var(--app-subtle);
|
||||
padding: 20px;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.action-fields > :deep(.n-form-item),
|
||||
.evidence-fields > :deep(.n-form-item) {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,17 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import {
|
||||
NButton,
|
||||
NCollapse,
|
||||
NCollapseItem,
|
||||
NDrawer,
|
||||
NDrawerContent,
|
||||
NInputNumber,
|
||||
NScrollbar,
|
||||
NSelect,
|
||||
NTag
|
||||
} from 'naive-ui'
|
||||
import { ScanLine } from '@lucide/vue'
|
||||
import { NButton, NCollapse, NCollapseItem, NInputNumber, NSelect, NSpin, NTag } from 'naive-ui'
|
||||
import { RefreshCw, ScanLine } from '@lucide/vue'
|
||||
import { breakdownApi } from '../api'
|
||||
import { diagnosisInput, diagnosisStatusLabels, scopeDiagnosisShots, summarizeDiagnosis } from '../diagnosis'
|
||||
import type { DiagnosisLocation, DiagnosisScope } from '../diagnosis'
|
||||
@@ -24,6 +14,7 @@ import type {
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import WorkflowExecutionPanel from '../../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../../workflows/execution'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
|
||||
@@ -36,32 +27,34 @@ const props = defineProps<{
|
||||
/** 全项目预览所需的正式剧集编号。 */
|
||||
episodeNos: number[]
|
||||
}>()
|
||||
/** 关闭抽屉后定位对应镜头或节拍。 */
|
||||
/** 关闭弹窗后定位对应镜头或节拍。 */
|
||||
const emit = defineEmits<{ locate: [location: DiagnosisLocation] }>()
|
||||
/** 统一操作消息层。 */
|
||||
const message = useActionMessage()
|
||||
/** 任务观察独立于抽屉显隐,关闭抽屉后继续跟踪真实进度。 */
|
||||
/** 任务观察独立于弹窗显隐,关闭弹窗后继续跟踪真实进度。 */
|
||||
const execution = useWorkflowExecution(
|
||||
computed(() => props.projectId),
|
||||
'storyboard-legacy-action-diagnosis'
|
||||
)
|
||||
/** 右侧诊断抽屉是否展开。 */
|
||||
const drawerOpen = ref(false)
|
||||
/** 等待抽屉离场后再转移焦点,避免焦点陷阱把定位焦点拉回。 */
|
||||
/** 居中诊断弹窗是否打开。 */
|
||||
const dialogOpen = ref(false)
|
||||
/** 首批诊断数据完成前保留固定加载区域,不渲染会闪现的空结果。 */
|
||||
const dialogDataReady = ref(false)
|
||||
/** 等待弹窗离场后再转移焦点,避免焦点陷阱把定位焦点拉回。 */
|
||||
const pendingLocation = ref<DiagnosisLocation | null>(null)
|
||||
/** 本次查看及提交的诊断范围。 */
|
||||
const scope = ref<DiagnosisScope>({ kind: 'project' })
|
||||
/** 当前集摘要与抽屉结果分开保存,切换抽屉范围不会改变摘要含义。 */
|
||||
/** 当前集摘要与弹窗结果分开保存,切换弹窗范围不会改变摘要含义。 */
|
||||
const episodeResults = ref<LegacyActionDiagnosisResults | null>(null)
|
||||
/** 当前集摘要的读取状态。 */
|
||||
const summaryBusy = ref(false)
|
||||
/** 当前集摘要的读取错误。 */
|
||||
const summaryError = ref('')
|
||||
/** 抽屉范围对应的后端结果,节拍及镜头会再次筛选。 */
|
||||
/** 弹窗范围对应的后端结果,节拍及镜头会再次筛选。 */
|
||||
const results = ref<LegacyActionDiagnosisResults | null>(null)
|
||||
/** 抽屉结果读取状态。 */
|
||||
/** 弹窗结果读取状态。 */
|
||||
const resultsBusy = ref(false)
|
||||
/** 抽屉结果读取错误。 */
|
||||
/** 弹窗结果读取错误。 */
|
||||
const resultsError = ref('')
|
||||
/** 只读范围预览;全项目按正式剧集汇总,任何一集失败都不能启动。 */
|
||||
const previews = ref<LegacyActionDiagnosisPreview[] | null>(null)
|
||||
@@ -87,7 +80,7 @@ const repairIssue = ref<number | null>(null)
|
||||
const repairPreview = ref<StoryboardHandRepairPreview | null>(null)
|
||||
/** 修复建议读取状态。 */
|
||||
const repairBusy = ref(false)
|
||||
/** 请求版本用于忽略范围变化、关闭抽屉及组件卸载后的迟到响应。 */
|
||||
/** 请求版本用于忽略范围变化、关闭弹窗及组件卸载后的迟到响应。 */
|
||||
let summaryVersion = 0
|
||||
/** 当前范围结果请求版本。 */
|
||||
let resultsVersion = 0
|
||||
@@ -96,6 +89,15 @@ let previewVersion = 0
|
||||
/** 项目级校验和修复建议的请求版本。 */
|
||||
let handVersion = 0
|
||||
|
||||
/** 合并用户触发的只读请求状态;后台任务轮询不触发整窗遮罩。 */
|
||||
const dialogLoading = computed(() => resultsBusy.value || handBusy.value || previewBusy.value || repairBusy.value)
|
||||
/** 已有结果或校验的刷新只使用按钮加载态,首次读取及预览、修复请求保留整窗加载反馈。 */
|
||||
const dialogOverlayLoading = computed(
|
||||
() =>
|
||||
dialogLoading.value &&
|
||||
(!dialogDataReady.value || (handBusy.value && !handDiagnostics.value) || previewBusy.value || repairBusy.value)
|
||||
)
|
||||
|
||||
/** 当前查看范围的中文名称,同时用于费用确认。 */
|
||||
const scopeLabel = computed(() => {
|
||||
const target = scope.value
|
||||
@@ -108,7 +110,7 @@ const scopeLabel = computed(() => {
|
||||
const scopeKey = computed(() => JSON.stringify(scope.value))
|
||||
/** 当前集摘要根据真实诊断记录统计。 */
|
||||
const summaryCounts = computed(() => (episodeResults.value ? summarizeDiagnosis(episodeResults.value.shots) : null))
|
||||
/** 抽屉统计严格对应当前集、节拍或镜头范围。 */
|
||||
/** 弹窗统计严格对应当前集、节拍或镜头范围。 */
|
||||
const scopedShots = computed(() => scopeDiagnosisShots(results.value?.shots ?? [], scope.value))
|
||||
/** 当前范围的状态计数。 */
|
||||
const counts = computed(() => summarizeDiagnosis(scopedShots.value))
|
||||
@@ -128,9 +130,11 @@ const previewCount = computed(() => previews.value?.reduce((sum, item) => sum +
|
||||
const concurrencyValid = computed(
|
||||
() => Number.isSafeInteger(concurrency.value) && concurrency.value >= 1 && concurrency.value <= 5
|
||||
)
|
||||
/** 启动前必须取得当前范围预览,并保证没有同项目同工作流活动任务。 */
|
||||
/** 底栏启动操作要求数据就绪、读取结束且预览有效,同时保证没有同项目同工作流活动任务。 */
|
||||
const canStart = computed(
|
||||
() =>
|
||||
dialogDataReady.value &&
|
||||
!dialogLoading.value &&
|
||||
!!previews.value &&
|
||||
previewCount.value > 0 &&
|
||||
concurrencyValid.value &&
|
||||
@@ -175,7 +179,7 @@ async function loadSummary() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取当前抽屉范围结果;同集结果同时更新顶部摘要。
|
||||
* 读取当前弹窗范围结果;同集结果同时更新顶部摘要。
|
||||
* @returns 当前结果读取结束
|
||||
*/
|
||||
async function loadResults() {
|
||||
@@ -233,18 +237,22 @@ async function loadPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 读取全项目结构化证据;证据不足时不以零冲突暗示安全。 */
|
||||
/**
|
||||
* 读取全项目结构化证据,刷新期间保留已展示内容,避免弹窗高度收缩后又恢复。
|
||||
* @returns 本轮校验读取结束
|
||||
*/
|
||||
async function loadHandDiagnostics() {
|
||||
const version = ++handVersion
|
||||
handBusy.value = true
|
||||
handError.value = ''
|
||||
handDiagnostics.value = null
|
||||
repairPreview.value = null
|
||||
repairIssue.value = null
|
||||
repairBusy.value = false
|
||||
try {
|
||||
const data = await breakdownApi.handOccupancyDiagnostics(props.projectId)
|
||||
if (version === handVersion) handDiagnostics.value = data
|
||||
if (version === handVersion) {
|
||||
handDiagnostics.value = data
|
||||
repairPreview.value = null
|
||||
repairIssue.value = null
|
||||
}
|
||||
} catch (cause) {
|
||||
if (version === handVersion) handError.value = errorMessage(cause)
|
||||
} finally {
|
||||
@@ -304,7 +312,7 @@ function issueDescriptions(issues: unknown[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从顶部或镜头入口打开抽屉;指定镜头时自动取得只读范围预览。
|
||||
* 从顶部或镜头入口打开弹窗;指定镜头时自动取得只读范围预览。
|
||||
* @param location 可选的节拍或镜头坐标
|
||||
*/
|
||||
function open(location?: DiagnosisLocation) {
|
||||
@@ -316,20 +324,20 @@ function open(location?: DiagnosisLocation) {
|
||||
: props.episodeNo === undefined
|
||||
? { kind: 'project' }
|
||||
: { kind: 'episode', episodeNo: props.episodeNo }
|
||||
drawerOpen.value = true
|
||||
dialogOpen.value = true
|
||||
if (location) void loadPreview()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭抽屉后通知列表定位,保留当前任务观察。
|
||||
* 关闭弹窗后通知列表定位,保留当前任务观察。
|
||||
* @param location 待定位的镜头或节拍
|
||||
*/
|
||||
function locate(location: DiagnosisLocation) {
|
||||
pendingLocation.value = location
|
||||
drawerOpen.value = false
|
||||
dialogOpen.value = false
|
||||
}
|
||||
|
||||
/** 抽屉关闭动画结束后定位镜头,键盘焦点与正文高亮保持一致。 */
|
||||
/** 弹窗关闭动画结束后定位镜头,键盘焦点与正文高亮保持一致。 */
|
||||
function finishLocate() {
|
||||
if (!pendingLocation.value) return
|
||||
const location = pendingLocation.value
|
||||
@@ -358,7 +366,7 @@ watch(
|
||||
[() => props.projectId, () => props.episodeNo],
|
||||
() => {
|
||||
pendingLocation.value = null
|
||||
drawerOpen.value = false
|
||||
dialogOpen.value = false
|
||||
++handVersion
|
||||
handDiagnostics.value = null
|
||||
handBusy.value = false
|
||||
@@ -367,9 +375,17 @@ watch(
|
||||
},
|
||||
{ immediate: true, flush: 'sync' }
|
||||
)
|
||||
/** 首批范围结果与结构化校验全部结束后才显示正文,失败时显示对应错误。 */
|
||||
watch(
|
||||
dialogLoading,
|
||||
loading => {
|
||||
if (dialogOpen.value && !loading) dialogDataReady.value = true
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 关闭或切换范围立即废弃预览及结果请求,禁止确认旧预览。 */
|
||||
watch(
|
||||
[drawerOpen, scopeKey],
|
||||
[dialogOpen, scopeKey],
|
||||
([shown]) => {
|
||||
++previewVersion
|
||||
++resultsVersion
|
||||
@@ -380,6 +396,7 @@ watch(
|
||||
resultsBusy.value = false
|
||||
resultsError.value = ''
|
||||
resultFilter.value = 'attention'
|
||||
dialogDataReady.value = false
|
||||
if (shown) {
|
||||
void loadResults()
|
||||
if (!handDiagnostics.value && !handBusy.value) void loadHandDiagnostics()
|
||||
@@ -391,13 +408,13 @@ watch(
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 后台任务结束后更新摘要和已打开的结果,不因关闭抽屉停止跟踪。 */
|
||||
/** 后台任务结束后更新摘要和已打开的结果,不因关闭弹窗停止跟踪。 */
|
||||
watch(
|
||||
() => execution.query.data.value?.status,
|
||||
(status, previous) => {
|
||||
if (status !== previous && (status === 'completed' || status === 'failed')) {
|
||||
void loadSummary()
|
||||
if (drawerOpen.value) void loadResults()
|
||||
if (dialogOpen.value) void loadResults()
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -423,254 +440,280 @@ defineExpose({ open })
|
||||
>
|
||||
<NTag v-if="execution.active.value" type="info" size="small" :bordered="false">诊断中</NTag>
|
||||
</div>
|
||||
<NButton text :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="drawerOpen" @click="open()"
|
||||
<NButton text :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="dialogOpen" @click="open()"
|
||||
>查看诊断</NButton
|
||||
>
|
||||
</div>
|
||||
<!-- 以下是独立滚动的右侧诊断抽屉模块,手机自动使用全屏宽度 -->
|
||||
<NDrawer
|
||||
v-model:show="drawerOpen"
|
||||
placement="right"
|
||||
width="min(560px, 100vw)"
|
||||
class="storyboard-diagnosis-drawer"
|
||||
@after-leave="finishLocate"
|
||||
>
|
||||
<NDrawerContent title="动作诊断" closable :native-scrollbar="false">
|
||||
<p class="diagnosis-intro">检查手部动作占用与冲突,帮助定位需要处理的镜头。</p>
|
||||
<!-- 以下是当前范围模块,剧集编号始终与阅读列表一致 -->
|
||||
<section class="diagnosis-section">
|
||||
<h3>诊断范围</h3>
|
||||
<div class="diagnosis-scope-controls">
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="episodeNo === undefined"
|
||||
:type="scope.kind !== 'project' ? 'primary' : 'default'"
|
||||
@click="scope = { kind: 'episode', episodeNo: episodeNo! }"
|
||||
>当前集</NButton
|
||||
>
|
||||
<NButton
|
||||
size="small"
|
||||
:type="scope.kind === 'project' ? 'primary' : 'default'"
|
||||
@click="scope = { kind: 'project' }"
|
||||
>全项目</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="diagnosis-scope-label">{{ scopeLabel }}</p>
|
||||
<p class="text-xs text-muted">当前支持手部动作冲突检查。</p>
|
||||
</section>
|
||||
<!-- 以下是诊断结果模块,默认隐藏未诊断长列表 -->
|
||||
<section class="diagnosis-section">
|
||||
<div class="diagnosis-section-heading">
|
||||
<h3>诊断结果</h3>
|
||||
<NButton text size="small" :loading="resultsBusy" @click="loadResults">刷新结果</NButton>
|
||||
</div>
|
||||
<p v-if="resultsError" class="text-danger" role="alert">{{ resultsError }}</p>
|
||||
<template v-else-if="results">
|
||||
<div class="diagnosis-counts">
|
||||
<span>范围内 {{ counts.total }} 镜</span
|
||||
><span :class="{ 'text-danger': counts.conflict }">冲突 {{ counts.conflict }}</span>
|
||||
<span>证据不足 {{ counts.insufficient }}</span
|
||||
><span>证据无效 {{ counts.invalid }}</span
|
||||
><span>已过期 {{ counts.stale }}</span> <span>未诊断 {{ counts.pending }}</span
|
||||
><span>未发现冲突 {{ counts.clear }}</span>
|
||||
</div>
|
||||
<NSelect
|
||||
v-model:value="resultFilter"
|
||||
aria-label="筛选诊断结果"
|
||||
size="small"
|
||||
class="diagnosis-result-filter"
|
||||
:options="[
|
||||
{ label: '需处理:冲突、证据异常与过期', value: 'attention' },
|
||||
{ label: `未诊断(${counts.pending})`, value: 'pending' },
|
||||
{ label: `全部镜头(${counts.total})`, value: 'all' }
|
||||
]"
|
||||
/>
|
||||
<div v-if="!visibleShots.length" class="diagnosis-empty">
|
||||
<p>
|
||||
{{
|
||||
counts.total === 0
|
||||
? '当前范围尚无镜头。'
|
||||
: counts.pending === counts.total
|
||||
? `${counts.pending} 个镜头尚未诊断,暂无法判断冲突情况。`
|
||||
: resultFilter === 'attention'
|
||||
? '当前没有需处理的诊断记录。'
|
||||
: '当前筛选下没有镜头。'
|
||||
}}
|
||||
</p>
|
||||
<NButton
|
||||
v-if="counts.pending && resultFilter !== 'pending'"
|
||||
text
|
||||
size="small"
|
||||
@click="resultFilter = 'pending'"
|
||||
>查看未诊断镜头</NButton
|
||||
>
|
||||
</div>
|
||||
<NScrollbar
|
||||
v-if="visibleShots.length"
|
||||
class="diagnosis-result-list"
|
||||
tabindex="0"
|
||||
aria-label="镜头诊断列表"
|
||||
>
|
||||
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item">
|
||||
<div class="diagnosis-section-heading">
|
||||
<span class="text-xs text-muted"
|
||||
>第 {{ item.episodeNo }} 集 / 节拍 {{ item.beatNo }} / 镜头 {{ item.shotNo }}</span
|
||||
>
|
||||
<NTag
|
||||
:type="
|
||||
item.status === 'conflict_found'
|
||||
? 'error'
|
||||
: item.status === 'no_conflict_found'
|
||||
? 'success'
|
||||
: 'default'
|
||||
"
|
||||
size="small"
|
||||
:bordered="false"
|
||||
>{{ diagnosisStatusLabels[item.status] }}</NTag
|
||||
>
|
||||
</div>
|
||||
<p class="font-medium">{{ item.title }}</p>
|
||||
<p
|
||||
v-for="(description, index) in issueDescriptions(item.issues)"
|
||||
:key="index"
|
||||
class="text-muted"
|
||||
<!-- 以下是居中动作诊断弹窗,正文自然增高,仅超过可用视口后统一滚动 -->
|
||||
<AppDialog v-model:open="dialogOpen" title="动作诊断" :width="640" @closed="finishLocate">
|
||||
<NSpin
|
||||
:show="dialogOverlayLoading"
|
||||
description="正在加载诊断数据…"
|
||||
class="storyboard-diagnosis-dialog"
|
||||
:aria-busy="dialogLoading"
|
||||
>
|
||||
<div class="diagnosis-dialog-body">
|
||||
<!-- 首批数据加载期间仅显示遮罩,避免先显示零计数或空结果再跳变 -->
|
||||
<div v-if="dialogDataReady" class="diagnosis-dialog-content">
|
||||
<!-- 以下是当前范围模块,剧集编号始终与阅读列表一致 -->
|
||||
<section class="diagnosis-section">
|
||||
<h3>诊断范围</h3>
|
||||
<div class="diagnosis-scope-controls">
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="episodeNo === undefined"
|
||||
:type="scope.kind !== 'project' ? 'primary' : 'default'"
|
||||
@click="scope = { kind: 'episode', episodeNo: episodeNo! }"
|
||||
>当前集</NButton
|
||||
>
|
||||
{{ description }}
|
||||
</p>
|
||||
<NButton text size="small" @click="locate(item)">定位镜头</NButton>
|
||||
</article>
|
||||
</NScrollbar>
|
||||
</template>
|
||||
<p v-else class="text-muted">{{ resultsBusy ? '正在读取当前范围结果…' : '尚未读取结果' }}</p>
|
||||
</section>
|
||||
<!-- 以下是使用 Naive UI 折叠组件的全项目结构化校验模块,默认收起 -->
|
||||
<section class="diagnosis-section">
|
||||
<NCollapse>
|
||||
<NCollapseItem name="hand-diagnostics">
|
||||
<template #header>
|
||||
<span class="diagnosis-evidence-title">结构化动作校验</span>
|
||||
<span class="ml-2 text-xs text-muted">全项目</span>
|
||||
</template>
|
||||
<div class="diagnosis-section-heading">
|
||||
<span class="text-xs text-muted">直接读取已有动作证据,不调用模型</span>
|
||||
<NButton text size="small" :loading="handBusy" @click="loadHandDiagnostics"
|
||||
>刷新校验</NButton
|
||||
<NButton
|
||||
size="small"
|
||||
:type="scope.kind === 'project' ? 'primary' : 'default'"
|
||||
@click="scope = { kind: 'project' }"
|
||||
>全项目</NButton
|
||||
>
|
||||
</div>
|
||||
<p v-if="handError" class="text-danger" role="alert">{{ handError }}</p>
|
||||
<template v-else-if="handDiagnostics">
|
||||
<p class="mt-2">
|
||||
有效动作证据 {{ handDiagnostics.evidenceShotCount }} /
|
||||
{{ handDiagnostics.shotCount }} 镜
|
||||
</p>
|
||||
<p class="text-muted">
|
||||
{{
|
||||
handDiagnostics.assessment === 'no_shots'
|
||||
? '全项目尚无镜头。'
|
||||
: handDiagnostics.assessment === 'insufficient_evidence'
|
||||
? '证据不足,暂无法判断冲突情况。'
|
||||
: handDiagnostics.assessment === 'partial_evidence'
|
||||
? `部分镜头缺少有效证据;现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
|
||||
: `现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
|
||||
}}
|
||||
</p>
|
||||
<article
|
||||
v-for="(issue, index) in handDiagnostics.diagnostics"
|
||||
:key="index"
|
||||
class="diagnosis-result-item"
|
||||
<p class="diagnosis-scope-label">{{ scopeLabel }}</p>
|
||||
</section>
|
||||
<!-- 以下是诊断结果模块,默认隐藏未诊断长列表 -->
|
||||
<section class="diagnosis-section">
|
||||
<div class="diagnosis-section-heading">
|
||||
<h3>诊断结果</h3>
|
||||
<!-- 刷新图标始终占位,加载前后按钮和标题行保持同一尺寸 -->
|
||||
<NButton
|
||||
text
|
||||
size="small"
|
||||
class="diagnosis-refresh-button"
|
||||
:loading="resultsBusy"
|
||||
@click="loadResults"
|
||||
>
|
||||
<p class="text-xs text-muted">
|
||||
第 {{ issue.episodeNo }} 集 / 节拍 {{ issue.beatNo }} / 镜头 {{ issue.shotNo }} /
|
||||
阶段
|
||||
{{ issue.phaseNo }}
|
||||
<template #icon><RefreshCw :size="14" aria-hidden="true" /></template>
|
||||
刷新结果
|
||||
</NButton>
|
||||
</div>
|
||||
<p v-if="resultsError" class="text-danger" role="alert">{{ resultsError }}</p>
|
||||
<template v-else-if="results">
|
||||
<div class="diagnosis-counts">
|
||||
<span>范围内 {{ counts.total }} 镜</span
|
||||
><span :class="{ 'text-danger': counts.conflict }">冲突 {{ counts.conflict }}</span>
|
||||
<span>证据不足 {{ counts.insufficient }}</span
|
||||
><span>证据无效 {{ counts.invalid }}</span
|
||||
><span>已过期 {{ counts.stale }}</span> <span>未诊断 {{ counts.pending }}</span
|
||||
><span>未发现冲突 {{ counts.clear }}</span>
|
||||
</div>
|
||||
<NSelect
|
||||
v-model:value="resultFilter"
|
||||
aria-label="筛选诊断结果"
|
||||
size="small"
|
||||
class="diagnosis-result-filter"
|
||||
:options="[
|
||||
{ label: '需处理:冲突、证据异常与过期', value: 'attention' },
|
||||
{ label: `未诊断(${counts.pending})`, value: 'pending' },
|
||||
{ label: `全部镜头(${counts.total})`, value: 'all' }
|
||||
]"
|
||||
/>
|
||||
<div v-if="!visibleShots.length" class="diagnosis-empty">
|
||||
<p>
|
||||
{{
|
||||
counts.total === 0
|
||||
? '当前范围尚无镜头。'
|
||||
: counts.pending === counts.total
|
||||
? `${counts.pending} 个镜头尚未诊断,暂无法判断冲突情况。`
|
||||
: resultFilter === 'attention'
|
||||
? '当前没有需处理的诊断记录。'
|
||||
: '当前筛选下没有镜头。'
|
||||
}}
|
||||
</p>
|
||||
<p>{{ issue.suggestion }}</p>
|
||||
<div class="diagnosis-scope-controls">
|
||||
<NButton text size="small" @click="locate(issue)">定位镜头</NButton>
|
||||
<NButton
|
||||
v-if="counts.pending && resultFilter !== 'pending'"
|
||||
text
|
||||
size="small"
|
||||
@click="resultFilter = 'pending'"
|
||||
>查看未诊断镜头</NButton
|
||||
>
|
||||
</div>
|
||||
<div
|
||||
v-if="visibleShots.length"
|
||||
class="diagnosis-result-list"
|
||||
tabindex="0"
|
||||
aria-label="镜头诊断列表"
|
||||
>
|
||||
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item">
|
||||
<div class="diagnosis-section-heading">
|
||||
<span class="text-xs text-muted"
|
||||
>第 {{ item.episodeNo }} 集 / 节拍 {{ item.beatNo }} / 镜头
|
||||
{{ item.shotNo }}</span
|
||||
>
|
||||
<NTag
|
||||
:type="
|
||||
item.status === 'conflict_found'
|
||||
? 'error'
|
||||
: item.status === 'no_conflict_found'
|
||||
? 'success'
|
||||
: 'default'
|
||||
"
|
||||
size="small"
|
||||
:bordered="false"
|
||||
>{{ diagnosisStatusLabels[item.status] }}</NTag
|
||||
>
|
||||
</div>
|
||||
<p class="font-medium">{{ item.title }}</p>
|
||||
<p
|
||||
v-for="(description, index) in issueDescriptions(item.issues)"
|
||||
:key="index"
|
||||
class="text-muted"
|
||||
>
|
||||
{{ description }}
|
||||
</p>
|
||||
<NButton text size="small" @click="locate(item)">定位镜头</NButton>
|
||||
</article>
|
||||
</div>
|
||||
</template>
|
||||
<p v-else class="text-muted">{{ resultsBusy ? '正在读取当前范围结果…' : '尚未读取结果' }}</p>
|
||||
</section>
|
||||
<!-- 以下是使用 Naive UI 折叠组件的全项目结构化校验模块,默认收起 -->
|
||||
<section class="diagnosis-section">
|
||||
<NCollapse class="diagnosis-evidence-collapse">
|
||||
<NCollapseItem name="hand-diagnostics">
|
||||
<template #header>
|
||||
<span class="diagnosis-evidence-title">结构化动作校验</span>
|
||||
<span class="ml-2 text-xs text-muted">全项目</span>
|
||||
</template>
|
||||
<!-- 校验刷新放在折叠标题右侧,仅展开时显示,点击不会切换折叠。 -->
|
||||
<template #header-extra="{ collapsed }">
|
||||
<NButton
|
||||
v-if="!collapsed"
|
||||
text
|
||||
size="small"
|
||||
:loading="repairBusy && repairIssue === index"
|
||||
@click="showRepair(index)"
|
||||
>{{ repairIssue === index ? '收起修复建议' : '查看修复建议' }}</NButton
|
||||
class="diagnosis-refresh-button"
|
||||
:loading="handBusy"
|
||||
@click.stop="loadHandDiagnostics"
|
||||
>
|
||||
</div>
|
||||
<div v-if="repairIssue === index && repairPreview" class="diagnosis-repair">
|
||||
<div v-for="(repair, repairIndex) in repairsFor(issue)" :key="repairIndex">
|
||||
<p>{{ repair.suggestion }}</p>
|
||||
<p v-if="repair.blockingReasons.length" class="text-xs text-muted">
|
||||
{{ repair.blockingReasons.join(';') }}
|
||||
<template #icon><RefreshCw :size="14" aria-hidden="true" /></template>
|
||||
刷新校验
|
||||
</NButton>
|
||||
</template>
|
||||
<p class="text-xs text-muted">直接读取已有动作证据,不调用模型</p>
|
||||
<p v-if="handError" class="text-danger" role="alert">{{ handError }}</p>
|
||||
<template v-else-if="handDiagnostics">
|
||||
<p class="mt-2">
|
||||
有效动作证据 {{ handDiagnostics.evidenceShotCount }} /
|
||||
{{ handDiagnostics.shotCount }} 镜
|
||||
</p>
|
||||
<p class="text-muted">
|
||||
{{
|
||||
handDiagnostics.assessment === 'no_shots'
|
||||
? '全项目尚无镜头。'
|
||||
: handDiagnostics.assessment === 'insufficient_evidence'
|
||||
? '证据不足,暂无法判断冲突情况。'
|
||||
: handDiagnostics.assessment === 'partial_evidence'
|
||||
? `部分镜头缺少有效证据;现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
|
||||
: `现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
|
||||
}}
|
||||
</p>
|
||||
<article
|
||||
v-for="(issue, index) in handDiagnostics.diagnostics"
|
||||
:key="index"
|
||||
class="diagnosis-result-item mt-3"
|
||||
>
|
||||
<p class="text-xs text-muted">
|
||||
第 {{ issue.episodeNo }} 集 / 节拍 {{ issue.beatNo }} / 镜头
|
||||
{{ issue.shotNo }} / 阶段
|
||||
{{ issue.phaseNo }}
|
||||
</p>
|
||||
</div>
|
||||
<p v-if="!repairsFor(issue).length" class="text-muted">当前没有可用修复建议。</p>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
<p v-else class="text-muted">{{ handBusy ? '正在读取全项目校验…' : '尚未读取校验' }}</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</section>
|
||||
<!-- 以下是统一的 AI 诊断启动模块,预览和费用确认集中展示 -->
|
||||
<section class="diagnosis-section">
|
||||
<h3>启动 AI 诊断</h3>
|
||||
<p class="text-muted mt-2">{{ scopeLabel }} · 已有当前版本有效结果的镜头将跳过。</p>
|
||||
<!-- 以下是使用 Naive UI 折叠组件的高级设置模块,默认收起 -->
|
||||
<NCollapse class="diagnosis-advanced">
|
||||
<NCollapseItem name="advanced-settings">
|
||||
<template #header><span class="text-xs text-muted">高级设置</span></template>
|
||||
<label class="diagnosis-concurrency"
|
||||
><span>任务并发</span
|
||||
><NInputNumber
|
||||
v-model:value="concurrency"
|
||||
aria-label="诊断任务并发"
|
||||
:min="1"
|
||||
:max="5"
|
||||
:precision="0"
|
||||
size="small"
|
||||
/></label>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<div v-if="previews" class="diagnosis-preview" aria-live="polite">
|
||||
<p>{{ scopeLabel }} · 范围内 {{ previewCount }} 个镜头</p>
|
||||
<p class="text-xs text-muted">
|
||||
缺少结构化动作证据 {{ previews.reduce((sum, item) => sum + item.needsEvidenceCount, 0) }} 镜 ·
|
||||
快照无效 {{ previews.reduce((sum, item) => sum + item.invalidSnapshotCount, 0) }} 镜
|
||||
</p>
|
||||
</div>
|
||||
<p v-if="previewError" class="text-danger" role="alert">{{ previewError }}</p>
|
||||
<p class="text-xs text-muted mt-3">AI 诊断会产生模型费用,仅保存诊断记录,不修改镜头。</p>
|
||||
<div class="diagnosis-start-actions">
|
||||
<NButton
|
||||
:loading="previewBusy"
|
||||
:disabled="previewBusy || starting || execution.active.value"
|
||||
@click="loadPreview"
|
||||
>{{ previews ? '重新预览范围' : '预览诊断范围' }}</NButton
|
||||
>
|
||||
<ConfirmAction
|
||||
label="启动 AI 诊断"
|
||||
:description="confirmation"
|
||||
primary
|
||||
:disabled="!canStart"
|
||||
:loading="starting"
|
||||
@confirm="startDiagnosis"
|
||||
<p>{{ issue.suggestion }}</p>
|
||||
<div class="diagnosis-scope-controls">
|
||||
<NButton text size="small" @click="locate(issue)">定位镜头</NButton>
|
||||
<NButton
|
||||
text
|
||||
size="small"
|
||||
:loading="repairBusy && repairIssue === index"
|
||||
@click="showRepair(index)"
|
||||
>{{ repairIssue === index ? '收起修复建议' : '查看修复建议' }}</NButton
|
||||
>
|
||||
</div>
|
||||
<div v-if="repairIssue === index && repairPreview" class="diagnosis-repair">
|
||||
<div v-for="(repair, repairIndex) in repairsFor(issue)" :key="repairIndex">
|
||||
<p>{{ repair.suggestion }}</p>
|
||||
<p v-if="repair.blockingReasons.length" class="text-xs text-muted">
|
||||
{{ repair.blockingReasons.join(';') }}
|
||||
</p>
|
||||
</div>
|
||||
<p v-if="!repairsFor(issue).length" class="text-muted">
|
||||
当前没有可用修复建议。
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
<p v-else class="text-muted">{{ handBusy ? '正在读取全项目校验…' : '尚未读取校验' }}</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</section>
|
||||
<!-- 以下是诊断配置、预览与费用说明模块,执行操作统一保留在弹窗底栏 -->
|
||||
<section class="diagnosis-section">
|
||||
<h3>启动 AI 诊断</h3>
|
||||
<p class="text-muted mt-2">{{ scopeLabel }} · 已有当前版本有效结果的镜头将跳过。</p>
|
||||
<!-- 以下是使用 Naive UI 折叠组件的高级设置模块,默认收起 -->
|
||||
<NCollapse class="diagnosis-advanced">
|
||||
<NCollapseItem name="advanced-settings">
|
||||
<template #header><span class="text-xs text-muted">高级设置</span></template>
|
||||
<label class="diagnosis-concurrency"
|
||||
><span>任务并发</span
|
||||
><NInputNumber
|
||||
v-model:value="concurrency"
|
||||
aria-label="诊断任务并发"
|
||||
:min="1"
|
||||
:max="5"
|
||||
:precision="0"
|
||||
size="small"
|
||||
/></label>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<div v-if="previews" class="diagnosis-preview" aria-live="polite">
|
||||
<p>{{ scopeLabel }} · 范围内 {{ previewCount }} 个镜头</p>
|
||||
<p class="text-xs text-muted">
|
||||
缺少结构化动作证据
|
||||
{{ previews.reduce((sum, item) => sum + item.needsEvidenceCount, 0) }} 镜 · 快照无效
|
||||
{{ previews.reduce((sum, item) => sum + item.invalidSnapshotCount, 0) }} 镜
|
||||
</p>
|
||||
</div>
|
||||
<p v-if="previewError" class="text-danger" role="alert">{{ previewError }}</p>
|
||||
<p class="text-xs text-muted mt-3">AI 诊断会产生模型费用,仅保存诊断记录,不修改镜头。</p>
|
||||
<p v-if="execution.active.value" class="text-xs text-muted mt-3">
|
||||
诊断任务进行中,可关闭弹窗继续查看分镜。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是持久化诊断任务进度模块,刷新页面后仍可恢复 -->
|
||||
<WorkflowExecutionPanel
|
||||
v-if="execution.executionId.value"
|
||||
title="动作诊断任务"
|
||||
:execution="execution.query.data.value ?? null"
|
||||
:loading="execution.query.loading.value"
|
||||
:error="execution.query.error.value ?? ''"
|
||||
@refresh="execution.query.refresh()"
|
||||
@dismiss="execution.dismiss()"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="execution.active.value" class="text-xs text-muted mt-3">
|
||||
诊断任务进行中,可关闭抽屉继续查看分镜。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是持久化诊断任务进度模块,刷新页面后仍可恢复 -->
|
||||
<WorkflowExecutionPanel
|
||||
v-if="execution.executionId.value"
|
||||
title="动作诊断任务"
|
||||
:execution="execution.query.data.value ?? null"
|
||||
:loading="execution.query.loading.value"
|
||||
:error="execution.query.error.value ?? ''"
|
||||
@refresh="execution.query.refresh()"
|
||||
@dismiss="execution.dismiss()"
|
||||
</div>
|
||||
</NSpin>
|
||||
<!-- 以下是固定底栏操作模块,正文滚动时仍可预览范围并进行费用确认 -->
|
||||
<template #footer>
|
||||
<NButton
|
||||
:loading="previewBusy"
|
||||
:disabled="!dialogDataReady || dialogLoading || starting || execution.active.value"
|
||||
@click="loadPreview"
|
||||
>{{ previews ? '重新预览范围' : '预览诊断范围' }}</NButton
|
||||
>
|
||||
<ConfirmAction
|
||||
label="启动 AI 诊断"
|
||||
:description="confirmation"
|
||||
primary
|
||||
:disabled="!canStart"
|
||||
:loading="starting"
|
||||
@confirm="startDiagnosis"
|
||||
/>
|
||||
</NDrawerContent>
|
||||
</NDrawer>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@@ -685,18 +728,17 @@ defineExpose({ open })
|
||||
.storyboard-diagnosis-summary > .n-button {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* 抽屉分区依靠留白和细线区分,避免再堆叠大面积面板。 */
|
||||
.storyboard-diagnosis-drawer .n-drawer-body-content-wrapper {
|
||||
padding: 20px 24px 32px;
|
||||
/* 加载占位保留最低高度,正文可随内容自然增高,最大高度由公共弹窗按视口限制。 */
|
||||
.diagnosis-dialog-body {
|
||||
min-height: min(600px, calc(100dvh - 160px));
|
||||
}
|
||||
.storyboard-diagnosis-drawer .n-drawer-header {
|
||||
padding: 20px 24px;
|
||||
}
|
||||
.diagnosis-intro {
|
||||
@apply text-sm text-muted leading-6;
|
||||
.diagnosis-dialog-content {
|
||||
@apply space-y-4;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
/* 各分区使用主题次级底色和留白区分,移除贯穿弹窗的分隔线。 */
|
||||
.diagnosis-section {
|
||||
@apply py-5 border-b border-(--app-border) text-sm leading-6;
|
||||
@apply p-4 bg-(--app-subtle) text-sm leading-6;
|
||||
}
|
||||
.diagnosis-section h3,
|
||||
.diagnosis-evidence-title {
|
||||
@@ -705,6 +747,18 @@ defineExpose({ open })
|
||||
.diagnosis-section-heading {
|
||||
@apply flex items-center justify-between gap-3;
|
||||
}
|
||||
/* 折叠标题与结果标题保持相同行高,展开后出现刷新按钮时不额外撑高标题。 */
|
||||
.diagnosis-evidence-collapse .n-collapse-item__header {
|
||||
min-height: 28px;
|
||||
}
|
||||
/* 文字按钮默认随加载图标增高;固定高度并保留图标宽度,避免居中弹窗上下晃动。 */
|
||||
.diagnosis-refresh-button.n-button {
|
||||
height: 28px;
|
||||
min-width: 92px;
|
||||
}
|
||||
.diagnosis-refresh-button .n-button__icon {
|
||||
margin-block: 0;
|
||||
}
|
||||
.diagnosis-scope-controls {
|
||||
@apply flex flex-wrap items-center gap-2 mt-3;
|
||||
}
|
||||
@@ -714,18 +768,18 @@ defineExpose({ open })
|
||||
.diagnosis-counts {
|
||||
@apply flex flex-wrap gap-x-4 gap-y-1 mt-3 mb-4 text-xs text-muted;
|
||||
}
|
||||
/* 长结果列表独立滚动,避免把范围预览和启动操作推到列表末尾。 */
|
||||
.diagnosis-result-list {
|
||||
max-height: min(40dvh, 360px);
|
||||
}
|
||||
.diagnosis-result-filter {
|
||||
@apply mb-3;
|
||||
}
|
||||
.diagnosis-empty {
|
||||
@apply py-4 text-muted;
|
||||
}
|
||||
/* 镜头结果以略浅底色单独成组,不再给每条结果增加边框。 */
|
||||
.diagnosis-result-list {
|
||||
@apply space-y-3;
|
||||
}
|
||||
.diagnosis-result-item {
|
||||
@apply py-4 border-t border-(--app-border) space-y-2;
|
||||
@apply p-3 bg-(--app-control) space-y-2;
|
||||
}
|
||||
.diagnosis-result-item .n-tag {
|
||||
flex-shrink: 0;
|
||||
@@ -739,23 +793,14 @@ defineExpose({ open })
|
||||
.diagnosis-concurrency .n-input-number {
|
||||
@apply w-28;
|
||||
}
|
||||
.diagnosis-preview,
|
||||
.diagnosis-repair {
|
||||
@apply bg-(--app-subtle) p-3 mt-3;
|
||||
/* 预览与修复建议沿用主题灰阶,与所在分区保留清晰层级。 */
|
||||
.diagnosis-preview {
|
||||
@apply bg-(--app-control) p-3 mt-3;
|
||||
}
|
||||
.diagnosis-start-actions {
|
||||
@apply flex flex-wrap justify-end gap-3 mt-4;
|
||||
.diagnosis-repair {
|
||||
@apply bg-(--app-surface) p-3 mt-3;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.n-drawer.storyboard-diagnosis-drawer {
|
||||
width: 100vw !important;
|
||||
}
|
||||
.storyboard-diagnosis-drawer .n-drawer-body-content-wrapper {
|
||||
padding: 16px 16px 28px;
|
||||
}
|
||||
.storyboard-diagnosis-drawer .n-drawer-header {
|
||||
padding: 16px;
|
||||
}
|
||||
.storyboard-diagnosis-summary {
|
||||
@apply items-start;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ defineExpose({ locate })
|
||||
|
||||
<template>
|
||||
<div ref="root" class="breakdown-storyboard">
|
||||
<!-- 以下是分镜剧集选择与工作区入口模块 -->
|
||||
<div v-if="plan || $slots.actions" class="breakdown-storyboard-toolbar">
|
||||
<!-- 以下是当前剧集选择与分镜数量模块 -->
|
||||
<div v-if="plan" class="breakdown-storyboard-toolbar">
|
||||
<label v-if="plan" class="breakdown-episode-picker"
|
||||
><span>选择剧集</span
|
||||
><NSelect
|
||||
@@ -86,10 +86,9 @@ defineExpose({ locate })
|
||||
>{{ plan.beats.length }} 个节拍 ·
|
||||
{{ episode?.beatShots.reduce((sum, beat) => sum + beat.shots.length, 0) ?? 0 }} 个镜头</span
|
||||
>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是当前集诊断摘要插槽,完整结果在右侧抽屉展示 -->
|
||||
<!-- 以下是当前集诊断摘要插槽,完整结果在居中弹窗展示 -->
|
||||
<slot name="diagnosis" />
|
||||
<!-- 以下是当前集节拍与分镜正文模块 -->
|
||||
<template v-if="plan">
|
||||
@@ -189,7 +188,7 @@ defineExpose({ locate })
|
||||
<style>
|
||||
/* 本组件专属布局与 Naive 内部结构覆盖。 */
|
||||
@reference "../../../styles/styles.css";
|
||||
/* 问题定位保留轮廓提示,便于关闭抽屉后识别目标。 */
|
||||
/* 问题定位保留轮廓提示,便于关闭弹窗后识别目标。 */
|
||||
.diagnosis-located {
|
||||
outline: 1px solid var(--app-accent);
|
||||
outline-offset: 3px;
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { breakdownApi } from '../api'
|
||||
import type { Checkpoint } from '../../workflows/types'
|
||||
import type { QualityRepairCandidates, QualityRepairPlan, QualityRepairTarget, ShotActionDraft } from '../repair.types'
|
||||
import { actionDraft, actionDraftIssue, qualityIssueLabel } from '../repair'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import ShotActionEditor from './ShotActionEditor.vue'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
|
||||
/** 未入库镜头的质量门禁修订面板,正式资产仍使用独立接口保护。 */
|
||||
const props = defineProps<{
|
||||
/** 当前项目编号。 */
|
||||
projectId: string
|
||||
/** 当前最新原始检查点。 */
|
||||
checkpoint?: Checkpoint
|
||||
/** 活动任务、读取错误等外部禁用条件。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 保存后读取新检查点,不能直接宣称已正式入库。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 实际修复计划。 */
|
||||
const plan = ref<QualityRepairPlan | null>(null)
|
||||
/** 实际局部修复候选。 */
|
||||
const candidates = ref<QualityRepairCandidates | null>(null)
|
||||
/** 只读查询状态。 */
|
||||
const loading = ref(false)
|
||||
/** 查询或版本错误。 */
|
||||
const error = ref('')
|
||||
/** 当前人工选择的修订目标。 */
|
||||
const target = ref<QualityRepairTarget | null>(null)
|
||||
/** 用户编辑的独立草稿。 */
|
||||
const draft = ref<ShotActionDraft | null>(null)
|
||||
/** 编辑弹窗可见性。 */
|
||||
const open = ref(false)
|
||||
/** 草稿修订号,任何修改均撤销先前确认。 */
|
||||
const draftVersion = ref(0)
|
||||
/** 项目级活动操作锁。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 计划必须与当前原始检查点完全一致。 */
|
||||
const current = computed(() => !!plan.value?.checkpointId && plan.value.checkpointId === props.checkpoint?.checkpointId)
|
||||
/** 当前镜头的有效候选指纹与建议。 */
|
||||
const candidate = computed(() =>
|
||||
target.value && candidates.value && candidates.value.checkpointId === plan.value?.checkpointId
|
||||
? candidates.value.candidates.find(
|
||||
item =>
|
||||
item.shotId ===
|
||||
`episode:${target.value!.episodeNo}/beat:${target.value!.beatNo}/shot:${target.value!.shotNo}`
|
||||
)
|
||||
: undefined
|
||||
)
|
||||
/** 草稿字段校验问题。 */
|
||||
const issue = computed(() => (draft.value ? actionDraftIssue(draft.value) : '请先选择待修订镜头。'))
|
||||
/** 当前编辑目标的可读名称。 */
|
||||
const targetLabel = computed(() =>
|
||||
target.value
|
||||
? `第 ${target.value.episodeNo} 集 · 节拍 ${target.value.beatNo} · 镜头 ${target.value.shotNo}`
|
||||
: '镜头修订'
|
||||
)
|
||||
/** 请求版本控制,关闭或切换项目后不回填旧结果。 */
|
||||
let version = 0
|
||||
/** 当前查询取消控制器。 */
|
||||
let controller: AbortController | undefined
|
||||
|
||||
/** 按需读取真实修复计划与有效候选,不触发模型。 */
|
||||
async function load() {
|
||||
if (loading.value || props.disabled) return
|
||||
const currentVersion = ++version
|
||||
const id = props.projectId
|
||||
controller?.abort()
|
||||
controller = new AbortController()
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
plan.value = null
|
||||
candidates.value = null
|
||||
try {
|
||||
const [nextPlan, nextCandidates] = await Promise.all([
|
||||
breakdownApi.qualityRepairPlan(id, controller.signal),
|
||||
breakdownApi.qualityRepairCandidates(id, controller.signal)
|
||||
])
|
||||
if (version !== currentVersion) return
|
||||
if (nextPlan.projectId !== id || nextCandidates.projectId !== id)
|
||||
throw new Error('修复清单所属项目不一致,请刷新。')
|
||||
plan.value = nextPlan
|
||||
candidates.value = nextCandidates
|
||||
if (nextPlan.repairPlan.length && nextPlan.checkpointId !== props.checkpoint?.checkpointId)
|
||||
throw new Error('拆解结果已更新,请先刷新候选状态,再重新读取修复清单。')
|
||||
} catch (cause) {
|
||||
if (version === currentVersion) error.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === currentVersion) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从对应版本的原始镜头创建完整草稿,不用历史诊断重建动作证据。
|
||||
* @param item 当前修复计划中的镜头坐标
|
||||
*/
|
||||
function edit(item: QualityRepairTarget) {
|
||||
if (!current.value || props.disabled) return
|
||||
const shot = props.checkpoint?.state.storyboardEpisodeShots
|
||||
?.find(episode => episode.episodeNo === item.episodeNo)
|
||||
?.beatShots.find(beat => beat.beatNo === item.beatNo)
|
||||
?.shots.find(value => value.shotNo === item.shotNo)
|
||||
if (!shot) {
|
||||
error.value = '当前版本缺少镜头原始数据,请刷新拆解结果。'
|
||||
return
|
||||
}
|
||||
target.value = { ...item }
|
||||
draft.value = actionDraft(shot)
|
||||
open.value = true
|
||||
}
|
||||
|
||||
/** 人工确认后只写入新的检查点,恢复资格采用服务端结果。 */
|
||||
async function save() {
|
||||
if (
|
||||
!current.value ||
|
||||
props.disabled ||
|
||||
operation.value.pending ||
|
||||
issue.value ||
|
||||
!target.value ||
|
||||
!draft.value ||
|
||||
!plan.value?.checkpointId
|
||||
)
|
||||
return
|
||||
const id = props.projectId
|
||||
const input = {
|
||||
...actionDraft(draft.value),
|
||||
episodeNo: target.value.episodeNo,
|
||||
beatNo: target.value.beatNo,
|
||||
shotNo: target.value.shotNo,
|
||||
expectedCheckpointId: plan.value.checkpointId,
|
||||
...(candidate.value
|
||||
? { expectedFingerprint: candidate.value.expectedFingerprint, source: 'candidate' as const }
|
||||
: { source: 'manual' as const })
|
||||
}
|
||||
const success = await runOperation(
|
||||
id,
|
||||
'正在保存镜头人工修订',
|
||||
async () => {
|
||||
const result = await breakdownApi.repairQualityShot(id, input)
|
||||
if (result.projectId !== id || !result.checkpointId || result.checkpointId === input.expectedCheckpointId)
|
||||
throw new Error('未取得新的修订版本,请刷新确认。')
|
||||
return result
|
||||
},
|
||||
result => ({
|
||||
type: result.canResumeBreakdown ? 'success' : 'warning',
|
||||
content: result.canResumeBreakdown
|
||||
? '人工修订已保存,可继续恢复拆解。正式数据尚未提交。'
|
||||
: '人工修订已保存,仍有待处理质量问题。'
|
||||
})
|
||||
)
|
||||
if (props.projectId !== id) return
|
||||
if (success) {
|
||||
open.value = false
|
||||
plan.value = null
|
||||
candidates.value = null
|
||||
} else {
|
||||
plan.value = null
|
||||
error.value = '保存未成功,请刷新拆解结果并重新读取修复清单。'
|
||||
}
|
||||
emit('refresh')
|
||||
}
|
||||
|
||||
watch(
|
||||
draft,
|
||||
() => {
|
||||
draftVersion.value++
|
||||
},
|
||||
{ deep: true, flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
() => [props.projectId, props.checkpoint?.checkpointId],
|
||||
() => {
|
||||
version++
|
||||
controller?.abort()
|
||||
loading.value = false
|
||||
plan.value = null
|
||||
candidates.value = null
|
||||
target.value = null
|
||||
draft.value = null
|
||||
open.value = false
|
||||
error.value = ''
|
||||
}
|
||||
)
|
||||
onScopeDispose(() => {
|
||||
version++
|
||||
controller?.abort()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是未入库分镜质量门禁的按需修订入口 -->
|
||||
<section class="workspace-panel space-y-4" aria-label="分镜质量修订">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">分镜质量修订</h3>
|
||||
<NButton :loading="loading" :disabled="disabled || loading" @click="load">读取修复清单</NButton>
|
||||
</div>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
用于尚未入库的质量阻断镜头。读取不调用模型;人工修订保存为新快照,通过后再恢复拆解。
|
||||
</p>
|
||||
<p v-if="error" role="alert" class="text-xs leading-6 text-danger">{{ error }}</p>
|
||||
<p v-if="plan && !plan.repairPlan.length && !error" role="status" class="text-xs text-muted">
|
||||
当前没有可人工修订的质量阻断镜头,不代表未诊断镜头已通过。
|
||||
</p>
|
||||
<article
|
||||
v-for="item in plan?.repairPlan"
|
||||
:key="`${item.episodeNo}-${item.beatNo}-${item.shotNo}`"
|
||||
class="flex flex-wrap items-center justify-between gap-3"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm">第 {{ item.episodeNo }} 集 · 节拍 {{ item.beatNo }} · 镜头 {{ item.shotNo }}</p>
|
||||
<p class="mt-2 break-words text-xs text-muted">
|
||||
{{ item.blockingCodes.map(qualityIssueLabel).join('、') }}
|
||||
</p>
|
||||
</div>
|
||||
<NButton :disabled="disabled || !current" @click="edit(item)">人工修订</NButton>
|
||||
</article>
|
||||
</section>
|
||||
<!-- 以下是版本化镜头人工修订模块,沿用公共弹窗底栏与间距 -->
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
:title="targetLabel"
|
||||
description="修订完整动作与阶段证据;保存前后端会重新审核当前镜头。此操作不调用模型。"
|
||||
:busy="operation.pending"
|
||||
wide
|
||||
>
|
||||
<div v-if="draft" class="space-y-5">
|
||||
<p v-if="candidate" class="text-xs leading-6 text-muted">
|
||||
{{ candidate.suggestion }} {{ candidate.blockingReasons.join(';') }}
|
||||
</p>
|
||||
<ShotActionEditor v-model="draft" :disabled="disabled || operation.pending || !current" />
|
||||
<p v-if="issue" role="status" class="text-xs leading-6 text-danger">{{ issue }}</p>
|
||||
<p
|
||||
v-if="operation.error && operation.label === '正在保存镜头人工修订'"
|
||||
role="alert"
|
||||
class="text-xs leading-6 text-danger"
|
||||
>
|
||||
{{ operation.error }}
|
||||
</p>
|
||||
</div>
|
||||
<template #footer
|
||||
><NButton :disabled="operation.pending" @click="open = false">取消</NButton
|
||||
><ConfirmAction
|
||||
:key="draftVersion"
|
||||
label="保存人工修订"
|
||||
description="将保存当前完整动作与阶段证据。若版本变化或质量审核仍不通过,后端会拒绝保存。保存成功后仍需恢复拆解与正式提交。"
|
||||
:disabled="disabled || operation.pending || !current || !!issue"
|
||||
@confirm="save"
|
||||
/></template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
@@ -0,0 +1,100 @@
|
||||
import type { ShotActionDraft } from './repair.types'
|
||||
import { actionResourceOptions } from '../projects/quality-policy'
|
||||
|
||||
/**
|
||||
* 将后端质量代码转为页面可理解的问题描述。
|
||||
* @param code 后端质量原因码
|
||||
* @returns 中文原因,未知问题保留代码便于定位
|
||||
*/
|
||||
export function qualityIssueLabel(code: string): string {
|
||||
const labels: Record<string, string> = {
|
||||
duplicate_action_id: '动作编号重复',
|
||||
invalid_state_execution: '静态状态被要求执行',
|
||||
invalid_duration_phase: '动作阶段无效',
|
||||
missing_action_phase: '动作缺少对应阶段',
|
||||
unknown_phase_action_id: '阶段引用了未知动作',
|
||||
state_used_as_action_phase: '静态状态被用作动作阶段',
|
||||
duration_phase_sum_mismatch: '阶段时长合计不一致',
|
||||
unknown_resource_action_id: '资源引用了未知动作',
|
||||
resource_action_not_in_phase: '资源动作不属于当前阶段',
|
||||
invalid_resource_owner_ref: '资源主体引用无效',
|
||||
action_resource_conflict: '动作资源占用冲突',
|
||||
hand_occupancy_conflict: '手部占用冲突',
|
||||
missing_required_actions: '缺少必需动作',
|
||||
missing_duration_planning: '缺少时长规划',
|
||||
insufficient_action_duration: '动作执行时间不足',
|
||||
unknown_hand_action_id: '手部证据引用了未知动作',
|
||||
hand_action_not_in_phase: '手部动作不属于当前阶段',
|
||||
invalid_hand_character_ref: '手部主体引用无效'
|
||||
}
|
||||
return labels[code] ?? `待复核问题(${code})`
|
||||
}
|
||||
|
||||
/**
|
||||
* 深复制实际动作与全部证据,缺失字段保留待人工填写。
|
||||
* @param shot 原始镜头中的可编辑字段
|
||||
* @returns 独立的完整修订草稿
|
||||
*/
|
||||
export function actionDraft(shot: Partial<ShotActionDraft>): ShotActionDraft {
|
||||
return JSON.parse(
|
||||
JSON.stringify({
|
||||
requiredActions: shot.requiredActions ?? [],
|
||||
durationPlanning: shot.durationPlanning ?? {
|
||||
complexity: 'low',
|
||||
phases: [],
|
||||
transitionSeconds: 0,
|
||||
recommendedDurationSeconds: 0,
|
||||
reason: ''
|
||||
}
|
||||
})
|
||||
) as ShotActionDraft
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验动作编号、阶段时长与证据引用,不替代后端质量审核。
|
||||
* @param draft 当前人工编辑草稿
|
||||
* @returns 首项问题,空字符串表示可以提交审核
|
||||
*/
|
||||
export function actionDraftIssue(draft: ShotActionDraft): string {
|
||||
const ids = draft.requiredActions.map(item => item.id.trim())
|
||||
if (!ids.length || ids.some(item => !item) || new Set(ids).size !== ids.length) return '请填写不重复的动作编号。'
|
||||
if (draft.requiredActions.some(item => !item.description.trim() || !['action', 'state'].includes(item.kind)))
|
||||
return '请补齐动作描述与类型。'
|
||||
const planning = draft.durationPlanning
|
||||
if (!planning.phases.length) return '请至少添加一个动作阶段。'
|
||||
if (!['low', 'medium', 'high'].includes(planning.complexity) || !planning.reason.trim())
|
||||
return '请补齐复杂度与时长依据。'
|
||||
if (
|
||||
!Number.isFinite(planning.transitionSeconds) ||
|
||||
planning.transitionSeconds < 0 ||
|
||||
!Number.isFinite(planning.recommendedDurationSeconds) ||
|
||||
planning.recommendedDurationSeconds <= 0
|
||||
)
|
||||
return '阶段衔接与建议时长需填写有效秒数。'
|
||||
for (const phase of planning.phases) {
|
||||
if (!phase.action.trim()) return '请填写每个阶段的动作描述。'
|
||||
if (!Number.isFinite(phase.estimatedSeconds) || phase.estimatedSeconds <= 0) return '阶段时长必须大于 0 秒。'
|
||||
const references = [
|
||||
...(phase.actionIds ?? []),
|
||||
...(phase.handOccupancy?.map(item => item.actionId) ?? []),
|
||||
...(phase.resourceOccupancy?.map(item => item.actionId) ?? [])
|
||||
]
|
||||
if (references.some(id => !ids.includes(id))) return '阶段证据引用了不存在的动作编号,请重新选择。'
|
||||
if (
|
||||
phase.handOccupancy?.some(
|
||||
item => !item.characterRef.trim() || !['left', 'right', 'both'].includes(item.hands)
|
||||
)
|
||||
)
|
||||
return '手部证据需填写主体引用和使用的手。'
|
||||
if (
|
||||
phase.resourceOccupancy?.some(
|
||||
item =>
|
||||
!item.ownerRef.trim() ||
|
||||
!actionResourceOptions.some(option => option.value === item.resource) ||
|
||||
!['support', 'hold', 'move', 'interact', 'other'].includes(item.usage)
|
||||
)
|
||||
)
|
||||
return '资源证据需填写主体引用、资源和用途。'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import type { ActionResource } from '../projects/types'
|
||||
|
||||
/** 单镜头中必须执行或保持的动作。 */
|
||||
export interface RequiredAction {
|
||||
/** 动作唯一编号。 */
|
||||
id: string
|
||||
/** 具体动作描述。 */
|
||||
description: string
|
||||
/** 动作或静态状态。 */
|
||||
kind: 'action' | 'state'
|
||||
/** 是否必须在本镜头完成。 */
|
||||
mustPerformInShot: boolean
|
||||
}
|
||||
|
||||
/** 同一阶段的手部占用证据。 */
|
||||
export interface HandOccupancy {
|
||||
/** 被引用的动作编号。 */
|
||||
actionId: string
|
||||
/** 主体引用。 */
|
||||
characterRef: string
|
||||
/** 使用的手。 */
|
||||
hands: 'left' | 'right' | 'both'
|
||||
/** 是否允许共享。 */
|
||||
shareable?: boolean
|
||||
}
|
||||
|
||||
/** 通用身体或道具资源占用证据。 */
|
||||
export interface ResourceOccupancy {
|
||||
/** 主体引用。 */
|
||||
ownerRef: string
|
||||
/** 动作资源。 */
|
||||
resource: ActionResource
|
||||
/** 被引用的动作编号。 */
|
||||
actionId: string
|
||||
/** 具体用途。 */
|
||||
usage: 'support' | 'hold' | 'move' | 'interact' | 'other'
|
||||
/** 是否允许共享。 */
|
||||
shareable: boolean
|
||||
}
|
||||
|
||||
/** 镜头完整动作时长规划,保留手部及通用资源证据。 */
|
||||
export interface ShotDurationPlanning {
|
||||
/** 动作复杂度。 */
|
||||
complexity: 'low' | 'medium' | 'high'
|
||||
/** 按先后执行的动作阶段。 */
|
||||
phases: Array<{
|
||||
/** 阶段描述。 */
|
||||
action: string
|
||||
/** 阶段覆盖的动作编号。 */
|
||||
actionIds?: string[]
|
||||
/** 阶段预估秒数。 */
|
||||
estimatedSeconds: number
|
||||
/** 手部占用明细。 */
|
||||
handOccupancy?: HandOccupancy[]
|
||||
/** 身体与道具占用明细。 */
|
||||
resourceOccupancy?: ResourceOccupancy[]
|
||||
}>
|
||||
/** 阶段切换所需秒数。 */
|
||||
transitionSeconds: number
|
||||
/** 建议镜头总时长。 */
|
||||
recommendedDurationSeconds: number
|
||||
/** 时长规划依据。 */
|
||||
reason: string
|
||||
}
|
||||
|
||||
/** 镜头人工修订草稿,仅包含后端允许编辑的动作字段。 */
|
||||
export interface ShotActionDraft {
|
||||
/** 全部必需动作。 */
|
||||
requiredActions: RequiredAction[]
|
||||
/** 完整阶段规划。 */
|
||||
durationPlanning: ShotDurationPlanning
|
||||
}
|
||||
|
||||
/** 只读质量修复目标。 */
|
||||
export interface QualityRepairTarget {
|
||||
/** 剧集编号。 */
|
||||
episodeNo: number
|
||||
/** 节拍编号。 */
|
||||
beatNo: number
|
||||
/** 镜头编号。 */
|
||||
shotNo: number
|
||||
/** 后端质量阻断原因码。 */
|
||||
blockingCodes: string[]
|
||||
}
|
||||
|
||||
/** 当前可恢复版本的修复计划。 */
|
||||
export interface QualityRepairPlan {
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 被审核的检查点版本。 */
|
||||
checkpointId: string | null
|
||||
/** 待修订数量。 */
|
||||
repairCount: number
|
||||
/** 真实阻断镜头清单。 */
|
||||
repairPlan: QualityRepairTarget[]
|
||||
}
|
||||
|
||||
/** 当前有效的局部修复候选。 */
|
||||
export interface QualityRepairCandidates {
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 当前检查点版本。 */
|
||||
checkpointId: string | null
|
||||
/** 已验证指纹的候选清单。 */
|
||||
candidates: Array<{
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 检查点镜头位置标识。 */
|
||||
shotId: string
|
||||
/** 质量分类。 */
|
||||
category: string
|
||||
/** 问题原因码。 */
|
||||
issueCodes: string[]
|
||||
/** 当前目标镜头内容指纹。 */
|
||||
expectedFingerprint: string
|
||||
/** 后端修复建议。 */
|
||||
suggestion: string
|
||||
/** 限制与注意事项。 */
|
||||
blockingReasons: string[]
|
||||
/** 必须人工确认。 */
|
||||
requiresManualConfirmation: true
|
||||
/** 候选建议本身是否需要模型。 */
|
||||
willCallModel: boolean
|
||||
/** 查询不修改资产。 */
|
||||
willModifyAssets: false
|
||||
}>
|
||||
}
|
||||
|
||||
/** 版本约束下的人工修订请求。 */
|
||||
export interface QualityRepairInput extends ShotActionDraft {
|
||||
/** 被编辑的检查点版本。 */
|
||||
expectedCheckpointId: string
|
||||
/** 从候选发起时必须提供镜头指纹。 */
|
||||
expectedFingerprint?: string
|
||||
/** 修订来源。 */
|
||||
source: 'manual' | 'candidate'
|
||||
/** 剧集编号。 */
|
||||
episodeNo: number
|
||||
/** 节拍编号。 */
|
||||
beatNo: number
|
||||
/** 镜头编号。 */
|
||||
shotNo: number
|
||||
}
|
||||
|
||||
/** 人工修订成功后仍需按后端就绪状态恢复拆解。 */
|
||||
export interface QualityRepairResult {
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 新检查点版本。 */
|
||||
checkpointId: string
|
||||
/** 后端判断是否可恢复拆解。 */
|
||||
canResumeBreakdown: boolean
|
||||
/** 检查点是否可恢复。 */
|
||||
checkpointRecoverable: boolean
|
||||
/** 尚未验收的剧集编号。 */
|
||||
pendingEpisodeNos: number[]
|
||||
/** 尚存的质量问题,原样保留。 */
|
||||
remainingQualityIssues: unknown[]
|
||||
}
|
||||
@@ -34,6 +34,8 @@ export interface BreakdownTask {
|
||||
|
||||
/** 传给预览与启动接口的相同配置。 */
|
||||
export interface BreakdownInput {
|
||||
/** 仅生成候选,正式资产由独立确认入口提交。 */
|
||||
candidateOnly?: boolean
|
||||
groupSize: number
|
||||
modules: BreakdownModule[]
|
||||
}
|
||||
@@ -100,6 +102,10 @@ export interface EpisodePlan {
|
||||
|
||||
/** 最小连续镜头及其主体形态绑定。 */
|
||||
export interface StoryboardShot {
|
||||
/** 完整必需动作,缺失时不自动补造历史证据。 */
|
||||
requiredActions?: import('./repair.types').RequiredAction[]
|
||||
/** 阶段时长与资源占用证据。 */
|
||||
durationPlanning?: import('./repair.types').ShotDurationPlanning
|
||||
shotNo: number
|
||||
title: string
|
||||
description: string
|
||||
@@ -143,8 +149,23 @@ export interface WorkflowExecution {
|
||||
|
||||
/** latest 和 checkpoint 的恢复状态;失败 checkpoint 可能只有 execution。 */
|
||||
export interface BreakdownState extends BreakdownResult {
|
||||
/** 后端候选模式标记,缺省时不推断为候选。 */
|
||||
candidateOnly?: boolean
|
||||
/** 最新快照是否已经写入正式主体与分镜。 */
|
||||
storyboardPersisted?: boolean
|
||||
/** 候选是否已经通过安全提交入口保存。 */
|
||||
candidateCommitted?: boolean
|
||||
/** 候选生成时固定的剧本正文版本。 */
|
||||
expectedEpisodeFingerprints?: Record<number, string>
|
||||
/** 尚未完成质量审核的剧集。 */
|
||||
storyboardPendingQualityEpisodeNos?: number[]
|
||||
workflowExecution?: WorkflowExecution
|
||||
runConfig?: BreakdownInput & { episodeGroups: EpisodeGroup[] }
|
||||
runConfig?: BreakdownInput & {
|
||||
/** 抽取任务使用的剧集分组。 */
|
||||
episodeGroups: EpisodeGroup[]
|
||||
/** 候选固定的源剧集编号,仅用于完整性提示。 */
|
||||
sourceEpisodes?: { episodeNo: number }[]
|
||||
}
|
||||
taskSummary?: TaskSummary
|
||||
tasks?: BreakdownTask[]
|
||||
breakdownResult?: BreakdownResult
|
||||
@@ -153,6 +174,24 @@ export interface BreakdownState extends BreakdownResult {
|
||||
/** 不同失败阶段的恢复端点,不能用 retry 替代所有恢复。 */
|
||||
export type BreakdownAction = 'start' | 'retry' | 'resume-shots' | 'resume-storyboard'
|
||||
|
||||
/** 安全提交候选的正式资产统计。 */
|
||||
export interface BreakdownCandidateCommit {
|
||||
/** 所属项目编号。 */
|
||||
projectId: string
|
||||
/** 正式主体数量。 */
|
||||
subjectCount: number
|
||||
/** 正式形态数量。 */
|
||||
subjectFormCount: number
|
||||
/** 正式剧集数量。 */
|
||||
episodeCount: number
|
||||
/** 正式节拍数量。 */
|
||||
beatCount: number
|
||||
/** 正式镜头数量。 */
|
||||
shotCount: number
|
||||
/** 镜头主体绑定数量。 */
|
||||
shotSubjectCount: number
|
||||
}
|
||||
|
||||
/** 已持久化分镜的手部动作诊断;无证据不代表无冲突。 */
|
||||
export interface StoryboardHandOccupancyDiagnostics {
|
||||
projectId: string
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { computed, ref } from 'vue'
|
||||
import { NButton, NTabs, NTabPane } from 'naive-ui'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import type { CreativeProfileInput } from '../types'
|
||||
import CreativeProfileSettings from './CreativeProfileSettings.vue'
|
||||
import QualityPolicySettings from './QualityPolicySettings.vue'
|
||||
|
||||
/** 项目全局配置弹窗参数。 */
|
||||
const props = defineProps<{
|
||||
@@ -20,28 +21,48 @@ const open = defineModel<boolean>('open', { default: false })
|
||||
const saving = ref(false)
|
||||
/** 配置表单实例,footer 调用表单自身的校验与保存入口。 */
|
||||
const form = ref<InstanceType<typeof CreativeProfileSettings> | null>(null)
|
||||
/** 项目级配置分类保持同一个弹窗与底栏。 */
|
||||
const tab = ref('generation')
|
||||
/** 质量策略表单实例。 */
|
||||
const qualityForm = ref<InstanceType<typeof QualityPolicySettings> | null>(null)
|
||||
/** 当前标签的独立保存入口,避免跨接口混合保存。 */
|
||||
const activeForm = computed(() => (tab.value === 'quality' ? qualityForm.value : form.value))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是项目图片与视频全局配置弹窗模块 -->
|
||||
<AppDialog v-model:open="open" title="项目全局配置" :busy="saving" wide>
|
||||
<template #description>设置项目画布、图片和视频生成模型,后续生成默认使用这里保存的配置。</template>
|
||||
<CreativeProfileSettings
|
||||
v-if="open"
|
||||
ref="form"
|
||||
:key="props.projectId"
|
||||
:project-id="props.projectId"
|
||||
:disabled="props.disabled"
|
||||
hide-actions
|
||||
@busy="saving = $event"
|
||||
@saved="emit('saved', $event)"
|
||||
/>
|
||||
<template #description>设置生成模型、画布与质量规则,后续制作使用已保存的项目配置。</template>
|
||||
<!-- 以下是生成配置与质量规则分类导航,保存期间禁止切换 -->
|
||||
<NTabs v-if="open" v-model:value="tab" type="line" size="small">
|
||||
<NTabPane name="generation" tab="生成配置" :disabled="saving" display-directive="show:lazy">
|
||||
<CreativeProfileSettings
|
||||
v-if="open"
|
||||
ref="form"
|
||||
:key="props.projectId"
|
||||
:project-id="props.projectId"
|
||||
:disabled="props.disabled"
|
||||
hide-actions
|
||||
@busy="saving = $event"
|
||||
@saved="emit('saved', $event)"
|
||||
/>
|
||||
</NTabPane>
|
||||
<NTabPane name="quality" tab="质量规则" :disabled="saving" display-directive="show:lazy">
|
||||
<QualityPolicySettings
|
||||
ref="qualityForm"
|
||||
:key="props.projectId"
|
||||
:project-id="props.projectId"
|
||||
:disabled="props.disabled"
|
||||
@busy="saving = $event"
|
||||
/>
|
||||
</NTabPane>
|
||||
</NTabs>
|
||||
<!-- 以下是固定底栏取消与保存配置模块 -->
|
||||
<template #footer>
|
||||
<NButton :disabled="saving" @click="open = false">取消</NButton>
|
||||
<NButton type="primary" :loading="saving" :disabled="!form?.canSave" @click="form?.save()"
|
||||
>保存配置</NButton
|
||||
>
|
||||
<NButton type="primary" :loading="saving" :disabled="!activeForm?.canSave" @click="activeForm?.save()">{{
|
||||
tab === 'quality' ? '保存质量规则' : '保存配置'
|
||||
}}</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
@@ -0,0 +1,234 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NFormItem, NInput, NSelect } from 'naive-ui'
|
||||
import { projectsApi } from '../../projects/api'
|
||||
import { actionResourceOptions, policyDraft, policyIssue } from '../../projects/quality-policy'
|
||||
import type { ProjectQualityPolicy } from '../../projects/types'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
|
||||
/** 项目质量策略独立编辑表单。 */
|
||||
const props = defineProps<{
|
||||
/** 当前正式项目编号。 */
|
||||
projectId: string
|
||||
/** 项目有活动操作时禁止保存。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 保存状态交给弹窗锁定关闭与标签切换。 */
|
||||
const emit = defineEmits<{ busy: [value: boolean]; saved: [] }>()
|
||||
/** 读取期间不以本地默认值覆盖服务端。 */
|
||||
const loading = ref(false)
|
||||
/** 保存状态。 */
|
||||
const saving = ref(false)
|
||||
/** 实际读取或保存错误。 */
|
||||
const error = ref('')
|
||||
/** 真实保存成功提示。 */
|
||||
const notice = ref('')
|
||||
/** 服务端策略的独立草稿。 */
|
||||
const policy = ref<ProjectQualityPolicy | null>(null)
|
||||
/** 模式选择不自动修改允许范围。 */
|
||||
const physicsOptions = [
|
||||
{ value: 'realistic', label: '写实物理' },
|
||||
{ value: 'stylized', label: '风格化表现' },
|
||||
{ value: 'fantasy', label: '幻想表现' }
|
||||
]
|
||||
/** 草稿校验错误。 */
|
||||
const issue = computed(() => (policy.value ? policyIssue(policy.value) : ''))
|
||||
/** 只有已读取真实策略且没有活动操作才允许提交。 */
|
||||
const canSave = computed(() => !!policy.value && !issue.value && !props.disabled && !loading.value && !saving.value)
|
||||
/** 规则文本仅做逐行编辑,空行不作为规则提交。 */
|
||||
const rulesText = ref('')
|
||||
/** 保留输入中的换行,仅在策略草稿中去除空白规则。 */
|
||||
watch(rulesText, value => {
|
||||
if (policy.value)
|
||||
policy.value.customRules = value
|
||||
.split('\n')
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
})
|
||||
/** 读取与保存使用递增版本隔离项目切换和组件卸载。 */
|
||||
let version = 0
|
||||
/** 当前读取的取消控制器。 */
|
||||
let controller: AbortController | undefined
|
||||
|
||||
/** 从真实接口读取完整策略,失败后提供重试。 */
|
||||
async function load() {
|
||||
const current = ++version
|
||||
const id = props.projectId
|
||||
controller?.abort()
|
||||
controller = new AbortController()
|
||||
policy.value = null
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
notice.value = ''
|
||||
try {
|
||||
const result = await projectsApi.qualityPolicy(id, controller.signal)
|
||||
if (current !== version) return
|
||||
if (result.projectId !== id) throw new Error('质量策略所属项目不一致,请重新读取。')
|
||||
policy.value = policyDraft(result.policy)
|
||||
rulesText.value = policy.value.customRules.join('\n')
|
||||
} catch (cause) {
|
||||
if (current === version) error.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (current === version) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 新增一项精确例外,必须填写主体和依据后才可保存。 */
|
||||
function addException() {
|
||||
if (!policy.value || props.disabled || saving.value) return
|
||||
const items = (policy.value.actionExceptions ??= [])
|
||||
if (items.length < 30)
|
||||
items.push({ code: 'action_resource_conflict', ownerRef: '', resource: 'left_hand', reason: '' })
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除当前草稿中的精确例外,保存前不改变后端。
|
||||
* @param index 例外在草稿中的位置
|
||||
*/
|
||||
function removeException(index: number) {
|
||||
policy.value?.actionExceptions?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 保存完整策略,保留项目和请求归属检查。 */
|
||||
async function save() {
|
||||
if (!canSave.value || !policy.value) return
|
||||
const id = props.projectId
|
||||
const current = version
|
||||
const input = policyDraft(policy.value)
|
||||
saving.value = true
|
||||
error.value = ''
|
||||
notice.value = ''
|
||||
try {
|
||||
const result = await projectsApi.saveQualityPolicy(id, input)
|
||||
if (current !== version) return
|
||||
if (result.projectId !== id) throw new Error('质量策略保存回执所属项目不一致。')
|
||||
policy.value = policyDraft(result.policy)
|
||||
rulesText.value = policy.value.customRules.join('\n')
|
||||
notice.value = '质量策略已保存,后续创作、拆解和生成使用此策略。'
|
||||
emit('saved')
|
||||
} catch (cause) {
|
||||
if (current === version) error.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (current === version) saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.projectId, load, { immediate: true })
|
||||
watch(saving, value => emit('busy', value), { flush: 'sync' })
|
||||
onScopeDispose(() => {
|
||||
version++
|
||||
controller?.abort()
|
||||
})
|
||||
/** 弹窗底栏复用同一个保存入口。 */
|
||||
defineExpose({ save, canSave })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是质量策略读取反馈模块 -->
|
||||
<div class="quality-policy-settings">
|
||||
<p v-if="loading" role="status" class="text-sm text-muted">正在读取项目质量策略……</p>
|
||||
<div v-if="error" role="alert" class="flex flex-wrap items-center gap-3 text-sm text-danger">
|
||||
<span>{{ error }}</span
|
||||
><NButton v-if="!policy" text @click="load">重新读取</NButton>
|
||||
</div>
|
||||
<template v-if="policy">
|
||||
<!-- 以下是物理表现与明确动作许可模块 -->
|
||||
<section class="space-y-4" aria-label="动作与物理规则">
|
||||
<div>
|
||||
<h3 class="text-sm font-medium">动作与物理规则</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
选择表现方式后,仍需明确勾选允许的动作范围。保存不会重新生成已有资产。
|
||||
</p>
|
||||
</div>
|
||||
<NFormItem label="物理表现方式" :label-props="{ id: 'quality-physics-mode-label' }">
|
||||
<NSelect
|
||||
v-model:value="policy.physicsMode"
|
||||
aria-labelledby="quality-physics-mode-label"
|
||||
:options="physicsOptions"
|
||||
:disabled="disabled || saving"
|
||||
/>
|
||||
</NFormItem>
|
||||
<div class="grid gap-4 sm:grid-cols-3">
|
||||
<NCheckbox v-model:checked="policy.allowExaggeratedMotion" :disabled="disabled || saving"
|
||||
>允许夸张动作</NCheckbox
|
||||
>
|
||||
<NCheckbox v-model:checked="policy.allowNonPhysicalActions" :disabled="disabled || saving"
|
||||
>允许非物理动作</NCheckbox
|
||||
>
|
||||
<NCheckbox v-model:checked="policy.allowSupernaturalAbilities" :disabled="disabled || saving"
|
||||
>允许超自然能力</NCheckbox
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 以下是逐行声明的自定义规则模块 -->
|
||||
<NFormItem label="自定义规则" :label-props="{ for: 'quality-custom-rules' }">
|
||||
<NInput
|
||||
v-model:value="rulesText"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 8 }"
|
||||
:input-props="{ id: 'quality-custom-rules' }"
|
||||
placeholder="每行一条,最多 30 条;请写明具体允许的例外"
|
||||
:disabled="disabled || saving"
|
||||
/>
|
||||
</NFormItem>
|
||||
<!-- 以下是主体和具体动作资源的精确例外模块 -->
|
||||
<section class="space-y-4" aria-label="精确动作例外">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">精确动作例外</h3>
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="disabled || saving || (policy.actionExceptions?.length ?? 0) >= 30"
|
||||
@click="addException"
|
||||
>添加例外</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="text-xs leading-6 text-muted">仅对填写的主体与资源放宽动作资源冲突,需记录明确依据。</p>
|
||||
<div v-for="(item, index) in policy.actionExceptions" :key="index" class="quality-exception-row">
|
||||
<NFormItem label="主体引用"
|
||||
><NInput
|
||||
v-model:value="item.ownerRef"
|
||||
:aria-label="`例外 ${index + 1} 主体引用`"
|
||||
placeholder="填写镜头中的主体引用"
|
||||
:disabled="disabled || saving"
|
||||
/></NFormItem>
|
||||
<NFormItem label="动作资源"
|
||||
><NSelect
|
||||
v-model:value="item.resource"
|
||||
:aria-label="`例外 ${index + 1} 动作资源`"
|
||||
:options="actionResourceOptions"
|
||||
:disabled="disabled || saving"
|
||||
/></NFormItem>
|
||||
<NFormItem label="确认依据"
|
||||
><NInput
|
||||
v-model:value="item.reason"
|
||||
:aria-label="`例外 ${index + 1} 确认依据`"
|
||||
:disabled="disabled || saving"
|
||||
/></NFormItem>
|
||||
<NButton :disabled="disabled || saving" @click="removeException(index)">移除</NButton>
|
||||
</div>
|
||||
</section>
|
||||
<p v-if="issue" role="status" class="text-xs leading-6 text-danger">{{ issue }}</p>
|
||||
</template>
|
||||
<p v-if="notice" role="status" class="text-xs leading-6 text-muted">{{ notice }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.quality-policy-settings {
|
||||
display: grid;
|
||||
gap: 24px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
.quality-exception-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(120px, 1fr) minmax(100px, 0.7fr) minmax(160px, 1.5fr) auto;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.quality-exception-row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -10,7 +10,7 @@ import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import { NScrollbar, NButton, NCheckbox, NInputNumber, NProgress, NSelect, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { computed, inject, ref, watch } from 'vue'
|
||||
import { ArrowLeft, CheckCircle2, CircleAlert, Film, Image, MessageSquareText } from '@lucide/vue'
|
||||
import { CheckCircle2, CircleAlert, Film, Image, MessageSquareText } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge } from '../../components/ui'
|
||||
import BeatShotDirectory from '../storyboard/components/BeatShotDirectory.vue'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
@@ -312,9 +312,6 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
|
||||
从可生成的提示词和首帧,到异步视频任务与最终成片。
|
||||
</p>
|
||||
</div>
|
||||
<RouterLink :to="`/projects/${id}/storyboard`" class="text-button">
|
||||
<ArrowLeft :size="14" />回到分镜设计
|
||||
</RouterLink>
|
||||
</div>
|
||||
<section class="production-batch-config workspace-panel" aria-label="项目生产配置">
|
||||
<div class="production-section-heading">
|
||||
@@ -369,17 +366,11 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
|
||||
当前有
|
||||
{{ identityBlocked }}
|
||||
项角色身份尚未准备完成。请先确认角色母版并完成身份锁定,再生成镜头首帧。
|
||||
<RouterLink :to="`/projects/${id}/subject-identity`" class="text-button ml-2"
|
||||
>前往主体身份 →</RouterLink
|
||||
></ContextNotice
|
||||
>
|
||||
</ContextNotice>
|
||||
<ContextNotice v-if="invalidGenerationSpecs" type="warning" :show-icon="false">
|
||||
当前有
|
||||
{{ invalidGenerationSpecs }}
|
||||
个镜头的设计信息还不完整。请先补齐镜头设计和即时视觉状态。
|
||||
<RouterLink :to="`/projects/${id}/storyboard`" class="text-button ml-2">
|
||||
前往分镜设计 →
|
||||
</RouterLink>
|
||||
</ContextNotice>
|
||||
<ContextNotice v-if="staleKeyframes" role="status" type="info" :show-icon="false">
|
||||
当前有
|
||||
@@ -893,9 +884,7 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
|
||||
v-else-if="query.data.value"
|
||||
title="本集还没有正式镜头"
|
||||
description="先完成剧本拆解和分镜设计,再进入镜头生产。"
|
||||
>
|
||||
<RouterLink :to="`/projects/${id}/storyboard`" class="button button-secondary">前往分镜设计</RouterLink>
|
||||
</EmptyState>
|
||||
/>
|
||||
<p v-else-if="query.loading.value" class="panel mt-5 p-8 text-sm text-muted" role="status">
|
||||
正在检查全项目生产就绪状态……
|
||||
</p>
|
||||
|
||||
@@ -10,7 +10,34 @@ import { ApiError, errorMessage } from '../../lib/http'
|
||||
import { generationConfigApi } from '../generation-config/api'
|
||||
import { productionApi } from './api'
|
||||
import { getProductionSession } from './model'
|
||||
import type { ProductionStartInput, ProductionStage } from './types'
|
||||
import type { ProductionPlan, ProductionStartInput, ProductionStage } from './types'
|
||||
|
||||
/**
|
||||
* 指定续跑阶段会跳过上游生成,必须使用已有有效资产而非可生成数量。
|
||||
* @param plan 后端当前真实生产计划
|
||||
* @param scope 用户选择的本轮执行范围
|
||||
* @returns 与后端续跑门禁一致的阻断原因
|
||||
*/
|
||||
export function productionResumeIssues(
|
||||
plan: Pick<ProductionPlan, 'characterIdentity' | 'subjectImages' | 'keyframes'>,
|
||||
scope: ProductionStartInput
|
||||
): string[] {
|
||||
if (!scope.startFrom) return []
|
||||
const issues: string[] = []
|
||||
const identity = plan.characterIdentity
|
||||
if (!identity || identity.ready !== identity.total) issues.push('指定阶段续跑前,需要全部角色身份确认并锁定。')
|
||||
if (
|
||||
(scope.startFrom === 'keyframes' || scope.startFrom === 'videoPrompts') &&
|
||||
(!plan.subjectImages.total || plan.subjectImages.skipped !== plan.subjectImages.total)
|
||||
)
|
||||
issues.push('指定阶段续跑前,需要全部主体参考图有效且未过期。')
|
||||
if (
|
||||
scope.startFrom === 'videoPrompts' &&
|
||||
(!plan.keyframes.total || plan.keyframes.skipped !== plan.keyframes.total)
|
||||
)
|
||||
issues.push('从视频提示词续跑前,需要全部有效首帧就绪。')
|
||||
return issues
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用后端计划区分可自动补齐和人工阻塞,保留项目归属及活动任务检查。
|
||||
@@ -45,6 +72,7 @@ export async function checkPipeline(projectId: string, scope: ProductionStartInp
|
||||
const issues: string[] = []
|
||||
if (plan.entryReadiness && !plan.entryReadiness.ready)
|
||||
issues.push(plan.entryReadiness.reason || '项目尚未满足生产入口条件。')
|
||||
issues.push(...productionResumeIssues(plan, scope))
|
||||
if (!profile) issues.push('尚未配置项目画布与生成模型,请先在右上角“项目配置”中保存配置。')
|
||||
const shotIds = new Set(plan.details.keyframes.map(item => item.shotId))
|
||||
if (
|
||||
|
||||
@@ -8,11 +8,32 @@ import type {
|
||||
ProjectDetail,
|
||||
ProjectStageReadiness,
|
||||
ProjectDurationBudgetSummary,
|
||||
ProjectQualityPolicy,
|
||||
ProjectQualityPolicyResult,
|
||||
UpdateProjectInput
|
||||
} from './types'
|
||||
|
||||
/** 项目与 Create Drama API;路径严格对应后端 dev。 */
|
||||
export const projectsApi = {
|
||||
/**
|
||||
* 读取服务端解析后的完整质量策略。
|
||||
* @param id 当前项目编号
|
||||
* @param signal 请求取消信号
|
||||
* @returns 项目质量策略
|
||||
*/
|
||||
qualityPolicy: (id: string, signal?: AbortSignal) =>
|
||||
request<ProjectQualityPolicyResult>(`/projects/${encodeURIComponent(id)}/quality-policy`, { signal }),
|
||||
/**
|
||||
* 显式替换完整质量策略,不触发模型生成。
|
||||
* @param id 当前项目编号
|
||||
* @param policy 用户明确确认的完整策略
|
||||
* @returns 服务端实际保存的策略
|
||||
*/
|
||||
saveQualityPolicy: (id: string, policy: ProjectQualityPolicy) =>
|
||||
request<ProjectQualityPolicyResult>(`/projects/${encodeURIComponent(id)}/quality-policy`, {
|
||||
method: 'PUT',
|
||||
body: policy
|
||||
}),
|
||||
list: (signal?: AbortSignal) => request<Project[]>('/projects', { signal }),
|
||||
detail: (id: string, signal?: AbortSignal) =>
|
||||
request<ProjectDetail>(`/projects/${encodeURIComponent(id)}`, { signal }),
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { ProjectQualityPolicy } from './types'
|
||||
|
||||
/** 动作资源选项在项目例外与镜头修订中共用。 */
|
||||
export const actionResourceOptions = [
|
||||
{ value: 'left_hand', label: '左手' },
|
||||
{ value: 'right_hand', label: '右手' },
|
||||
{ value: 'left_foot', label: '左脚' },
|
||||
{ value: 'right_foot', label: '右脚' },
|
||||
{ value: 'body', label: '身体' },
|
||||
{ value: 'support', label: '支撑点' },
|
||||
{ value: 'prop', label: '道具' }
|
||||
]
|
||||
|
||||
/**
|
||||
* 创建独立策略草稿,完整保留服务端的精确例外。
|
||||
* @param policy 服务端已保存的策略
|
||||
* @returns 可编辑且不污染原值的副本
|
||||
*/
|
||||
export function policyDraft(policy: ProjectQualityPolicy): ProjectQualityPolicy {
|
||||
return {
|
||||
...policy,
|
||||
customRules: [...policy.customRules],
|
||||
...(policy.actionExceptions ? { actionExceptions: policy.actionExceptions.map(item => ({ ...item })) } : {})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查策略完整性与后端数组上限,不从剧本风格自动推断例外。
|
||||
* @param policy 当前完整策略
|
||||
* @returns 首项可展示的问题,空字符串表示校验通过
|
||||
*/
|
||||
export function policyIssue(policy: ProjectQualityPolicy): string {
|
||||
if (policy.version !== 1 || !['realistic', 'stylized', 'fantasy'].includes(policy.physicsMode))
|
||||
return '请选择有效的物理表现方式。'
|
||||
if (
|
||||
[policy.allowExaggeratedMotion, policy.allowNonPhysicalActions, policy.allowSupernaturalAbilities].some(
|
||||
item => typeof item !== 'boolean'
|
||||
)
|
||||
)
|
||||
return '请明确选择动作允许范围。'
|
||||
if (policy.customRules.length > 30 || (policy.actionExceptions?.length ?? 0) > 30)
|
||||
return '自定义规则和精确例外各最多 30 项。'
|
||||
if (policy.customRules.some(item => !item.trim())) return '自定义规则不能为空。'
|
||||
if (
|
||||
policy.actionExceptions?.some(
|
||||
item =>
|
||||
item.code !== 'action_resource_conflict' ||
|
||||
!item.ownerRef.trim() ||
|
||||
!item.reason.trim() ||
|
||||
!actionResourceOptions.some(option => option.value === item.resource)
|
||||
)
|
||||
)
|
||||
return '精确例外需填写主体引用、资源与确认依据。'
|
||||
return ''
|
||||
}
|
||||
@@ -149,3 +149,41 @@ export interface ProjectDurationBudgetSummary {
|
||||
willCallModel: false
|
||||
willModifyAssets: false
|
||||
}
|
||||
|
||||
/** 通用动作资源,与后端精确质量例外枚举一致。 */
|
||||
export type ActionResource = 'left_hand' | 'right_hand' | 'left_foot' | 'right_foot' | 'body' | 'support' | 'prop'
|
||||
|
||||
/** 项目级完整质量策略,只有用户明确保存才放宽物理约束。 */
|
||||
export interface ProjectQualityPolicy {
|
||||
/** 策略版本。 */
|
||||
version: 1
|
||||
/** 物理表现方式。 */
|
||||
physicsMode: 'realistic' | 'stylized' | 'fantasy'
|
||||
/** 是否允许夸张动作。 */
|
||||
allowExaggeratedMotion: boolean
|
||||
/** 是否允许非物理动作。 */
|
||||
allowNonPhysicalActions: boolean
|
||||
/** 是否允许超自然能力。 */
|
||||
allowSupernaturalAbilities: boolean
|
||||
/** 明确声明的例外规则,最多三十项。 */
|
||||
customRules: string[]
|
||||
/** 针对主体及具体资源的精确例外。 */
|
||||
actionExceptions?: Array<{
|
||||
/** 后端允许的质量问题代码。 */
|
||||
code: 'action_resource_conflict'
|
||||
/** 主体引用。 */
|
||||
ownerRef: string
|
||||
/** 允许例外的资源。 */
|
||||
resource: ActionResource
|
||||
/** 用户明确确认的依据。 */
|
||||
reason: string
|
||||
}>
|
||||
}
|
||||
|
||||
/** 质量策略读写回执。 */
|
||||
export interface ProjectQualityPolicyResult {
|
||||
/** 所属项目编号。 */
|
||||
projectId: string
|
||||
/** 服务端实际保存或解析的策略。 */
|
||||
policy: ProjectQualityPolicy
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import ActionMenu from '../../components/ui/ActionMenu.vue'
|
||||
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
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'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
@@ -320,9 +319,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<h2 class="text-lg font-semibold">分镜设计</h2>
|
||||
<p class="mt-2 text-sm text-muted">从镜头拆解到摄影设计,再补齐每一镜的即时状态。</p>
|
||||
</div>
|
||||
<RouterLink :to="`/projects/${id}/breakdown`" class="text-button"
|
||||
><ArrowLeft :size="14" />回到拆解</RouterLink
|
||||
>
|
||||
</div>
|
||||
<section class="mt-3" aria-label="分镜生成配置">
|
||||
<AppForm :model="formModel" :rules="rules" :disabled="operation.pending" validate-on-change>
|
||||
@@ -484,9 +480,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<h3 class="text-sm font-semibold">视频提示词批量操作</h3>
|
||||
<p class="my-3 text-xs leading-6 text-muted">
|
||||
生成前会检查镜头设计和主体参考图是否齐全。这里只生成提示词;首帧、视频任务、状态检查与失败重试已整理到
|
||||
<RouterLink :to="`/projects/${id}/production`" class="text-button mx-1"
|
||||
>镜头生产</RouterLink
|
||||
>。
|
||||
镜头生产。
|
||||
</p>
|
||||
<ConfirmAction
|
||||
:loading="
|
||||
@@ -667,11 +661,8 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
v-else-if="data"
|
||||
title="本集还没有正式分镜"
|
||||
description="先完成剧本拆解,再回来完善镜头设计和画面状态。"
|
||||
><RouterLink :to="`/projects/${id}/breakdown`" class="button button-secondary mt-4"
|
||||
>前往拆解</RouterLink
|
||||
></EmptyState
|
||||
></WorkspacePage
|
||||
>
|
||||
></EmptyState
|
||||
></WorkspacePage>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -181,9 +181,6 @@ function exportResult(kind: 'spec' | 'prompt') {
|
||||
</p>
|
||||
<p v-if="references.missing.length" class="mt-3 text-xs text-muted">
|
||||
请在形态图库补齐图片或设置主图,再刷新本镜头参考图。
|
||||
<RouterLink :to="`/projects/${projectId}/subject-images`" class="text-button ml-2"
|
||||
>前往形态图片</RouterLink
|
||||
>
|
||||
</p>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
@@ -413,13 +413,6 @@ function runNextAction() {
|
||||
<!-- 以下是项目已读取但正式主体目录尚未返回时的完整骨架屏模块 -->
|
||||
<SubjectIdentitySkeleton v-if="initialLoading" />
|
||||
<WorkspacePage v-else split compact mobile-scroll class="identity-workspace-page">
|
||||
<template #notice>
|
||||
<div v-if="subjectImagesAccess.enabled" class="flex justify-end text-xs">
|
||||
<RouterLink :to="`/projects/${projectId}/subject-images`" class="text-button"
|
||||
>继续形态图片 →</RouterLink
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<template #header>
|
||||
<!-- 以下是类型筛选、主体数量与操作入口 -->
|
||||
<div class="workspace-toolbar">
|
||||
@@ -461,11 +454,7 @@ function runNextAction() {
|
||||
默认以中国人物作为选角基线;项目和角色的明确事实始终优先。场景和道具使用稳定身份母版流程。
|
||||
</ContextNotice>
|
||||
<ContextNotice v-if="styleQuery.data.value && !hasStyle" type="info" :show-icon="false">
|
||||
先创建项目视觉风格,才能 AI 生成身份或身份图片。<RouterLink
|
||||
:to="`/projects/${projectId}/visual-style`"
|
||||
class="text-button ml-2"
|
||||
>设置视觉风格 →</RouterLink
|
||||
></ContextNotice
|
||||
先创建项目视觉风格,才能 AI 生成身份或身份图片。</ContextNotice
|
||||
>
|
||||
<section v-if="casting" class="workspace-panel" aria-label="角色选角流程">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
@@ -969,11 +958,7 @@ function runNextAction() {
|
||||
<EmptyState
|
||||
v-else-if="catalog.data.value"
|
||||
title="还没有可展示的正式主体"
|
||||
description="先完成剧本拆解与主体形态持久化,再来管理稳定身份。"
|
||||
><RouterLink :to="`/projects/${projectId}/breakdown`" class="button button-secondary"
|
||||
>前往剧本拆解</RouterLink
|
||||
></EmptyState
|
||||
>
|
||||
description="先完成剧本拆解与主体形态持久化,再来管理稳定身份。" />
|
||||
<StableAnchorQualityDialog
|
||||
v-if="
|
||||
subject &&
|
||||
|
||||
@@ -13,17 +13,7 @@ import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import { NButton, NCheckbox, NInput, NInputNumber, NPopover, NScrollbar, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch, type Directive } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
Search,
|
||||
Download,
|
||||
ImagePlus,
|
||||
ArrowLeft,
|
||||
ArrowRight,
|
||||
LayoutGrid,
|
||||
Columns3,
|
||||
LoaderCircle,
|
||||
Settings2
|
||||
} from '@lucide/vue'
|
||||
import { Search, Download, ImagePlus, ArrowLeft, LayoutGrid, Columns3, LoaderCircle, Settings2 } from '@lucide/vue'
|
||||
import { AssetImage, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
@@ -35,7 +25,6 @@ import ImageGalleryDialog from './components/ImageGalleryDialog.vue'
|
||||
import FormPromptDialog from './components/FormPromptDialog.vue'
|
||||
import FormPromptBatch from './components/FormPromptBatch.vue'
|
||||
import { useKeyframeImpact } from './useKeyframeImpact'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { queryText, referenceLocation, referenceTargets } from '../production/asset-links'
|
||||
import { masonryColumnCount, masonryRowSpan, type GalleryLayout } from './layout'
|
||||
|
||||
@@ -65,7 +54,6 @@ const {
|
||||
generate,
|
||||
generateProject
|
||||
} = useSubjectImages()
|
||||
const project = useProjectContext()
|
||||
const sourceShotId = computed(() => queryText(route.query.sourceShotId))
|
||||
const targetFormId = computed(() => queryText(route.query.subjectFormId))
|
||||
const targetForm = computed(() => forms.value.find(form => form.id === targetFormId.value))
|
||||
@@ -233,7 +221,6 @@ const promptForm = computed(() => forms.value.find(form => form.id === promptId.
|
||||
const generateForm = computed(() => forms.value.find(form => form.id === generateId.value) ?? null)
|
||||
const galleryForm = computed(() => forms.value.find(form => form.id === galleryId.value) ?? null)
|
||||
const completeCount = computed(() => forms.value.filter(form => primaryImage(form.images)).length)
|
||||
const stageComplete = computed(() => project.stageReadiness.value?.subjectAssets.ready === true)
|
||||
const filtered = computed(() =>
|
||||
forms.value.filter(
|
||||
form =>
|
||||
@@ -309,11 +296,6 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
|
||||
<template>
|
||||
<WorkspacePage compact mobile-scroll class="gallery-workspace-page">
|
||||
<template #notice>
|
||||
<div v-if="stageComplete" class="flex justify-end text-xs">
|
||||
<RouterLink :to="`/projects/${id}/storyboard`" class="text-button">继续分镜设计 →</RouterLink>
|
||||
</div>
|
||||
</template>
|
||||
<template #default>
|
||||
<!-- 批量设置使用弹窗,入口跟随图库筛选区。 -->
|
||||
<WorkspaceTools
|
||||
@@ -331,16 +313,10 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
为人物、场景和道具准备造型参考图。已有图片直接从数据库读取。
|
||||
</p>
|
||||
</div>
|
||||
<RouterLink :to="`/projects/${id}/storyboard`" class="text-button"
|
||||
>去检查分镜参考图<ArrowRight :size="14"
|
||||
/></RouterLink>
|
||||
</div>
|
||||
<DetailDisclosure title="母版继承与过期处理" class="mt-4">
|
||||
人物、场景、道具的基础形态默认复用已确认并锁定的身份母版,无需再次生图。其他形态仍需单独生成。自动复用的主图随母版更新;你手选或独立生成的主图保留,母版变化后需要核对。
|
||||
<RouterLink :to="`/projects/${id}/subject-identity`" class="text-button ml-2"
|
||||
>管理主体身份 →</RouterLink
|
||||
></DetailDisclosure
|
||||
>
|
||||
</DetailDisclosure>
|
||||
<FormPromptBatch
|
||||
:generating="isOperationRunning(operation, '批量生成形态正式提示词')"
|
||||
:forms="forms"
|
||||
@@ -853,10 +829,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
: '先完成剧本拆解和主体形态持久化,再来生成参考图。'
|
||||
"
|
||||
>
|
||||
<NButton v-if="forms.length" @click="resetFilters">清除筛选</NButton>
|
||||
<RouterLink v-else :to="`/projects/${id}/breakdown`" class="button button-secondary"
|
||||
>前往剧本拆解</RouterLink
|
||||
> </EmptyState
|
||||
<NButton v-if="forms.length" @click="resetFilters">清除筛选</NButton> </EmptyState
|
||||
><FormPromptDialog
|
||||
v-model:open="promptOpen"
|
||||
:form="promptForm"
|
||||
|
||||
@@ -44,8 +44,6 @@ const addingImage = computed(() => operation.value.pending && operation.value.la
|
||||
const imageAddError = computed(() => (operation.value.label === '添加风格参考图' ? operation.value.error : ''))
|
||||
/** 未保存的风格修改用于阻止 AI 覆盖。 */
|
||||
const dirty = ref(false)
|
||||
/** 后端确认视觉风格准备好后提供下一步入口。 */
|
||||
const nextReady = computed(() => projectContext.stageReadiness.value?.visualStyle.ready === true)
|
||||
|
||||
/** 状态是只读说明,与操作按钮分组;读取失败不能被误报成尚未创建。 */
|
||||
const statusInfo = computed(() => {
|
||||
@@ -153,13 +151,6 @@ function removeImage(image: VisualStyleImage) {
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #notice>
|
||||
<div v-if="nextReady && style" class="flex justify-end text-xs">
|
||||
<RouterLink :to="`/projects/${projectId}/subject-identity`" class="text-button"
|
||||
>继续主体身份 →</RouterLink
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<div class="workspace-section-stack">
|
||||
<ContextNotice v-if="query.error.value" role="alert" type="error" :show-icon="false"
|
||||
>{{ query.error.value }} 当前内容读取失败;已有内容不会被覆盖。
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { NSelect, NSpin } from 'naive-ui'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import BreakdownPage from '@/features/breakdown/BreakdownPage.vue'
|
||||
import { projectContextKey, type useProjectData } from '@/features/projects/context'
|
||||
@@ -206,12 +206,12 @@ function handDiagnosticsResponse(evidenceShotCount: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从真实挂载的抽屉读取内容,不把诊断抽屉误当成拆解设置弹窗。
|
||||
* @returns 当前动作诊断抽屉
|
||||
* 从真实挂载的动作诊断弹窗读取内容,避免误取拆解设置弹窗。
|
||||
* @returns 当前动作诊断弹窗
|
||||
*/
|
||||
function qualityDrawer() {
|
||||
const panel = document.querySelector<HTMLElement>('.storyboard-diagnosis-drawer')
|
||||
if (!panel) throw new Error('动作诊断抽屉未打开')
|
||||
function qualityDialog() {
|
||||
const panel = document.querySelector<HTMLElement>('.app-dialog[aria-label="动作诊断"]')
|
||||
if (!panel) throw new Error('动作诊断弹窗未打开')
|
||||
return new DOMWrapper(panel)
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\);/)
|
||||
})
|
||||
|
||||
it('分镜选择与计数、入口同排,默认显示实际剧集,切换后内容和统计同步', async () => {
|
||||
it('分镜选择与计数同排且没有阶段快捷入口,切换后内容和统计同步', async () => {
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>().mockImplementation(async () => diagnosisResultsResponse())
|
||||
@@ -410,9 +410,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(select.props('value')).toBe(1)
|
||||
expect(toolbar.text()).toContain('长剧集')
|
||||
expect(toolbar.get('.breakdown-storyboard-summary').text()).toContain('25 个节拍 · 25 个镜头')
|
||||
expect(toolbar.get('.breakdown-storyboard-summary router-link-stub').attributes('to')).toBe(
|
||||
'/projects/breakdown-scroll-test/storyboard'
|
||||
)
|
||||
expect(toolbar.find('router-link-stub').exists()).toBe(false)
|
||||
expect(wrapper!.find('.breakdown-storyboard > .surface-inset').exists()).toBe(false)
|
||||
select.vm.$emit('update:value', 2)
|
||||
await flushPromises()
|
||||
@@ -427,7 +425,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(wrapper!.findAll('.beat-section')).toHaveLength(25)
|
||||
})
|
||||
|
||||
it('分镜为空时保留空提示与进入设计入口,不显示空选择器', async () => {
|
||||
it('分镜为空时仅保留空提示,不显示空选择器或阶段快捷入口', async () => {
|
||||
const record = checkpoint()
|
||||
record.state.breakdownResult!.storyboardPlans = []
|
||||
record.state.breakdownResult!.storyboardEpisodeShots = []
|
||||
@@ -435,9 +433,8 @@ describe('拆解页内容滚动', () => {
|
||||
await selectTab('分镜')
|
||||
expect(wrapper!.get('.breakdown-storyboard').text()).toContain('分镜规划尚未生成')
|
||||
expect(wrapper!.find('.breakdown-episode-picker').exists()).toBe(false)
|
||||
expect(wrapper!.get('.breakdown-storyboard-summary router-link-stub').attributes('to')).toBe(
|
||||
'/projects/breakdown-scroll-test/storyboard'
|
||||
)
|
||||
expect(wrapper!.find('.breakdown-storyboard-toolbar').exists()).toBe(false)
|
||||
expect(wrapper!.find('.breakdown-storyboard router-link-stub').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('分镜顶部无叠加操作行,选择标签保持单行且统计操作垂直居中', () => {
|
||||
@@ -516,7 +513,7 @@ describe('拆解页内容滚动', () => {
|
||||
expect(drawerPanel().text()).toContain('重试失败抽取')
|
||||
})
|
||||
|
||||
it('诊断摘要与抽屉按需读取,展开结构化校验后展示证据不足', async () => {
|
||||
it('诊断摘要与弹窗按需读取,展开结构化校验后展示证据不足', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
const url = String(input)
|
||||
if (url.includes('storyboard-legacy-action-diagnosis-results')) return diagnosisResultsResponse()
|
||||
@@ -531,17 +528,124 @@ describe('拆解页内容滚动', () => {
|
||||
expect(String(fetcher.mock.calls[0]?.[0])).toContain('diagnosis-results?episodeNo=1')
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDrawer()
|
||||
const panel = qualityDialog()
|
||||
expect(panel.findAll('button').some(button => button.text() === '刷新校验')).toBe(false)
|
||||
expect(panel.get('.storyboard-diagnosis-dialog').attributes('aria-busy')).toBe('false')
|
||||
const footer = panel.get('.n-card__footer')
|
||||
expect(footer.text()).toContain('预览诊断范围')
|
||||
expect(footer.text()).toContain('启动 AI 诊断')
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(panel.text()).toContain('有效动作证据 0 / 25 镜')
|
||||
expect(panel.text()).toContain('证据不足,暂无法判断冲突情况')
|
||||
expect(panel.get('.n-collapse-item__header-extra button').text()).toBe('刷新校验')
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(panel.findAll('button').some(button => button.text() === '刷新校验')).toBe(false)
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([input]) => String(input).endsWith('storyboard-hand-occupancy-diagnostics'))
|
||||
).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('关闭抽屉后的迟到校验响应不会污染再次打开的状态', async () => {
|
||||
it('刷新已加载的诊断结果只显示按钮加载,保留正文节点、折叠展开和滚动位置', async () => {
|
||||
let resultRequests = 0
|
||||
let resolveRefresh: ((value: Response) => void) | undefined
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
const url = String(input)
|
||||
if (url.includes('storyboard-legacy-action-diagnosis-results')) {
|
||||
resultRequests++
|
||||
if (resultRequests > 2)
|
||||
return new Promise<Response>(resolve => {
|
||||
resolveRefresh = resolve
|
||||
})
|
||||
return diagnosisResultsResponse()
|
||||
}
|
||||
if (url.endsWith('storyboard-hand-occupancy-diagnostics')) return handDiagnosticsResponse(0)
|
||||
throw new Error(`未预期的诊断请求:${url}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
mountPage()
|
||||
await selectTab('分镜')
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDialog()
|
||||
await panel.findAll('.n-collapse-item__header-main')[1]!.trigger('click')
|
||||
await flushPromises()
|
||||
const content = panel.get('.diagnosis-dialog-content').element
|
||||
const scroll = panel.get<HTMLElement>('.dialog-body-scroll .n-scrollbar-container').element
|
||||
scroll.scrollTop = 80
|
||||
const refreshButton = panel.findAll('button').find(button => button.text() === '刷新结果')!
|
||||
const refreshIcon = refreshButton.get('.n-button__icon').element
|
||||
await refreshButton.trigger('click')
|
||||
await flushPromises()
|
||||
try {
|
||||
const spin = wrapper!
|
||||
.findAllComponents(NSpin)
|
||||
.find(item => item.classes().includes('storyboard-diagnosis-dialog'))!
|
||||
expect(spin.props('show')).toBe(false)
|
||||
expect(refreshButton.classes()).toContain('n-button--loading')
|
||||
expect(refreshButton.get('.n-button__icon').element).toBe(refreshIcon)
|
||||
expect(panel.get('.diagnosis-dialog-content').element).toBe(content)
|
||||
expect(panel.find('.diagnosis-concurrency').isVisible()).toBe(true)
|
||||
expect(scroll.scrollTop).toBe(80)
|
||||
expect(panel.text()).toContain('当前范围尚无镜头')
|
||||
} finally {
|
||||
resolveRefresh!(diagnosisResultsResponse())
|
||||
await flushPromises()
|
||||
}
|
||||
expect(refreshButton.classes()).not.toContain('n-button--loading')
|
||||
expect(panel.get('.diagnosis-dialog-content').element).toBe(content)
|
||||
})
|
||||
|
||||
it('刷新已加载的结构化校验保留证据正文和图标占位,不触发整窗遮罩', async () => {
|
||||
let handRequests = 0
|
||||
let resolveRefresh: ((value: Response) => void) | undefined
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
const url = String(input)
|
||||
if (url.includes('storyboard-legacy-action-diagnosis-results')) return diagnosisResultsResponse()
|
||||
if (url.endsWith('storyboard-hand-occupancy-diagnostics')) {
|
||||
handRequests++
|
||||
if (handRequests > 1)
|
||||
return new Promise<Response>(resolve => {
|
||||
resolveRefresh = resolve
|
||||
})
|
||||
return handDiagnosticsResponse(0)
|
||||
}
|
||||
throw new Error(`未预期的诊断请求:${url}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
mountPage()
|
||||
await selectTab('分镜')
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDialog()
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
const evidence = panel.findAll('p').find(item => item.text().includes('有效动作证据'))!.element
|
||||
const refreshButton = panel.findAll('button').find(button => button.text() === '刷新校验')!
|
||||
const refreshIcon = refreshButton.find('.n-button__icon')
|
||||
await refreshButton.trigger('click')
|
||||
await flushPromises()
|
||||
try {
|
||||
expect(panel.text()).toContain('有效动作证据 0 / 25 镜')
|
||||
expect(panel.findAll('p').find(item => item.text().includes('有效动作证据'))!.element).toBe(evidence)
|
||||
const spin = wrapper!
|
||||
.findAllComponents(NSpin)
|
||||
.find(item => item.classes().includes('storyboard-diagnosis-dialog'))!
|
||||
expect(spin.props('show')).toBe(false)
|
||||
expect(refreshButton.classes()).toContain('n-button--loading')
|
||||
expect(refreshIcon.exists()).toBe(true)
|
||||
expect(refreshButton.get('.n-button__icon').element).toBe(refreshIcon.element)
|
||||
} finally {
|
||||
resolveRefresh!(handDiagnosticsResponse(0))
|
||||
await flushPromises()
|
||||
}
|
||||
expect(refreshButton.classes()).not.toContain('n-button--loading')
|
||||
expect(panel.findAll('p').find(item => item.text().includes('有效动作证据'))!.element).toBe(evidence)
|
||||
expect(panel.get('.n-collapse-item__header-extra button').element).toBe(refreshButton.element)
|
||||
})
|
||||
|
||||
it('打开诊断弹窗时展示加载态,关闭后的迟到校验响应不污染新状态', async () => {
|
||||
let resolveFirst: ((value: Response) => void) | undefined
|
||||
let handRequests = 0
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async input => {
|
||||
@@ -563,13 +667,22 @@ describe('拆解页内容滚动', () => {
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(handRequests).toBe(1)
|
||||
await qualityDrawer().get('.n-drawer-header__close').trigger('click')
|
||||
expect(qualityDialog().get('.storyboard-diagnosis-dialog').attributes('aria-busy')).toBe('true')
|
||||
expect(qualityDialog().text()).not.toContain('诊断结果')
|
||||
expect(
|
||||
qualityDialog()
|
||||
.get('.n-card__footer')
|
||||
.findAll('button')
|
||||
.every(button => (button.element as HTMLButtonElement).disabled)
|
||||
).toBe(true)
|
||||
await qualityDialog().get('.n-card-header__close').trigger('click')
|
||||
await flushPromises()
|
||||
resolveFirst!(handDiagnosticsResponse(25))
|
||||
await flushPromises()
|
||||
await wrapper!.get('.storyboard-diagnosis-summary button').trigger('click')
|
||||
await flushPromises()
|
||||
const panel = qualityDrawer()
|
||||
const panel = qualityDialog()
|
||||
expect(panel.get('.storyboard-diagnosis-dialog').attributes('aria-busy')).toBe('false')
|
||||
await panel.get('.n-collapse-item__header-main').trigger('click')
|
||||
await flushPromises()
|
||||
expect(panel.text()).not.toContain('有效动作证据 25 / 25')
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import BreakdownCandidatePanel from '@/features/breakdown/components/BreakdownCandidatePanel.vue'
|
||||
import ConfirmAction from '@/features/workflows/ConfirmAction.vue'
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import { breakdownApi } from '@/features/breakdown/api'
|
||||
|
||||
/** 候选完整性只使用最新原始状态。 */
|
||||
const state = {
|
||||
candidateOnly: true,
|
||||
storyboardShotValidation: { valid: true, issues: [] },
|
||||
expectedEpisodeFingerprints: { 1: 'fingerprint' },
|
||||
runConfig: { groupSize: 3, modules: [] as [], episodeGroups: [], sourceEpisodes: [{ episodeNo: 1 }] },
|
||||
subjectCandidates: [
|
||||
{
|
||||
profileId: 'p',
|
||||
name: '人物',
|
||||
ref: '@人物',
|
||||
module: 'character' as const,
|
||||
description: '',
|
||||
appearance_prompt: ''
|
||||
}
|
||||
],
|
||||
subjectForms: [],
|
||||
storyboardEpisodeShots: [
|
||||
{
|
||||
episodeNo: 1,
|
||||
episodePlan: { episodeNo: 1 } as never,
|
||||
beatShots: [
|
||||
{
|
||||
beatNo: 1,
|
||||
shots: [
|
||||
{ shotNo: 1, title: '', description: '', visualFocus: '', subjectRefs: [], durationSeconds: 2 }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
vi.restoreAllMocks()
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
describe('候选版本与提交保护', () => {
|
||||
it('当前版本仍有效时仅提交一次并刷新正式结果', async () => {
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([
|
||||
{ checkpointId: 'ready', createdAt: '', workflowName: 'breakdown', state }
|
||||
])
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate').mockResolvedValue({
|
||||
projectId: 'candidate-ready-test',
|
||||
subjectCount: 1,
|
||||
subjectFormCount: 0,
|
||||
episodeCount: 1,
|
||||
beatCount: 1,
|
||||
shotCount: 1,
|
||||
shotSubjectCount: 0
|
||||
})
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
props: { projectId: 'candidate-ready-test', checkpointId: 'ready', state, disabled: false }
|
||||
})
|
||||
wrapper.getComponent(ConfirmAction).vm.$emit('confirm')
|
||||
wrapper.getComponent(ConfirmAction).vm.$emit('confirm')
|
||||
await flushPromises()
|
||||
expect(commit).toHaveBeenCalledExactlyOnceWith('candidate-ready-test')
|
||||
expect(wrapper.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
it('确认之后发现服务端版本已变化时禁止提交正式替换', async () => {
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([
|
||||
{ checkpointId: 'new', createdAt: '', workflowName: 'breakdown', state }
|
||||
])
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
props: { projectId: 'candidate-version-test', checkpointId: 'old', state, disabled: false }
|
||||
})
|
||||
wrapper.getComponent(ConfirmAction).vm.$emit('confirm')
|
||||
await flushPromises()
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
expect(wrapper.text()).toContain('候选版本已变化')
|
||||
expect(wrapper.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
it('新快照无明确候选标记时不恢复旧候选提交入口', async () => {
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
props: { projectId: 'candidate-marker-test', checkpointId: 'old', state, disabled: false }
|
||||
})
|
||||
expect(wrapper.text()).toContain('提交候选为正式结果')
|
||||
await wrapper.setProps({ checkpointId: 'new', state: {} })
|
||||
expect(wrapper.findComponent(ConfirmAction).exists()).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it, vi, afterEach } from 'vitest'
|
||||
import { candidateCommitIssue } from '@/features/breakdown/candidate'
|
||||
import { breakdownApi } from '@/features/breakdown/api'
|
||||
import type { BreakdownState } from '@/features/breakdown/types'
|
||||
|
||||
/** 构造已完成审核但尚未入库的候选快照。 */
|
||||
function readyCandidate(): BreakdownState {
|
||||
return {
|
||||
candidateOnly: true,
|
||||
storyboardPersisted: false,
|
||||
expectedEpisodeFingerprints: { 1: 'fingerprint' },
|
||||
runConfig: { groupSize: 3, modules: ['character'], episodeGroups: [], sourceEpisodes: [{ episodeNo: 1 }] },
|
||||
subjectCandidates: [
|
||||
{
|
||||
profileId: 'person',
|
||||
name: '人物',
|
||||
ref: '@人物',
|
||||
description: '',
|
||||
module: 'character',
|
||||
appearance_prompt: ''
|
||||
}
|
||||
],
|
||||
subjectForms: [],
|
||||
storyboardEpisodeShots: [
|
||||
{
|
||||
episodeNo: 1,
|
||||
episodePlan: { episodeNo: 1 } as never,
|
||||
beatShots: [
|
||||
{
|
||||
beatNo: 1,
|
||||
shots: [
|
||||
{
|
||||
shotNo: 1,
|
||||
title: '镜头',
|
||||
description: '',
|
||||
visualFocus: '',
|
||||
subjectRefs: [],
|
||||
durationSeconds: 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
storyboardShotValidation: { valid: true, issues: [] },
|
||||
storyboardPendingQualityEpisodeNos: []
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('候选提交资格', () => {
|
||||
it('只允许完整、未提交、审核通过的候选快照进入确认', () => {
|
||||
expect(candidateCommitIssue(readyCandidate())).toBe('')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), candidateOnly: false })).toContain('候选')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardPersisted: true })).toContain('提交')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardPendingQualityEpisodeNos: [1] })).toContain('审核')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardShotValidation: undefined })).toContain('校验')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), expectedEpisodeFingerprints: undefined })).toContain('版本')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), storyboardEpisodeShots: [] })).toContain('完整')
|
||||
})
|
||||
|
||||
it('启动明确发送候选模式,提交不发送客户端资产', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: { projectId: 'p/id' } })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await breakdownApi.run('p/id', 'start', { groupSize: 3, modules: ['character'], candidateOnly: true })
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string).candidateOnly).toBe(true)
|
||||
await breakdownApi.commitCandidate('p/id')
|
||||
expect(fetcher.mock.calls[1]![0]).toContain('/projects/p%2Fid/breakdown/commit-candidate')
|
||||
expect(JSON.parse(fetcher.mock.calls[1]![1]!.body as string)).toEqual({ confirmed: true })
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { actionDraft, actionDraftIssue } from '@/features/breakdown/repair'
|
||||
import type { ShotActionDraft } from '@/features/breakdown/repair.types'
|
||||
|
||||
/** 含手部和身体资源证据的真实字段夹具。 */
|
||||
const saved: ShotActionDraft = {
|
||||
requiredActions: [{ id: 'a', description: '扶住栏杆', kind: 'action', mustPerformInShot: true }],
|
||||
durationPlanning: {
|
||||
complexity: 'low',
|
||||
phases: [
|
||||
{
|
||||
action: '站稳',
|
||||
actionIds: ['a'],
|
||||
estimatedSeconds: 2,
|
||||
handOccupancy: [{ actionId: 'a', characterRef: '@人物', hands: 'left' }],
|
||||
resourceOccupancy: [
|
||||
{ actionId: 'a', ownerRef: '@人物', resource: 'left_hand', usage: 'hold', shareable: false }
|
||||
]
|
||||
}
|
||||
],
|
||||
transitionSeconds: 0,
|
||||
recommendedDurationSeconds: 2,
|
||||
reason: '保持稳定'
|
||||
}
|
||||
}
|
||||
describe('镜头动作修订草稿', () => {
|
||||
it('完整保留证据且编辑草稿不污染源镜头', () => {
|
||||
const draft = actionDraft(saved)
|
||||
draft.durationPlanning.phases[0]!.resourceOccupancy![0]!.usage = 'support'
|
||||
expect(saved.durationPlanning.phases[0]!.resourceOccupancy![0]!.usage).toBe('hold')
|
||||
expect(draft.durationPlanning.phases[0]!.handOccupancy).toEqual(saved.durationPlanning.phases[0]!.handOccupancy)
|
||||
expect(actionDraftIssue(draft)).toBe('')
|
||||
})
|
||||
it('拒绝失效的动作引用、重复编号和无效阶段时长', () => {
|
||||
const draft = actionDraft(saved)
|
||||
draft.requiredActions[0]!.id = 'changed'
|
||||
expect(actionDraftIssue(draft)).toContain('引用')
|
||||
draft.requiredActions.push({ ...draft.requiredActions[0]! })
|
||||
expect(actionDraftIssue(draft)).toContain('编号')
|
||||
draft.requiredActions = [{ ...saved.requiredActions[0]! }]
|
||||
draft.durationPlanning.phases[0]!.estimatedSeconds = 0
|
||||
expect(actionDraftIssue(draft)).toContain('时长')
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { productionApi } from '@/features/production/api'
|
||||
import { validateProductionScope } from '@/features/production/useAdvancedProduction'
|
||||
import { productionResumeIssues, validateProductionScope } from '@/features/production/useAdvancedProduction'
|
||||
import type { ProductionStartInput } from '@/features/production/types'
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
@@ -59,4 +59,23 @@ describe('生产后端真实请求契约', () => {
|
||||
validateProductionScope({ startFrom: 'subjectImages', stopAfter: 'subjectImages', videoPromptLimit: 1 })
|
||||
).toBe('')
|
||||
})
|
||||
|
||||
it('指定续跑阶段时要求已有有效资产,不能把可生成误判为已完成', () => {
|
||||
const stage = { total: 1, planned: 1, skipped: 0, upstreamResolvable: 0, manualBlocked: 0 }
|
||||
const plan = { subjectImages: stage, keyframes: stage }
|
||||
expect(productionResumeIssues(plan, {})).toEqual([])
|
||||
expect(productionResumeIssues(plan, { startFrom: 'subjectImages' }).join()).toContain('角色身份')
|
||||
expect(productionResumeIssues(plan, { startFrom: 'keyframes' }).join()).toContain('主体参考图')
|
||||
expect(productionResumeIssues(plan, { startFrom: 'videoPrompts' }).join()).toContain('有效首帧')
|
||||
expect(
|
||||
productionResumeIssues(
|
||||
{
|
||||
characterIdentity: { total: 1, ready: 1, pending: 0, autoResolvable: 0, manualBlocked: 0 },
|
||||
subjectImages: { ...stage, skipped: 1, planned: 0 },
|
||||
keyframes: { ...stage, skipped: 1, planned: 0 }
|
||||
},
|
||||
{ startFrom: 'videoPrompts' }
|
||||
)
|
||||
).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,45 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { policyDraft, policyIssue } from '@/features/projects/quality-policy'
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import type { ProjectQualityPolicy } from '@/features/projects/types'
|
||||
|
||||
/** 保留已有精确例外的服务端完整策略。 */
|
||||
const saved: ProjectQualityPolicy = {
|
||||
version: 1,
|
||||
physicsMode: 'realistic',
|
||||
allowExaggeratedMotion: false,
|
||||
allowNonPhysicalActions: false,
|
||||
allowSupernaturalAbilities: false,
|
||||
customRules: ['规则'],
|
||||
actionExceptions: [
|
||||
{ code: 'action_resource_conflict', ownerRef: '@人物', resource: 'left_hand', reason: '明确依据' }
|
||||
]
|
||||
}
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
describe('项目质量策略', () => {
|
||||
it('草稿编辑不污染已保存策略,完整保留精确例外', () => {
|
||||
const draft = policyDraft(saved)
|
||||
draft.actionExceptions![0]!.reason = '新依据'
|
||||
draft.customRules.push('新规则')
|
||||
expect(saved.actionExceptions![0]!.reason).toBe('明确依据')
|
||||
expect(saved.customRules).toEqual(['规则'])
|
||||
expect(policyIssue(draft)).toBe('')
|
||||
})
|
||||
it('拒绝超过上限或缺少精确例外依据的规则', () => {
|
||||
expect(policyIssue({ ...saved, customRules: [''] })).toContain('规则')
|
||||
expect(policyIssue({ ...saved, customRules: Array(31).fill('规则') })).toContain('30')
|
||||
expect(policyIssue({ ...saved, actionExceptions: [{ ...saved.actionExceptions![0]!, reason: '' }] })).toContain(
|
||||
'依据'
|
||||
)
|
||||
})
|
||||
it('完整提交正式质量策略接口,保留用户明确的权限选择', async () => {
|
||||
const fetcher = vi
|
||||
.fn<typeof fetch>()
|
||||
.mockImplementation(async () => new Response(JSON.stringify({ data: { projectId: 'p', policy: saved } })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await projectsApi.saveQualityPolicy('p', saved)
|
||||
expect(fetcher.mock.calls[0]![0]).toContain('/projects/p/quality-policy')
|
||||
expect(fetcher.mock.calls[0]![1]!.method).toBe('PUT')
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]!.body as string)).toEqual(saved)
|
||||
})
|
||||
})
|
||||
@@ -2094,18 +2094,22 @@ describe('工作台页面交互', () => {
|
||||
await expandSections()
|
||||
button('预览分组').click()
|
||||
await flushPromises()
|
||||
expect(button('开始拆解').disabled).toBe(false)
|
||||
expect(button('生成拆解候选').disabled).toBe(false)
|
||||
await drawerPanel().get('#group-size').setValue('2')
|
||||
expect(document.body.textContent).not.toContain('开始拆解')
|
||||
expect(document.body.textContent).not.toContain('生成拆解候选')
|
||||
button('预览分组').click()
|
||||
await flushPromises()
|
||||
button('开始拆解').click()
|
||||
button('生成拆解候选').click()
|
||||
await flushPromises()
|
||||
button('确认开始拆解').click()
|
||||
button('确认生成拆解候选').click()
|
||||
await flushPromises()
|
||||
const post = fetcher.mock.calls.find(call => call[1]?.method === 'POST')
|
||||
expect(post?.[0]).toBe('/api/projects/page-test-project/breakdown/start')
|
||||
expect(JSON.parse(post![1]!.body as string)).toEqual({ groupSize: 2, modules: ['character', 'scene', 'prop'] })
|
||||
expect(JSON.parse(post![1]!.body as string)).toEqual({
|
||||
groupSize: 2,
|
||||
modules: ['character', 'scene', 'prop'],
|
||||
candidateOnly: true
|
||||
})
|
||||
expect(provided.refresh).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user