feat(short-drama-agent-front): 接入首帧授权与连续性审核
This commit is contained in:
1 parent
dbf97e6f98
commit
518b630a46
35 files changed
+3070
-97
No files matched your search
@@ -0,0 +1,37 @@
|
||||
# 首帧审核与固定几何连续性接入
|
||||
|
||||
日期:2026-11-07。前端起点 `dbf97e6f`,只读核对后端 `6721a4df`,本轮不修改后端。
|
||||
|
||||
## 已接入
|
||||
|
||||
- 单执行 GET 与 SSE 共用可选 `projectId`。项目与执行共同构成查询身份,切项目关闭旧连接,丢弃旧响应和错误;SSE 断线只回到 GET 轮询,历史无参数调用继续兼容。
|
||||
- 候选历史展示 `legacyTermination` 的原状态、终止时间、审计编号、费用结论和新授权要求。终止不改写原始审核,不解除 Primary 门禁。
|
||||
- 独立新审核只传 `legacyVisionAuthorizationId`;物理专项补跑同时传原任务、请求指纹和 `physicalRetryAuthorizationId`。均须手动输入已有授权、明确勾选费用并从弹窗底栏提交,不提供签发入口,不自动重试。
|
||||
- 202 只观察已受理执行。200 按实际质量与来源结果展示;409 刷新历史并保留任务及费用门禁。执行完成、质量通过和正式 Primary 分别表达。
|
||||
- 多次执行保持审核任务身份,采用历史返回的最新执行,保留本机曾观察到的旧执行编号。已被更新执行取代的本机旧提交不会永久保留未知状态锁。
|
||||
- 分镜设计与生产页复用一个全屏连续性审核抽屉,当前集正式顺序连续选择两到三镜,并从正式生成规格求共同 Scene Form。展示 Primary、原图、摄影设计、布局母版、场景形态当前性及原始来源依据。
|
||||
- 人工分别填写观察面、地标顺序、固定结构位置或数量及其证据。未知明确保留;不把开关门即时状态自动投影成固定结构变化。免费诊断支持 passed、failed、needs_review、insufficient_evidence、stale。
|
||||
- 审核保存绑定本次已诊断观察的来源指纹,编辑后须重新诊断。刷新可恢复本机最近审核编号,也可手动读取其他正式编号。回读分别展示审核人、时间、原始结论和当前失效原因,不修改 Primary。
|
||||
- 固定结构 `layoutSupplement` 独立免费预览,不混入摄影 draft;展示当前版本、待审提示词、draftFingerprint、完整 layoutConfirmation 及三个确认/生产标志。待审指纹没有进入任何生图请求。
|
||||
- 正式布局确认原样使用本次返回的完整参数,仅补充真实 `confirmedBy`。保存后重新读取布局、母版、场景形态来源和首帧诊断,并回读原审核失效状态;不生成素材、不变更 Primary。
|
||||
- 操作反馈沿用应用 Naive Message。正式提交使用 Loading 和关闭锁,免费读取不阻止关闭。手机底栏可换行,图片按实际宽高或稳定比例预留空间,加载骨架静态显示。
|
||||
|
||||
## 后端契约限制
|
||||
|
||||
### 同一审核任务的完整执行历史尚无公开读取能力
|
||||
|
||||
`GET /storyboard-shots/:shotId/keyframes/:keyframeId/validations` 经 `shot-keyframe-asset.service.ts` 与 `readVisionRecovery()` 仅投影任务当前 `executionId`。项目工作流路由只有 latest 与 events,单执行路由需要已知编号,没有按 `validationTaskId` 枚举全部执行的接口。物理专项授权的旧执行及旧回执虽保存在内部审计记录,当前历史 DTO 未公开。
|
||||
|
||||
因此本轮实现的是:正式最新执行恢复 + 本机已实际观察到的执行记录。不能宣称从新浏览器完整找回未曾观察到的旧执行。后续需要后端正式提供任务执行列表及其公开摘要;本轮未猜测 URL,也未新增后端接口。
|
||||
|
||||
### 专项补跑入口按公开证据提供,最终资格由后端确认
|
||||
|
||||
步骤摘要含完成状态、issues、用量,但没有 General 的独立 passed 字段及完整 Physical 原始失败回执。前端仅在最新任务 General 已完成且无硬问题、Physical 失败且有计量时提供已有授权输入,文案明确为“补跑要求”。正式授权受理后才能确认原 General 通过并显示本次单步范围。实际原图、来源、模型、原费用回执与一次性授权继续由后端核对;不向用户伪造缺失证据。
|
||||
|
||||
## 验证边界
|
||||
|
||||
自动化全部使用 Mock,测试环境禁止未模拟请求连接真实服务。覆盖项目切换迟到 404、SSE 断线、同任务多执行、独立授权、物理专项三项参数、200 质量展示、终止与 Primary 限制、连续性观察/保存/回读/失效、布局待审及版本冲突。
|
||||
|
||||
本地 Chrome 复用已有 `localhost:4312` 标签页:真实项目只读核对三张 Primary、正式设计、当前布局与来源失效;写入交互使用临时隔离页面拦截全部 API,验证布局正式确认与审核失效保留原结论。检查桌面、390 × 844 手机、长内容滚动、固定底栏、深浅主题及授权按钮禁用/确认状态。临时验收文件在提交前移除。
|
||||
|
||||
真实付费 Provider 调用为 0,未提交真实授权、连续性审核或布局修改,未改动正式数据。
|
||||
@@ -93,6 +93,8 @@ const emit = defineEmits<{ closed: [] }>()
|
||||
}
|
||||
.app-drawer-footer {
|
||||
display: flex;
|
||||
/* 多项正式操作在窄屏换行,始终保留关闭和提交入口。 */
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import ContinuityReviewDrawer from './components/ContinuityReviewDrawer.vue'
|
||||
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
|
||||
import { ScanEye } from '@lucide/vue'
|
||||
import { isOperationRunning } from '../workflows/operations'
|
||||
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
@@ -28,7 +31,10 @@ import QualityDialog from './components/QualityDialog.vue'
|
||||
import EpisodeAssemblyPanel from './components/EpisodeAssemblyPanel.vue'
|
||||
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
/** 批量质量操作弹窗。 */
|
||||
const qualityOpen = ref(false)
|
||||
/** 免费连续性诊断与人工审核入口。 */
|
||||
const continuityOpen = ref(false)
|
||||
|
||||
/** 镜头生产页将项目批处理与单镜头资产管理放在同一条可核验链路中。 */
|
||||
const {
|
||||
@@ -285,6 +291,18 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
|
||||
></span
|
||||
>
|
||||
<div class="toolbar-actions">
|
||||
<!-- 以下是相邻镜头连续性审核入口,移动端保留图标和操作说明 -->
|
||||
<WorkspaceActionTooltip label="连续性审核" mobile-only>
|
||||
<NButton
|
||||
class="mobile-toolbar-icon"
|
||||
:disabled="!id || shots.length < 2"
|
||||
aria-label="连续性审核"
|
||||
@click="continuityOpen = true"
|
||||
><ScanEye :size="18" class="mobile-action-icon" /><span class="workspace-action-label"
|
||||
>连续性审核</span
|
||||
></NButton
|
||||
>
|
||||
</WorkspaceActionTooltip>
|
||||
<!-- 以下是移动端图标入口模块,桌面保留完整文字,手机保留中文无障碍说明 -->
|
||||
<NButton
|
||||
class="mobile-toolbar-icon"
|
||||
@@ -892,6 +910,13 @@ const videoRules = { videoLimit: integerRule('本批镜头上限'), videoRepairA
|
||||
<p v-else-if="query.loading.value" class="panel mt-5 p-8 text-sm text-muted" role="status">
|
||||
正在检查全项目生产就绪状态……
|
||||
</p>
|
||||
<ContinuityReviewDrawer
|
||||
v-model:open="continuityOpen"
|
||||
:project-id="id"
|
||||
:shots="shots"
|
||||
:disabled="blocked"
|
||||
@changed="refreshProject"
|
||||
/>
|
||||
<QualityDialog
|
||||
v-model:open="qualityOpen"
|
||||
:project-id="id"
|
||||
|
||||
@@ -155,8 +155,15 @@ export const productionApi = {
|
||||
body: { concurrency },
|
||||
timeoutMs: 0
|
||||
}),
|
||||
listKeyframes: (shotId: string, signal?: AbortSignal) =>
|
||||
request<ShotKeyframe[]>(`${shotPath(shotId)}/keyframes`, { signal }),
|
||||
/**
|
||||
* 查询镜头候选,可指定项目隔离读取。
|
||||
* @param shotId 正式镜头
|
||||
* @param signal 取消信号
|
||||
* @param projectId 可选项目范围
|
||||
* @returns 当前候选列表
|
||||
*/
|
||||
listKeyframes: (shotId: string, signal?: AbortSignal, projectId?: string) =>
|
||||
request<ShotKeyframe[]>(keyframeScope(`${shotPath(shotId)}/keyframes`, projectId), { signal }),
|
||||
keyframeSpec: (shotId: string, signal?: AbortSignal, projectId?: string) =>
|
||||
request<KeyframeSpec>(keyframeScope(`${shotPath(shotId)}/keyframe-spec`, projectId), { signal }),
|
||||
/** 按本次请求选择的图片模型与参数预览最终输入,不创建首帧任务。 */
|
||||
|
||||
@@ -0,0 +1,724 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem, NInput, NSelect, NSkeleton } from 'naive-ui'
|
||||
import { AssetImage } from '../../../components/ui'
|
||||
import AppDrawer from '../../../components/ui/AppDrawer.vue'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import { useActionMessage, showActionFeedback } from '../../../components/ui/useActionMessage'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { storyboardApi } from '../../storyboard/api'
|
||||
import { directionLabel } from '../../storyboard/model'
|
||||
import type { DesignedShot } from '../../storyboard/types'
|
||||
import { productionApi } from '../api'
|
||||
import { sourceDiagnosticsApi } from '../../subject-images/source-diagnostics'
|
||||
import { subjectImagesApi } from '../../subject-images/api'
|
||||
import {
|
||||
continuityApi,
|
||||
continuityInvalidationLabels,
|
||||
continuitySelectionValid,
|
||||
continuityStatusLabels,
|
||||
validObservation
|
||||
} from '../continuity'
|
||||
import type {
|
||||
ContinuityDiagnosis,
|
||||
ContinuityInput,
|
||||
ContinuityIssue,
|
||||
ContinuityObservation,
|
||||
GeometryFrameObservation
|
||||
} from '../continuity.types'
|
||||
import GeometryObservationEditor from './GeometryObservationEditor.vue'
|
||||
import LayoutSupplementPanel from './LayoutSupplementPanel.vue'
|
||||
|
||||
/** 现有生产工作区的增量入口,范围仅限当前集正式镜头。 */
|
||||
const props = defineProps<{
|
||||
/** 项目归属。 */ projectId: string
|
||||
/** 当前集完整正式镜头顺序。 */ shots: DesignedShot[]
|
||||
/** 活动任务等状态只阻止正式写入,免费读取仍可关闭。 */ disabled: boolean
|
||||
}>()
|
||||
/** 全屏审核界面开关。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 正式确认后通知生产页回读真实来源。 */
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
/** 用户明确选择的镜头。 */
|
||||
const selected = ref<string[]>([])
|
||||
/** 当前共同场景形态。 */
|
||||
const sceneFormId = ref('')
|
||||
/** 最新诊断及原始依据。 */
|
||||
const diagnosis = ref<ContinuityDiagnosis | null>(null)
|
||||
/** 相同来源问题合并镜头范围,避免三镜重复堆叠相同提示。 */
|
||||
const diagnosisIssues = computed(() => {
|
||||
const groups = new Map<string, ContinuityIssue>()
|
||||
for (const issue of diagnosis.value?.issues ?? []) {
|
||||
const key = JSON.stringify([issue.code, issue.featureKey, issue.message])
|
||||
const existing = groups.get(key)
|
||||
if (existing) existing.shotIds = [...new Set([...existing.shotIds, ...issue.shotIds])]
|
||||
else groups.set(key, { ...issue, shotIds: [...issue.shotIds] })
|
||||
}
|
||||
return [...groups.values()].map(issue => ({
|
||||
...issue,
|
||||
scope: issue.shotIds
|
||||
.map(id => {
|
||||
const frame = diagnosis.value?.frames.find(item => item.shotId === id)
|
||||
return frame ? `${frame.beatNo}.${frame.shotNo}` : '未定位镜头'
|
||||
})
|
||||
.join('、')
|
||||
}))
|
||||
})
|
||||
/** 用户逐镜填写的观察,不自动判断左右或数量。 */
|
||||
const observation = ref<ContinuityObservation | null>(null)
|
||||
/** 最近一次消费的观察快照,编辑后禁止保存旧结论。 */
|
||||
const diagnosedInput = ref<ContinuityInput | null>(null)
|
||||
/** 明确填写的真实审核人。 */
|
||||
const reviewer = ref('')
|
||||
/** 本次免费诊断请求。 */
|
||||
const diagnosing = ref(false)
|
||||
/** 正式保存期间防止重复操作及意外关闭。 */
|
||||
const saving = ref(false)
|
||||
/** 子级布局正式写入状态。 */
|
||||
const layoutSaving = ref(false)
|
||||
/** 布局正式确认表单通过当前抽屉底栏提交。 */
|
||||
const layoutPanelRef = ref<InstanceType<typeof LayoutSupplementPanel> | null>(null)
|
||||
/** 已知历史审核编号或用户输入的正式编号。 */
|
||||
const reviewId = ref('')
|
||||
/** 用户输入后再显式读取,避免输入时反复请求。 */
|
||||
const requestedReviewId = ref('')
|
||||
/** 当前审核提交锁。 */
|
||||
const busy = computed(() => saving.value || layoutSaving.value)
|
||||
/** 正式镜头选择约束。 */
|
||||
const selectionValid = computed(() =>
|
||||
continuitySelectionValid(
|
||||
selected.value,
|
||||
props.shots.map(item => item.shotId)
|
||||
)
|
||||
)
|
||||
/** 当前打开范围包含项目及整集镜头身份。 */
|
||||
const context = computed(() =>
|
||||
open.value ? JSON.stringify([props.projectId, props.shots.map(item => item.shotId)]) : ''
|
||||
)
|
||||
/** 所选正式来源按需读取,普通浏览不做全项目检查。 */
|
||||
const sourcesKey = computed(() =>
|
||||
context.value && selectionValid.value ? JSON.stringify([props.projectId, selected.value]) : ''
|
||||
)
|
||||
/** 正式场景绑定及当前 Primary 列表。 */
|
||||
const sources = useQuery(sourcesKey, async (value, signal) => {
|
||||
if (!value) return []
|
||||
const [projectId, shotIds] = JSON.parse(value) as [string, string[]]
|
||||
return Promise.all(
|
||||
shotIds.map(async shotId => {
|
||||
const [spec, keyframes] = await Promise.all([
|
||||
storyboardApi.generationSpec(shotId, signal, projectId),
|
||||
productionApi.listKeyframes(shotId, signal, projectId)
|
||||
])
|
||||
if (
|
||||
spec.projectId !== projectId ||
|
||||
spec.shotId !== shotId ||
|
||||
keyframes.some(item => item.shotId !== shotId)
|
||||
)
|
||||
throw new Error('镜头来源与当前项目不匹配。')
|
||||
return { spec, primary: keyframes.find(item => item.isPrimary) ?? null }
|
||||
})
|
||||
)
|
||||
})
|
||||
/** 仅提供每个选中镜头均实际绑定的同一场景形态。 */
|
||||
const scenes = computed(
|
||||
() =>
|
||||
sources.data.value?.[0]?.spec.subjects.filter(
|
||||
subject =>
|
||||
subject.module === 'scene' &&
|
||||
sources.data.value?.every(item =>
|
||||
item.spec.subjects.some(
|
||||
other =>
|
||||
other.module === 'scene' &&
|
||||
other.subjectFormId === subject.subjectFormId &&
|
||||
other.subjectId === subject.subjectId
|
||||
)
|
||||
)
|
||||
) ?? []
|
||||
)
|
||||
/** 当前场景正式主体,供布局来源查询。 */
|
||||
const scene = computed(() => scenes.value.find(item => item.subjectFormId === sceneFormId.value))
|
||||
/** 场景形态和布局母版独立回读。 */
|
||||
const sceneKey = computed(() =>
|
||||
context.value && scene.value ? JSON.stringify([props.projectId, scene.value.subjectId, sceneFormId.value]) : ''
|
||||
)
|
||||
/** 读取当前布局和母版;只读校验形态主图来源,不调 Vision。 */
|
||||
const sceneSources = useQuery(sceneKey, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [projectId, subjectId, formId] = JSON.parse(value) as [string, string, string]
|
||||
const [layouts, images] = await Promise.all([
|
||||
sourceDiagnosticsApi.scene(projectId, subjectId, formId, signal),
|
||||
subjectImagesApi.listImages(formId, signal)
|
||||
])
|
||||
const primary = images.find(item => item.isPrimary && item.subjectFormId === formId)
|
||||
const currentness = primary ? await subjectImagesApi.validationPreview(formId, primary.id, signal) : null
|
||||
return { layouts, currentness }
|
||||
})
|
||||
/** 项目范围内的审核回读,原结论与当前失效分开。 */
|
||||
const reviewKey = computed(() =>
|
||||
context.value && requestedReviewId.value ? JSON.stringify([props.projectId, requestedReviewId.value]) : ''
|
||||
)
|
||||
/** 指定审核可在刷新后重新取得当前性。 */
|
||||
const reviewQuery = useQuery(reviewKey, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [projectId, id] = JSON.parse(value) as [string, string]
|
||||
return continuityApi.review(projectId, id, signal)
|
||||
})
|
||||
/** 保存仅接受本次已诊断且未编辑的指纹观察。 */
|
||||
const canSave = computed(
|
||||
() =>
|
||||
!!diagnosis.value?.observation &&
|
||||
['passed', 'failed', 'needs_review'].includes(diagnosis.value.status) &&
|
||||
diagnosis.value.fingerprint === observation.value?.expectedFingerprint &&
|
||||
JSON.stringify(diagnosedInput.value?.observation) === JSON.stringify(observation.value) &&
|
||||
!!reviewer.value.trim() &&
|
||||
reviewer.value.trim().length <= 120 &&
|
||||
!props.disabled &&
|
||||
!busy.value &&
|
||||
!diagnosing.value
|
||||
)
|
||||
/** 与来源和参数绑定的诊断身份。 */
|
||||
const target = computed(() => JSON.stringify([context.value, selected.value, sceneFormId.value]))
|
||||
/** 请求代次防止切范围、关闭或编辑期间回填旧结果。 */
|
||||
let generation = 0
|
||||
/** 免费诊断取消控制器。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 复用现有消息层。 */
|
||||
const message = useActionMessage()
|
||||
watch(
|
||||
context,
|
||||
() => {
|
||||
selected.value = open.value ? props.shots.slice(0, 3).map(item => item.shotId) : []
|
||||
sceneFormId.value = ''
|
||||
reviewer.value = ''
|
||||
try {
|
||||
reviewId.value = localStorage.getItem('continuity-review:' + props.projectId) || ''
|
||||
} catch {
|
||||
reviewId.value = ''
|
||||
}
|
||||
requestedReviewId.value = reviewId.value
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
watch(scenes, items => {
|
||||
if (!items.some(item => item.subjectFormId === sceneFormId.value))
|
||||
sceneFormId.value = items.length === 1 ? items[0]!.subjectFormId : ''
|
||||
})
|
||||
watch(
|
||||
target,
|
||||
() => {
|
||||
generation++
|
||||
controller?.abort()
|
||||
diagnosing.value = false
|
||||
diagnosis.value = null
|
||||
observation.value = null
|
||||
diagnosedInput.value = null
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
onScopeDispose(() => {
|
||||
generation++
|
||||
controller?.abort()
|
||||
})
|
||||
/**
|
||||
* 始终按正式顺序保存选择,避免输入点击顺序成为镜头顺序。
|
||||
* @param ids 用户选择镜头
|
||||
*/
|
||||
function selectShots(ids: string[]) {
|
||||
selected.value = props.shots.filter(item => ids.includes(item.shotId)).map(item => item.shotId)
|
||||
}
|
||||
/**
|
||||
* 从真实图组建立空白人工观察,所有未知项明确保持未知。
|
||||
* @param result 当前正式诊断
|
||||
* @returns 尚未填写的观察
|
||||
*/
|
||||
function blankObservation(result: ContinuityDiagnosis): ContinuityObservation {
|
||||
return {
|
||||
expectedFingerprint: result.fingerprint!,
|
||||
landmarks: ['', ''],
|
||||
frames: result.frames.map(frame => ({
|
||||
shotId: frame.shotId,
|
||||
view: 'unknown',
|
||||
landmarkOrder: 'unknown',
|
||||
evidence: '',
|
||||
features: []
|
||||
}))
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 免费核对当前图组或显式提交人工观察,绝不调用付费 Provider。
|
||||
* @param withObservation 是否包含用户填写的观察
|
||||
* @returns 当前诊断完成
|
||||
*/
|
||||
async function diagnose(withObservation = false) {
|
||||
if (
|
||||
!selectionValid.value ||
|
||||
!scene.value ||
|
||||
diagnosing.value ||
|
||||
busy.value ||
|
||||
sources.loading.value ||
|
||||
sources.error.value
|
||||
)
|
||||
return
|
||||
if (withObservation && !validObservation(observation.value, selected.value)) {
|
||||
showActionFeedback(message, '请填写两个不同地标、逐镜观察依据及固定结构位置或数量。', 'warning')
|
||||
return
|
||||
}
|
||||
const identity = target.value
|
||||
const current = ++generation
|
||||
controller?.abort()
|
||||
controller = new AbortController()
|
||||
const input: ContinuityInput = JSON.parse(
|
||||
JSON.stringify({
|
||||
shotIds: [...selected.value],
|
||||
sceneFormId: sceneFormId.value,
|
||||
...(withObservation ? { observation: observation.value } : {})
|
||||
})
|
||||
)
|
||||
diagnosing.value = true
|
||||
diagnosedInput.value = null
|
||||
try {
|
||||
const result = await continuityApi.diagnose(props.projectId, input, controller.signal)
|
||||
if (identity !== target.value || current !== generation) return
|
||||
if (
|
||||
result.projectId !== props.projectId ||
|
||||
result.sceneFormId !== input.sceneFormId ||
|
||||
result.frames.length !== input.shotIds.length ||
|
||||
result.frames.some((frame, i) => frame.shotId !== input.shotIds[i])
|
||||
)
|
||||
throw new Error('诊断与当前项目或镜头范围不匹配。')
|
||||
diagnosis.value = result
|
||||
diagnosedInput.value = input
|
||||
if (!withObservation) observation.value = result.fingerprint && result.layout ? blankObservation(result) : null
|
||||
if (result.status === 'stale') {
|
||||
observation.value = null
|
||||
diagnosedInput.value = null
|
||||
}
|
||||
} catch (cause) {
|
||||
if (identity === target.value && current === generation)
|
||||
showActionFeedback(message, errorMessage(cause), 'error')
|
||||
} finally {
|
||||
if (current === generation) diagnosing.value = false
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 保存本次诊断的原始观察及真实审核人,重复提交由正式服务幂等处理。
|
||||
* @returns 审核写入和当前性回读完成
|
||||
*/
|
||||
async function saveReview() {
|
||||
if (!canSave.value || !diagnosedInput.value) return
|
||||
const identity = target.value
|
||||
const projectId = props.projectId
|
||||
const input = JSON.parse(
|
||||
JSON.stringify({ ...diagnosedInput.value, reviewer: reviewer.value.trim() })
|
||||
) as ContinuityInput & { reviewer: string }
|
||||
saving.value = true
|
||||
try {
|
||||
const result = await continuityApi.save(projectId, input)
|
||||
if (identity !== target.value) return
|
||||
if (!result.reviewId || result.diagnosis.fingerprint !== input.observation?.expectedFingerprint)
|
||||
throw new Error('审核记录与本次诊断不一致,请重新核对。')
|
||||
reviewId.value = result.reviewId
|
||||
requestedReviewId.value = result.reviewId
|
||||
try {
|
||||
localStorage.setItem('continuity-review:' + projectId, result.reviewId)
|
||||
} catch {
|
||||
/* 保存位置失败不影响正式记录。 */
|
||||
}
|
||||
await reviewQuery.refresh()
|
||||
if (identity !== target.value) return
|
||||
showActionFeedback(message, '连续性审核已保存,主首帧保持原状。', 'success')
|
||||
} catch (cause) {
|
||||
if (identity === target.value) {
|
||||
showActionFeedback(message, errorMessage(cause), 'error')
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
diagnosedInput.value = null
|
||||
observation.value = null
|
||||
diagnosis.value = null
|
||||
await sources.refresh()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
/** 明确读取输入编号;同编号只刷新一次,不在输入时请求。 */
|
||||
function loadReview() {
|
||||
const id = reviewId.value.trim()
|
||||
if (!id) return
|
||||
if (requestedReviewId.value === id) void reviewQuery.refresh()
|
||||
else requestedReviewId.value = id
|
||||
}
|
||||
/** 正式布局变化后只刷新来源,不发起生成。 */
|
||||
async function refreshSources() {
|
||||
const identity = context.value
|
||||
generation++
|
||||
controller?.abort()
|
||||
diagnosing.value = false
|
||||
diagnosis.value = null
|
||||
observation.value = null
|
||||
diagnosedInput.value = null
|
||||
await Promise.all([sources.refresh(), sceneSources.refresh(), reviewQuery.refresh()])
|
||||
if (identity !== context.value) return
|
||||
emit('changed')
|
||||
if (open.value && selectionValid.value && scene.value) await diagnose()
|
||||
}
|
||||
/**
|
||||
* 将用户明确编辑的一镜观察写回当前表单。
|
||||
* @param index 正式图组索引
|
||||
* @param value 当前人工观察
|
||||
*/
|
||||
function updateFrame(index: number, value: GeometryFrameObservation) {
|
||||
if (observation.value) observation.value.frames[index] = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是同场景连续镜头的全屏诊断与持久化审核模块 -->
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
title="跨镜固定几何审核"
|
||||
description="免费对照相邻两到三镜的固定结构,审核不会自动修改主首帧。"
|
||||
:busy="busy"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<section class="space-y-3">
|
||||
<WorkspaceSectionHeading
|
||||
title="选择审核范围"
|
||||
description="选择同一场景形态下、同集正式顺序连续的两到三镜。"
|
||||
/>
|
||||
<NSelect
|
||||
:value="selected"
|
||||
multiple
|
||||
:max="3"
|
||||
:disabled="busy || diagnosing"
|
||||
aria-label="连续性审核镜头"
|
||||
:options="
|
||||
shots.map(item => ({
|
||||
label: `${item.beatNo}.${item.shotNo} · ${item.title}`,
|
||||
value: item.shotId
|
||||
}))
|
||||
"
|
||||
@update:value="selectShots"
|
||||
/>
|
||||
<p v-if="selected.length && !selectionValid" class="text-sm text-muted">请选择相邻的两到三镜。</p>
|
||||
<NSelect
|
||||
v-model:value="sceneFormId"
|
||||
:disabled="busy || diagnosing || sources.loading.value"
|
||||
:loading="sources.loading.value"
|
||||
aria-label="连续性场景形态"
|
||||
placeholder="选择共同场景形态"
|
||||
:options="
|
||||
scenes.map(item => ({
|
||||
label: `${item.subjectName} · ${item.subjectFormName}`,
|
||||
value: item.subjectFormId
|
||||
}))
|
||||
"
|
||||
/>
|
||||
<p v-if="selectionValid && sources.data.value?.length && !scenes.length" class="text-sm text-muted">
|
||||
这些镜头没有共同的正式场景形态,请调整选择。
|
||||
</p>
|
||||
<NButton
|
||||
:loading="diagnosing"
|
||||
:disabled="!selectionValid || !scene || busy || sources.loading.value || !!sources.error.value"
|
||||
@click="diagnose()"
|
||||
>免费读取当前证据</NButton
|
||||
>
|
||||
</section>
|
||||
<!-- 以下是按真实三镜卡片结构预留的静态加载骨架 -->
|
||||
<section
|
||||
v-if="sources.loading.value && !sources.data.value?.length"
|
||||
class="continuity-frame-grid"
|
||||
role="status"
|
||||
aria-label="正在读取镜头与主首帧"
|
||||
>
|
||||
<article v-for="shotId in selected" :key="shotId" class="min-w-0 space-y-3" aria-hidden="true">
|
||||
<NSkeleton :animated="false" :height="20" width="60%" />
|
||||
<div class="relative aspect-square">
|
||||
<NSkeleton :animated="false" class="absolute inset-0" width="100%" height="100%" />
|
||||
</div>
|
||||
<NSkeleton :animated="false" :height="14" width="85%" /><NSkeleton
|
||||
:animated="false"
|
||||
:height="14"
|
||||
width="65%"
|
||||
/>
|
||||
</article>
|
||||
</section>
|
||||
<!-- 以下是当前 Primary、摄影设计与场景来源模块,缺图时预留稳定区域 -->
|
||||
<section v-if="sources.data.value?.length" class="continuity-frame-grid">
|
||||
<article v-for="item in sources.data.value" :key="item.spec.shotId" class="min-w-0 space-y-3">
|
||||
<h3 class="font-semibold">
|
||||
镜头 {{ item.spec.beatNo }}.{{ item.spec.shotNo }} · {{ item.spec.title }}
|
||||
</h3>
|
||||
<AssetImage
|
||||
:src="item.primary?.imageUrl"
|
||||
:style="{
|
||||
aspectRatio:
|
||||
item.primary?.width && item.primary?.height
|
||||
? `${item.primary.width} / ${item.primary.height}`
|
||||
: '1 / 1'
|
||||
}"
|
||||
:alt="`镜头 ${item.spec.beatNo}.${item.spec.shotNo} 当前主首帧`"
|
||||
preview
|
||||
object-fit="contain"
|
||||
empty-text="暂无当前主首帧"
|
||||
/>
|
||||
<p class="wrap-anywhere text-xs text-muted">当前主首帧:{{ item.primary?.id || '未设置' }}</p>
|
||||
<p class="text-sm">
|
||||
镜头设计:{{
|
||||
[
|
||||
item.spec.direction.shotSize,
|
||||
item.spec.direction.cameraAngle,
|
||||
item.spec.direction.cameraMovement
|
||||
]
|
||||
.filter(Boolean)
|
||||
.map(value => directionLabel(value))
|
||||
.join(' · ') || '未填写'
|
||||
}}
|
||||
</p>
|
||||
<NCollapse
|
||||
><NCollapseItem name="direction" title="完整镜头设计"
|
||||
><dl class="space-y-2 text-sm">
|
||||
<div v-for="(value, field) in item.spec.direction" :key="field">
|
||||
{{ directionLabel(value, field) }}
|
||||
</div>
|
||||
</dl></NCollapseItem
|
||||
></NCollapse
|
||||
>
|
||||
<p class="text-sm">
|
||||
场景形态:{{
|
||||
item.spec.subjects
|
||||
.filter(subject => subject.module === 'scene')
|
||||
.map(subject => `${subject.subjectName} · ${subject.subjectFormName}`)
|
||||
.join('、')
|
||||
}}
|
||||
</p>
|
||||
<p v-if="diagnosis?.frames.find(frame => frame.shotId === item.spec.shotId)" class="text-sm">
|
||||
当前来源:{{
|
||||
continuityStatusLabels[
|
||||
diagnosis.frames.find(frame => frame.shotId === item.spec.shotId)!.status
|
||||
]
|
||||
}}
|
||||
{{
|
||||
userFacingText(
|
||||
diagnosis.frames.find(frame => frame.shotId === item.spec.shotId)!.reason,
|
||||
''
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
<NCollapse
|
||||
v-if="
|
||||
diagnosis?.frames.find(frame => frame.shotId === item.spec.shotId)?.formalSourceFingerprint
|
||||
"
|
||||
>
|
||||
<NCollapseItem name="source" title="高级来源详情">
|
||||
<pre class="whitespace-pre-wrap break-words text-xs">{{
|
||||
JSON.stringify(
|
||||
diagnosis.frames.find(frame => frame.shotId === item.spec.shotId),
|
||||
null,
|
||||
2
|
||||
)
|
||||
}}</pre>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</article>
|
||||
</section>
|
||||
<!-- 以下是当前布局母版、场景形态当前性及历史版本模块 -->
|
||||
<section v-if="sceneSources.data.value" class="space-y-3">
|
||||
<WorkspaceSectionHeading title="布局母版与场景来源" />
|
||||
<p class="text-sm">
|
||||
场景形态当前性:{{
|
||||
sceneSources.loading.value || sceneSources.error.value
|
||||
? '待重新核对'
|
||||
: sceneSources.data.value.currentness
|
||||
? sceneSources.data.value.currentness.sourceCurrent
|
||||
? '来源有效'
|
||||
: userFacingText(
|
||||
sceneSources.data.value.currentness.sourceStaleReason,
|
||||
'来源已变化,需要重新核对'
|
||||
)
|
||||
: '缺少主图证据'
|
||||
}}
|
||||
</p>
|
||||
<div v-for="layout in sceneSources.data.value.layouts" :key="layout.id" class="space-y-3">
|
||||
<p class="text-sm">
|
||||
{{ layout.name }} ·
|
||||
<span class="wrap-anywhere text-xs text-muted">当前版本:{{ layout.version }}</span>
|
||||
</p>
|
||||
<p v-if="!layout.masters.length" class="text-sm text-muted">暂无适用布局母版。</p>
|
||||
<div class="continuity-frame-grid">
|
||||
<article v-for="master in layout.masters" :key="master.id" class="space-y-2 min-w-0">
|
||||
<AssetImage :src="master.imageUrl" alt="布局母版" preview object-fit="contain" />
|
||||
<p class="text-sm">
|
||||
{{ master.subjectFormId ? '当前场景形态机位' : '全局布局母版' }} ·
|
||||
{{
|
||||
master.spatialLayoutVersion === layout.version && master.status === 'confirmed'
|
||||
? '当前版本已确认'
|
||||
: '待重新确认'
|
||||
}}
|
||||
</p>
|
||||
<p v-if="master.viewDescription" class="text-sm text-muted">{{ master.viewDescription }}</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 以下是固定地标与逐镜人工观察模块,不将门的开关当作几何变化 -->
|
||||
<section v-if="observation" class="space-y-4">
|
||||
<WorkspaceSectionHeading
|
||||
title="人工观察"
|
||||
description="相对已确认布局核对观察面与地标顺序。只记录固定结构位置和完整可辨数量;开门、关门属于即时状态。无法判断时请保留未知。"
|
||||
/>
|
||||
<div class="continuity-landmarks">
|
||||
<NInput
|
||||
v-model:value="observation.landmarks[0]"
|
||||
:disabled="busy || diagnosing"
|
||||
:maxlength="120"
|
||||
placeholder="固定地标一"
|
||||
:input-props="{ 'aria-label': '固定地标一' }"
|
||||
/><NInput
|
||||
v-model:value="observation.landmarks[1]"
|
||||
:disabled="busy || diagnosing"
|
||||
:maxlength="120"
|
||||
placeholder="固定地标二"
|
||||
:input-props="{ 'aria-label': '固定地标二' }"
|
||||
/>
|
||||
</div>
|
||||
<div class="continuity-frame-grid">
|
||||
<article v-for="(frame, index) in observation.frames" :key="frame.shotId" class="min-w-0 space-y-3">
|
||||
<h3 class="font-semibold">
|
||||
镜头 {{ diagnosis?.frames[index]?.beatNo }}.{{ diagnosis?.frames[index]?.shotNo }} 观察
|
||||
</h3>
|
||||
<GeometryObservationEditor
|
||||
:model-value="frame"
|
||||
:disabled="busy || diagnosing"
|
||||
@update:model-value="updateFrame(index, $event)"
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
<NButton :loading="diagnosing" :disabled="busy" @click="diagnose(true)">免费诊断人工观察</NButton>
|
||||
</section>
|
||||
<!-- 以下是最新诊断结论及正式审核保存模块 -->
|
||||
<section v-if="diagnosis" class="space-y-3 text-sm" role="status">
|
||||
<WorkspaceSectionHeading :title="`诊断结果:${continuityStatusLabels[diagnosis.status]}`" />
|
||||
<p v-for="(issue, index) in diagnosisIssues" :key="index">
|
||||
镜头 {{ issue.scope }}:{{ userFacingText(issue.message) }}
|
||||
</p>
|
||||
<p v-if="!diagnosis.issues.length">本次提交的固定结构观察未发现冲突。</p>
|
||||
<NInput
|
||||
v-if="diagnosis.observation"
|
||||
v-model:value="reviewer"
|
||||
:disabled="busy"
|
||||
:maxlength="120"
|
||||
placeholder="填写真实审核人"
|
||||
:input-props="{ 'aria-label': '连续性审核人' }"
|
||||
/>
|
||||
<p
|
||||
v-if="
|
||||
diagnosis.observation &&
|
||||
JSON.stringify(diagnosedInput?.observation) !== JSON.stringify(observation)
|
||||
"
|
||||
class="text-muted"
|
||||
>
|
||||
观察已修改,请重新诊断后再保存。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是正式历史审核回读,失效保留原结论及原始诊断 -->
|
||||
<section class="space-y-3">
|
||||
<WorkspaceSectionHeading
|
||||
title="读取历史审核"
|
||||
description="刷新后恢复本机最近审核,也可填写已有审核编号。"
|
||||
/>
|
||||
<div class="flex items-end gap-2">
|
||||
<NInput
|
||||
v-model:value="reviewId"
|
||||
placeholder="审核编号"
|
||||
:input-props="{ 'aria-label': '连续性历史审核编号' }"
|
||||
/><NButton :loading="reviewQuery.loading.value" :disabled="!reviewId.trim()" @click="loadReview"
|
||||
>读取</NButton
|
||||
>
|
||||
</div>
|
||||
<article v-if="reviewQuery.data.value" class="space-y-2 text-sm">
|
||||
<p>
|
||||
审核人:{{ reviewQuery.data.value.reviewer }} ·
|
||||
{{ formatDate(reviewQuery.data.value.reviewedAt) }}
|
||||
</p>
|
||||
<p>原审核结论:{{ continuityStatusLabels[reviewQuery.data.value.diagnosis.status] }}</p>
|
||||
<p>当前状态:{{ continuityStatusLabels[reviewQuery.data.value.status] }}</p>
|
||||
<template v-if="reviewQuery.data.value.invalidation"
|
||||
><p>
|
||||
{{ continuityInvalidationLabels[reviewQuery.data.value.invalidation.code] || '来源已变化' }}
|
||||
</p>
|
||||
<p v-for="(issue, index) in reviewQuery.data.value.invalidation.issues" :key="index">
|
||||
{{ userFacingText(issue.message) }}
|
||||
</p></template
|
||||
>
|
||||
<NCollapse
|
||||
><NCollapseItem name="original" title="原始诊断">
|
||||
<pre class="whitespace-pre-wrap break-words text-xs">{{
|
||||
JSON.stringify(reviewQuery.data.value.diagnosis, null, 2)
|
||||
}}</pre>
|
||||
</NCollapseItem></NCollapse
|
||||
>
|
||||
</article>
|
||||
</section>
|
||||
<!-- 以下是布局补充与正式确认模块,确认后回读来源但不生成素材 -->
|
||||
<LayoutSupplementPanel
|
||||
ref="layoutPanelRef"
|
||||
v-if="scene && selected[0] && sceneSources.data.value"
|
||||
:project-id="projectId"
|
||||
:shot-id="selected[0]"
|
||||
:scene-subject-id="scene.subjectId"
|
||||
:scene-form-id="sceneFormId"
|
||||
:layouts="sceneSources.data.value.layouts"
|
||||
:disabled="disabled || saving || diagnosing"
|
||||
@busy="layoutSaving = $event"
|
||||
@changed="refreshSources"
|
||||
/>
|
||||
</div>
|
||||
<template #footer>
|
||||
<NButton :disabled="busy" @click="open = false">关闭</NButton>
|
||||
<NButton
|
||||
v-if="diagnosis?.observation"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="!canSave"
|
||||
@click="saveReview"
|
||||
>保存本次连续性审核</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="layoutPanelRef?.previewAvailable"
|
||||
type="primary"
|
||||
:loading="layoutSaving"
|
||||
:disabled="!layoutPanelRef.canConfirm || saving || diagnosing"
|
||||
@click="layoutPanelRef.confirmLayout()"
|
||||
>确认正式布局</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* 与工作区共用列间距,窄屏逐镜排列,长内容交给公共抽屉滚动。 */
|
||||
.continuity-frame-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: var(--app-content-gap);
|
||||
}
|
||||
.continuity-landmarks {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--app-content-gap);
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.continuity-frame-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@media (max-width: 639px) {
|
||||
.continuity-landmarks {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,122 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NFormItem, NInput, NInputNumber, NSelect } from 'naive-ui'
|
||||
import { Trash2 } from '@lucide/vue'
|
||||
import WorkspaceActionTooltip from '../../../components/ui/WorkspaceActionTooltip.vue'
|
||||
import type { GeometryFrameObservation } from '../continuity.types'
|
||||
|
||||
/** 逐镜编辑人工观察,不从摄影设计推断真实像素。 */
|
||||
defineProps<{
|
||||
/** 请求期间禁止编辑。 */ disabled: boolean
|
||||
}>()
|
||||
/** 当前镜头的人工观察。 */
|
||||
const frame = defineModel<GeometryFrameObservation>({ required: true })
|
||||
/**
|
||||
* 添加位置或数量观察,空白项只在提交时检查。
|
||||
* @param kind 观察类型
|
||||
*/
|
||||
function addFeature(kind: 'side' | 'count') {
|
||||
if (frame.value.features.length >= 24) return
|
||||
frame.value.features.push({
|
||||
key: '',
|
||||
evidence: '',
|
||||
...(kind === 'side' ? { side: 'unknown' as const } : { count: null })
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是观察面、地标顺序和人工依据模块 -->
|
||||
<section class="space-y-3">
|
||||
<NFormItem label="观察面">
|
||||
<NSelect
|
||||
v-model:value="frame.view"
|
||||
:disabled="disabled"
|
||||
aria-label="观察面"
|
||||
:options="[
|
||||
{ label: '相同观察面', value: 'same_side' },
|
||||
{ label: '反向观察面', value: 'opposite_side' },
|
||||
{ label: '无法判断', value: 'unknown' }
|
||||
]"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem label="地标顺序">
|
||||
<NSelect
|
||||
v-model:value="frame.landmarkOrder"
|
||||
:disabled="disabled"
|
||||
aria-label="地标顺序"
|
||||
:options="[
|
||||
{ label: '与布局顺序一致', value: 'as_layout' },
|
||||
{ label: '与布局顺序相反', value: 'reversed' },
|
||||
{ label: '无法判断', value: 'unknown' }
|
||||
]"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NInput
|
||||
v-model:value="frame.evidence"
|
||||
type="textarea"
|
||||
:maxlength="500"
|
||||
:disabled="disabled"
|
||||
placeholder="填写观察面与地标顺序的画面依据"
|
||||
:input-props="{ 'aria-label': '观察面依据' }"
|
||||
/>
|
||||
<!-- 以下是固定结构的位置和数量模块,开关状态不作为固定结构变化 -->
|
||||
<div v-for="(feature, index) in frame.features" :key="index" class="space-y-2 bg-(--app-subtle) p-3">
|
||||
<div class="flex items-end gap-2">
|
||||
<NInput
|
||||
v-model:value="feature.key"
|
||||
:disabled="disabled"
|
||||
:maxlength="120"
|
||||
placeholder="跨镜一致的固定结构名称"
|
||||
:input-props="{ 'aria-label': '固定结构名称' }"
|
||||
/>
|
||||
<WorkspaceActionTooltip label="删除固定结构观察"
|
||||
><NButton
|
||||
square
|
||||
class="workspace-action-button"
|
||||
:disabled="disabled"
|
||||
aria-label="删除固定结构观察"
|
||||
@click="frame.features.splice(index, 1)"
|
||||
><Trash2 :size="16" /></NButton
|
||||
></WorkspaceActionTooltip>
|
||||
</div>
|
||||
<NSelect
|
||||
v-if="feature.side !== undefined"
|
||||
v-model:value="feature.side"
|
||||
:disabled="disabled"
|
||||
aria-label="固定结构位置"
|
||||
:options="[
|
||||
{ label: '画面左侧', value: 'left' },
|
||||
{ label: '画面右侧', value: 'right' },
|
||||
{ label: '无法判断', value: 'unknown' }
|
||||
]"
|
||||
/>
|
||||
<NInputNumber
|
||||
v-else
|
||||
v-model:value="feature.count"
|
||||
:disabled="disabled"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:precision="0"
|
||||
clearable
|
||||
placeholder="完整可辨数量,无法判断请留空"
|
||||
:input-props="{ 'aria-label': '固定结构数量' }"
|
||||
class="w-full"
|
||||
/>
|
||||
<NInput
|
||||
v-model:value="feature.evidence"
|
||||
:disabled="disabled"
|
||||
:maxlength="500"
|
||||
placeholder="填写此结构的画面证据"
|
||||
:input-props="{ 'aria-label': '固定结构依据' }"
|
||||
/>
|
||||
</div>
|
||||
<div class="workspace-action-group flex flex-wrap gap-2">
|
||||
<NButton :disabled="disabled || frame.features.length >= 24" @click="addFeature('side')"
|
||||
>添加固定位置</NButton
|
||||
>
|
||||
<NButton :disabled="disabled || frame.features.length >= 24" @click="addFeature('count')"
|
||||
>添加固定数量</NButton
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -80,6 +80,9 @@ const reviewLabels: Record<string, string> = {
|
||||
const isPassed = computed(
|
||||
() =>
|
||||
!props.stale &&
|
||||
!vision.history.data.value?.some(
|
||||
item => item.id === reviewQuery.data.value?.validationTaskId && item.legacyTermination
|
||||
) &&
|
||||
!wrongCanvas.value &&
|
||||
props.item.inputSnapshotStatus !== 'invalid' &&
|
||||
(effectiveStatus.value === 'passed' || effectiveStatus.value === 'manual_accepted')
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import { executionStageLabel } from '../../workflows/execution'
|
||||
import type { WorkflowExecution } from '../../workflows/execution.types'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
|
||||
/** 单次视觉审核执行状态,完成和质量通过分别表达。 */
|
||||
const props = defineProps<{
|
||||
/** 正式执行记录。 */ execution: WorkflowExecution
|
||||
/** 只读刷新状态。 */ loading: boolean
|
||||
}>()
|
||||
/** 仅触发只读刷新。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 只有明确质量通过且未标记恢复才使用成功语义。 */
|
||||
const passed = computed(
|
||||
() =>
|
||||
props.execution.status === 'completed' &&
|
||||
props.execution.result?.passed === true &&
|
||||
props.execution.result.qualityDecision === 'passed' &&
|
||||
props.execution.result.recoveryRequired !== true
|
||||
)
|
||||
/** 执行完成后仍清晰保留真实质量结论。 */
|
||||
const label = computed(() => {
|
||||
if (passed.value) return '审核质量通过'
|
||||
if (props.execution.status === 'failed') return '执行失败,质量未确认'
|
||||
if (props.execution.status === 'completed')
|
||||
return props.execution.result?.passed === false ? '执行完成,质量未通过' : '执行完成,质量待核对'
|
||||
return props.execution.status === 'pending' ? '等待审核' : '审核进行中'
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是正式执行与实际质量结论模块,不用满格绿色进度暗示通过 -->
|
||||
<section class="mt-4 space-y-2 text-sm" role="status" :class="passed ? 'bg-(--app-success-soft) p-3' : ''">
|
||||
<WorkspaceSectionHeading title="当前审核执行"
|
||||
><template #actions
|
||||
><NButton :loading="loading" @click="emit('refresh')">刷新进度</NButton></template
|
||||
></WorkspaceSectionHeading
|
||||
>
|
||||
<p>{{ label }} · {{ executionStageLabel(execution.stage) }}</p>
|
||||
<p v-if="execution.total > 0">已处理步骤:{{ execution.current }} / {{ execution.total }}</p>
|
||||
<p v-else>尚无可确认的步骤进度。</p>
|
||||
<p class="wrap-anywhere text-xs text-muted">
|
||||
执行编号:{{ execution.id }} · {{ formatDate(execution.updatedAt) }}
|
||||
</p>
|
||||
<p v-if="execution.error">{{ userFacingText(execution.error) }}</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -10,9 +10,11 @@ import { errorMessage } from '../../../lib/http'
|
||||
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { formatDate } from '../../../lib/format'
|
||||
import { useKeyframeVision } from '../keyframe-vision'
|
||||
import { physicalRetryTarget, submitKeyframeVision, useKeyframeVision } from '../keyframe-vision'
|
||||
import KeyframeExecutionStatus from './KeyframeExecutionStatus.vue'
|
||||
import { useActionMessage, showActionFeedback } from '../../../components/ui/useActionMessage'
|
||||
import { qualityApi } from '../quality-api'
|
||||
import { parseKeyframeValidationOutput } from '../quality'
|
||||
import { parseKeyframeValidationOutput, keyframeValidationPassed } from '../quality'
|
||||
|
||||
/** 历史仅按正式首帧目标读取,不写入手动晋升会话。 */
|
||||
const props = defineProps<{
|
||||
@@ -30,7 +32,7 @@ const props = defineProps<{
|
||||
observation?: ReturnType<typeof useKeyframeVision>
|
||||
}>()
|
||||
/** 通知候选重新读取当前质量状态。 */
|
||||
const emit = defineEmits<{ reviewed: [] }>()
|
||||
const emit = defineEmits<{ reviewed: []; busy: [value: boolean] }>()
|
||||
/** 普通入口展开后查询,独立弹窗打开时直接查询。 */
|
||||
const open = ref(props.initialOpen ?? false)
|
||||
/** 查询键包含全部归属信息,旧请求会被取消。 */
|
||||
@@ -47,7 +49,14 @@ const visionKey = computed(() =>
|
||||
)
|
||||
: ''
|
||||
)
|
||||
const { history: query, execution, state, uncertain } = props.observation ?? useKeyframeVision(visionKey)
|
||||
const {
|
||||
history: query,
|
||||
execution,
|
||||
state,
|
||||
uncertain,
|
||||
observedExecutions,
|
||||
submissionMode
|
||||
} = props.observation ?? useKeyframeVision(visionKey)
|
||||
/** 后台结束时同步刷新人工复核与候选状态。 */
|
||||
watch(
|
||||
() => state.value.active,
|
||||
@@ -77,7 +86,121 @@ const reviewQuery = useQuery(key, (value, signal) => {
|
||||
const [, shotId, keyframeId] = JSON.parse(value) as [string | undefined, string, string]
|
||||
return qualityApi.keyframeQualityReview(shotId, keyframeId, signal)
|
||||
})
|
||||
/** 当前正式质量摘要。 */
|
||||
const review = computed(() => reviewQuery.data.value)
|
||||
/** 终止记录不能经人工接受绕过独立授权与 Primary 门禁。 */
|
||||
const terminatedReview = computed(() =>
|
||||
query.data.value?.some(item => item.id === review.value?.validationTaskId && item.legacyTermination)
|
||||
)
|
||||
/** 只有最新任务的物理失败证据可申请单步补跑。 */
|
||||
const physicalTarget = computed(() => physicalRetryTarget(query.data.value ?? []))
|
||||
/** 旧终止之后若已出现新任务,继续遵守新任务门禁。 */
|
||||
const independentAvailable = computed(
|
||||
() => !!state.value.terminated && !query.data.value?.some(item => !item.legacyTermination)
|
||||
)
|
||||
/** 用户明确填写的已有授权编号,不提供签发入口。 */
|
||||
const authorizationId = ref('')
|
||||
/** 单独确认本次费用和范围,修改编号后撤销。 */
|
||||
const authorizationAcknowledged = ref(false)
|
||||
/** 授权请求进行期间防止重复操作与意外关闭。 */
|
||||
const authorizationPending = ref(false)
|
||||
/** 复用应用消息层展示操作结果。 */
|
||||
const message = useActionMessage()
|
||||
/** 统一由所属弹窗底栏提交新授权,正文仅保留输入和范围说明。 */
|
||||
const authorizationAvailable = computed(() => independentAvailable.value || !!physicalTarget.value)
|
||||
/** 当前表单可明确提交,仍由提交方法再次检查真实任务门禁。 */
|
||||
const authorizationReady = computed(
|
||||
() =>
|
||||
authorizationAvailable.value &&
|
||||
!props.disabled &&
|
||||
!!authorizationId.value.trim() &&
|
||||
authorizationAcknowledged.value &&
|
||||
!state.value.active &&
|
||||
!uncertain.value &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
!authorizationPending.value
|
||||
)
|
||||
/** 底栏使用与本次授权范围一致的名称。 */
|
||||
const authorizationLabel = computed(() => (physicalTarget.value ? '授权仅补跑物理专项' : '提交独立新审核授权'))
|
||||
/** 所属弹窗复用统一底栏,不在正文重复放置操作。 */
|
||||
defineExpose({
|
||||
authorizationAvailable,
|
||||
authorizationReady,
|
||||
authorizationPending,
|
||||
authorizationLabel,
|
||||
submitAuthorization,
|
||||
authorizationAcknowledged,
|
||||
setAuthorizationAcknowledged
|
||||
})
|
||||
watch([key, authorizationId], () => {
|
||||
authorizationAcknowledged.value = false
|
||||
})
|
||||
watch(key, () => {
|
||||
authorizationId.value = ''
|
||||
})
|
||||
/**
|
||||
* 所属弹窗在固定底栏确认本次费用和范围。
|
||||
* @param value 用户明确勾选状态
|
||||
*/
|
||||
function setAuthorizationAcknowledged(value: boolean) {
|
||||
authorizationAcknowledged.value = value
|
||||
}
|
||||
/**
|
||||
* 明确提交独立授权,冲突后只刷新历史,不自动重试。
|
||||
* @returns 本次提交和历史刷新完成
|
||||
*/
|
||||
async function submitAuthorization() {
|
||||
if (
|
||||
!authorizationId.value.trim() ||
|
||||
!authorizationAcknowledged.value ||
|
||||
authorizationPending.value ||
|
||||
props.disabled ||
|
||||
state.value.active ||
|
||||
uncertain.value ||
|
||||
query.loading.value ||
|
||||
query.error.value ||
|
||||
(!independentAvailable.value && !physicalTarget.value)
|
||||
)
|
||||
return
|
||||
const target = key.value
|
||||
const shotId = props.shotId
|
||||
const keyframeId = props.keyframeId
|
||||
const projectId = props.projectId
|
||||
const physical = physicalTarget.value
|
||||
const input = physical
|
||||
? {
|
||||
resumeValidationTaskId: physical.id,
|
||||
expectedRequestFingerprint: physical.requestFingerprint!,
|
||||
physicalRetryAuthorizationId: authorizationId.value.trim()
|
||||
}
|
||||
: { legacyVisionAuthorizationId: authorizationId.value.trim() }
|
||||
authorizationPending.value = true
|
||||
emit('busy', true)
|
||||
authorizationAcknowledged.value = false
|
||||
try {
|
||||
const result = await submitKeyframeVision(shotId, keyframeId, input, query.data.value ?? [], projectId)
|
||||
if (target !== key.value) return
|
||||
showActionFeedback(
|
||||
message,
|
||||
result
|
||||
? keyframeValidationPassed(result)
|
||||
? '审核已通过,请核对候选后再设置主首帧。'
|
||||
: '审核未通过,主首帧仍受质量限制。'
|
||||
: '已受理,请观察当前审核进度。',
|
||||
result && keyframeValidationPassed(result) ? 'success' : 'info'
|
||||
)
|
||||
} catch (cause) {
|
||||
if (target === key.value) showActionFeedback(message, errorMessage(cause), 'error')
|
||||
} finally {
|
||||
authorizationPending.value = false
|
||||
emit('busy', false)
|
||||
if (target === key.value) {
|
||||
await Promise.all([query.refresh(), reviewQuery.refresh()])
|
||||
if (target === key.value) emit('reviewed')
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 视线复核的系统选项只在展示层转成中文。 */
|
||||
const gazeEvidenceLabels: Record<string, string> = {
|
||||
aligned: '符合预期',
|
||||
@@ -110,34 +233,43 @@ async function submitReview() {
|
||||
!reviewer.value.trim() ||
|
||||
submitting.value ||
|
||||
props.disabled ||
|
||||
terminatedReview.value ||
|
||||
state.value.active ||
|
||||
state.value.unknown ||
|
||||
uncertain.value
|
||||
)
|
||||
return
|
||||
const identity = key.value
|
||||
const shotId = props.shotId
|
||||
const keyframeId = props.keyframeId
|
||||
const reason = reviewReason.value.trim()
|
||||
const reviewerName = reviewer.value.trim()
|
||||
submitting.value = true
|
||||
submitError.value = ''
|
||||
submitSuccess.value = ''
|
||||
try {
|
||||
const taskId = review.value.validationTaskId
|
||||
if (reviewAction.value === 'accepted') {
|
||||
const preview = await qualityApi.previewKeyframeAccept(props.shotId, props.keyframeId, taskId)
|
||||
const preview = await qualityApi.previewKeyframeAccept(shotId, keyframeId, taskId)
|
||||
if (!preview.canAccept || !preview.requiresManualConfirmation) {
|
||||
throw new Error('候选未通过人工接受预检查')
|
||||
}
|
||||
await qualityApi.acceptKeyframeReview(props.shotId, props.keyframeId, {
|
||||
if (identity !== key.value) return
|
||||
await qualityApi.acceptKeyframeReview(shotId, keyframeId, {
|
||||
validationTaskId: taskId,
|
||||
expectedPrimaryId: preview.expectedPrimaryId,
|
||||
reviewer: reviewer.value.trim(),
|
||||
reason: reviewReason.value.trim()
|
||||
reviewer: reviewerName,
|
||||
reason
|
||||
})
|
||||
if (identity !== key.value) return
|
||||
submitSuccess.value = '已人工接受,主首帧已更新。'
|
||||
} else {
|
||||
await qualityApi.rejectKeyframeReview(props.shotId, props.keyframeId, {
|
||||
await qualityApi.rejectKeyframeReview(shotId, keyframeId, {
|
||||
validationTaskId: taskId,
|
||||
reviewer: reviewer.value.trim(),
|
||||
reason: reviewReason.value.trim()
|
||||
reviewer: reviewerName,
|
||||
reason
|
||||
})
|
||||
if (identity !== key.value) return
|
||||
submitSuccess.value = '已记录人工拒绝,候选图片仍保留。'
|
||||
}
|
||||
reviewAction.value = null
|
||||
@@ -146,11 +278,12 @@ async function submitReview() {
|
||||
query.refresh()
|
||||
emit('reviewed')
|
||||
} catch (cause) {
|
||||
submitError.value = errorMessage(cause)
|
||||
if (identity === key.value) submitError.value = errorMessage(cause)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
/** 正式历史原状态与展示结论分开。 */
|
||||
const records = computed(() =>
|
||||
(query.data.value ?? []).map(item => ({ ...item, validation: parseKeyframeValidationOutput(item.output) }))
|
||||
)
|
||||
@@ -174,8 +307,8 @@ const records = computed(() =>
|
||||
>
|
||||
<section v-if="review" class="panel p-3 text-xs leading-6">
|
||||
<p class="font-semibold">当前质量复核</p>
|
||||
<p>AI 检查:{{ decisionLabel(review.qualityDecision) }}</p>
|
||||
<p>当前状态:{{ decisionLabel(review.effectiveQualityStatus) }}</p>
|
||||
<p>AI 检查:{{ terminatedReview ? '已终止,无有效结论' : decisionLabel(review.qualityDecision) }}</p>
|
||||
<p>当前状态:{{ terminatedReview ? '质量未确认' : decisionLabel(review.effectiveQualityStatus) }}</p>
|
||||
<p v-if="review.manualReview">
|
||||
人工审核:{{ review.manualReview.decision === 'accepted' ? '已接受' : '已拒绝' }} ·
|
||||
{{ review.manualReview.reason || '未填写理由' }}
|
||||
@@ -191,7 +324,7 @@ const records = computed(() =>
|
||||
<p class="text-muted">{{ item.reason }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="review?.manualReviewAvailable" class="panel mt-3 p-3 text-xs">
|
||||
<section v-if="review?.manualReviewAvailable && !terminatedReview" class="panel mt-3 p-3 text-xs">
|
||||
<p class="font-semibold">人工复核</p>
|
||||
<p class="mt-2 text-muted">请先预览候选图片并确认视觉效果。接受会替换当前主首帧,拒绝只保存审核记录。</p>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
@@ -241,6 +374,47 @@ const records = computed(() =>
|
||||
submitSuccess
|
||||
}}</ContextNotice>
|
||||
<p v-if="reviewQuery.error.value" class="text-danger">{{ reviewQuery.error.value }}</p>
|
||||
<!-- 以下是独立授权和仅补跑物理专项模块,不签发授权、不自动重试 -->
|
||||
<section v-if="independentAvailable || physicalTarget" class="mt-4 space-y-3 text-sm">
|
||||
<h3 class="font-semibold">{{ physicalTarget ? '仅补跑物理专项' : '独立新审核授权' }}</h3>
|
||||
<template v-if="physicalTarget">
|
||||
<p>补跑要求:原通用检查已通过;本次仅补跑一个物理步骤,不重复提交通用检查。</p>
|
||||
<p>物理专项原失败原因:{{ userFacingText(physicalTarget.error, '原物理回执未能形成有效结果。') }}</p>
|
||||
<p>原费用已记录,保留原回执;本次需要独立授权,可能产生新费用。</p>
|
||||
<p class="wrap-anywhere text-xs text-muted">原审核任务:{{ physicalTarget.id }}</p>
|
||||
</template>
|
||||
<p v-else>原审核已人工终止,未标记通过。请填写已取得的独立授权编号,新审核可能产生费用。</p>
|
||||
<NInput
|
||||
v-model:value="authorizationId"
|
||||
:disabled="authorizationPending || disabled"
|
||||
placeholder="填写已签发的授权编号"
|
||||
:input-props="{ 'aria-label': '审核授权编号' }"
|
||||
/>
|
||||
</section>
|
||||
<!-- 以下是当前执行和本机已观察到的历史执行模块 -->
|
||||
<section v-if="submissionMode === 'physical'" class="mt-3 space-y-2 text-sm" role="status">
|
||||
<h3 class="font-semibold">仅补跑物理专项</h3>
|
||||
<p>原通用检查已通过,原费用已记录;本次仅补跑一个物理步骤,不重复提交通用检查。</p>
|
||||
<p>当前审核状态以以下正式执行及最新质量结论为准。</p>
|
||||
</section>
|
||||
<KeyframeExecutionStatus
|
||||
v-if="execution.data.value"
|
||||
:execution="execution.data.value"
|
||||
:loading="execution.loading.value"
|
||||
@refresh="execution.refresh"
|
||||
/>
|
||||
<p v-if="execution.error.value" class="mt-3 text-sm text-muted">{{ execution.error.value }}</p>
|
||||
<NCollapse v-if="observedExecutions.length" class="mt-3">
|
||||
<NCollapseItem name="executions" title="历史执行记录">
|
||||
<p class="text-xs text-muted">
|
||||
显示本机已观察到的执行;刷新会读取服务保存的最新执行。较早且未观察到的执行暂不可查询。
|
||||
</p>
|
||||
<p v-for="item in observedExecutions" :key="item.executionId" class="mt-2 wrap-anywhere text-xs">
|
||||
审核任务:{{ item.taskId }} · 执行:{{ item.executionId
|
||||
}}{{ item.status ? ` · 观察时状态:${stepLabels[item.status] ?? '待确认'}` : '' }}
|
||||
</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<!-- 以下是当前审核任务和费用核查状态 -->
|
||||
<p
|
||||
v-if="state.unknown || uncertain || (state.active && !state.active.executionId)"
|
||||
@@ -260,13 +434,38 @@ const records = computed(() =>
|
||||
{{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} ·
|
||||
{{ stepLabels[record.status] ?? '待确认' }} ·
|
||||
{{
|
||||
record.status === 'completed' && record.validation
|
||||
? record.validation.passed
|
||||
!record.legacyTermination && record.status === 'completed' && record.validation
|
||||
? keyframeValidationPassed(record.validation)
|
||||
? '视觉通过'
|
||||
: '视觉未通过'
|
||||
: '暂无结论'
|
||||
}}
|
||||
</p>
|
||||
<p class="mt-2 wrap-anywhere text-xs text-muted">
|
||||
审核任务:{{ record.id
|
||||
}}<template v-if="record.executionId"> · 最新执行:{{ record.executionId }}</template>
|
||||
</p>
|
||||
<section v-if="record.legacyTermination" class="mt-2 space-y-1 text-sm">
|
||||
<p>历史审核已人工终止,原任务状态:{{ stepLabels[record.status] ?? '待确认' }};未标记通过。</p>
|
||||
<p>人工终止时间:{{ formatDate(record.legacyTermination.terminatedAt) }}</p>
|
||||
<p class="wrap-anywhere">审计编号:{{ record.legacyTermination.auditId }}</p>
|
||||
<p>
|
||||
费用结论:{{
|
||||
{
|
||||
unresolved: '待核查',
|
||||
'billing-confirmed': '已确认计费',
|
||||
'no-charge-confirmed': '已确认未计费'
|
||||
}[record.legacyTermination.billingFinding]
|
||||
}}
|
||||
</p>
|
||||
<p>
|
||||
{{
|
||||
record.legacyTermination.requiresNewAuthorization
|
||||
? '需要独立新授权'
|
||||
: '授权要求以当前审核准入为准'
|
||||
}},不能自动重新提交。
|
||||
</p>
|
||||
</section>
|
||||
<p v-if="record.allowedTexts !== undefined" class="text-muted">
|
||||
原文字授权:{{
|
||||
record.allowedTexts === null
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NSelect } from 'naive-ui'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import { useActionMessage, showActionFeedback } from '../../../components/ui/useActionMessage'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { layoutApi, type ConfirmedLayout, type LayoutSupplementPreview } from '../layout-api'
|
||||
import { sourceDiagnosticsApi } from '../../subject-images/source-diagnostics'
|
||||
|
||||
/** 从正式来源查询得到的布局及母版,不根据诊断结论猜测。 */
|
||||
const props = defineProps<{
|
||||
/** 当前项目。 */ projectId: string
|
||||
/** 本次免费模拟的正式镜头。 */ shotId: string
|
||||
/** 正式场景主体。 */ sceneSubjectId: string
|
||||
/** 当前场景形态。 */ sceneFormId: string
|
||||
/** 正式布局和母版。 */ layouts: Awaited<ReturnType<typeof sourceDiagnosticsApi.scene>>
|
||||
/** 活动任务或上游未就绪时阻止正式确认。 */ disabled: boolean
|
||||
}>()
|
||||
/** 保存后通知页面回读来源;提交期间锁定外部抽屉关闭。 */
|
||||
const emit = defineEmits<{ changed: []; busy: [value: boolean] }>()
|
||||
/** 用户选择的真实布局。 */
|
||||
const layoutId = ref('')
|
||||
/** 固定结构待审约束。 */
|
||||
const instruction = ref('')
|
||||
/** 明确的人工证据或设计依据。 */
|
||||
const evidence = ref('')
|
||||
/** 真实确认人,不自动填写虚构身份。 */
|
||||
const confirmedBy = ref('')
|
||||
/** 明确接受布局版本变化及影响范围。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 当前免费预览。 */
|
||||
const preview = ref<LayoutSupplementPreview | null>(null)
|
||||
/** 最近正式确认结果,保留前后版本便于核对。 */
|
||||
const confirmed = ref<{ previous: string; layout: ConfirmedLayout } | null>(null)
|
||||
/** 免费预览加载,不阻止关闭。 */
|
||||
const loading = ref(false)
|
||||
/** 正式写入期间锁定重复操作。 */
|
||||
const saving = ref(false)
|
||||
/** 当前选择的正式布局。 */
|
||||
const layout = computed(() => props.layouts.find(item => item.id === layoutId.value))
|
||||
/** 完整预览身份包括当前版本,改变任一输入废弃旧响应。 */
|
||||
const target = computed(() =>
|
||||
JSON.stringify([
|
||||
props.projectId,
|
||||
props.shotId,
|
||||
props.sceneSubjectId,
|
||||
props.sceneFormId,
|
||||
layoutId.value,
|
||||
layout.value?.version,
|
||||
instruction.value,
|
||||
evidence.value
|
||||
])
|
||||
)
|
||||
/** 按钮参数检查,不提前展示字段错误。 */
|
||||
const valid = computed(
|
||||
() =>
|
||||
!!layout.value &&
|
||||
!!instruction.value.trim() &&
|
||||
instruction.value.trim().length <= 1000 &&
|
||||
!!evidence.value.trim() &&
|
||||
evidence.value.trim().length <= 1000
|
||||
)
|
||||
/** 复用消息反馈。 */
|
||||
const message = useActionMessage()
|
||||
/** 正式操作由所属抽屉固定底栏提供,预览表单不重复放置提交按钮。 */
|
||||
const previewAvailable = computed(() => !!preview.value)
|
||||
/** 当前确认条件,只允许真实确认人和本次明确勾选。 */
|
||||
const canConfirm = computed(
|
||||
() => previewAvailable.value && !!confirmedBy.value.trim() && acknowledged.value && !saving.value && !props.disabled
|
||||
)
|
||||
/** 向所属抽屉公开同一套正式提交守卫。 */
|
||||
defineExpose({ previewAvailable, canConfirm, saving, confirmLayout })
|
||||
/** 预览取消信号及过期序号。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 组件销毁后不回填结果。 */
|
||||
let disposed = false
|
||||
watch(
|
||||
() => props.layouts,
|
||||
layouts => {
|
||||
if (!layouts.some(item => item.id === layoutId.value))
|
||||
layoutId.value = layouts.length === 1 ? layouts[0]!.id : ''
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
watch(
|
||||
target,
|
||||
() => {
|
||||
controller?.abort()
|
||||
preview.value = null
|
||||
acknowledged.value = false
|
||||
loading.value = false
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(confirmedBy, () => {
|
||||
acknowledged.value = false
|
||||
})
|
||||
watch(
|
||||
() => JSON.stringify([props.projectId, props.shotId, props.sceneSubjectId, props.sceneFormId]),
|
||||
() => {
|
||||
confirmed.value = null
|
||||
confirmedBy.value = ''
|
||||
instruction.value = ''
|
||||
evidence.value = ''
|
||||
}
|
||||
)
|
||||
onScopeDispose(() => {
|
||||
disposed = true
|
||||
controller?.abort()
|
||||
})
|
||||
/**
|
||||
* 免费模拟固定结构,待审指纹永不转交生图接口。
|
||||
* @returns 本次预览完成
|
||||
*/
|
||||
async function loadPreview() {
|
||||
if (!valid.value || !layout.value || loading.value || saving.value) return
|
||||
const identity = target.value
|
||||
controller?.abort()
|
||||
controller = new AbortController()
|
||||
const signal = controller.signal
|
||||
preview.value = null
|
||||
acknowledged.value = false
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await layoutApi.preview(
|
||||
props.projectId,
|
||||
props.shotId,
|
||||
{
|
||||
layoutId: layout.value.id,
|
||||
expectedVersion: layout.value.version,
|
||||
sceneSubjectId: props.sceneSubjectId,
|
||||
instruction: instruction.value.trim(),
|
||||
evidence: evidence.value.trim()
|
||||
},
|
||||
signal
|
||||
)
|
||||
if (disposed || identity !== target.value || signal.aborted) return
|
||||
if (
|
||||
result.shotId !== props.shotId ||
|
||||
result.productionReady !== false ||
|
||||
result.requiresLayoutConfirmation !== true ||
|
||||
result.requiresMasterReconfirmation !== true ||
|
||||
!/^[a-f0-9]{64}$/.test(result.draftFingerprint) ||
|
||||
typeof result.providerPrompt !== 'string' ||
|
||||
!result.layoutConfirmation ||
|
||||
result.layoutConfirmation.expectedVersion !== layout.value?.version
|
||||
)
|
||||
throw new Error('待审预览与当前布局不匹配,请重新预览。')
|
||||
preview.value = result
|
||||
} catch (cause) {
|
||||
if (!disposed && identity === target.value && !signal.aborted)
|
||||
showActionFeedback(message, errorMessage(cause), 'error')
|
||||
} finally {
|
||||
if (!disposed && identity === target.value) loading.value = false
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 仅确认本次 Preview 的完整参数,不自动生成受影响素材。
|
||||
* @returns 正式确认与来源刷新完成
|
||||
*/
|
||||
async function confirmLayout() {
|
||||
if (!preview.value || !confirmedBy.value.trim() || !acknowledged.value || saving.value || props.disabled) return
|
||||
const identity = target.value
|
||||
const input = JSON.parse(JSON.stringify(preview.value.layoutConfirmation))
|
||||
saving.value = true
|
||||
acknowledged.value = false
|
||||
emit('busy', true)
|
||||
try {
|
||||
const result = await layoutApi.confirm(props.projectId, input, confirmedBy.value)
|
||||
if (disposed || identity !== target.value) return
|
||||
if (result.name !== input.name || !result.version || result.version === input.expectedVersion)
|
||||
throw new Error('未取得新的布局版本,请刷新核对,勿重复确认。')
|
||||
confirmed.value = { previous: input.expectedVersion, layout: result }
|
||||
preview.value = null
|
||||
showActionFeedback(message, '布局已确认,请重新核对母版、场景形态和首帧来源。', 'success')
|
||||
emit('changed')
|
||||
} catch (cause) {
|
||||
if (!disposed && identity === target.value) {
|
||||
showActionFeedback(message, errorMessage(cause), 'error')
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
preview.value = null
|
||||
emit('changed')
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
emit('busy', false)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是待审固定结构免费模拟模块,与摄影草案分开 -->
|
||||
<section class="space-y-4">
|
||||
<WorkspaceSectionHeading title="固定结构待审预览" description="这是免费模拟输入,不能直接用于生图。" />
|
||||
<NSelect
|
||||
v-model:value="layoutId"
|
||||
:options="layouts.map(item => ({ label: item.name, value: item.id }))"
|
||||
:disabled="saving"
|
||||
placeholder="选择当前布局"
|
||||
aria-label="待审结构布局"
|
||||
/>
|
||||
<p v-if="layout" class="wrap-anywhere text-xs text-muted">当前布局版本:{{ layout.version }}</p>
|
||||
<NInput
|
||||
v-model:value="instruction"
|
||||
type="textarea"
|
||||
:maxlength="1000"
|
||||
:disabled="saving"
|
||||
placeholder="待审结构约束,例如固定连接位置与活动方向"
|
||||
:input-props="{ 'aria-label': '待审结构约束' }"
|
||||
/>
|
||||
<NInput
|
||||
v-model:value="evidence"
|
||||
type="textarea"
|
||||
:maxlength="1000"
|
||||
:disabled="saving"
|
||||
placeholder="填写人工观察或设计依据"
|
||||
:input-props="{ 'aria-label': '布局结构依据' }"
|
||||
/>
|
||||
<NButton :loading="loading" :disabled="!valid || saving" @click="loadPreview">免费预览结构约束</NButton>
|
||||
<!-- 以下是待审提示词、独立指纹与正式确认参数模块 -->
|
||||
<section v-if="preview" class="space-y-3 text-sm">
|
||||
<p>待审输入不能用于生图;需要确认布局并重新确认母版。</p>
|
||||
<NCollapse>
|
||||
<NCollapseItem name="preview" title="预览画面描述与高级详情">
|
||||
<pre class="whitespace-pre-wrap break-words text-xs">{{ preview.providerPrompt }}</pre>
|
||||
<dl class="mt-3 space-y-2 wrap-anywhere text-xs text-muted">
|
||||
<div>待审指纹:{{ preview.draftFingerprint }}</div>
|
||||
<div>可用于生产:{{ preview.productionReady ? '是' : '否' }}</div>
|
||||
<div>需要布局确认:{{ preview.requiresLayoutConfirmation ? '是' : '否' }}</div>
|
||||
<div>需要母版重新确认:{{ preview.requiresMasterReconfirmation ? '是' : '否' }}</div>
|
||||
</dl>
|
||||
<pre class="mt-3 whitespace-pre-wrap break-words text-xs">{{
|
||||
JSON.stringify(preview.layoutConfirmation, null, 2)
|
||||
}}</pre>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<WorkspaceSectionHeading
|
||||
title="正式布局确认"
|
||||
description="保存会改变布局版本。母版、场景形态及已有首帧需要重新核对,不会自动生成素材。"
|
||||
/>
|
||||
<NInput
|
||||
v-model:value="confirmedBy"
|
||||
:disabled="saving"
|
||||
placeholder="填写真实确认人"
|
||||
:input-props="{ 'aria-label': '布局确认人' }"
|
||||
/>
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="saving || disabled"
|
||||
>我已核对以上完整约束,确认修改正式布局及来源影响</NCheckbox
|
||||
>
|
||||
</section>
|
||||
<!-- 以下是版本变化与最新母版来源影响,不自动生成或替换主图 -->
|
||||
<section v-if="confirmed" class="space-y-2 wrap-anywhere text-sm" role="status">
|
||||
<p class="font-semibold">布局已更新</p>
|
||||
<p class="text-xs">原版本:{{ confirmed.previous }}</p>
|
||||
<p class="text-xs">新版本:{{ confirmed.layout.version }}</p>
|
||||
<p>
|
||||
布局母版:{{
|
||||
layouts
|
||||
.find(item => item.id === confirmed?.layout.id)
|
||||
?.masters.some(
|
||||
master =>
|
||||
master.spatialLayoutVersion === confirmed?.layout.version &&
|
||||
master.status === 'confirmed'
|
||||
)
|
||||
? '已有新版确认记录,仍需核对适用形态'
|
||||
: '需要重新确认'
|
||||
}}
|
||||
</p>
|
||||
<p>场景形态与已有首帧:请查看最新来源核对结果;历史图片和结论仍保留。</p>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
@@ -112,6 +112,10 @@ const provider = ref('')
|
||||
const generationOptions = ref<GenerationOptions>({})
|
||||
/** 后台任务期间表单也保持锁定。 */
|
||||
const pending = computed(() => operation.value.pending || execution.active.value)
|
||||
/** 历史中的独立授权请求期间锁定关闭。 */
|
||||
const authorizationPending = ref(false)
|
||||
/** 候选历史授权表单通过统一底栏明确提交。 */
|
||||
const visionHistoryRef = ref<InstanceType<typeof KeyframeValidationHistory> | null>(null)
|
||||
/** 当前目标的单镜头范围。 */
|
||||
const singleShot = computed(() => props.target?.kind === 'batch' && !!props.target.shotId)
|
||||
/** 质量面板的formRef状态,随目标更新。 */
|
||||
@@ -134,6 +138,17 @@ const height = ref<number | null>(null)
|
||||
const texts = ref('')
|
||||
/** 质量面板的acknowledged状态,随目标更新。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 统一底栏只确认当前实际操作范围,授权操作不重复要求两次确认。 */
|
||||
const footerAcknowledged = computed({
|
||||
get: () =>
|
||||
visionHistoryRef.value?.authorizationAvailable
|
||||
? visionHistoryRef.value.authorizationAcknowledged
|
||||
: acknowledged.value,
|
||||
set: (value: boolean) => {
|
||||
if (visionHistoryRef.value?.authorizationAvailable) visionHistoryRef.value.setAuthorizationAcknowledged(value)
|
||||
else acknowledged.value = value
|
||||
}
|
||||
})
|
||||
/** 质量面板的videoRepair状态,随目标更新。 */
|
||||
const videoRepair = computed(() => props.target?.kind === 'video' && action.value === 'repair')
|
||||
/** 质量面板的input状态,随目标更新。 */
|
||||
@@ -285,7 +300,12 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
|
||||
<template>
|
||||
<!-- 以下是质量操作与显式费用确认模块 -->
|
||||
<AppDialog v-model:open="open" :title="`质量检查 · ${target?.title ?? ''}`" wide>
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
:title="`质量检查 · ${target?.title ?? ''}`"
|
||||
:busy="pending || authorizationPending"
|
||||
wide
|
||||
>
|
||||
<ContextNotice
|
||||
v-if="target?.kind === 'video' && (videoQuery.error.value || videoQuery.data.value?.staleReason)"
|
||||
type="warning"
|
||||
@@ -304,7 +324,7 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
@submit="submit"
|
||||
>
|
||||
<NRadioGroup
|
||||
v-if="target && target.kind !== 'batch'"
|
||||
v-if="target && target.kind !== 'batch' && !visionHistoryRef?.authorizationAvailable"
|
||||
v-model:value="action"
|
||||
:disabled="pending"
|
||||
class="mt-4"
|
||||
@@ -349,7 +369,7 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
>当前候选暂时不能执行这项检查,请查看原因或刷新任务状态。</ContextNotice
|
||||
>
|
||||
<NCollapse
|
||||
v-if="!videoRepair"
|
||||
v-if="!videoRepair && !visionHistoryRef?.authorizationAvailable"
|
||||
v-model:expanded-names="optionsExpanded"
|
||||
display-directive="show"
|
||||
class="mt-4"
|
||||
@@ -418,7 +438,12 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
/>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<ContextNotice type="warning" :show-icon="false" class="mt-4">
|
||||
<ContextNotice
|
||||
v-if="!visionHistoryRef?.authorizationAvailable"
|
||||
type="warning"
|
||||
:show-icon="false"
|
||||
class="mt-4"
|
||||
>
|
||||
<template v-if="videoRepair">最多生成 1 个候选,可能收费。付费复检通过后才会设为主视频。</template>
|
||||
<template v-else-if="target?.kind === 'video'"
|
||||
>本次会检查视频画面,可能使用多个识图模型并产生费用。</template
|
||||
@@ -452,6 +477,7 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
原审核缺少可核对的请求版本,暂不能安全继续。
|
||||
</p>
|
||||
<KeyframeValidationHistory
|
||||
ref="visionHistoryRef"
|
||||
v-if="open && target?.kind === 'keyframe'"
|
||||
:project-id="projectId"
|
||||
:shot-id="target.shotId"
|
||||
@@ -461,6 +487,7 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
:disabled="disabled || pending"
|
||||
initial-open
|
||||
@reviewed="emit('changed')"
|
||||
@busy="authorizationPending = $event"
|
||||
/>
|
||||
<QualityResult v-if="session.receipt" :receipt="session.receipt" @locate="emit('locate', $event)" />
|
||||
<NCollapse v-else-if="saved" class="mt-4" :default-expanded-names="['saved']"
|
||||
@@ -476,13 +503,28 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
<!-- 以下是底栏左侧费用确认与右侧操作按钮模块 -->
|
||||
<template #footer>
|
||||
<div class="quality-dialog-footer">
|
||||
<NCheckbox v-model:checked="acknowledged" :disabled="pending" class="quality-dialog-acknowledgement"
|
||||
>我已确认费用、处理范围,且同项目没有其他生成任务。</NCheckbox
|
||||
<NCheckbox
|
||||
v-model:checked="footerAcknowledged"
|
||||
:disabled="pending || authorizationPending"
|
||||
class="quality-dialog-acknowledgement"
|
||||
>{{
|
||||
visionHistoryRef?.authorizationAvailable
|
||||
? '我已确认授权、费用与本次处理范围,且同项目没有其他生成任务。'
|
||||
: '我已确认费用、处理范围,且同项目没有其他生成任务。'
|
||||
}}</NCheckbox
|
||||
>
|
||||
<div class="quality-dialog-actions">
|
||||
<NButton @click="open = false">关闭</NButton>
|
||||
<NButton :disabled="pending || authorizationPending" @click="open = false">关闭</NButton>
|
||||
<NButton
|
||||
v-if="vision.state.value.resumable"
|
||||
v-if="visionHistoryRef?.authorizationAvailable"
|
||||
type="primary"
|
||||
:loading="authorizationPending"
|
||||
:disabled="blocked || !visionHistoryRef.authorizationReady"
|
||||
@click="visionHistoryRef.submitAuthorization()"
|
||||
>{{ visionHistoryRef.authorizationLabel }}</NButton
|
||||
>
|
||||
<NButton
|
||||
v-else-if="vision.state.value.resumable"
|
||||
type="primary"
|
||||
:loading="pending"
|
||||
:disabled="
|
||||
|
||||
@@ -6,6 +6,7 @@ import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { computed } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { downloadText } from '../../../lib/format'
|
||||
import { keyframeValidationPassed } from '../quality'
|
||||
import type { QualityReceipt } from '../quality.types'
|
||||
|
||||
/** 摘要、失败与完整逐轮信息默认直接显示,不用完成请求冒充质量通过。 */
|
||||
@@ -18,7 +19,9 @@ const passed = computed(() =>
|
||||
? props.receipt.result.targetCount > 0 && props.receipt.result.passed === props.receipt.result.targetCount
|
||||
: props.receipt.kind === 'video-repair'
|
||||
? false
|
||||
: props.receipt.result.passed
|
||||
: props.receipt.kind === 'keyframe'
|
||||
? keyframeValidationPassed(props.receipt.result)
|
||||
: props.receipt.result.passed
|
||||
)
|
||||
/** 当前失败问题列表。 */
|
||||
const issues = computed(() => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import IssueHint from '../../../components/ui/IssueHint.vue'
|
||||
import { useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
import ProviderInputInspector from './ProviderInputInspector.vue'
|
||||
import { NButton, NCollapse, NCollapseItem, NSelect, NTag } from 'naive-ui'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { ImagePlus, RefreshCw } from '@lucide/vue'
|
||||
import { AssetImage } from '../../../components/ui'
|
||||
@@ -360,6 +360,10 @@ const historyBlocked = computed(() => {
|
||||
})
|
||||
/** 首帧校验历史弹窗的显示状态。 */
|
||||
const historyOpen = ref(false)
|
||||
/** 历史授权提交期间锁定记录弹窗。 */
|
||||
const historyAuthorizationPending = ref(false)
|
||||
/** 记录弹窗在统一底栏提交独立审核授权。 */
|
||||
const visionHistoryRef = ref<InstanceType<typeof KeyframeValidationHistory> | null>(null)
|
||||
/**
|
||||
* 打开指定首帧的校验历史,供主首帧与候选卡片共用。
|
||||
* @param keyframeId 需要查看历史的首帧 ID
|
||||
@@ -576,7 +580,13 @@ async function setPrimaryKeyframe() {
|
||||
qualityApi.keyframeHistory(shotId, keyframeId, undefined, props.projectId)
|
||||
])
|
||||
const vision = visionState(history)
|
||||
if (vision.active || vision.unknown || vision.resumable) throw new Error('审核尚未结算,暂不能设为主首帧。')
|
||||
if (
|
||||
vision.active ||
|
||||
vision.unknown ||
|
||||
vision.resumable ||
|
||||
history.some(item => item.id === review.validationTaskId && item.legacyTermination)
|
||||
)
|
||||
throw new Error('审核尚未结算,暂不能设为主首帧。')
|
||||
if (!['passed', 'manual_accepted'].includes(review.effectiveQualityStatus))
|
||||
throw new Error('此候选尚未通过当前质量要求,请先完成质量检查或有效人工复核。')
|
||||
const result = await productionApi.setPrimaryKeyframe(shotId, keyframeId)
|
||||
@@ -1145,19 +1155,39 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
:stale-reason="videoHistoryId === currentVideo?.id ? videoStaleReason : videoHistoryAsset?.staleReason"
|
||||
/>
|
||||
</AppDialog>
|
||||
<AppDialog v-model:open="historyOpen" title="首帧记录" wide>
|
||||
<AppDialog v-model:open="historyOpen" title="首帧记录" :busy="historyAuthorizationPending" wide>
|
||||
<div v-if="historyOpen && historyKeyframeId" :key="historyKeyframeId" class="workspace-section-stack">
|
||||
<!-- 以下是按需读取的候选生成证据 -->
|
||||
<KeyframeInputDetails :project-id="projectId" :shot-id="shot.shotId" :keyframe-id="historyKeyframeId" />
|
||||
<KeyframeValidationHistory
|
||||
ref="visionHistoryRef"
|
||||
:project-id="projectId"
|
||||
:shot-id="shot.shotId"
|
||||
:keyframe-id="historyKeyframeId"
|
||||
:disabled="historyBlocked"
|
||||
@busy="historyAuthorizationPending = $event"
|
||||
initial-open
|
||||
@reviewed="refreshAfterReview"
|
||||
/>
|
||||
</div>
|
||||
<template #footer>
|
||||
<NCheckbox
|
||||
v-if="visionHistoryRef?.authorizationAvailable"
|
||||
:checked="visionHistoryRef.authorizationAcknowledged"
|
||||
:disabled="historyAuthorizationPending"
|
||||
@update:checked="visionHistoryRef.setAuthorizationAcknowledged($event)"
|
||||
>我已确认授权、费用与本次处理范围</NCheckbox
|
||||
>
|
||||
<NButton :disabled="historyAuthorizationPending" @click="historyOpen = false">关闭</NButton
|
||||
><NButton
|
||||
v-if="visionHistoryRef?.authorizationAvailable"
|
||||
type="primary"
|
||||
:loading="historyAuthorizationPending"
|
||||
:disabled="!visionHistoryRef.authorizationReady"
|
||||
@click="visionHistoryRef.submitAuthorization()"
|
||||
>{{ visionHistoryRef.authorizationLabel }}</NButton
|
||||
></template
|
||||
>
|
||||
</AppDialog>
|
||||
<KeyframeDialog
|
||||
v-model:open="keyframeOpen"
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
import { request } from '../../lib/http'
|
||||
import type { ContinuityDiagnosis, ContinuityInput, ContinuityObservation, ContinuityReview } from './continuity.types'
|
||||
|
||||
/**
|
||||
* 校验选择属于同集正式顺序的相邻两到三镜。
|
||||
* @param selected 已选顺序
|
||||
* @param ordered 当前集完整顺序
|
||||
* @returns 是否可以提交诊断
|
||||
*/
|
||||
export function continuitySelectionValid(selected: string[], ordered: string[]) {
|
||||
const start = ordered.indexOf(selected[0] ?? '')
|
||||
return (
|
||||
selected.length >= 2 &&
|
||||
selected.length <= 3 &&
|
||||
start >= 0 &&
|
||||
selected.every((id, i) => ordered[start + i] === id) &&
|
||||
new Set(selected).size === selected.length
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交时校验逐镜观察,无法判断使用真实 unknown/null,不猜测证据。
|
||||
* @param observation 人工观察
|
||||
* @param shotIds 正式镜头顺序
|
||||
* @returns 是否满足正式 Schema
|
||||
*/
|
||||
export function validObservation(observation: ContinuityObservation | null, shotIds: string[]) {
|
||||
return (
|
||||
!!observation &&
|
||||
/^[a-f0-9]{64}$/.test(observation.expectedFingerprint) &&
|
||||
observation.landmarks.every(item => !!item.trim() && item.trim().length <= 120) &&
|
||||
observation.landmarks[0].trim() !== observation.landmarks[1].trim() &&
|
||||
observation.frames.length === shotIds.length &&
|
||||
observation.frames.every(
|
||||
(frame, i) =>
|
||||
frame.shotId === shotIds[i] &&
|
||||
!!frame.evidence.trim() &&
|
||||
frame.evidence.trim().length <= 500 &&
|
||||
frame.features.length > 0 &&
|
||||
frame.features.length <= 24 &&
|
||||
new Set(frame.features.map(item => item.key.trim())).size === frame.features.length &&
|
||||
frame.features.every(
|
||||
item =>
|
||||
!!item.key.trim() &&
|
||||
item.key.trim().length <= 120 &&
|
||||
!!item.evidence.trim() &&
|
||||
item.evidence.trim().length <= 500 &&
|
||||
(item.side !== undefined) !== (item.count !== undefined) &&
|
||||
(item.count === undefined ||
|
||||
item.count === null ||
|
||||
(Number.isInteger(item.count) && item.count >= 0 && item.count <= 100))
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/** 公共诊断状态中文,不将证据不足表现为通过。 */
|
||||
export const continuityStatusLabels: Record<string, string> = {
|
||||
passed: '通过',
|
||||
failed: '未通过',
|
||||
needs_review: '待人工复核',
|
||||
insufficient_evidence: '证据不足',
|
||||
stale: '已失效'
|
||||
}
|
||||
/** 历史失效原因只在展示层转为中文。 */
|
||||
export const continuityInvalidationLabels: Record<string, string> = {
|
||||
primary_changed: '主首帧已变化',
|
||||
evidence_changed: '正式来源、布局或审核证据已变化',
|
||||
current_evidence_unavailable: '当前证据不足',
|
||||
group_scope_changed: '镜头或场景范围已变化'
|
||||
}
|
||||
/**
|
||||
* 项目连续性接口路径。
|
||||
* @param projectId 正式项目
|
||||
* @returns 同项目路径
|
||||
*/
|
||||
function path(projectId: string) {
|
||||
return `/projects/${encodeURIComponent(projectId)}/storyboard-keyframes/continuity`
|
||||
}
|
||||
/** 连续性只读诊断与独立审核记录,不修改 Primary。 */
|
||||
export const continuityApi = {
|
||||
/**
|
||||
* 免费读取诊断或消费人工观察。
|
||||
* @param projectId 项目范围
|
||||
* @param input 正式镜头和本次指纹
|
||||
* @param signal 取消失效查询
|
||||
* @returns 诊断结果
|
||||
*/
|
||||
diagnose: (projectId: string, input: ContinuityInput, signal?: AbortSignal) =>
|
||||
request<ContinuityDiagnosis>(`${path(projectId)}/diagnosis`, {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
signal,
|
||||
timeoutMs: 0
|
||||
}),
|
||||
/**
|
||||
* 保存本次明确审核,重复参数由服务端幂等复用。
|
||||
* @param projectId 项目范围
|
||||
* @param input 本次观察指纹和真实审核人
|
||||
* @returns 不可变审核记录
|
||||
*/
|
||||
save: (projectId: string, input: ContinuityInput & { reviewer: string }) =>
|
||||
request<ContinuityReview>(`${path(projectId)}/reviews`, { method: 'POST', body: input, timeoutMs: 0 }),
|
||||
/**
|
||||
* 回读原始结论及当前失效原因。
|
||||
* @param projectId 项目范围
|
||||
* @param reviewId 正式审核编号
|
||||
* @param signal 取消过期读取
|
||||
* @returns 历史审核与当前性
|
||||
*/
|
||||
review: (projectId: string, reviewId: string, signal?: AbortSignal) =>
|
||||
request<ContinuityReview>(`${path(projectId)}/reviews/${encodeURIComponent(reviewId)}`, {
|
||||
signal,
|
||||
timeoutMs: 0
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import type { SpatialLayoutConstraint } from './layout-api'
|
||||
import type { ShotDirection } from '../storyboard/types'
|
||||
|
||||
/** 固定几何诊断公开状态,执行完成与质量通过分开。 */
|
||||
export type ContinuityStatus = 'passed' | 'failed' | 'needs_review' | 'insufficient_evidence' | 'stale'
|
||||
/** 单个固定结构的位置或数量观察,不能记录开关状态。 */
|
||||
export interface GeometryFeature {
|
||||
/** 跨镜一致的结构名称。 */ key: string
|
||||
/** 局部画面方位,与数量互斥。 */ side?: 'left' | 'right' | 'unknown'
|
||||
/** 完整可辨认的数量,无法判断为 null。 */ count?: number | null
|
||||
/** 人工看到的像素证据。 */ evidence: string
|
||||
}
|
||||
/** 当前镜头的人工观察面和地标顺序。 */
|
||||
export interface GeometryFrameObservation {
|
||||
/** 正式镜头编号。 */ shotId: string
|
||||
/** 相对布局的观察面。 */ view: 'same_side' | 'opposite_side' | 'unknown'
|
||||
/** 固定地标相对布局顺序。 */ landmarkOrder: 'as_layout' | 'reversed' | 'unknown'
|
||||
/** 机位和地标的观察依据。 */ evidence: string
|
||||
/** 固定结构方位或数量。 */ features: GeometryFeature[]
|
||||
}
|
||||
/** 绑定本次正式图组指纹的人工观察。 */
|
||||
export interface ContinuityObservation {
|
||||
/** 最近一次诊断证据指纹。 */ expectedFingerprint: string
|
||||
/** 两个不同的稳定地标。 */ landmarks: [string, string]
|
||||
/** 按正式镜头顺序逐镜观察。 */ frames: GeometryFrameObservation[]
|
||||
}
|
||||
/** 同一场景形态下的相邻两到三镜请求。 */
|
||||
export interface ContinuityInput {
|
||||
/** 正式顺序的镜头编号。 */ shotIds: string[]
|
||||
/** 正式场景形态编号。 */ sceneFormId: string
|
||||
/** 第二次诊断时提交,不自动生成。 */ observation?: ContinuityObservation
|
||||
}
|
||||
/** 可定位的结构冲突或证据不足。 */
|
||||
export interface ContinuityIssue {
|
||||
/** 原始业务代码。 */ code: string
|
||||
/** 涉及镜头编号。 */ shotIds: string[]
|
||||
/** 固定结构名称。 */ featureKey?: string
|
||||
/** 可读问题。 */ message: string
|
||||
}
|
||||
/** 当前 Primary 与正式来源的公开诊断切片。 */
|
||||
export interface ContinuityFrame {
|
||||
/** 镜头编号。 */ shotId: string
|
||||
/** 正式集数。 */ episodeNo: number
|
||||
/** 段落序号。 */ beatNo: number
|
||||
/** 镜头序号。 */ shotNo: number
|
||||
/** 正式摄影设计。 */ direction: ShotDirection
|
||||
/** 当前场景绑定。 */ scene: {
|
||||
/** 主体编号。 */ subjectId: string
|
||||
/** 主体引用。 */ subjectRef: string
|
||||
/** 场景形态编号。 */ formId: string
|
||||
/** 当前位置。 */ position: string
|
||||
/** 即时状态,不参与固定结构数量判断。 */ transientState: string
|
||||
}
|
||||
/** 当前主首帧编号。 */ primaryId: string | null
|
||||
/** 当前原图。 */ imageUrl?: string
|
||||
/** 原图宽度。 */ width?: number
|
||||
/** 原图高度。 */ height?: number
|
||||
/** 此镜证据状态。 */ status: ContinuityStatus
|
||||
/** 当前性问题说明。 */ reason?: string
|
||||
/** 正式来源指纹。 */ formalSourceFingerprint?: string
|
||||
/** 实际输入指纹。 */ providerInputFingerprint?: string
|
||||
/** 审核任务编号。 */ validationTaskId?: string
|
||||
/** 当前工作流执行编号。 */ workflowExecutionId?: string | null
|
||||
/** 所用布局母版或机位参考,保留公开原始证据。 */ layoutReferences?: Array<{
|
||||
/** 参考图片编号。 */ imageId: string
|
||||
/** 参考图片地址。 */ imageUrl: string
|
||||
/** 参考职责。 */ role: string
|
||||
/** 正式布局编号。 */ spatialLayoutId?: string
|
||||
/** 所用布局版本。 */ spatialLayoutVersion?: string
|
||||
}>
|
||||
}
|
||||
/** 免费诊断结果,不修改单镜质量和 Primary。 */
|
||||
export interface ContinuityDiagnosis {
|
||||
/** 项目归属。 */ projectId: string
|
||||
/** 场景形态范围。 */ sceneFormId: string
|
||||
/** 当前图组。 */ frames: ContinuityFrame[]
|
||||
/** 本次来源指纹,证据不足时为空。 */ fingerprint: string | null
|
||||
/** 当前共同布局。 */ layout: {
|
||||
/** 布局编号。 */ id: string
|
||||
/** 布局名称。 */ name: string
|
||||
/** 当前版本。 */ version: string
|
||||
/** 布局证据。 */ evidence: string
|
||||
/** 正式约束。 */ constraints: SpatialLayoutConstraint[]
|
||||
} | null
|
||||
/** 已消费的人工观察。 */ observation: ContinuityObservation | null
|
||||
/** 实际诊断结论。 */ status: ContinuityStatus
|
||||
/** 当前范围的问题。 */ issues: ContinuityIssue[]
|
||||
}
|
||||
/** 持久化审核独立保留原始结论和当前失效信息。 */
|
||||
export interface ContinuityReview {
|
||||
/** 正式审核编号。 */ reviewId: string
|
||||
/** 真实审核人。 */ reviewer: string
|
||||
/** 审核时间。 */ reviewedAt: string
|
||||
/** 当前结论,失效不覆盖原诊断。 */ status: ContinuityStatus
|
||||
/** 当前失效原因。 */ invalidation: {
|
||||
/** 失效业务分类。 */ code: string
|
||||
/** 当前问题。 */ issues: ContinuityIssue[]
|
||||
} | null
|
||||
/** 保存时的不可变原始诊断。 */ diagnosis: ContinuityDiagnosis
|
||||
}
|
||||
@@ -3,9 +3,10 @@ import { useQuery } from '../../composables/useQuery'
|
||||
import { ApiError } from '../../lib/http'
|
||||
import type { WorkflowExecution } from '../workflows/execution.types'
|
||||
import { workflowExecutionApi } from '../workflows/execution-api'
|
||||
import { rememberVisionExecutions, type ObservedVisionExecution } from './vision-execution-history'
|
||||
import { qualityApi } from './quality-api'
|
||||
import { isVisualValidation } from './quality'
|
||||
import type { KeyframeValidationHistoryItem, ResumeKeyframeValidation } from './quality.types'
|
||||
import type { KeyframeValidationHistoryItem, ResumeKeyframeValidation, KeyframeVisionInput } from './quality.types'
|
||||
|
||||
/** 当前候选的最近一次客户端提交,用于断线后只读恢复。 */
|
||||
interface Submission {
|
||||
@@ -19,6 +20,8 @@ interface Submission {
|
||||
executionId?: string
|
||||
/** 已明确结算,可解除断线保护。 */
|
||||
settled?: boolean
|
||||
/** 已受理的明确授权范围,用于刷新后恢复说明。 */
|
||||
mode?: 'physical' | 'independent'
|
||||
}
|
||||
|
||||
/** 同一窗口内的各入口共享候选提交状态。 */
|
||||
@@ -62,14 +65,40 @@ function saveSubmission(key: string, value?: Submission) {
|
||||
* @returns 与写入安全相关的当前记录
|
||||
*/
|
||||
export function visionState(records: KeyframeValidationHistoryItem[]) {
|
||||
const active = records.find(item => item.status === 'pending' || item.status === 'running')
|
||||
const unknown = records.find(
|
||||
item => item.recoveryRequired ?? (item.status === 'failed' && visionOutput(item).recoveryRequired !== false)
|
||||
)
|
||||
const resumable = records.find(
|
||||
item => item.status === 'failed' && (item.resumeAvailable ?? visionOutput(item).resumeAvailable) === true
|
||||
)
|
||||
return { active, unknown, resumable }
|
||||
const eligible = records.filter(item => !item.legacyTermination)
|
||||
const latest = eligible[0]
|
||||
const active = eligible.find(item => item.status === 'pending' || item.status === 'running')
|
||||
const unknown =
|
||||
latest &&
|
||||
(latest.recoveryRequired ?? (latest.status === 'failed' && visionOutput(latest).recoveryRequired !== false))
|
||||
? latest
|
||||
: undefined
|
||||
const resumable =
|
||||
latest?.status === 'failed' && (latest.resumeAvailable ?? visionOutput(latest).resumeAvailable) === true
|
||||
? latest
|
||||
: undefined
|
||||
const terminated = records.find(item => item.legacyTermination)
|
||||
return { active, unknown, resumable, terminated }
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据公开证据提供单步授权入口,实际通用通过和计费证据由服务再次核对。
|
||||
* @param records 当前候选审核历史
|
||||
* @returns 最近可核对的物理失败任务
|
||||
*/
|
||||
export function physicalRetryTarget(records: KeyframeValidationHistoryItem[]) {
|
||||
const task = records.find(item => !item.legacyTermination)
|
||||
if (task?.status !== 'failed' || !task.requestFingerprint || !/^[a-f0-9]{64}$/.test(task.requestFingerprint))
|
||||
return undefined
|
||||
const general = task.steps?.find(step => step.name === 'general')
|
||||
const physical = task.steps?.find(step => step.name === 'physical')
|
||||
return task.steps?.length === 2 &&
|
||||
general?.status === 'completed' &&
|
||||
general.issues?.every(issue => issue.severity !== 'error') &&
|
||||
physical?.status === 'failed' &&
|
||||
physical.usage
|
||||
? task
|
||||
: undefined
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,15 +135,30 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
/** 旧版活跃记录没有执行编号,仍只能观察和核查。 */
|
||||
const executionKey = computed(() =>
|
||||
observeExecution
|
||||
? (state.value.active?.executionId ??
|
||||
(submission.value?.settled ? '' : submission.value?.executionId) ??
|
||||
? ((submission.value?.settled ? undefined : submission.value?.executionId) ??
|
||||
history.data.value?.find(item => !item.legacyTermination)?.executionId ??
|
||||
'')
|
||||
: ''
|
||||
)
|
||||
/** 只读取执行状态,不展示工作流内部原始结果。 */
|
||||
const execution = useQuery(executionKey, (id, signal) =>
|
||||
id ? workflowExecutionApi.get(id, signal) : Promise.resolve(null)
|
||||
/** 将项目范围包含在查询键内,同编号跨项目也会关闭旧连接。 */
|
||||
const scopedExecutionKey = computed(() =>
|
||||
executionKey.value ? JSON.stringify([key.value, executionKey.value]) : ''
|
||||
)
|
||||
/** 只读取当前项目的正式执行,拒绝不同归属的响应。 */
|
||||
const execution = useQuery(scopedExecutionKey, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [target, id] = JSON.parse(value) as [string, string]
|
||||
const [shotId, keyframeId, projectId] = JSON.parse(target) as [string, string, string?]
|
||||
const record = await workflowExecutionApi.get(id, signal, projectId)
|
||||
if (
|
||||
record.id !== id ||
|
||||
(projectId && record.projectId !== projectId) ||
|
||||
(record.metadata?.shotId && record.metadata.shotId !== shotId) ||
|
||||
(record.metadata?.keyframeId && record.metadata.keyframeId !== keyframeId)
|
||||
)
|
||||
throw new Error('审核执行与当前项目或候选不匹配。')
|
||||
return record
|
||||
})
|
||||
/** 未明确结算的断线状态禁止再次写入。 */
|
||||
const uncertain = computed(() => !!submission.value && !submission.value.settled && !state.value.active)
|
||||
/** 继续完全依赖同一条正式历史的任务和指纹。 */
|
||||
@@ -131,28 +175,39 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
!!history.error.value ||
|
||||
!!state.value.active ||
|
||||
!!state.value.unknown ||
|
||||
uncertain.value
|
||||
uncertain.value ||
|
||||
(!!state.value.terminated && !history.data.value?.some(item => !item.legacyTermination))
|
||||
)
|
||||
/** SSE 断开时回到只读轮询。 */
|
||||
let live = false
|
||||
watch(
|
||||
executionKey,
|
||||
(id, _, onCleanup) => {
|
||||
scopedExecutionKey,
|
||||
(value, _, onCleanup) => {
|
||||
const [target, id] = value ? (JSON.parse(value) as [string, string]) : ['', '']
|
||||
const projectId = target ? (JSON.parse(target) as [string, string, string?])[2] : undefined
|
||||
live = false
|
||||
if (!id || typeof EventSource === 'undefined') return
|
||||
const source = new EventSource(workflowExecutionApi.executionEventsUrl(id))
|
||||
const source = new EventSource(workflowExecutionApi.executionEventsUrl(id, projectId))
|
||||
onCleanup(() => {
|
||||
source.close()
|
||||
live = false
|
||||
})
|
||||
source.addEventListener('message', event => {
|
||||
if (id !== executionKey.value) return
|
||||
if (value !== scopedExecutionKey.value) return
|
||||
try {
|
||||
const payload = JSON.parse(event.data) as
|
||||
| WorkflowExecution
|
||||
| { done: true; result?: WorkflowExecution }
|
||||
const record = 'done' in payload ? payload.result : payload
|
||||
if (!record || record.id !== id) return
|
||||
if (!record || record.id !== id || (projectId && record.projectId !== projectId)) return
|
||||
if (record.workflowName !== 'shot-keyframe-validation') return
|
||||
const known = execution.data.value
|
||||
if (
|
||||
known?.id === record.id &&
|
||||
(['completed', 'failed'].includes(known.status) ||
|
||||
Date.parse(known.updatedAt) > Date.parse(record.updatedAt))
|
||||
)
|
||||
return
|
||||
live = true
|
||||
execution.data.value = record
|
||||
if (!history.loading.value) void history.refresh()
|
||||
@@ -163,12 +218,18 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
})
|
||||
source.addEventListener('error', () => {
|
||||
live = false
|
||||
source.close()
|
||||
})
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(history.data, records => {
|
||||
if (records && key.value)
|
||||
rememberVisionExecutions(
|
||||
key.value,
|
||||
records.flatMap(item => (item.executionId ? [{ taskId: item.id, executionId: item.executionId }] : []))
|
||||
)
|
||||
const saved = submission.value
|
||||
if (!records || !saved || saved.settled) return
|
||||
const latest = records[0]
|
||||
@@ -177,9 +238,21 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
: latest && (latest.id !== saved.before || latest.executionId !== saved.beforeExecutionId)
|
||||
? latest
|
||||
: undefined
|
||||
if (!found || !['failed', 'completed'].includes(found.status)) return
|
||||
if (saved.executionId && found.executionId !== saved.executionId) return
|
||||
saveSubmission(key.value, { ...saved, settled: true, taskId: found.id })
|
||||
if (!found) return
|
||||
const finished = !!found.legacyTermination || ['failed', 'completed'].includes(found.status)
|
||||
if (saved.executionId && found.executionId !== saved.executionId && !found.legacyTermination) {
|
||||
// 原执行的迟到快照不能结算新提交;其它正式新执行替换旧观察句柄。
|
||||
if (!found.executionId || found.executionId === saved.beforeExecutionId) return
|
||||
saveSubmission(key.value, {
|
||||
...saved,
|
||||
executionId: found.executionId,
|
||||
mode: undefined,
|
||||
settled: finished,
|
||||
taskId: found.id
|
||||
})
|
||||
return
|
||||
}
|
||||
if (finished) saveSubmission(key.value, { ...saved, settled: true, taskId: found.id })
|
||||
})
|
||||
|
||||
const timer = setInterval(() => {
|
||||
@@ -189,7 +262,41 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
}
|
||||
}, 2500)
|
||||
onScopeDispose(() => clearInterval(timer))
|
||||
return { history, state, execution, uncertain, blocked, resume }
|
||||
/** 公开最新任务与本机已知的多次执行,读取不提交审核。 */
|
||||
const observedExecutions = ref<ObservedVisionExecution[]>([])
|
||||
watch(
|
||||
[history.data, execution.data, key],
|
||||
([records, current, target]) => {
|
||||
observedExecutions.value = target
|
||||
? rememberVisionExecutions(
|
||||
target,
|
||||
(records ?? []).flatMap(item =>
|
||||
item.executionId
|
||||
? [
|
||||
{
|
||||
taskId: item.id,
|
||||
executionId: item.executionId,
|
||||
...(current?.id === item.executionId ? { status: current.status } : {})
|
||||
}
|
||||
]
|
||||
: []
|
||||
)
|
||||
)
|
||||
: []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/** 本机已提交且仍对应当前正式任务的授权范围。 */
|
||||
const submissionMode = computed(() => {
|
||||
const saved = submission.value
|
||||
const latest = history.data.value?.find(item => !item.legacyTermination)
|
||||
return saved?.taskId &&
|
||||
latest?.id === saved.taskId &&
|
||||
(!latest.executionId || latest.executionId === saved.executionId)
|
||||
? saved.mode
|
||||
: undefined
|
||||
})
|
||||
return { history, state, execution, uncertain, blocked, resume, observedExecutions, submissionMode }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,26 +311,50 @@ export function useKeyframeVision(key: Ref<string>, observeExecution = true) {
|
||||
export async function submitKeyframeVision(
|
||||
shotId: string,
|
||||
assetId: string,
|
||||
input: string[] | ResumeKeyframeValidation,
|
||||
input: KeyframeVisionInput,
|
||||
records: KeyframeValidationHistoryItem[],
|
||||
projectId?: string
|
||||
) {
|
||||
const key = JSON.stringify(projectId ? [shotId, assetId, projectId] : [shotId, assetId])
|
||||
const previous = readSubmission(key)
|
||||
const current = visionState(records)
|
||||
if (current.active || current.unknown || (previous && !previous.settled))
|
||||
const independent = !Array.isArray(input) && 'legacyVisionAuthorizationId' in input
|
||||
const physical = !Array.isArray(input) && 'physicalRetryAuthorizationId' in input
|
||||
const physicalTask = physicalRetryTarget(records)
|
||||
if (
|
||||
current.active ||
|
||||
(current.unknown && !(physical && physicalTask?.id === current.unknown.id)) ||
|
||||
(previous && !previous.settled)
|
||||
)
|
||||
throw new Error('已有审核或费用待核查,请查看审核记录。')
|
||||
if (Array.isArray(input)) {
|
||||
if (independent) {
|
||||
if (!current.terminated || !input.legacyVisionAuthorizationId.trim() || Object.keys(input).length !== 1)
|
||||
throw new Error('请单独填写新审核授权编号。')
|
||||
} else if (Array.isArray(input)) {
|
||||
if (current.terminated && !records.some(item => !item.legacyTermination))
|
||||
throw new Error('历史审核已终止,需要独立新授权。')
|
||||
if (current.resumable) throw new Error('有可继续的审核,请通过继续原审核操作处理。')
|
||||
} else if (
|
||||
!current.resumable ||
|
||||
current.resumable.id !== input.resumeValidationTaskId ||
|
||||
current.resumable.requestFingerprint !== input.expectedRequestFingerprint ||
|
||||
!/^[a-f0-9]{64}$/.test(input.expectedRequestFingerprint)
|
||||
) {
|
||||
throw new Error('原审核参数或任务状态已变化,请刷新记录。')
|
||||
} else {
|
||||
const task = physical ? physicalTask : current.resumable
|
||||
if (
|
||||
!task ||
|
||||
task.id !== input.resumeValidationTaskId ||
|
||||
task.requestFingerprint !== input.expectedRequestFingerprint ||
|
||||
!/^[a-f0-9]{64}$/.test(input.expectedRequestFingerprint) ||
|
||||
(physical && !input.physicalRetryAuthorizationId.trim()) ||
|
||||
Object.keys(input).some(
|
||||
field =>
|
||||
![
|
||||
'resumeValidationTaskId',
|
||||
'expectedRequestFingerprint',
|
||||
...(physical ? ['physicalRetryAuthorizationId'] : [])
|
||||
].includes(field)
|
||||
)
|
||||
)
|
||||
throw new Error('原审核参数或任务状态已变化,请刷新记录。')
|
||||
}
|
||||
const pending: Submission = {
|
||||
...(physical ? { mode: 'physical' as const } : independent ? { mode: 'independent' as const } : {}),
|
||||
before: records[0]?.id ?? null,
|
||||
beforeExecutionId: records[0]?.executionId
|
||||
}
|
||||
@@ -233,6 +364,12 @@ export async function submitKeyframeVision(
|
||||
if (result.shotId !== shotId || result.keyframeId !== assetId || !result.validationTaskId)
|
||||
throw new Error('审核回执与当前候选不一致,请刷新审核记录。')
|
||||
if ('executionId' in result && result.status === 'pending' && result.executionId) {
|
||||
rememberVisionExecutions(key, [
|
||||
...records.flatMap(item =>
|
||||
item.executionId ? [{ taskId: item.id, executionId: item.executionId }] : []
|
||||
),
|
||||
{ taskId: result.validationTaskId, executionId: result.executionId, status: 'pending' }
|
||||
])
|
||||
saveSubmission(key, { ...pending, taskId: result.validationTaskId, executionId: result.executionId })
|
||||
return null
|
||||
}
|
||||
@@ -259,7 +396,7 @@ export async function submitKeyframeVision(
|
||||
throw new Error('原审核结果或费用待核查,请查看审核记录。', { cause })
|
||||
}
|
||||
saveSubmission(key, previous)
|
||||
throw new Error('候选或审核输入可能已变化,请刷新正式候选后核对。', { cause })
|
||||
throw cause
|
||||
}
|
||||
if (cause instanceof ApiError && cause.status >= 400 && cause.status < 500) saveSubmission(key, previous)
|
||||
throw cause
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import { request } from '../../lib/http'
|
||||
import { keyframeScope } from './keyframe-scope'
|
||||
import type { KeyframeGenerationPreview } from './types'
|
||||
|
||||
/** 待确认固定结构,不能与摄影草案混用。 */
|
||||
export interface LayoutSupplement {
|
||||
/** 正式布局编号。 */ layoutId: string
|
||||
/** 当前布局版本。 */ expectedVersion: string
|
||||
/** 布局内正式场景主体。 */ sceneSubjectId: string
|
||||
/** 待确认固定结构约束。 */ instruction: string
|
||||
/** 人工观察或设计依据。 */ evidence: string
|
||||
}
|
||||
/** 正式共享布局中的构图或固定结构规则。 */
|
||||
export interface SpatialCompositionRule {
|
||||
/** 规则关联主体。 */ subjectId: string
|
||||
/** 可选的参照主体。 */ referenceSubjectId?: string
|
||||
/** 结构、比例、摆放、取景或功能细节。 */ kind:
|
||||
| 'structural-connection'
|
||||
| 'relative-scale'
|
||||
| 'placement'
|
||||
| 'framing'
|
||||
| 'functional-detail'
|
||||
/** 结构要求。 */ requirement: string
|
||||
/** 人工验收依据。 */ acceptance: string
|
||||
}
|
||||
/** 原有空间约束与本次新增约束共用正式 Schema。 */
|
||||
export interface SpatialLayoutConstraint {
|
||||
/** 物理空间关系类别。 */ kind: 'attachment' | 'connection' | 'proximity' | 'surface-region' | 'orientation'
|
||||
/** 完整约束说明。 */ description: string
|
||||
/** 同项目适用场景或道具。 */ subjectIds: string[]
|
||||
/** 剧本事实与人工美术设计明确区分。 */ source: 'script' | 'art-direction'
|
||||
/** 确认后供首帧使用的固定结构指令。 */ keyframeInstruction?: string
|
||||
/** 原有完整构图规则。 */ compositionRules?: SpatialCompositionRule[]
|
||||
}
|
||||
/** Preview 返回的完整正式确认参数,必须原样保留已有约束。 */
|
||||
export interface LayoutConfirmation {
|
||||
/** 原布局名称。 */ name: string
|
||||
/** 适用场景主体。 */ sceneSubjectIds: string[]
|
||||
/** 完整原约束及新增约束,保持后端返回原值。 */ constraints: SpatialLayoutConstraint[]
|
||||
/** 完整来源依据。 */ evidence: string
|
||||
/** 乐观锁版本。 */ expectedVersion: string
|
||||
}
|
||||
/** 待审模拟结果与正式执行指纹隔离。 */
|
||||
export interface LayoutSupplementPreview extends Omit<KeyframeGenerationPreview, 'previewFingerprint'> {
|
||||
/** 不可用于生成的待审指纹。 */ draftFingerprint: string
|
||||
/** 正式确认所需原始参数。 */ layoutConfirmation: LayoutConfirmation
|
||||
/** 待审输入不能直接生图。 */ productionReady: false
|
||||
/** 必须正式确认布局。 */ requiresLayoutConfirmation: true
|
||||
/** 必须复核布局母版。 */ requiresMasterReconfirmation: true
|
||||
}
|
||||
/** 正式确认后返回的当前布局。 */
|
||||
export interface ConfirmedLayout extends Omit<LayoutConfirmation, 'expectedVersion'> {
|
||||
/** 正式布局编号。 */ id: string
|
||||
/** 新布局版本。 */ version: string
|
||||
/** 真实确认人。 */ confirmedBy: string
|
||||
}
|
||||
/** 免费预览和显式正式确认,不包含生成入口。 */
|
||||
export const layoutApi = {
|
||||
/**
|
||||
* 免费编译固定结构模拟输入。
|
||||
* @param projectId 当前项目
|
||||
* @param shotId 正式镜头
|
||||
* @param layoutSupplement 待审结构
|
||||
* @param signal 取消失效预览
|
||||
* @returns 无正式执行指纹的待审输入
|
||||
*/
|
||||
preview: (projectId: string, shotId: string, layoutSupplement: LayoutSupplement, signal?: AbortSignal) =>
|
||||
request<LayoutSupplementPreview>(
|
||||
keyframeScope(`/storyboard-shots/${encodeURIComponent(shotId)}/keyframe/preview`, projectId),
|
||||
{ method: 'POST', body: { layoutSupplement }, signal, timeoutMs: 0 }
|
||||
),
|
||||
/**
|
||||
* 使用本次返回的确认参数,仅补充真实确认人。
|
||||
* @param projectId 当前项目
|
||||
* @param confirmation 本次预览返回的完整参数
|
||||
* @param confirmedBy 用户明确填写的真实确认人
|
||||
* @returns 正式新版本
|
||||
*/
|
||||
confirm: (projectId: string, confirmation: LayoutConfirmation, confirmedBy: string) =>
|
||||
request<ConfirmedLayout>(`/projects/${encodeURIComponent(projectId)}/shared-spatial-layouts`, {
|
||||
method: 'PUT',
|
||||
body: { ...confirmation, confirmedBy: confirmedBy.trim() },
|
||||
timeoutMs: 0
|
||||
})
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import type {
|
||||
KeyframeRepair,
|
||||
KeyframeValidation,
|
||||
KeyframeValidationAccepted,
|
||||
ResumeKeyframeValidation,
|
||||
KeyframeVisionInput,
|
||||
KeyframeQualityStart,
|
||||
KeyframeValidationHistoryItem,
|
||||
QualityInput,
|
||||
@@ -58,13 +58,15 @@ export const qualityApi = {
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability${provider ? `?provider=${encodeURIComponent(provider)}` : ''}`,
|
||||
{ signal }
|
||||
),
|
||||
/** 显式请求一次审核,返回后台受理或既有质量结果。 */
|
||||
validateKeyframe: (
|
||||
shotId: string,
|
||||
assetId: string,
|
||||
input: string[] | ResumeKeyframeValidation,
|
||||
projectId?: string
|
||||
) =>
|
||||
/**
|
||||
* 显式请求一次审核,互斥提交新文字、原任务继续或独立授权。
|
||||
* @param shotId 正式镜头编号
|
||||
* @param assetId 当前首帧候选编号
|
||||
* @param input 已确认的单一审核范围
|
||||
* @param projectId 当前项目范围,省略时兼容历史调用
|
||||
* @returns 后台受理句柄或既有真实质量结果
|
||||
*/
|
||||
validateKeyframe: (shotId: string, assetId: string, input: KeyframeVisionInput, projectId?: string) =>
|
||||
request<KeyframeValidation | KeyframeValidationAccepted>(
|
||||
keyframeScope(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(assetId)}/validate`,
|
||||
|
||||
@@ -11,6 +11,31 @@ import type {
|
||||
VideoValidation
|
||||
} from './quality.types'
|
||||
|
||||
/**
|
||||
* 仅在质量、来源与结构检查均明确允许时展示首帧通过,保留原始回执不变。
|
||||
* @param result 正式质量回执或历史解析结果
|
||||
* @returns 是否可展示质量通过
|
||||
*/
|
||||
export function keyframeValidationPassed(
|
||||
result: VisualValidation & {
|
||||
/** 正式来源及实际质量状态。 */ qualityDecision?: string
|
||||
/** 结果或费用是否仍待核查。 */ recoveryRequired?: boolean
|
||||
}
|
||||
) {
|
||||
return (
|
||||
result.passed === true &&
|
||||
result.recoveryRequired !== true &&
|
||||
(result.qualityDecision === undefined || result.qualityDecision === 'passed') &&
|
||||
result.subjectCountConsistent &&
|
||||
result.temporalConsistency !== false &&
|
||||
!result.unauthorizedText.detected &&
|
||||
!result.issues.some(issue => issue.severity === 'error') &&
|
||||
result.subjects.every(
|
||||
subject => subject.identityConsistent && subject.formConsistent && subject.stateConsistent !== false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/** 未返回的操作不显示上次成功结论;网络失败不会自动重发。 */
|
||||
const sessions = reactive<
|
||||
Record<string, { receipt: QualityReceipt | null; error: string; videoValidation?: VideoValidation }>
|
||||
|
||||
@@ -38,11 +38,13 @@ export interface VisualValidation {
|
||||
|
||||
/** 首帧校验回执;历史记录通过独立 validations GET 读取。 */
|
||||
export interface KeyframeValidation extends VisualValidation {
|
||||
shotId: string
|
||||
keyframeId: string
|
||||
validationTaskId: string
|
||||
imageUrl: string
|
||||
isPrimary: boolean
|
||||
/** 当前来源及实际审核结论,历史调用可能缺省。 */ qualityDecision?: string
|
||||
/** 是否仍需要核查结果或费用。 */ recoveryRequired?: boolean
|
||||
/** 正式镜头编号。 */ shotId: string
|
||||
/** 当前候选编号。 */ keyframeId: string
|
||||
/** 原审核任务编号。 */ validationTaskId: string
|
||||
/** 已校验图片。 */ imageUrl: string
|
||||
/** 当前主首帧标记。 */ isPrimary: boolean
|
||||
}
|
||||
|
||||
/** 视频校验包括抽样帧及按需专项检查;修复候选通过后后端会自动晋升为主视频。 */
|
||||
@@ -225,6 +227,21 @@ export interface ResumeKeyframeValidation {
|
||||
/** 同一任务保存的请求版本。 */ expectedRequestFingerprint: string
|
||||
}
|
||||
|
||||
/** 独立新审核只允许提供已签发的授权编号。 */
|
||||
export interface LegacyVisionAuthorization {
|
||||
/** 独立审核授权编号。 */ legacyVisionAuthorizationId: string
|
||||
}
|
||||
/** 仅复用原通用结果并单独补跑物理专项。 */
|
||||
export interface PhysicalRetryAuthorization extends ResumeKeyframeValidation {
|
||||
/** 已单独签发的物理专项授权编号。 */ physicalRetryAuthorizationId: string
|
||||
}
|
||||
/** 单次审核参数,三种授权流程互斥。 */
|
||||
export type KeyframeVisionInput =
|
||||
| string[]
|
||||
| ResumeKeyframeValidation
|
||||
| LegacyVisionAuthorization
|
||||
| PhysicalRetryAuthorization
|
||||
|
||||
/** 单一步骤已解析并公开的问题。 */
|
||||
export interface KeyframeStepIssue {
|
||||
/** 问题分类。 */ code: string
|
||||
@@ -275,6 +292,13 @@ export interface KeyframeValidationHistoryItem {
|
||||
recoveryReason?: string | null
|
||||
/** 新版工作流执行编号。 */
|
||||
executionId?: string
|
||||
/** 原任务的人工终止审计,不能作为质量通过。 */
|
||||
legacyTermination?: {
|
||||
/** 审计编号。 */ auditId: string
|
||||
/** 人工终止时间。 */ terminatedAt: string
|
||||
/** 费用核查结论。 */ billingFinding: 'unresolved' | 'billing-confirmed' | 'no-charge-confirmed'
|
||||
/** 是否必须取得独立授权。 */ requiresNewAuthorization: boolean
|
||||
}
|
||||
/** 公开步骤进度。 */
|
||||
steps?: KeyframeValidationStep[]
|
||||
/** 调用错误 */
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/** 客户端曾实际观察到的执行,仅用于补充正式历史的最新执行编号。 */
|
||||
export interface ObservedVisionExecution {
|
||||
/** 原审核任务编号。 */ taskId: string
|
||||
/** 已实际取得的执行编号。 */ executionId: string
|
||||
/** 最近观察到的公开执行状态。 */ status?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取本机曾观察到的执行,不推断服务端未公开的历史。
|
||||
* @param key 项目和候选范围
|
||||
* @returns 已知执行记录
|
||||
*/
|
||||
export function readVisionExecutions(key: string): ObservedVisionExecution[] {
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(localStorage.getItem('vision-executions:' + key) || '[]')
|
||||
return Array.isArray(parsed)
|
||||
? parsed.filter(item => item && typeof item.taskId === 'string' && typeof item.executionId === 'string')
|
||||
: []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并真实编号,同一任务的新执行不会覆盖旧执行。
|
||||
* @param key 项目和候选范围
|
||||
* @param entries 正式响应或事件中取得的记录
|
||||
* @returns 合并后的已知记录
|
||||
*/
|
||||
export function rememberVisionExecutions(key: string, entries: ObservedVisionExecution[]) {
|
||||
const records = readVisionExecutions(key)
|
||||
for (const item of entries) {
|
||||
const existing = records.find(
|
||||
record => record.executionId === item.executionId && record.taskId === item.taskId
|
||||
)
|
||||
if (existing) Object.assign(existing, item)
|
||||
else records.push(item)
|
||||
}
|
||||
try {
|
||||
localStorage.setItem('vision-executions:' + key, JSON.stringify(records))
|
||||
} catch {
|
||||
/* 存储不可用不影响正式查询。 */
|
||||
}
|
||||
return records
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import ContinuityReviewDrawer from '../production/components/ContinuityReviewDrawer.vue'
|
||||
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
|
||||
import { ScanEye } from '@lucide/vue'
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import { isOperationRunning } from '../workflows/operations'
|
||||
|
||||
@@ -39,6 +42,8 @@ import { projectsApi } from '../projects/api'
|
||||
import type { ProjectDurationBudgetSummary } from '../projects/types'
|
||||
|
||||
const detailTab = ref('design')
|
||||
/** 即使生产入口受来源门禁限制,也可免费核对连续性。 */
|
||||
const continuityOpen = ref(false)
|
||||
/** 动作审计只能定位当前项目正式列表中的镜头。 */
|
||||
const feedback = useActionMessage()
|
||||
/**
|
||||
@@ -93,6 +98,13 @@ const keyframeProject = computed(() => (detailTab.value === 'keyframes' ? id.val
|
||||
const keyframeReadiness = useQuery(keyframeProject, (projectId, signal) =>
|
||||
projectId ? productionApi.keyframeReadiness(projectId, true, signal) : Promise.resolve(null)
|
||||
)
|
||||
/**
|
||||
* 布局确认后并行回读当前分镜与首帧来源,不重复提交业务写入。
|
||||
* @returns 两项正式查询完成
|
||||
*/
|
||||
async function refreshContinuitySources() {
|
||||
await Promise.all([query.refresh(), keyframeReadiness.refresh()])
|
||||
}
|
||||
/** 只使用当前镜头对应的结果。 */
|
||||
const shotReadiness = computed(() =>
|
||||
keyframeReadiness.data.value?.items.find(item => item.shotId === shot.value?.shotId)
|
||||
@@ -366,6 +378,18 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<!-- 以下是复用生产工作区的连续性审核入口 -->
|
||||
<WorkspaceActionTooltip label="连续性审核" mobile-only
|
||||
><NButton
|
||||
class="mobile-toolbar-icon"
|
||||
:disabled="!id || shots.length < 2"
|
||||
aria-label="连续性审核"
|
||||
@click="continuityOpen = true"
|
||||
><ScanEye :size="18" class="mobile-action-icon" /><span class="workspace-action-label"
|
||||
>连续性审核</span
|
||||
></NButton
|
||||
></WorkspaceActionTooltip
|
||||
>
|
||||
<div class="flex gap-3">
|
||||
<ActionMenu
|
||||
label="分镜更多操作"
|
||||
@@ -632,7 +656,8 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<ProjectWorkspaceSkeleton
|
||||
v-if="(!data && query.loading.value) || (!breakdownRecords.data.value && breakdownRecords.loading.value)"
|
||||
variant="storyboard"
|
||||
body-only />
|
||||
body-only
|
||||
/>
|
||||
<div v-else-if="shots.length" class="panel storyboard-workspace workspace-surface">
|
||||
<nav class="shot-list directory-panel" aria-label="本集镜头">
|
||||
<div class="directory-heading">
|
||||
@@ -763,8 +788,15 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
<EmptyState v-else-if="data" title="本集还没有正式分镜" description="请先完成剧本拆解。"></EmptyState
|
||||
></WorkspacePage>
|
||||
<EmptyState v-else-if="data" title="本集还没有正式分镜" description="请先完成剧本拆解。"></EmptyState>
|
||||
<ContinuityReviewDrawer
|
||||
v-model:open="continuityOpen"
|
||||
:project-id="id"
|
||||
:shots="shots"
|
||||
:disabled="blocked"
|
||||
@changed="refreshContinuitySources"
|
||||
/>
|
||||
</WorkspacePage>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { keyframeScope } from '../production/keyframe-scope'
|
||||
import { request } from '../../lib/http'
|
||||
import type { WorkflowExecution } from './execution.types'
|
||||
|
||||
@@ -26,10 +27,21 @@ export const workflowExecutionApi = {
|
||||
/**
|
||||
* 订阅单个已确认执行,不发现或提交其他任务。
|
||||
* @param executionId 正式执行编号
|
||||
* @param projectId 当前项目范围,省略时兼容历史调用
|
||||
* @returns 服务端单执行事件地址
|
||||
*/
|
||||
executionEventsUrl: (executionId: string) =>
|
||||
`${(import.meta.env.VITE_API_BASE_URL || '/api').replace(/\/$/, '')}/workflow-executions/${encodeURIComponent(executionId)}/events`,
|
||||
get: (executionId: string, signal?: AbortSignal) =>
|
||||
request<WorkflowExecution>(`/workflow-executions/${encodeURIComponent(executionId)}`, { signal })
|
||||
executionEventsUrl: (executionId: string, projectId?: string) =>
|
||||
`${(import.meta.env.VITE_API_BASE_URL || '/api').replace(/\/$/, '')}${keyframeScope(`/workflow-executions/${encodeURIComponent(executionId)}/events`, projectId)}`,
|
||||
/**
|
||||
* 读取指定项目内的执行,省略范围时兼容历史调用。
|
||||
* @param executionId 执行编号
|
||||
* @param signal 取消信号
|
||||
* @param projectId 项目范围
|
||||
* @returns 正式执行记录
|
||||
*/
|
||||
get: (executionId: string, signal?: AbortSignal, projectId?: string) =>
|
||||
request<WorkflowExecution>(
|
||||
keyframeScope(`/workflow-executions/${encodeURIComponent(executionId)}`, projectId),
|
||||
{ signal }
|
||||
)
|
||||
}
|
||||
@@ -169,13 +169,14 @@ export function useWorkflowExecution(
|
||||
}
|
||||
}
|
||||
)
|
||||
const key = computed(() => executionId.value)
|
||||
/** 项目和执行共同作为查询身份,切换项目立即废弃旧响应。 */
|
||||
const key = computed(() => JSON.stringify([projectId.value, executionId.value]))
|
||||
const query = usePolling(
|
||||
key,
|
||||
async (id, signal): Promise<WorkflowExecution | null> => {
|
||||
if (!id) return null
|
||||
const targetProjectId = projectId.value
|
||||
const record = await workflowExecutionApi.get(id, signal)
|
||||
async (value, signal): Promise<WorkflowExecution | null> => {
|
||||
const [targetProjectId, id] = JSON.parse(value) as [string, string]
|
||||
if (!id || !targetProjectId) return null
|
||||
const record = await workflowExecutionApi.get(id, signal, targetProjectId)
|
||||
if (record.projectId !== targetProjectId || record.workflowName !== workflowName || record.id !== id)
|
||||
throw new Error('后台任务与当前项目或工作流不匹配,请刷新核对。')
|
||||
const known = query.data.value
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
/** 项目配置的确定性业务状态说明,不将配置限制显示为系统故障。 */
|
||||
const configurationErrorLabels: Record<string, string> = {
|
||||
KEYFRAME_VALIDATION_ACTIVE: '已有审核正在进行,请查看当前执行进度。',
|
||||
KEYFRAME_VALIDATION_RECOVERY_REQUIRED: '原审核结果或费用待核查,请刷新历史并核对,勿重复提交。',
|
||||
KEYFRAME_VALIDATION_AUTHORIZATION_INVALID: '授权无效、已使用或不适用于当前候选,请核对授权编号。',
|
||||
KEYFRAME_VALIDATION_LEGACY_TERMINATED: '原审核已人工终止,新审核需要独立授权。',
|
||||
CONTINUITY_REVIEW_STALE: '诊断来源已变化,请重新读取证据、核对观察后再保存。',
|
||||
CONTINUITY_REVIEW_INVALID: '审核记录证据不完整,不能作为有效结论。',
|
||||
IMAGE_INPUT_STALE: '图片或正式来源已变化,请刷新候选并重新核对。',
|
||||
CREATIVE_PROFILE_REQUIRED: '请先保存项目生成配置,再重新检查制作计划。',
|
||||
CANVAS_CHANGE_REQUIRES_REVALIDATION:
|
||||
'已有分镜,暂时不能直接修改作品画幅。需要先重新核对镜头设计和相关素材,当前配置未保存。',
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { NInput } from 'naive-ui'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import ContinuityReviewDrawer from '@/features/production/components/ContinuityReviewDrawer.vue'
|
||||
import GeometryObservationEditor from '@/features/production/components/GeometryObservationEditor.vue'
|
||||
import { createContinuityMock, continuityShots, fingerprint } from '../../fixtures/continuity'
|
||||
import type { GeometryFrameObservation } from '@/features/production/continuity.types'
|
||||
|
||||
/** 挂载实际表单逻辑,布局和 Teleport 在本地 Chrome 独立验证。 */
|
||||
let wrapper: VueWrapper
|
||||
/**
|
||||
* 从当前隔离页面点击真实按钮。
|
||||
* @param label 完整按钮名称
|
||||
*/
|
||||
async function click(label: string) {
|
||||
const button = wrapper.findAll('button').find(item => item.text() === label)
|
||||
expect(button, `应存在按钮 ${label}`).toBeDefined()
|
||||
await button!.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
localStorage.clear()
|
||||
sessionStorage.clear()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('连续性审核真实组件流程', () => {
|
||||
it('完成观察才能保存本次指纹,编辑后需重新诊断,历史失效保留原结论', async () => {
|
||||
const mock = createContinuityMock()
|
||||
vi.stubGlobal('fetch', mock.fetcher)
|
||||
wrapper = mount(ContinuityReviewDrawer, {
|
||||
props: { open: true, projectId: 'mock-project', shots: continuityShots, disabled: false },
|
||||
global: {
|
||||
stubs: {
|
||||
AppDrawer: { template: '<div><slot/><slot name="footer"/></div>' },
|
||||
AssetImage: true,
|
||||
LayoutSupplementPanel: true
|
||||
}
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
expect(mock.calls.every(item => item.method === 'GET')).toBe(true)
|
||||
await click('免费读取当前证据')
|
||||
expect(wrapper.text()).toContain('证据不足')
|
||||
expect(wrapper.text()).toContain('开门、关门属于即时状态')
|
||||
const inputs = wrapper.findAllComponents(NInput)
|
||||
inputs.find(item => item.props('placeholder') === '固定地标一')!.vm.$emit('update:value', '窗')
|
||||
inputs.find(item => item.props('placeholder') === '固定地标二')!.vm.$emit('update:value', '门')
|
||||
for (const [i, editor] of wrapper.findAllComponents(GeometryObservationEditor).entries()) {
|
||||
const frame: GeometryFrameObservation = {
|
||||
shotId: 's' + (i + 1),
|
||||
view: 'same_side',
|
||||
landmarkOrder: 'as_layout',
|
||||
evidence: '画面同侧地标可辨',
|
||||
features: [{ key: '铰链', side: 'left', evidence: '铰链连接可辨' }]
|
||||
}
|
||||
editor.vm.$emit('update:modelValue', frame)
|
||||
}
|
||||
await flushPromises()
|
||||
await click('免费诊断人工观察')
|
||||
expect(wrapper.text()).toContain('诊断结果:通过')
|
||||
wrapper
|
||||
.findAllComponents(NInput)
|
||||
.find(item => item.props('placeholder') === '填写真实审核人')!
|
||||
.vm.$emit('update:value', '测试审核人')
|
||||
await flushPromises()
|
||||
await click('保存本次连续性审核')
|
||||
const writes = mock.calls.filter(item => item.url.endsWith('/continuity/reviews'))
|
||||
expect(writes).toHaveLength(1)
|
||||
expect((writes[0]!.body.observation as { expectedFingerprint: string }).expectedFingerprint).toBe(fingerprint)
|
||||
expect(wrapper.text()).toContain('原审核结论:通过')
|
||||
mock.state.stale = true
|
||||
await click('读取')
|
||||
expect(wrapper.text()).toContain('当前状态:已失效')
|
||||
expect(wrapper.text()).toContain('原审核结论:通过')
|
||||
wrapper.findAllComponents(GeometryObservationEditor)[0]!.vm.$emit('update:modelValue', {
|
||||
shotId: 's1',
|
||||
view: 'unknown',
|
||||
landmarkOrder: 'unknown',
|
||||
evidence: '编辑了观察',
|
||||
features: []
|
||||
})
|
||||
await flushPromises()
|
||||
const save = wrapper.findAll('button').find(item => item.text() === '保存本次连续性审核')!
|
||||
expect(save.attributes('disabled')).toBeDefined()
|
||||
expect(mock.calls.filter(item => item.method === 'PUT')).toHaveLength(0)
|
||||
})
|
||||
it('三镜相同来源问题合并范围,仍保留逐镜来源状态', async () => {
|
||||
const mock = createContinuityMock()
|
||||
mock.state.stale = true
|
||||
vi.stubGlobal('fetch', mock.fetcher)
|
||||
wrapper = mount(ContinuityReviewDrawer, {
|
||||
props: { open: true, projectId: 'mock-project', shots: continuityShots, disabled: false },
|
||||
global: {
|
||||
stubs: {
|
||||
AppDrawer: { template: '<div><slot/><slot name="footer"/></div>' },
|
||||
AssetImage: true,
|
||||
LayoutSupplementPanel: true
|
||||
}
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
await click('免费读取当前证据')
|
||||
expect(wrapper.text()).toContain('镜头 1.1、1.2、1.3:布局来源已变化')
|
||||
expect(wrapper.text().match(/镜头 1.1、1.2、1.3:布局来源已变化/g)).toHaveLength(1)
|
||||
})
|
||||
it('预览参数变化废弃待审结果,版本冲突不重发正式确认', async () => {
|
||||
const mock = createContinuityMock()
|
||||
vi.stubGlobal('fetch', mock.fetcher)
|
||||
wrapper = mount(ContinuityReviewDrawer, {
|
||||
props: { open: true, projectId: 'mock-project', shots: continuityShots, disabled: false },
|
||||
global: { stubs: { AppDrawer: { template: '<div><slot/><slot name="footer"/></div>' }, AssetImage: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
const inputs = wrapper.findAllComponents(NInput)
|
||||
inputs
|
||||
.find(item => item.props('placeholder') === '待审结构约束,例如固定连接位置与活动方向')!
|
||||
.vm.$emit('update:value', '固定门轴')
|
||||
inputs
|
||||
.find(item => item.props('placeholder') === '填写人工观察或设计依据')!
|
||||
.vm.$emit('update:value', '人工依据')
|
||||
await flushPromises()
|
||||
await click('免费预览结构约束')
|
||||
expect(wrapper.text()).toContain('需要确认布局并重新确认母版')
|
||||
inputs
|
||||
.find(item => item.props('placeholder') === '待审结构约束,例如固定连接位置与活动方向')!
|
||||
.vm.$emit('update:value', '修改后的门轴')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).not.toContain('确认正式布局')
|
||||
await click('免费预览结构约束')
|
||||
wrapper
|
||||
.findAllComponents(NInput)
|
||||
.find(item => item.props('placeholder') === '填写真实确认人')!
|
||||
.vm.$emit('update:value', 'goujun')
|
||||
await flushPromises()
|
||||
await wrapper.find('[role="checkbox"]').trigger('click')
|
||||
mock.state.conflict = true
|
||||
await click('确认正式布局')
|
||||
const writes = mock.calls.filter(item => item.method === 'PUT')
|
||||
expect(writes).toHaveLength(1)
|
||||
expect(writes[0]!.body.confirmedBy).toBe('goujun')
|
||||
expect(writes[0]!.body.expectedVersion).toBe(fingerprint)
|
||||
expect(wrapper.text()).not.toContain('确认正式布局')
|
||||
expect(wrapper.emitted('changed')).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,67 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { continuityApi, continuitySelectionValid, validObservation } from '@/features/production/continuity'
|
||||
import { layoutApi } from '@/features/production/layout-api'
|
||||
|
||||
/** 隔离正式 HTTP 契约,所有请求由 Mock 接收。 */
|
||||
const fetcher = vi.fn<typeof fetch>(async () => new Response(JSON.stringify({ data: {} })))
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
describe('固定几何诊断与正式保存契约', () => {
|
||||
it('只接受正式顺序连续的两到三镜,不跨间隔或重复', () => {
|
||||
expect(continuitySelectionValid(['a', 'b'], ['a', 'b', 'c', 'd'])).toBe(true)
|
||||
expect(continuitySelectionValid(['a', 'c'], ['a', 'b', 'c', 'd'])).toBe(false)
|
||||
expect(continuitySelectionValid(['b', 'a'], ['a', 'b', 'c'])).toBe(false)
|
||||
expect(continuitySelectionValid(['a', 'a'], ['a', 'b'])).toBe(false)
|
||||
})
|
||||
it('诊断、保存指纹及历史回读使用同项目的正式接口', async () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const observation = {
|
||||
expectedFingerprint: 'a'.repeat(64),
|
||||
landmarks: ['窗', '门'] as [string, string],
|
||||
frames: ['s1', 's2'].map(shotId => ({
|
||||
shotId,
|
||||
view: 'same_side' as const,
|
||||
landmarkOrder: 'as_layout' as const,
|
||||
evidence: '当前图可见',
|
||||
features: [{ key: '铰链', side: 'left' as const, evidence: '连接处可见' }]
|
||||
}))
|
||||
}
|
||||
const input = { shotIds: ['s1', 's2'], sceneFormId: 'form', observation }
|
||||
await continuityApi.diagnose('p', input)
|
||||
await continuityApi.save('p', { ...input, reviewer: '审核人' })
|
||||
await continuityApi.review('p', 'review')
|
||||
expect(fetcher.mock.calls.map(([url]) => String(url))).toEqual([
|
||||
'/api/projects/p/storyboard-keyframes/continuity/diagnosis',
|
||||
'/api/projects/p/storyboard-keyframes/continuity/reviews',
|
||||
'/api/projects/p/storyboard-keyframes/continuity/reviews/review'
|
||||
])
|
||||
expect(JSON.parse(fetcher.mock.calls[1]![1]!.body as string).observation.expectedFingerprint).toBe(
|
||||
'a'.repeat(64)
|
||||
)
|
||||
expect(validObservation(observation, ['s1', 's2'])).toBe(true)
|
||||
expect(validObservation({ ...observation, landmarks: ['窗', '窗'] }, ['s1', 's2'])).toBe(false)
|
||||
})
|
||||
it('布局预览不混入摄影草案,正式确认使用原返回参数和真实确认人', async () => {
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const supplement = {
|
||||
layoutId: 'layout',
|
||||
expectedVersion: 'b'.repeat(64),
|
||||
sceneSubjectId: 'scene',
|
||||
instruction: '远窗侧固定铰链',
|
||||
evidence: '人工确认'
|
||||
}
|
||||
await layoutApi.preview('p', 's', supplement)
|
||||
expect(JSON.parse(fetcher.mock.calls.at(-1)![1]!.body as string)).toEqual({ layoutSupplement: supplement })
|
||||
const confirmation = {
|
||||
name: '布局',
|
||||
sceneSubjectIds: ['scene'],
|
||||
constraints: [],
|
||||
evidence: '人工确认',
|
||||
expectedVersion: 'b'.repeat(64)
|
||||
}
|
||||
await layoutApi.confirm('p', confirmation, 'goujun')
|
||||
expect(JSON.parse(fetcher.mock.calls.at(-1)![1]!.body as string)).toEqual({
|
||||
...confirmation,
|
||||
confirmedBy: 'goujun'
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -83,3 +83,28 @@ describe('首帧质量正式后端契约', () => {
|
||||
expect(fetcher.mock.calls[0]![1]?.signal).toBeInstanceOf(AbortSignal)
|
||||
})
|
||||
})
|
||||
|
||||
// 同步复用回执也必须依据真实质量状态,不能只看 HTTP 200 或 passed 字段。
|
||||
describe('同步首帧质量展示门禁', () => {
|
||||
it('来源失效、待核查或存在硬错误时不显示通过,原回执保持不变', async () => {
|
||||
const { keyframeValidationPassed } = await import('@/features/production/quality')
|
||||
const result = {
|
||||
passed: true,
|
||||
summary: '历史通过',
|
||||
subjects: [],
|
||||
subjectCountConsistent: true,
|
||||
unauthorizedText: { detected: false, texts: [] },
|
||||
issues: []
|
||||
}
|
||||
expect(keyframeValidationPassed(result)).toBe(true)
|
||||
expect(keyframeValidationPassed({ ...result, qualityDecision: 'stale' })).toBe(false)
|
||||
expect(keyframeValidationPassed({ ...result, recoveryRequired: true })).toBe(false)
|
||||
expect(
|
||||
keyframeValidationPassed({
|
||||
...result,
|
||||
issues: [{ type: 'physical', severity: 'error', description: '结构冲突' }]
|
||||
})
|
||||
).toBe(false)
|
||||
expect(result.passed).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,113 @@
|
||||
import { defineComponent, ref } from 'vue'
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils'
|
||||
import { NInput, NCheckbox } from 'naive-ui'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import KeyframeValidationHistory from '@/features/production/components/KeyframeValidationHistory.vue'
|
||||
import KeyframeExecutionStatus from '@/features/production/components/KeyframeExecutionStatus.vue'
|
||||
import type { WorkflowExecution } from '@/features/workflows/execution.types'
|
||||
|
||||
/** 隔离当前弹窗与会话,所有 HTTP 均由 Mock 接收。 */
|
||||
let wrapper: VueWrapper
|
||||
/** 复用实际历史组件公开的底栏操作,不绕过提交守卫。 */
|
||||
const HistoryHarness = defineComponent({
|
||||
components: { KeyframeValidationHistory, NCheckbox },
|
||||
setup() {
|
||||
const history = ref<InstanceType<typeof KeyframeValidationHistory> | null>(null)
|
||||
return { history }
|
||||
},
|
||||
template:
|
||||
'<KeyframeValidationHistory ref="history" project-id="auth-ui" shot-id="s" keyframe-id="k" initial-open/><NCheckbox v-if="history?.authorizationAvailable" :checked="history.authorizationAcknowledged" @update:checked="history.setAuthorizationAcknowledged($event)"/><button v-if="history?.authorizationAvailable" :disabled="!history.authorizationReady" @click="history.submitAuthorization()">授权提交</button>'
|
||||
})
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
localStorage.clear()
|
||||
sessionStorage.clear()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('独立授权底栏与当前审核结论', () => {
|
||||
it('人工终止保留原状态和费用,显式填写、勾选后仅提交一个授权字段,409 刷新历史', async () => {
|
||||
let reads = 0
|
||||
const fetcher = vi.fn<typeof fetch>(async (input, init) => {
|
||||
const path = String(input)
|
||||
if (init?.method === 'POST')
|
||||
return new Response(
|
||||
JSON.stringify({ message: '授权无效', code: 'KEYFRAME_VALIDATION_AUTHORIZATION_INVALID' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
if (path.includes('/validations')) {
|
||||
reads++
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: [
|
||||
{
|
||||
id: 'terminated-task',
|
||||
status: 'running',
|
||||
output: null,
|
||||
error: null,
|
||||
createdAt: '2026-11-07',
|
||||
legacyTermination: {
|
||||
auditId: 'audit',
|
||||
terminatedAt: '2026-11-07',
|
||||
billingFinding: 'unresolved',
|
||||
requiresNewAuthorization: true
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
validationTaskId: 'terminated-task',
|
||||
qualityDecision: 'passed',
|
||||
effectiveQualityStatus: 'passed',
|
||||
manualReviewAvailable: true,
|
||||
historicalGazePreview: []
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(HistoryHarness)
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('原任务状态:执行中')
|
||||
expect(wrapper.text()).toContain('费用结论:待核查')
|
||||
expect(wrapper.text()).toContain('已终止,无有效结论')
|
||||
expect(wrapper.text()).not.toContain('人工接受')
|
||||
expect(wrapper.find('button:last-child').attributes('disabled')).toBeDefined()
|
||||
wrapper.findComponent(NInput).vm.$emit('update:value', 'independent-grant')
|
||||
await flushPromises()
|
||||
wrapper.findComponent(NCheckbox).vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await wrapper.find('button:last-child').trigger('click')
|
||||
await flushPromises()
|
||||
const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(posts).toHaveLength(1)
|
||||
expect(JSON.parse(String(posts[0]![1]?.body))).toEqual({ legacyVisionAuthorizationId: 'independent-grant' })
|
||||
expect(reads).toBeGreaterThan(1)
|
||||
expect(wrapper.find('button:last-child').attributes('disabled')).toBeDefined()
|
||||
})
|
||||
it('执行完成但质量未通过使用中性状态,缺少质量结论不报通过', () => {
|
||||
const record = {
|
||||
id: 'run',
|
||||
projectId: 'p',
|
||||
workflowName: 'shot-keyframe-validation',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
current: 2,
|
||||
total: 2,
|
||||
updatedAt: '2026-11-07',
|
||||
currentResourceId: null,
|
||||
metadata: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: '2026-11-07',
|
||||
createdAt: '2026-11-07',
|
||||
result: { passed: false, qualityDecision: 'failed' }
|
||||
} as WorkflowExecution
|
||||
wrapper = mount(KeyframeExecutionStatus, { props: { execution: record, loading: false } })
|
||||
expect(wrapper.text()).toContain('执行完成,质量未通过')
|
||||
expect(wrapper.classes().join(' ')).not.toContain('success')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,119 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { visionState, submitKeyframeVision, physicalRetryTarget } from '@/features/production/keyframe-vision'
|
||||
import { workflowExecutionApi } from '@/features/workflows/execution-api'
|
||||
import type { KeyframeValidationHistoryItem } from '@/features/production/quality.types'
|
||||
|
||||
/** 创建隔离的历史任务,不调用任何模型。 */
|
||||
const record = (extra: Partial<KeyframeValidationHistoryItem> = {}): KeyframeValidationHistoryItem => ({
|
||||
id: 'original-task',
|
||||
status: 'running',
|
||||
output: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
finishedAt: null,
|
||||
createdAt: '2026-11-07',
|
||||
...extra
|
||||
})
|
||||
afterEach(() => {
|
||||
sessionStorage.clear()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('历史终止和独立单步授权', () => {
|
||||
it('终止记录保持原状态,但不再作为活动任务,不允许普通重新审核', async () => {
|
||||
const terminated = record({
|
||||
legacyTermination: {
|
||||
auditId: 'audit',
|
||||
terminatedAt: '2026-11-07',
|
||||
billingFinding: 'unresolved',
|
||||
requiresNewAuthorization: true
|
||||
}
|
||||
})
|
||||
expect(visionState([terminated]).active).toBeUndefined()
|
||||
expect(visionState([terminated]).terminated?.id).toBe('original-task')
|
||||
await expect(submitKeyframeVision('s', 'k', [], [terminated], 'p')).rejects.toThrow('授权')
|
||||
})
|
||||
it('独立授权只发送授权编号,不混入文字或继续参数', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId: 's',
|
||||
keyframeId: 'k',
|
||||
validationTaskId: 'new-task',
|
||||
executionId: 'new-run',
|
||||
status: 'pending'
|
||||
}
|
||||
}),
|
||||
{ status: 202 }
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const terminated = record({
|
||||
legacyTermination: {
|
||||
auditId: 'audit',
|
||||
terminatedAt: '2026-11-07',
|
||||
billingFinding: 'unresolved',
|
||||
requiresNewAuthorization: true
|
||||
}
|
||||
})
|
||||
await expect(
|
||||
submitKeyframeVision('s', 'k', { legacyVisionAuthorizationId: 'grant' }, [terminated], 'p')
|
||||
).resolves.toBeNull()
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]![1]?.body))).toEqual({ legacyVisionAuthorizationId: 'grant' })
|
||||
expect(String(fetcher.mock.calls[0]![0])).toContain('projectId=p')
|
||||
})
|
||||
it('仅 General 已完成且 Physical 失败并有计量的原任务可进入单步授权', () => {
|
||||
const failed = record({
|
||||
status: 'failed',
|
||||
requestFingerprint: 'a'.repeat(64),
|
||||
recoveryRequired: true,
|
||||
steps: [
|
||||
{ name: 'general', status: 'completed', issues: [] },
|
||||
{ name: 'physical', status: 'failed', usage: { totalTokens: 40 } }
|
||||
]
|
||||
})
|
||||
expect(physicalRetryTarget([failed])?.id).toBe('original-task')
|
||||
expect(physicalRetryTarget([{ ...failed, steps: [{ name: 'general', status: 'failed' }] }])).toBeUndefined()
|
||||
})
|
||||
it('物理专项三项同时发送,可处理费用已记录的失败任务', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: {
|
||||
shotId: 's2',
|
||||
keyframeId: 'k2',
|
||||
validationTaskId: 'original-task',
|
||||
executionId: 'physical-run',
|
||||
status: 'pending'
|
||||
}
|
||||
}),
|
||||
{ status: 202 }
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const failed = record({
|
||||
status: 'failed',
|
||||
requestFingerprint: 'a'.repeat(64),
|
||||
recoveryRequired: true,
|
||||
steps: [
|
||||
{ name: 'general', status: 'completed', issues: [] },
|
||||
{ name: 'physical', status: 'failed', usage: { totalTokens: 40 } }
|
||||
]
|
||||
})
|
||||
const input = {
|
||||
resumeValidationTaskId: failed.id,
|
||||
expectedRequestFingerprint: failed.requestFingerprint!,
|
||||
physicalRetryAuthorizationId: 'physical-grant'
|
||||
}
|
||||
await expect(submitKeyframeVision('s2', 'k2', input, [failed], 'p')).resolves.toBeNull()
|
||||
expect(JSON.parse(String(fetcher.mock.calls[0]![1]?.body))).toEqual(input)
|
||||
})
|
||||
it('GET 和 SSE 传递相同项目范围,旧调用省略范围仍兼容', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(new Response(JSON.stringify({ data: {} })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await workflowExecutionApi.get('run', undefined, 'project')
|
||||
expect(String(fetcher.mock.calls[0]![0])).toContain('projectId=project')
|
||||
expect(workflowExecutionApi.executionEventsUrl('run', 'project')).toContain('projectId=project')
|
||||
expect(workflowExecutionApi.executionEventsUrl('run')).not.toContain('?')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,180 @@
|
||||
import { effectScope, ref } from 'vue'
|
||||
import { flushPromises } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { useKeyframeVision, visionState } from '@/features/production/keyframe-vision'
|
||||
import type { KeyframeValidationHistoryItem } from '@/features/production/quality.types'
|
||||
|
||||
/** 仅模拟公开历史,不连接真实执行和 Provider。 */
|
||||
function task(executionId = 'shared-run', status = 'running'): KeyframeValidationHistoryItem {
|
||||
return {
|
||||
id: 'same-task',
|
||||
executionId,
|
||||
status,
|
||||
output: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
finishedAt: null,
|
||||
createdAt: '2026-11-07'
|
||||
}
|
||||
}
|
||||
/** 带项目归属的真实形状执行片段。 */
|
||||
function execution(projectId: string, id = 'shared-run', status = 'running') {
|
||||
return {
|
||||
id,
|
||||
projectId,
|
||||
workflowName: 'shot-keyframe-validation',
|
||||
status,
|
||||
stage: 'validating',
|
||||
current: 0,
|
||||
total: 2,
|
||||
updatedAt: '2026-11-07T00:00:00Z'
|
||||
}
|
||||
}
|
||||
/** 记录所有事件连接,以模拟迟到事件及断线。 */
|
||||
class Source extends EventTarget {
|
||||
/** 测试创建的连接。 */ static instances: Source[] = []
|
||||
/** 断线不提交新审核。 */ close = vi.fn<() => void>()
|
||||
/**
|
||||
* 保存实际订阅地址。
|
||||
* @param url 同项目执行事件路径
|
||||
*/
|
||||
constructor(public url: string) {
|
||||
super()
|
||||
Source.instances.push(this)
|
||||
}
|
||||
}
|
||||
let scope = effectScope()
|
||||
afterEach(() => {
|
||||
scope.stop()
|
||||
scope = effectScope()
|
||||
Source.instances = []
|
||||
localStorage.clear()
|
||||
sessionStorage.clear()
|
||||
vi.useRealTimers()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
describe('审核 GET 与 SSE 项目隔离', () => {
|
||||
it('同执行编号切项目也关闭旧 SSE,旧 404 和迟到事件不污染新项目', async () => {
|
||||
let resolveOld!: (response: Response) => void
|
||||
const fetcher = vi.fn<typeof fetch>(async input => {
|
||||
const url = new URL(String(input), 'http://localhost')
|
||||
const p = url.searchParams.get('projectId')!
|
||||
if (url.pathname.endsWith('/validations')) return new Response(JSON.stringify({ data: [task()] }))
|
||||
if (p === 'scope-old')
|
||||
return new Promise<Response>(resolve => {
|
||||
resolveOld = resolve
|
||||
})
|
||||
return new Response(JSON.stringify({ data: execution(p) }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
vi.stubGlobal('EventSource', Source)
|
||||
const key = ref(JSON.stringify(['s', 'k', 'scope-old']))
|
||||
const vision = scope.run(() => useKeyframeVision(key))!
|
||||
await flushPromises()
|
||||
const old = Source.instances[0]!
|
||||
expect(old.url).toContain('projectId=scope-old')
|
||||
key.value = JSON.stringify(['s', 'k', 'scope-new'])
|
||||
await flushPromises()
|
||||
expect(old.close).toHaveBeenCalled()
|
||||
expect(Source.instances.at(-1)!.url).toContain('projectId=scope-new')
|
||||
resolveOld(new Response(JSON.stringify({ message: '项目不匹配' }), { status: 404 }))
|
||||
old.dispatchEvent(
|
||||
new MessageEvent('message', { data: JSON.stringify(execution('scope-old', 'shared-run', 'failed')) })
|
||||
)
|
||||
await flushPromises()
|
||||
expect(vision.execution.data.value?.projectId).toBe('scope-new')
|
||||
expect(vision.execution.error.value).toBe('')
|
||||
})
|
||||
it('SSE 断开后只读轮询恢复,绝不自动 POST', async () => {
|
||||
vi.useFakeTimers()
|
||||
const fetcher = vi.fn<typeof fetch>(
|
||||
async input =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: String(input).includes('/validations') ? [task()] : execution('poll-project')
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
vi.stubGlobal('EventSource', Source)
|
||||
scope.run(() => useKeyframeVision(ref(JSON.stringify(['s', 'k', 'poll-project']))))!
|
||||
await flushPromises()
|
||||
const source = Source.instances[0]!
|
||||
source.dispatchEvent(new Event('error'))
|
||||
await vi.advanceTimersByTimeAsync(2600)
|
||||
await flushPromises()
|
||||
expect(source.close).toHaveBeenCalled()
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url]) => String(url).includes('/workflow-executions/')).length
|
||||
).toBeGreaterThan(1)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('刷新时服务已有更新执行,不保留旧提交的未知费用锁', async () => {
|
||||
const key = JSON.stringify(['s', 'k', 'external-new-run'])
|
||||
sessionStorage.setItem(
|
||||
'keyframe-vision:' + key,
|
||||
JSON.stringify({
|
||||
before: 'same-task',
|
||||
beforeExecutionId: 'before-run',
|
||||
taskId: 'same-task',
|
||||
executionId: 'previous-run'
|
||||
})
|
||||
)
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
vi.fn<typeof fetch>(
|
||||
async input =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: String(input).includes('/validations')
|
||||
? [task('current-run', 'completed')]
|
||||
: execution('external-new-run', 'current-run', 'completed')
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
const vision = scope.run(() => useKeyframeVision(ref(key)))!
|
||||
await flushPromises()
|
||||
expect(vision.uncertain.value).toBe(false)
|
||||
expect(vision.execution.data.value?.id).toBe('current-run')
|
||||
})
|
||||
it('同任务出现新执行时切换观察编号,旧执行失败不覆盖新执行', async () => {
|
||||
let records = [task('old-execution', 'failed')]
|
||||
const fetcher = vi.fn<typeof fetch>(
|
||||
async input =>
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
data: String(input).includes('/validations')
|
||||
? records
|
||||
: execution(
|
||||
'multi',
|
||||
String(input).includes('new-execution') ? 'new-execution' : 'old-execution',
|
||||
String(input).includes('new-execution') ? 'running' : 'failed'
|
||||
)
|
||||
})
|
||||
)
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
vi.stubGlobal('EventSource', Source)
|
||||
const vision = scope.run(() => useKeyframeVision(ref(JSON.stringify(['s', 'k', 'multi']))))!
|
||||
await flushPromises()
|
||||
const old = Source.instances[0]!
|
||||
records = [task('new-execution', 'running')]
|
||||
await vision.history.refresh()
|
||||
await flushPromises()
|
||||
old.dispatchEvent(
|
||||
new MessageEvent('message', { data: JSON.stringify(execution('multi', 'old-execution', 'failed')) })
|
||||
)
|
||||
expect(vision.execution.data.value?.id).toBe('new-execution')
|
||||
expect(vision.state.value.active?.id).toBe('same-task')
|
||||
expect(vision.observedExecutions.value.map(item => item.executionId)).toEqual([
|
||||
'old-execution',
|
||||
'new-execution'
|
||||
])
|
||||
const state = visionState([
|
||||
task('new-execution', 'completed'),
|
||||
{ ...task('old-execution', 'failed'), id: 'older-task', recoveryRequired: true }
|
||||
])
|
||||
expect(state.unknown).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -171,7 +171,7 @@ describe('WorkflowExecution 前端契约', () => {
|
||||
const scope = effectScope()
|
||||
const tracker = scope.run(() => useWorkflowExecution(ref('project-1'), 'video-quality'))!
|
||||
await flushPromises()
|
||||
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/workflow-executions/execution-1')
|
||||
expect(fetcher.mock.calls[0]?.[0]).toBe('/api/workflow-executions/execution-1?projectId=project-1')
|
||||
expect(tracker.query.data.value?.stage).toBe('validating')
|
||||
tracker.dismiss()
|
||||
expect(localStorage.getItem('short-drama:workflow-execution:project-1:video-quality')).toBe('execution-1')
|
||||
|
||||
@@ -150,7 +150,8 @@ function stubFetch(fetcher: Mock<typeof fetch>) {
|
||||
warningCount: 0,
|
||||
issues: []
|
||||
})
|
||||
if (path.includes('/workflow-executions/')) return jsonResponse(executions.get(path.split('/').at(-1)!))
|
||||
if (path.includes('/workflow-executions/'))
|
||||
return jsonResponse(executions.get(path.split('?')[0]!.split('/').at(-1)!))
|
||||
const response = await implementation(url, init)
|
||||
const workflowName = path.endsWith('/storyboard-directions/generate')
|
||||
? 'storyboard-direction'
|
||||
@@ -1943,9 +1944,11 @@ describe('工作台页面交互', () => {
|
||||
for (const route of ['storyboard-directions', 'storyboard-visual-states'])
|
||||
expect(fetcher.mock.calls.filter(([url]) => String(url).includes('/' + route + '?'))).toHaveLength(2)
|
||||
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/duration-budget'))).toHaveLength(2)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url) === '/api/workflow-executions/page-execution-1')).toBe(
|
||||
true
|
||||
)
|
||||
expect(
|
||||
fetcher.mock.calls.some(
|
||||
([url]) => String(url) === `/api/workflow-executions/page-execution-1?projectId=${fixture.id}`
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('后台终态部分失败不显示全成功,默认补齐与显式覆盖参数独立', async () => {
|
||||
|
||||
Vendored
+214
@@ -0,0 +1,214 @@
|
||||
import type { ContinuityDiagnosis, ContinuityInput, ContinuityReview } from '@/features/production/continuity.types'
|
||||
import type { DesignedShot } from '@/features/storyboard/types'
|
||||
import type { LayoutConfirmation } from '@/features/production/layout-api'
|
||||
|
||||
/** 隔离测试使用的固定正式来源版本。 */
|
||||
export const fingerprint = 'a'.repeat(64)
|
||||
/** 隔离图组的摄影设计。 */
|
||||
export const direction = {
|
||||
shotSize: 'wide',
|
||||
cameraAngle: 'eye-level',
|
||||
cameraMovement: 'static',
|
||||
composition: '窗在左、门在右,结构位置清晰。',
|
||||
cameraPosition: '同侧观察面',
|
||||
lensIntent: 'wide',
|
||||
depthOfField: 'deep',
|
||||
visualIntent: '固定结构对照'
|
||||
}
|
||||
/** 三镜正式顺序,专用于免费 Mock 验收。 */
|
||||
export const continuityShots: DesignedShot[] = ['s1', 's2', 's3'].map((shotId, i) => ({
|
||||
shotId,
|
||||
shotNo: i + 1,
|
||||
beatNo: 1,
|
||||
title: `隔离测试镜头 ${i + 1}`,
|
||||
description: '固定结构测试画面',
|
||||
visualFocus: '固定结构',
|
||||
direction,
|
||||
visualState: null
|
||||
}))
|
||||
/** 与正式确认入口相同的完整参数。 */
|
||||
export const confirmation: LayoutConfirmation = {
|
||||
name: '测试空间',
|
||||
sceneSubjectIds: ['scene'],
|
||||
constraints: [{ kind: 'attachment', description: '固定连接位置', subjectIds: ['scene'], source: 'art-direction' }],
|
||||
evidence: '隔离人工依据',
|
||||
expectedVersion: fingerprint
|
||||
}
|
||||
/**
|
||||
* 创建与本次输入绑定的正式诊断形状。
|
||||
* @param input 免费诊断请求
|
||||
* @param imageUrl 隔离图片地址
|
||||
* @returns 当前图组与观察结论
|
||||
*/
|
||||
export function diagnosisFixture(input: ContinuityInput, imageUrl = '/storage/test-frame.png'): ContinuityDiagnosis {
|
||||
return {
|
||||
projectId: 'mock-project',
|
||||
sceneFormId: input.sceneFormId,
|
||||
fingerprint,
|
||||
layout: {
|
||||
id: 'layout',
|
||||
name: '测试空间',
|
||||
version: fingerprint,
|
||||
evidence: '隔离人工依据',
|
||||
constraints: confirmation.constraints
|
||||
},
|
||||
observation: input.observation ?? null,
|
||||
status: input.observation ? 'passed' : 'insufficient_evidence',
|
||||
issues: input.observation
|
||||
? []
|
||||
: [{ code: 'observations_missing', shotIds: input.shotIds, message: '待人工观察固定地标和局部结构' }],
|
||||
frames: input.shotIds.map((shotId, i) => ({
|
||||
shotId,
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: i + 1,
|
||||
direction,
|
||||
scene: {
|
||||
subjectId: 'scene',
|
||||
subjectRef: '@SC001',
|
||||
formId: 'scene-form',
|
||||
position: '同一空间',
|
||||
transientState: i === 0 ? '门关闭' : '门打开'
|
||||
},
|
||||
primaryId: 'primary-' + shotId,
|
||||
imageUrl,
|
||||
status: 'passed',
|
||||
formalSourceFingerprint: fingerprint,
|
||||
providerInputFingerprint: fingerprint,
|
||||
layoutReferences: []
|
||||
}))
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 创建可改变来源版本的纯 Mock 服务;未定义请求一律拒绝,不访问真实服务。
|
||||
* @param imageUrl 隔离测试图片
|
||||
* @returns Mock fetch、调用记录及可切换状态
|
||||
*/
|
||||
export function createContinuityMock(imageUrl = '/storage/test-frame.png') {
|
||||
const calls: Array<{ url: string; method: string; body: Record<string, unknown> }> = []
|
||||
const state = { stale: false, version: fingerprint, review: null as ContinuityReview | null, conflict: false }
|
||||
/**
|
||||
* 拦截全部请求,保证测试不产生真实 API 写入。
|
||||
* @param input 请求地址
|
||||
* @param init 请求参数
|
||||
* @returns 隔离的正式响应
|
||||
*/
|
||||
const fetcher: typeof fetch = async (input, init) => {
|
||||
const url = new URL(String(input), 'http://localhost')
|
||||
const path = url.pathname
|
||||
const method = init?.method ?? 'GET'
|
||||
const body = JSON.parse(String(init?.body || '{}')) as Record<string, unknown>
|
||||
calls.push({ url: String(input), method, body })
|
||||
let data: unknown
|
||||
let status = 200
|
||||
if (path.endsWith('/generation-spec')) {
|
||||
const shotId = path.split('/')[3]!
|
||||
data = {
|
||||
projectId: 'mock-project',
|
||||
shotId,
|
||||
episodeNo: 1,
|
||||
beatNo: 1,
|
||||
shotNo: Number(shotId.slice(1)),
|
||||
title: '隔离测试镜头',
|
||||
direction,
|
||||
subjects: [
|
||||
{
|
||||
subjectId: 'scene',
|
||||
subjectRef: '@SC001',
|
||||
subjectName: '测试场景',
|
||||
subjectFormId: 'scene-form',
|
||||
subjectFormName: '日间',
|
||||
module: 'scene'
|
||||
}
|
||||
]
|
||||
}
|
||||
} else if (path.endsWith('/keyframes')) {
|
||||
const shotId = path.split('/')[3]!
|
||||
data = [{ id: 'primary-' + shotId, shotId, isPrimary: true, status: 'completed', imageUrl }]
|
||||
} else if (path.endsWith('/shared-spatial-layouts')) {
|
||||
if (method === 'PUT') {
|
||||
if (state.conflict)
|
||||
return new Response(JSON.stringify({ message: '空间布局版本已变化,请重新审核' }), { status: 409 })
|
||||
state.version = 'b'.repeat(64)
|
||||
state.stale = true
|
||||
data = { ...body, id: 'layout', version: state.version }
|
||||
} else data = [{ id: 'layout', name: '测试空间', version: state.version, sceneSubjectIds: ['scene'] }]
|
||||
} else if (path.endsWith('/masters'))
|
||||
data = [
|
||||
{
|
||||
id: 'master',
|
||||
subjectFormId: null,
|
||||
viewDescription: '测试全局观察面',
|
||||
imageUrl,
|
||||
status: 'confirmed',
|
||||
spatialLayoutVersion: fingerprint
|
||||
}
|
||||
]
|
||||
else if (path.endsWith('/images'))
|
||||
data = [{ id: 'scene-primary', subjectFormId: 'scene-form', isPrimary: true, imageUrl }]
|
||||
else if (path.endsWith('/validate/preview'))
|
||||
data = {
|
||||
sourceCurrent: !state.stale,
|
||||
sourceStaleReason: state.stale ? '布局来源已变化,需要重新核对' : null
|
||||
}
|
||||
else if (path.endsWith('/continuity/diagnosis')) {
|
||||
data = diagnosisFixture(body as unknown as ContinuityInput, imageUrl)
|
||||
if (state.stale)
|
||||
data = {
|
||||
...(data as ContinuityDiagnosis),
|
||||
status: 'stale',
|
||||
fingerprint: null,
|
||||
layout: null,
|
||||
observation: null,
|
||||
issues: (body.shotIds as string[]).map(shotId => ({
|
||||
code: 'stale',
|
||||
shotIds: [shotId],
|
||||
message: '布局来源已变化'
|
||||
})),
|
||||
frames: (data as ContinuityDiagnosis).frames.map(frame => ({
|
||||
...frame,
|
||||
status: 'stale',
|
||||
reason: '布局来源已变化'
|
||||
}))
|
||||
}
|
||||
} else if (path.endsWith('/continuity/reviews') && method === 'POST') {
|
||||
if (state.conflict)
|
||||
return new Response(JSON.stringify({ message: '来源已变化', code: 'CONTINUITY_REVIEW_STALE' }), {
|
||||
status: 409
|
||||
})
|
||||
state.review ??= {
|
||||
reviewId: 'mock-review',
|
||||
reviewer: String(body.reviewer),
|
||||
reviewedAt: '2026-11-07T00:00:00Z',
|
||||
status: 'passed',
|
||||
invalidation: null,
|
||||
diagnosis: diagnosisFixture(body as unknown as ContinuityInput, imageUrl)
|
||||
}
|
||||
data = state.review
|
||||
} else if (path.includes('/continuity/reviews/')) {
|
||||
data = state.review
|
||||
? {
|
||||
...state.review,
|
||||
...(state.stale
|
||||
? { status: 'stale', invalidation: { code: 'evidence_changed', issues: [] } }
|
||||
: {})
|
||||
}
|
||||
: null
|
||||
} else if (path.endsWith('/keyframe/preview'))
|
||||
data = {
|
||||
shotId: path.split('/')[3],
|
||||
providerPrompt: '固定结构约束:门轴在远窗侧。',
|
||||
draftFingerprint: 'd'.repeat(64),
|
||||
layoutConfirmation: confirmation,
|
||||
productionReady: false,
|
||||
requiresLayoutConfirmation: true,
|
||||
requiresMasterReconfirmation: true
|
||||
}
|
||||
else {
|
||||
data = null
|
||||
status = 404
|
||||
}
|
||||
return new Response(JSON.stringify({ data }), { status })
|
||||
}
|
||||
return { fetcher, calls, state }
|
||||
}
|
||||
@@ -258,7 +258,9 @@ describe('后端 API 契约', () => {
|
||||
.slice(1)
|
||||
.every(
|
||||
([url, init]) =>
|
||||
url === '/api/workflow-executions/http-breakdown-execution' && init?.method === 'GET'
|
||||
url ===
|
||||
'/api/workflow-executions/http-breakdown-execution?projectId=http-breakdown-project' &&
|
||||
init?.method === 'GET'
|
||||
)
|
||||
).toBe(true)
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user