feat(short-drama-agent-front): 接入摄影审核与首帧制作
This commit is contained in:
1 parent
3503926d62
commit
751106985e
32 files changed
+1970
-153
No files matched your search
@@ -161,7 +161,7 @@ export const productionApi = {
|
||||
/** 按本次请求选择的图片模型与参数预览最终输入,不创建首帧任务。 */
|
||||
previewKeyframe: (
|
||||
shotId: string,
|
||||
input: Pick<GenerateKeyframeInput, 'provider' | 'generationOptions'>,
|
||||
input: Pick<GenerateKeyframeInput, 'provider' | 'generationOptions' | 'width' | 'height'>,
|
||||
signal?: AbortSignal
|
||||
) =>
|
||||
request<KeyframeGenerationPreview>(`${shotPath(shotId)}/keyframe/preview`, {
|
||||
|
||||
@@ -3,7 +3,8 @@ import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import IssueHint from '../../../components/ui/IssueHint.vue'
|
||||
import { productionMessage } from '../production-messages'
|
||||
import { computed } from 'vue'
|
||||
import { useKeyframeVision } from '../keyframe-vision'
|
||||
import { computed, watch } from 'vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { qualityApi } from '../quality-api'
|
||||
import { NButton, NTag } from 'naive-ui'
|
||||
@@ -29,7 +30,29 @@ const props = defineProps<{
|
||||
confirming: boolean
|
||||
}>()
|
||||
/** 用户显式触发候选审核、确认或免费恢复。 */
|
||||
const emit = defineEmits<{ recover: []; quality: []; edit: []; select: []; confirm: []; cancel: []; history: [] }>()
|
||||
const emit = defineEmits<{
|
||||
recover: []
|
||||
quality: []
|
||||
edit: []
|
||||
select: []
|
||||
confirm: []
|
||||
cancel: []
|
||||
history: []
|
||||
settled: []
|
||||
}>()
|
||||
/** 每张可见候选可独立找回自己的审核任务。 */
|
||||
const visionKey = computed(() =>
|
||||
props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id]) : ''
|
||||
)
|
||||
const vision = useKeyframeVision(visionKey)
|
||||
watch(
|
||||
() => vision.state.value.active,
|
||||
(active, previous) => {
|
||||
if (previous && !active && visionKey.value) emit('settled')
|
||||
}
|
||||
)
|
||||
/** 画幅不符的历史图保留浏览和只读审核记录。 */
|
||||
const wrongCanvas = computed(() => props.item.canvasDiagnosis?.status === 'mismatch')
|
||||
/** 质量状态以数据库为准;会话内检查仅在历史状态未知时兜底。 */
|
||||
const reviewKey = computed(() =>
|
||||
props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id, props.reviewRevision ?? 0]) : ''
|
||||
@@ -51,11 +74,11 @@ const reviewLabels: Record<string, string> = {
|
||||
const isPassed = computed(
|
||||
() =>
|
||||
!props.stale &&
|
||||
!wrongCanvas.value &&
|
||||
props.item.inputSnapshotStatus !== 'invalid' &&
|
||||
(effectiveStatus.value === 'passed' ||
|
||||
effectiveStatus.value === 'manual_accepted' ||
|
||||
(effectiveStatus.value === 'unknown' && props.validationPassed === true))
|
||||
(effectiveStatus.value === 'passed' || effectiveStatus.value === 'manual_accepted')
|
||||
)
|
||||
/** 晋升入口只接受持久化通过和已结算审核。 */
|
||||
const canSelect = computed(
|
||||
() =>
|
||||
props.item.status === 'completed' &&
|
||||
@@ -64,7 +87,10 @@ const canSelect = computed(
|
||||
!props.item.isPrimary &&
|
||||
!props.stale &&
|
||||
props.item.inputSnapshotStatus !== 'invalid' &&
|
||||
isPassed.value
|
||||
isPassed.value &&
|
||||
!reviewQuery.error.value &&
|
||||
!vision.blocked.value &&
|
||||
!vision.state.value.resumable
|
||||
)
|
||||
</script>
|
||||
|
||||
@@ -120,6 +146,30 @@ const canSelect = computed(
|
||||
>{{ item.width }} × {{ item.height }}</span
|
||||
>
|
||||
</div>
|
||||
<!-- 以下是候选的来源、画幅与后台审核状态 -->
|
||||
<p v-if="item.provider || item.model" class="mt-2 wrap-anywhere text-xs text-muted">
|
||||
{{ [item.provider, item.model].filter(Boolean).join(' / ') }}
|
||||
</p>
|
||||
<p
|
||||
v-if="item.canvasDiagnosis && item.status === 'completed'"
|
||||
class="mt-2 text-xs"
|
||||
:class="wrongCanvas ? 'text-danger' : 'text-muted'"
|
||||
>
|
||||
{{
|
||||
wrongCanvas
|
||||
? `历史画幅 ${item.canvasDiagnosis.actual ?? '未知'} 与交付画幅 ${item.canvasDiagnosis.expected ?? '未知'} 不符,仅供查看。`
|
||||
: item.canvasDiagnosis.status === 'matched'
|
||||
? `匹配交付画幅 ${item.canvasDiagnosis.expected}`
|
||||
: '画幅尚未确认'
|
||||
}}
|
||||
</p>
|
||||
<p
|
||||
v-if="vision.state.value.active || vision.state.value.unknown || vision.uncertain.value"
|
||||
role="status"
|
||||
class="mt-2 text-xs text-muted"
|
||||
>
|
||||
{{ vision.state.value.active?.executionId ? '质量审核在后台进行' : '审核结果或费用待核查' }}
|
||||
</p>
|
||||
<IssueHint v-if="item.error" :messages="[productionMessage(item.error)]" type="error" />
|
||||
<!-- 以下是来源记录与独立的免费恢复入口 -->
|
||||
<p v-if="item.inputSnapshotStatus" class="mt-2 text-xs text-muted">
|
||||
@@ -153,11 +203,15 @@ const canSelect = computed(
|
||||
>
|
||||
<p class="mt-2 text-[10px] text-muted">{{ formatDate(item.createdAt) }}</p>
|
||||
<div v-if="item.status === 'completed' && item.imageUrl" class="mt-2 flex flex-wrap items-center gap-3">
|
||||
<NButton text size="small" @click="emit('quality')">
|
||||
{{ validationPassed === null ? '质量检查' : '重新检查' }}
|
||||
<NButton v-if="!wrongCanvas && !stale" text size="small" @click="emit('quality')">
|
||||
{{
|
||||
vision.state.value.active || vision.state.value.unknown || vision.uncertain.value
|
||||
? '查看审核进度'
|
||||
: '质量检查'
|
||||
}}
|
||||
</NButton>
|
||||
<NButton
|
||||
v-if="item.source !== 'provider_variant'"
|
||||
v-if="item.source !== 'provider_variant' && !wrongCanvas && !stale"
|
||||
text
|
||||
size="small"
|
||||
:disabled="blocked"
|
||||
@@ -172,10 +226,10 @@ const canSelect = computed(
|
||||
设为主首帧
|
||||
</NButton>
|
||||
</div>
|
||||
<ContextNotice v-if="confirming" type="info" :show-icon="false" class="mt-2 text-xs">
|
||||
<ContextNotice v-if="confirming && canSelect" type="info" :show-icon="false" class="mt-2 text-xs">
|
||||
<p>该候选已满足当前质量要求。确认让后续视频使用此首帧?</p>
|
||||
<div class="mt-2 flex gap-3">
|
||||
<NButton type="primary" @click="emit('confirm')">确认切换</NButton>
|
||||
<NButton type="primary" :disabled="blocked" @click="emit('confirm')">确认切换</NButton>
|
||||
<NButton text size="small" @click="emit('cancel')">取消</NButton>
|
||||
</div>
|
||||
</ContextNotice>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import KeyframePreviewChecks from './KeyframePreviewChecks.vue'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
|
||||
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import AppForm from '../../../components/ui/AppForm.vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { generationConfigApi } from '../../generation-config/api'
|
||||
import type {
|
||||
@@ -20,7 +20,7 @@ import { errorMessage } from '../../../lib/http'
|
||||
import { productionApi } from '../api'
|
||||
import { directionLabel } from '../../storyboard/model'
|
||||
import type { ShotDirection, ShotVisualState } from '../../storyboard/types'
|
||||
import type { GenerateKeyframeInput } from '../types'
|
||||
import type { GenerateKeyframeInput, KeyframeGenerationPreview } from '../types'
|
||||
|
||||
/** 单镜头首帧表单;所有新图先生成候选,通过质量检查后再人工晋升。 */
|
||||
const props = defineProps<{
|
||||
@@ -38,6 +38,9 @@ const props = defineProps<{
|
||||
/** 仅发送已经确认的当前快照。 */
|
||||
submitGeneration: (input: GenerateKeyframeInput) => Promise<ImageGenerationSubmission>
|
||||
}>()
|
||||
/** 只读提供当次正式预览,候选必须匹配输入指纹才能展示。 */
|
||||
const emit = defineEmits<{ previewed: [preview: KeyframeGenerationPreview] }>()
|
||||
/** 当前候选生成窗口。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 生成参数表单,用于复用字段校验。 */
|
||||
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
@@ -71,7 +74,7 @@ const {
|
||||
recoveryNotice,
|
||||
canSubmit,
|
||||
loadPreview,
|
||||
submit
|
||||
submit: submitPreview
|
||||
} = useImageGenerationPreview({
|
||||
open,
|
||||
recoveryTarget: () => (props.shotId ? 'keyframe:' + props.shotId : ''),
|
||||
@@ -83,11 +86,18 @@ const {
|
||||
const shotId = props.shotId
|
||||
const result = await productionApi.previewKeyframe(shotId, input, signal)
|
||||
if (result?.shotId !== shotId) throw new Error('预览结果与当前镜头不匹配。')
|
||||
if (!signal.aborted && shotId === props.shotId) emit('previewed', result)
|
||||
return result
|
||||
},
|
||||
generate: input => props.submitGeneration({ ...input, setPrimary: false })
|
||||
})
|
||||
|
||||
/** 正式预览返回连续性阻断时,键盘和底栏提交均不可继续。 */
|
||||
async function submit() {
|
||||
if (preview.value?.specConsistencySummary?.blocking) return
|
||||
await submitPreview()
|
||||
}
|
||||
|
||||
/** 切换镜头或重新打开时只读取模型配置,忽略已关闭弹窗的结果。 */
|
||||
watch(
|
||||
[() => props.shotId, () => props.projectId, open],
|
||||
@@ -149,7 +159,7 @@ watch(
|
||||
:provider="imageProvider"
|
||||
:options="imageGenerationOptions"
|
||||
:aspect-ratio="projectAspectRatio"
|
||||
:disabled="disabled || submitting"
|
||||
:disabled="submitting"
|
||||
@update:provider="imageProvider = $event"
|
||||
@update:options="imageGenerationOptions = $event"
|
||||
/>
|
||||
@@ -203,55 +213,23 @@ watch(
|
||||
:stale-notice="staleNotice || recoveryNotice"
|
||||
@load="loadPreview"
|
||||
/>
|
||||
<div v-if="preview" class="mt-3 text-xs leading-6">
|
||||
<!-- 规格审计仅提示导演约束风险,不阻止首帧生成。 -->
|
||||
<section
|
||||
v-if="preview.specConsistencySummary"
|
||||
class="mt-3 bg-muted/10 p-3"
|
||||
aria-label="生成规格一致性检查"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<strong>生成规格检查</strong>
|
||||
<NTag
|
||||
size="small"
|
||||
:bordered="false"
|
||||
:type="preview.specConsistencySummary?.hasWarnings ? 'warning' : 'success'"
|
||||
>
|
||||
{{
|
||||
preview.specConsistencySummary?.hasWarnings
|
||||
? `发现 ${preview.specConsistencySummary.warningCount} 项预警`
|
||||
: '检查通过'
|
||||
}}
|
||||
</NTag>
|
||||
<span class="text-muted">仅提示,不阻止生成</span>
|
||||
</div>
|
||||
<NCollapse v-if="preview.specConsistencyIssues?.length" class="mt-2">
|
||||
<NCollapseItem name="issues" title="查看规格预警与处理建议">
|
||||
<div
|
||||
v-for="(issue, index) in preview.specConsistencyIssues"
|
||||
:key="`${issue.code}:${issue.subjectRef ?? index}`"
|
||||
class="mt-3 bg-muted/10 p-3"
|
||||
>
|
||||
<p class="font-medium">{{ userFacingText(issue.message) }}</p>
|
||||
<p v-if="issue.subjectRef" class="mt-1 text-muted">主体:{{ issue.subjectRef }}</p>
|
||||
<p class="mt-1 text-muted">涉及字段:{{ issue.fieldPaths.join('、') }}</p>
|
||||
<p class="mt-1">建议:{{ issue.suggestion }}</p>
|
||||
</div>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</section>
|
||||
</div>
|
||||
<!-- 以下是正式画幅、尺寸及连续性诊断 -->
|
||||
<KeyframePreviewChecks v-if="preview" :preview="preview" class="mt-3" />
|
||||
<NCheckbox
|
||||
id="confirm-keyframe-cost"
|
||||
v-model:checked="acknowledged"
|
||||
:disabled="!preview || submitting || !!recoveryNotice"
|
||||
:disabled="!preview || preview.specConsistencySummary?.blocking || submitting || !!recoveryNotice"
|
||||
class="mt-5 flex items-start gap-3 text-sm leading-6"
|
||||
>我已核对实际输入,并确认本次图片生成可能产生费用。
|
||||
</NCheckbox>
|
||||
</AppForm>
|
||||
<template #footer>
|
||||
<NButton :disabled="submitting" @click="open = false">取消</NButton>
|
||||
<NButton :disabled="!canSubmit" :loading="submitting" @click="formRef?.validate(submit)" type="primary"
|
||||
<NButton
|
||||
:disabled="!canSubmit || preview?.specConsistencySummary?.blocking"
|
||||
:loading="submitting"
|
||||
@click="formRef?.validate(submit)"
|
||||
type="primary"
|
||||
>确认生成首帧</NButton
|
||||
>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NCollapse, NCollapseItem, NTag } from 'naive-ui'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import type { KeyframeGenerationPreview } from '../types'
|
||||
|
||||
/** 只展示服务端返回的画幅、尺寸和一致性门禁。 */
|
||||
const props = defineProps<{
|
||||
/** 草案和正式预览共用的检查字段。 */
|
||||
preview: Pick<
|
||||
KeyframeGenerationPreview,
|
||||
'deliveryCanvas' | 'generationConfig' | 'continuity' | 'specConsistencySummary' | 'specConsistencyIssues'
|
||||
>
|
||||
}>()
|
||||
/** 实际使用的模型尺寸来自本次服务端配置。 */
|
||||
const size = computed(() => {
|
||||
const options = props.preview.generationConfig.options
|
||||
return options && typeof options === 'object' && 'size' in options && typeof options.size === 'string'
|
||||
? options.size
|
||||
: ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是交付画幅与本次实际模型尺寸 -->
|
||||
<section class="space-y-2 text-xs leading-6" aria-label="首帧画幅与连续性">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<NTag v-if="preview.deliveryCanvas" size="small" :bordered="false"
|
||||
>交付画幅 {{ preview.deliveryCanvas }}</NTag
|
||||
>
|
||||
<NTag v-if="size" size="small" :bordered="false">实际尺寸 {{ size }}</NTag>
|
||||
<NTag v-if="preview.specConsistencySummary?.blocking" type="warning" size="small" :bordered="false"
|
||||
>连续性待确认 · 暂不能生成</NTag
|
||||
>
|
||||
</div>
|
||||
<!-- 以下是具体待确认主体与规格检查问题 -->
|
||||
<ul v-if="preview.continuity?.reviewIssues.length" class="text-muted">
|
||||
<li v-for="issue in preview.continuity.reviewIssues" :key="issue.subjectRef + issue.code">
|
||||
{{ issue.subjectRef }}:{{
|
||||
issue.code === 'scene_state_transition_unconfirmed'
|
||||
? '场景即时状态衔接待确认'
|
||||
: '角色形态变化待确认'
|
||||
}}
|
||||
</li>
|
||||
</ul>
|
||||
<NCollapse v-if="preview.specConsistencyIssues?.length">
|
||||
<NCollapseItem
|
||||
name="spec-issues"
|
||||
:title="`生成规格提示(${preview.specConsistencySummary?.warningCount ?? preview.specConsistencyIssues.length})`"
|
||||
>
|
||||
<ul class="space-y-2">
|
||||
<li v-for="(issue, index) in preview.specConsistencyIssues" :key="index">
|
||||
{{ issue.subjectRef }} {{ userFacingText(issue.message) }}
|
||||
{{ userFacingText(issue.suggestion) }}
|
||||
</li>
|
||||
</ul>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</section>
|
||||
</template>
|
||||
@@ -4,12 +4,13 @@ import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem, NInput } from 'naive-ui'
|
||||
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 { qualityApi } from '../quality-api'
|
||||
import { parseKeyframeValidationOutput } from '../quality'
|
||||
|
||||
@@ -26,6 +27,7 @@ const props = defineProps<{
|
||||
/** 在独立弹窗内直接展示内容,并隐藏内部标题、说明与操作栏。 */
|
||||
initialOpen?: boolean
|
||||
}>()
|
||||
/** 通知候选重新读取当前质量状态。 */
|
||||
const emit = defineEmits<{ reviewed: [] }>()
|
||||
/** 普通入口展开后查询,独立弹窗打开时直接查询。 */
|
||||
const open = ref(props.initialOpen ?? false)
|
||||
@@ -35,13 +37,32 @@ const key = computed(() =>
|
||||
? JSON.stringify([props.projectId, props.shotId, props.keyframeId])
|
||||
: ''
|
||||
)
|
||||
/** 后端历史查询支持取消,空目标不请求。 */
|
||||
const query = useQuery(key, (value, signal) => {
|
||||
if (!value) return Promise.resolve([])
|
||||
const [, shotId, keyframeId] = JSON.parse(value) as [string | undefined, string, string]
|
||||
return qualityApi.keyframeHistory(shotId, keyframeId, signal)
|
||||
})
|
||||
/** 仅真实结构化结论可以显示通过,调用完成不等于视觉通过。 */
|
||||
/** 独立打开历史后恢复后台观察。 */
|
||||
const visionKey = computed(() => (key.value ? JSON.stringify([props.shotId, props.keyframeId]) : ''))
|
||||
const { history: query, execution, state, uncertain } = useKeyframeVision(visionKey)
|
||||
/** 后台结束时同步刷新人工复核与候选状态。 */
|
||||
watch(
|
||||
() => state.value.active,
|
||||
(active, previous) => {
|
||||
if (previous && !active && key.value) {
|
||||
void reviewQuery.refresh()
|
||||
emit('reviewed')
|
||||
}
|
||||
}
|
||||
)
|
||||
/** 公开步骤状态的中文名称。 */
|
||||
const stepLabels: Record<string, string> = {
|
||||
pending: '等待',
|
||||
running: '执行中',
|
||||
received: '已收到回执',
|
||||
completed: '完成',
|
||||
failed: '失败',
|
||||
needs_review: '需要人工核查'
|
||||
}
|
||||
/** 不显示内部模型名称作为审核步骤。 */
|
||||
const stepNames = { general: '通用画面', physical: '物理关系', gaze: '视线' }
|
||||
/** 仅显示公开词元计量。 */
|
||||
const usageLabels = { inputTokens: '输入', outputTokens: '输出', totalTokens: '合计', reasoningTokens: '推理' }
|
||||
/** 复核证据仅在展开历史时读取,不触发 Vision 或写入审核结论。 */
|
||||
const reviewQuery = useQuery(key, (value, signal) => {
|
||||
if (!value) return Promise.resolve(null)
|
||||
@@ -72,7 +93,10 @@ async function submitReview() {
|
||||
!reviewReason.value.trim() ||
|
||||
!reviewer.value.trim() ||
|
||||
submitting.value ||
|
||||
props.disabled
|
||||
props.disabled ||
|
||||
state.value.active ||
|
||||
state.value.unknown ||
|
||||
uncertain.value
|
||||
)
|
||||
return
|
||||
submitting.value = true
|
||||
@@ -158,10 +182,16 @@ const records = computed(() =>
|
||||
<p class="font-semibold">人工复核</p>
|
||||
<p class="mt-2 text-muted">请先预览候选图片并确认视觉效果。接受会替换当前主首帧,拒绝只保存审核记录。</p>
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
<NButton size="small" :disabled="disabled || submitting" @click="reviewAction = 'accepted'"
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="disabled || submitting || !!state.active || !!state.unknown || uncertain"
|
||||
@click="reviewAction = 'accepted'"
|
||||
>人工接受</NButton
|
||||
>
|
||||
<NButton size="small" :disabled="disabled || submitting" @click="reviewAction = 'rejected'"
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="disabled || submitting || !!state.active || !!state.unknown || uncertain"
|
||||
@click="reviewAction = 'rejected'"
|
||||
>人工拒绝</NButton
|
||||
>
|
||||
</div>
|
||||
@@ -198,11 +228,24 @@ const records = computed(() =>
|
||||
submitSuccess
|
||||
}}</ContextNotice>
|
||||
<p v-if="reviewQuery.error.value" class="text-danger">{{ reviewQuery.error.value }}</p>
|
||||
<!-- 以下是当前审核任务和费用核查状态 -->
|
||||
<p
|
||||
v-if="state.unknown || uncertain || (state.active && !state.active.executionId)"
|
||||
role="status"
|
||||
class="text-sm text-muted"
|
||||
>
|
||||
审核结果或费用待核查,请勿重复提交。
|
||||
</p>
|
||||
<p v-else-if="state.active" role="status" class="text-sm text-muted">
|
||||
审核{{ execution.data.value?.status === 'pending' ? '等待开始' : '在后台进行' }},关闭页面后仍会保存记录。
|
||||
</p>
|
||||
<p v-else-if="state.resumable" class="text-sm text-muted">可在质量检查中使用原参数继续;已保存的步骤会复用。</p>
|
||||
<p v-if="!records.length" class="text-muted">暂无校验记录。</p>
|
||||
<!-- 以下是实际校验结论、问题与调用错误模块 -->
|
||||
<article v-for="record in records" :key="record.id" class="panel mt-3 p-3">
|
||||
<p>
|
||||
{{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} · {{ record.status }} ·
|
||||
{{ formatDate(record.finishedAt || record.startedAt || record.createdAt) }} ·
|
||||
{{ stepLabels[record.status] ?? '待确认' }} ·
|
||||
{{
|
||||
record.status === 'completed' && record.validation
|
||||
? record.validation.passed
|
||||
@@ -218,10 +261,24 @@ const records = computed(() =>
|
||||
{{ userFacingText(issue.description) }}
|
||||
</p>
|
||||
</template>
|
||||
<!-- 以下是原始校验结果的 Naive 折叠模块 -->
|
||||
<NCollapse class="mt-2 text-muted">
|
||||
<NCollapseItem name="raw-record" title="原始记录">
|
||||
<pre class="whitespace-pre-wrap wrap-anywhere">{{ JSON.stringify(record.output, null, 2) }}</pre>
|
||||
<!-- 以下是公开步骤进度和计量,不展示模型回执 -->
|
||||
<NCollapse v-if="record.steps?.length" class="mt-2">
|
||||
<NCollapseItem
|
||||
v-for="step in record.steps"
|
||||
:key="step.name"
|
||||
:name="step.name"
|
||||
:title="`${stepNames[step.name]} · ${stepLabels[step.status]}`"
|
||||
>
|
||||
<dl class="grid gap-1 wrap-anywhere text-xs text-muted">
|
||||
<div v-if="step.startedAt">开始:{{ formatDate(step.startedAt) }}</div>
|
||||
<div v-if="step.finishedAt">完成:{{ formatDate(step.finishedAt) }}</div>
|
||||
<div v-if="step.requestId">请求编号:{{ step.requestId }}</div>
|
||||
<div v-if="step.providerRequestId">模型服务请求编号:{{ step.providerRequestId }}</div>
|
||||
<div v-for="(count, unit) in step.usage" :key="unit">
|
||||
{{ usageLabels[unit] }}词元:{{ count }}
|
||||
</div>
|
||||
</dl>
|
||||
<p v-if="step.error" class="mt-2 text-danger">{{ userFacingText(step.error) }}</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</article>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { integerRule, sizeRules } from '../../../lib/form-rules'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber, NRadioButton, NRadioGroup } from 'naive-ui'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { useKeyframeVision } from '../keyframe-vision'
|
||||
import { allowedTextLines, validQualityInput } from '../quality'
|
||||
import type { QualityAction, QualityInput, QualityTarget } from '../quality.types'
|
||||
import { useQuality } from '../useQuality'
|
||||
@@ -51,6 +52,13 @@ const { key, session, operation, execution, blocked, run } = useQuality(
|
||||
},
|
||||
id => emit('started', id)
|
||||
)
|
||||
/** 打开首帧质量弹窗时读取正式审核状态。 */
|
||||
const visionKey = computed(() =>
|
||||
open.value && props.target?.kind === 'keyframe' ? JSON.stringify([props.target.shotId, props.target.assetId]) : ''
|
||||
)
|
||||
const vision = useKeyframeVision(visionKey)
|
||||
/** 有原参数时继续;没有原参数时保留只读核查。 */
|
||||
const visionBlocked = computed(() => !!visionKey.value && vision.blocked.value)
|
||||
/** 质量弹窗重新读取所选候选自身的权限,不以会话历史代替后端事实。 */
|
||||
const videoKey = computed(() =>
|
||||
open.value && props.target?.kind === 'video' ? JSON.stringify([props.target.shotId, props.target.assetId]) : ''
|
||||
@@ -135,7 +143,7 @@ const input = computed<QualityInput>(() => ({
|
||||
maxRepairAttempts: action.value === 'validate' ? 0 : (attempts.value ?? -1),
|
||||
force: force.value,
|
||||
episodeNo: props.target?.kind === 'batch' ? props.target.episodeNo : 1,
|
||||
allowedTexts: allowedTextLines(texts.value),
|
||||
allowedTexts: vision.resumeTexts.value ?? allowedTextLines(texts.value),
|
||||
...(action.value === 'validate' || width.value === null ? {} : { width: width.value }),
|
||||
...(action.value === 'validate' || height.value === null ? {} : { height: height.value })
|
||||
}))
|
||||
@@ -229,7 +237,15 @@ watch(
|
||||
)
|
||||
/** 付费入口保留明确确认,不因菜单选择或查看历史自动提交。 */
|
||||
async function submit() {
|
||||
if (!acknowledged.value || !valid.value || blocked.value || !repairAvailable.value) return
|
||||
if (
|
||||
!acknowledged.value ||
|
||||
!valid.value ||
|
||||
blocked.value ||
|
||||
visionBlocked.value ||
|
||||
!repairAvailable.value ||
|
||||
(!!vision.resumeTexts.value && action.value !== 'validate')
|
||||
)
|
||||
return
|
||||
acknowledged.value = false
|
||||
await run(action.value, input.value)
|
||||
}
|
||||
@@ -358,8 +374,9 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
</div>
|
||||
<NFormItem class="mt-4 block" path="texts" label="额外允许的画面文字(一行一项,可留空)"
|
||||
><NInput
|
||||
v-model:value="texts"
|
||||
:disabled="pending"
|
||||
:value="vision.resumeTexts.value?.join('\n') ?? texts"
|
||||
@update:value="texts = $event"
|
||||
:disabled="pending || !!vision.resumeTexts.value"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 5 }"
|
||||
:input-props="{ 'aria-label': '额外允许的画面文字' }"
|
||||
@@ -427,11 +444,18 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
@refresh="execution.query.refresh"
|
||||
@dismiss="execution.dismiss"
|
||||
/>
|
||||
<p v-if="vision.state.value.resumable && !vision.resumeTexts.value" class="mt-3 text-xs text-muted">
|
||||
此窗口没有原审核参数,暂不能安全继续。
|
||||
</p>
|
||||
<KeyframeValidationHistory
|
||||
v-if="target?.kind === 'keyframe'"
|
||||
v-if="open && target?.kind === 'keyframe'"
|
||||
:project-id="projectId"
|
||||
:shot-id="target.shotId"
|
||||
:key="target.assetId"
|
||||
:keyframe-id="target.assetId"
|
||||
:disabled="disabled || pending"
|
||||
initial-open
|
||||
@reviewed="emit('changed')"
|
||||
/>
|
||||
<QualityResult v-if="session.receipt" :receipt="session.receipt" @locate="emit('locate', $event)" />
|
||||
<NCollapse v-else-if="saved" class="mt-4" :default-expanded-names="['saved']"
|
||||
@@ -457,9 +481,15 @@ const optionsExpanded = ref<string[]>(['options'])
|
||||
<NButton
|
||||
type="primary"
|
||||
:loading="pending"
|
||||
:disabled="blocked || !acknowledged || !repairAvailable"
|
||||
:disabled="
|
||||
blocked ||
|
||||
visionBlocked ||
|
||||
!acknowledged ||
|
||||
!repairAvailable ||
|
||||
(!!vision.resumeTexts.value && action !== 'validate')
|
||||
"
|
||||
@click="formRef?.validate(submit)"
|
||||
>{{ label }}</NButton
|
||||
>{{ vision.resumeTexts.value && action === 'validate' ? '继续原审核' : label }}</NButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,6 +28,7 @@ import type {
|
||||
GenerateKeyframeInput,
|
||||
KeyframeReadinessItem,
|
||||
KeyframeSpec,
|
||||
KeyframeGenerationPreview,
|
||||
PromptReadinessItem,
|
||||
VideoGenerationSpec,
|
||||
VideoReadinessItem
|
||||
@@ -47,6 +48,8 @@ import KeyframeValidationHistory from './KeyframeValidationHistory.vue'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import ModelCapabilities from './ModelCapabilities.vue'
|
||||
import type { QualityTarget } from '../quality.types'
|
||||
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
|
||||
import { visionState } from '../keyframe-vision'
|
||||
import { clearVideoConflict, clearVideoQualification, sessionKeyframePassed, sessionVideoValidation } from '../quality'
|
||||
import { useProjectGenerationRevision } from '../../generation-config/context'
|
||||
import { generationConfigApi } from '../../generation-config/api'
|
||||
@@ -98,6 +101,8 @@ const props = defineProps<{
|
||||
keyframeReadiness?: KeyframeReadinessItem
|
||||
/** 视频就绪项。 */
|
||||
videoReadiness?: VideoReadinessItem
|
||||
/** 分镜工作台只展示单镜头首帧,不进入项目级制作。 */
|
||||
keyframeOnly?: boolean
|
||||
/** 是否从深链接打开首帧生成。 */
|
||||
openKeyframe?: boolean
|
||||
/** 页面上游状态是否阻断操作。 */
|
||||
@@ -136,6 +141,18 @@ const assetPollInterval = computed(() => {
|
||||
query = usePolling(
|
||||
key,
|
||||
async (shotId, signal) => {
|
||||
if (props.keyframeOnly) {
|
||||
const keyframes = await productionApi.listKeyframes(shotId, signal)
|
||||
if (keyframes.some(item => item.shotId !== shotId)) throw new Error('候选与当前镜头不匹配。')
|
||||
return {
|
||||
keyframes,
|
||||
videos: [],
|
||||
qualityStatus: null,
|
||||
qualityStatusError: '',
|
||||
inputPlan: null,
|
||||
inputPlanError: ''
|
||||
}
|
||||
}
|
||||
const [keyframes, videos, qualityState, inputPlanState] = await Promise.all([
|
||||
productionApi.listKeyframes(shotId, signal),
|
||||
productionApi.listVideos(shotId, signal),
|
||||
@@ -164,10 +181,19 @@ query = usePolling(
|
||||
assetPollInterval
|
||||
)
|
||||
/** 单独读取已保存的提示词,查询失败不影响首帧和视频资产展示。 */
|
||||
const promptQuery = usePolling(key, (shotId, signal) => storyboardApi.videoPrompt(shotId, signal), false)
|
||||
const promptQuery = usePolling(
|
||||
key,
|
||||
(shotId, signal) => (props.keyframeOnly ? Promise.resolve(null) : storyboardApi.videoPrompt(shotId, signal)),
|
||||
false
|
||||
)
|
||||
const savedPrompt = computed(() => (promptQuery.data.value?.shotId === key.value ? promptQuery.data.value : null))
|
||||
/** 当前视频生成规格的首帧和主体参考图,独立查询避免影响资产列表。 */
|
||||
const videoInputQuery = usePolling(key, (shotId, signal) => productionApi.videoGenerationSpec(shotId, signal), false)
|
||||
const videoInputQuery = usePolling(
|
||||
key,
|
||||
(shotId, signal) =>
|
||||
props.keyframeOnly ? Promise.resolve(null) : productionApi.videoGenerationSpec(shotId, signal),
|
||||
false
|
||||
)
|
||||
/** 素材查询问题与就绪检查使用同一中文说明,避免重复展示后端术语。 */
|
||||
const videoInputError = computed(() => productionMessage(videoInputQuery.error.value))
|
||||
/** 视频准备问题按实际含义去重,保留所有不同的处理建议。 */
|
||||
@@ -322,6 +348,30 @@ function openShotKeyframeQuality() {
|
||||
}
|
||||
/** 当前查看历史的候选 ID;历史记录在独立弹窗内按候选隔离。 */
|
||||
const historyKeyframeId = ref('')
|
||||
/** 当前会话保留最近一次真实正式预览,只用于相同候选输入的证据展示。 */
|
||||
const latestKeyframePreview = ref<KeyframeGenerationPreview | null>(null)
|
||||
/** 历史候选的实际输入只有指纹完全一致时才能显示。 */
|
||||
const historyInput = computed(() => {
|
||||
const preview = latestKeyframePreview.value
|
||||
const item = keyframes.value.find(candidate => candidate.id === historyKeyframeId.value)
|
||||
return preview &&
|
||||
item &&
|
||||
item.shotId === preview.shotId &&
|
||||
preview.previewFingerprint === item.providerInputFingerprint
|
||||
? preview
|
||||
: null
|
||||
})
|
||||
/** 历史候选画幅或来源失效时保留浏览、禁止人工采用。 */
|
||||
const historyBlocked = computed(() => {
|
||||
const item = keyframes.value.find(candidate => candidate.id === historyKeyframeId.value)
|
||||
return (
|
||||
assetBlocked.value ||
|
||||
!item ||
|
||||
item.canvasDiagnosis?.status === 'mismatch' ||
|
||||
item.inputSnapshotStatus === 'invalid' ||
|
||||
(item.isPrimary && keyframeStale.value)
|
||||
)
|
||||
})
|
||||
/** 首帧校验历史弹窗的显示状态。 */
|
||||
const historyOpen = ref(false)
|
||||
/**
|
||||
@@ -341,6 +391,7 @@ const videoSpec = ref<VideoGenerationSpec | null>(null)
|
||||
const canGeneratePrompt = computed(
|
||||
() => !assetBlocked.value && !!props.promptReadiness && props.promptReadiness.issues.length === 0
|
||||
)
|
||||
/** 付费生成同时要求当前镜头就绪和有效正式预览。 */
|
||||
const canGenerateKeyframe = computed(
|
||||
() =>
|
||||
!assetBlocked.value &&
|
||||
@@ -518,14 +569,28 @@ async function setPrimaryKeyframe() {
|
||||
if (
|
||||
assetBlocked.value ||
|
||||
!keyframeId ||
|
||||
keyframes.value.find(item => item.id === keyframeId)?.source === 'provider_variant'
|
||||
!keyframes.value.some(
|
||||
item =>
|
||||
item.id === keyframeId &&
|
||||
item.source !== 'provider_variant' &&
|
||||
item.status === 'completed' &&
|
||||
!!item.imageUrl &&
|
||||
item.canvasDiagnosis?.status !== 'mismatch' &&
|
||||
item.inputSnapshotStatus !== 'invalid' &&
|
||||
!item.recoveryRequired
|
||||
)
|
||||
)
|
||||
return
|
||||
const shotId = props.shot.shotId
|
||||
confirmingKeyframe.value = ''
|
||||
await runOperation(props.projectId, `设置镜头 ${props.shot.shotNo} 主首帧`, async () => {
|
||||
// 晋升前重新读取持久化质量结论,刷新页面后也认可真实历史通过。
|
||||
const review = await qualityApi.keyframeQualityReview(shotId, keyframeId)
|
||||
const [review, history] = await Promise.all([
|
||||
qualityApi.keyframeQualityReview(shotId, keyframeId),
|
||||
qualityApi.keyframeHistory(shotId, keyframeId)
|
||||
])
|
||||
const vision = visionState(history)
|
||||
if (vision.active || vision.unknown || vision.resumable) throw new Error('审核尚未结算,暂不能设为主首帧。')
|
||||
if (!['passed', 'manual_accepted'].includes(review.effectiveQualityStatus))
|
||||
throw new Error('此候选尚未通过当前质量要求,请先完成质量检查或有效人工复核。')
|
||||
const result = await productionApi.setPrimaryKeyframe(shotId, keyframeId)
|
||||
@@ -620,7 +685,8 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
>{{ query.error.value }} 当前保留上次成功读取的资产,操作已暂停。
|
||||
</ContextNotice>
|
||||
|
||||
<div class="production-stage">
|
||||
<!-- 以下是项目制作中的视频提示词模块 -->
|
||||
<div v-if="!keyframeOnly" class="production-stage">
|
||||
<div class="production-stage-heading">
|
||||
<div>
|
||||
<h5 class="text-sm font-medium">01 · 视频提示词</h5>
|
||||
@@ -681,7 +747,7 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
<div class="production-stage">
|
||||
<div class="production-stage-heading">
|
||||
<div>
|
||||
<h5 class="text-sm font-medium">02 · 首帧</h5>
|
||||
<h5 class="text-sm font-medium">{{ keyframeOnly ? '本镜首帧' : '02 · 首帧' }}</h5>
|
||||
</div>
|
||||
<!-- 以下是首帧状态与对应原因入口模块,过期使用警告色 -->
|
||||
<ProductionStageStatus
|
||||
@@ -709,6 +775,7 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
@quality="openQuality('keyframe', currentKeyframe.id)"
|
||||
@edit="openEdit(currentKeyframe)"
|
||||
@history="openKeyframeHistory(currentKeyframe.id)"
|
||||
@settled="refreshAfterReview"
|
||||
/>
|
||||
</div>
|
||||
<p v-else class="mt-4 text-xs text-muted">尚无已确认主首帧。请生成候选,完成质量检查后再设为主首帧。</p>
|
||||
@@ -729,7 +796,10 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
视频质量链状态暂时无法读取;视频资产仍可查看。请稍后刷新。
|
||||
</ContextNotice>
|
||||
<div class="production-stage-actions">
|
||||
<NButton :disabled="!episodeNo || !canGenerateKeyframe" @click="openShotKeyframeQuality"
|
||||
<NButton
|
||||
v-if="!keyframeOnly"
|
||||
:disabled="!episodeNo || !canGenerateKeyframe"
|
||||
@click="openShotKeyframeQuality"
|
||||
>本镜首帧质量重跑</NButton
|
||||
>
|
||||
<NButton v-if="keyframeCandidates.length" @click="candidatesOpen = true">
|
||||
@@ -741,7 +811,7 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
</NTag>
|
||||
<NButton
|
||||
:loading="isOperationRunning(getOperation(projectId), `生成镜头 ${shot.shotNo} 首帧`)"
|
||||
:disabled="!canGenerateKeyframe"
|
||||
:disabled="!query.data.value"
|
||||
@click="keyframeOpen = true"
|
||||
><ImagePlus :size="14" />{{
|
||||
keyframeStale ? '生成替代候选' : currentKeyframe ? '再生成一张候选' : '生成首帧候选'
|
||||
@@ -750,7 +820,8 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="production-stage">
|
||||
<!-- 以下是项目制作中的视频资产模块 -->
|
||||
<div v-if="!keyframeOnly" class="production-stage">
|
||||
<div class="production-stage-heading">
|
||||
<div>
|
||||
<h5 class="text-sm font-medium">03 · 视频</h5>
|
||||
@@ -1039,6 +1110,7 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
@quality="openQuality('keyframe', item.id)"
|
||||
@edit="openEdit(item)"
|
||||
@history="openKeyframeHistory(item.id)"
|
||||
@settled="refreshAfterReview"
|
||||
@select="confirmingKeyframe = item.id"
|
||||
@confirm="setPrimaryKeyframe"
|
||||
@cancel="confirmingKeyframe = ''"
|
||||
@@ -1094,17 +1166,33 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
</AppDialog>
|
||||
<AppDialog
|
||||
v-model:open="historyOpen"
|
||||
title="首帧校验历史"
|
||||
description="查看当前候选的质量证据、历史记录和人工复核操作。"
|
||||
title="首帧记录"
|
||||
description="核对当前候选的生成输入、视觉审核与人工复核。"
|
||||
wide
|
||||
>
|
||||
<!-- 以下是同指纹的实际输入,历史无法取得时如实说明 -->
|
||||
<NCollapse v-if="historyOpen" class="mb-4">
|
||||
<NCollapseItem name="generation" title="当次参考图和画面描述">
|
||||
<ImageGenerationPreview
|
||||
v-if="historyInput"
|
||||
:preview="historyInput"
|
||||
:loading="false"
|
||||
error=""
|
||||
stale-notice=""
|
||||
display-only
|
||||
/>
|
||||
<p v-else class="text-xs text-muted">
|
||||
当前无法读取这张图的原始生成输入。可查看候选原图和已有审核记录。
|
||||
</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<KeyframeValidationHistory
|
||||
v-if="historyOpen && historyKeyframeId"
|
||||
:key="historyKeyframeId"
|
||||
:project-id="projectId"
|
||||
:shot-id="shot.shotId"
|
||||
:keyframe-id="historyKeyframeId"
|
||||
:disabled="assetBlocked"
|
||||
:disabled="historyBlocked"
|
||||
initial-open
|
||||
@reviewed="refreshAfterReview"
|
||||
/>
|
||||
@@ -1120,6 +1208,7 @@ defineExpose({ inspectSpecs, inspecting })
|
||||
:disabled="!canGenerateKeyframe"
|
||||
:previous-candidate-ids="keyframes.map(item => item.id)"
|
||||
:submit-generation="generateKeyframe"
|
||||
@previewed="latestKeyframePreview = $event"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
import { computed, onScopeDispose, ref, watch, type Ref } from 'vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { ApiError } from '../../lib/http'
|
||||
import { workflowExecutionApi } from '../workflows/execution-api'
|
||||
import { qualityApi } from './quality-api'
|
||||
import { isVisualValidation } from './quality'
|
||||
import type { KeyframeValidationHistoryItem } from './quality.types'
|
||||
|
||||
/** 当前候选的最近一次客户端提交,用于断线后只读恢复。 */
|
||||
interface Submission {
|
||||
/** 本次确认的文字授权。 */
|
||||
texts: string[]
|
||||
/** 请求前已存在的最近记录。 */
|
||||
before: string | null
|
||||
/** 同一任务继续时,原执行编号用于识别新一轮。 */
|
||||
beforeExecutionId?: string
|
||||
/** 服务确认的任务编号。 */
|
||||
taskId?: string
|
||||
/** 服务确认的执行编号。 */
|
||||
executionId?: string
|
||||
/** 任务属于其他提交,当前文字不能用于继续。 */
|
||||
external?: boolean
|
||||
/** 已明确结算,仅保留原参数供显式继续。 */
|
||||
settled?: boolean
|
||||
}
|
||||
|
||||
/** 同一窗口内的各入口共享候选提交状态。 */
|
||||
const submissions = ref<Record<string, Submission | undefined>>({})
|
||||
|
||||
/**
|
||||
* 读取原提交,刷新后仍禁止因连接中断直接重发。
|
||||
* @param key 镜头及候选查询键
|
||||
* @returns 原提交
|
||||
*/
|
||||
function readSubmission(key: string) {
|
||||
const memory = submissions.value[key]
|
||||
if (!key) return undefined
|
||||
try {
|
||||
const saved = sessionStorage.getItem('keyframe-vision:' + key)
|
||||
return saved ? (JSON.parse(saved) as Submission) : undefined
|
||||
} catch {
|
||||
return memory
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存观察位置,不发起审核。
|
||||
* @param key 镜头及候选查询键
|
||||
* @param value 原提交;缺省时清除
|
||||
*/
|
||||
function saveSubmission(key: string, value?: Submission) {
|
||||
try {
|
||||
const storageKey = 'keyframe-vision:' + key
|
||||
if (value) sessionStorage.setItem(storageKey, JSON.stringify(value))
|
||||
else sessionStorage.removeItem(storageKey)
|
||||
} catch {
|
||||
// 存储不可用时保留内存状态。
|
||||
}
|
||||
submissions.value[key] = value
|
||||
}
|
||||
|
||||
/**
|
||||
* 从公开审核历史判断是否应观察、阻断或显式继续。
|
||||
* @param records 按新到旧排列的候选历史
|
||||
* @returns 与写入安全相关的当前记录
|
||||
*/
|
||||
export function visionState(records: KeyframeValidationHistoryItem[]) {
|
||||
const active = records.find(item => item.status === 'pending' || item.status === 'running')
|
||||
const unknown = records.find(item => item.status === 'failed' && visionOutput(item).recoveryRequired !== false)
|
||||
const resumable = records.find(item => item.status === 'failed' && visionOutput(item).resumeAvailable === true)
|
||||
return { active, unknown, resumable }
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取历史公开输出中的状态字段。
|
||||
* @param record 历史记录
|
||||
* @returns 审核恢复状态及公开质量结论对象
|
||||
*/
|
||||
function visionOutput(record: KeyframeValidationHistoryItem): Record<string, unknown> {
|
||||
try {
|
||||
const value: unknown = typeof record.output === 'string' ? JSON.parse(record.output) : record.output
|
||||
return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按候选发现后台任务,轮询仅查询历史和正式执行记录。
|
||||
* @param key 镜头和候选 ID 的 JSON 查询键
|
||||
* @returns 观察状态和一次性提交凭据操作
|
||||
*/
|
||||
export function useKeyframeVision(key: Ref<string>) {
|
||||
/** 当前候选的客户端凭据。 */
|
||||
const submission = computed(() => readSubmission(key.value))
|
||||
/** 公开审核记录是刷新恢复的正式来源。 */
|
||||
const history = useQuery(key, (value, signal) => {
|
||||
if (!value) return Promise.resolve([])
|
||||
const [shotId, keyframeId] = JSON.parse(value) as [string, string]
|
||||
return qualityApi.keyframeHistory(shotId, keyframeId, signal)
|
||||
})
|
||||
/** 当前活跃、未结或可继续的记录。 */
|
||||
const state = computed(() => visionState(history.data.value ?? []))
|
||||
/** 旧版活跃记录没有执行编号,仍只能观察和核查。 */
|
||||
const executionKey = computed(
|
||||
() => state.value.active?.executionId ?? (submission.value?.settled ? '' : submission.value?.executionId) ?? ''
|
||||
)
|
||||
/** 只读取执行状态,不展示工作流内部原始结果。 */
|
||||
const execution = useQuery(executionKey, (id, signal) =>
|
||||
id ? workflowExecutionApi.get(id, signal) : Promise.resolve(null)
|
||||
)
|
||||
/** 未明确结算的断线状态禁止再次写入。 */
|
||||
const uncertain = computed(() => !!submission.value && !submission.value.settled && !state.value.active)
|
||||
/** 只有本次会话确知原文字授权时才能安全继续。 */
|
||||
const resumeTexts = computed(() => {
|
||||
const saved = submission.value
|
||||
return saved?.settled && !saved.external && saved.taskId && saved.taskId === state.value.resumable?.id
|
||||
? saved.texts
|
||||
: null
|
||||
})
|
||||
/** 初次读取或失败时不允许盲目启动,轮询期间不清空旧状态。 */
|
||||
const blocked = computed(
|
||||
() =>
|
||||
!history.data.value ||
|
||||
!!history.error.value ||
|
||||
!!state.value.active ||
|
||||
!!state.value.unknown ||
|
||||
uncertain.value ||
|
||||
(!!state.value.resumable && !resumeTexts.value)
|
||||
)
|
||||
|
||||
watch([history.data, submission], ([records, saved]) => {
|
||||
if (!records || !saved || saved.settled) return
|
||||
const latest = records[0]
|
||||
const found = saved.taskId
|
||||
? records.find(item => item.id === saved.taskId)
|
||||
: 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 })
|
||||
})
|
||||
|
||||
const timer = setInterval(() => {
|
||||
if (key.value && (state.value.active || uncertain.value)) {
|
||||
if (!history.loading.value) void history.refresh()
|
||||
if (executionKey.value && !execution.loading.value) void execution.refresh()
|
||||
}
|
||||
}, 2500)
|
||||
onScopeDispose(() => clearInterval(timer))
|
||||
return { history, state, execution, uncertain, blocked, resumeTexts }
|
||||
}
|
||||
|
||||
/**
|
||||
* 只提交一次审核;冲突和断线回到只读观察。
|
||||
* @param shotId 正式镜头
|
||||
* @param assetId 当前候选
|
||||
* @param texts 已明确确认的文字授权
|
||||
* @param records 提交前读取的审核历史
|
||||
* @returns 已复用的质量结论,或后台受理时返回空
|
||||
*/
|
||||
export async function submitKeyframeVision(
|
||||
shotId: string,
|
||||
assetId: string,
|
||||
texts: string[],
|
||||
records: KeyframeValidationHistoryItem[]
|
||||
) {
|
||||
const key = JSON.stringify([shotId, assetId])
|
||||
const previous = readSubmission(key)
|
||||
const current = visionState(records)
|
||||
if (current.active || current.unknown || (previous && !previous.settled))
|
||||
throw new Error('已有审核或费用待核查,请查看审核记录。')
|
||||
if (
|
||||
current.resumable &&
|
||||
(!previous ||
|
||||
previous.external ||
|
||||
previous.taskId !== current.resumable.id ||
|
||||
JSON.stringify(texts) !== JSON.stringify(previous.texts))
|
||||
)
|
||||
throw new Error('继续审核需要原审核参数,请核对原操作记录。')
|
||||
const pending: Submission = {
|
||||
texts: [...texts],
|
||||
before: records[0]?.id ?? null,
|
||||
beforeExecutionId: records[0]?.executionId
|
||||
}
|
||||
saveSubmission(key, pending)
|
||||
try {
|
||||
const result = await qualityApi.validateKeyframe(shotId, assetId, texts)
|
||||
if (result.shotId !== shotId || result.keyframeId !== assetId || !result.validationTaskId)
|
||||
throw new Error('审核回执与当前候选不一致,请刷新审核记录。')
|
||||
if ('executionId' in result && result.status === 'pending' && result.executionId) {
|
||||
saveSubmission(key, { ...pending, taskId: result.validationTaskId, executionId: result.executionId })
|
||||
return null
|
||||
}
|
||||
if ('passed' in result && isVisualValidation(result)) {
|
||||
saveSubmission(key, { ...pending, taskId: result.validationTaskId, settled: true })
|
||||
return result
|
||||
}
|
||||
throw new Error('审核回执不完整,请刷新审核记录。')
|
||||
} catch (cause) {
|
||||
if (cause instanceof ApiError && cause.status === 409) {
|
||||
const details = cause.details as { code?: string; taskId?: string; executionId?: string } | null
|
||||
const code = details?.code ?? cause.code ?? cause.message.split(':')[0]
|
||||
if (code === 'KEYFRAME_VALIDATION_ACTIVE') {
|
||||
saveSubmission(key, {
|
||||
...pending,
|
||||
taskId: details?.taskId,
|
||||
executionId: details?.executionId,
|
||||
external: true
|
||||
})
|
||||
return null
|
||||
}
|
||||
if (code === 'KEYFRAME_VALIDATION_RECOVERY_REQUIRED') {
|
||||
saveSubmission(key, { ...pending, taskId: details?.taskId, external: true })
|
||||
throw new Error('原审核结果或费用待核查,请查看审核记录。', { cause })
|
||||
}
|
||||
saveSubmission(key, previous)
|
||||
throw new Error('候选或审核输入可能已变化,请刷新正式候选后核对。', { cause })
|
||||
}
|
||||
if (cause instanceof ApiError && cause.status >= 400 && cause.status < 500) saveSubmission(key, previous)
|
||||
throw cause
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
ImageProviderCapability,
|
||||
KeyframeRepair,
|
||||
KeyframeValidation,
|
||||
KeyframeValidationAccepted,
|
||||
KeyframeQualityStart,
|
||||
KeyframeValidationHistoryItem,
|
||||
QualityInput,
|
||||
@@ -34,7 +35,7 @@ export interface KeyframeQualityReview {
|
||||
manualReviewAvailable: boolean
|
||||
}
|
||||
|
||||
/** 校验会调用视觉模型,POST 不设短超时、不自动重试;能力检查只读。 */
|
||||
/** 视觉审核提交不自动重试;首帧后台受理有连接超时,长同步操作等候实际结论。 */
|
||||
export const qualityApi = {
|
||||
repairVideo: (shotId: string, videoId: string, maxRepairAttempts: number) =>
|
||||
request<VideoRepair>(
|
||||
@@ -55,10 +56,11 @@ export const qualityApi = {
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframe-provider-capability${provider ? `?provider=${encodeURIComponent(provider)}` : ''}`,
|
||||
{ signal }
|
||||
),
|
||||
/** 显式请求一次审核,返回后台受理或既有质量结果。 */
|
||||
validateKeyframe: (shotId: string, assetId: string, allowedTexts: string[]) =>
|
||||
request<KeyframeValidation>(
|
||||
request<KeyframeValidation | KeyframeValidationAccepted>(
|
||||
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(assetId)}/validate`,
|
||||
{ method: 'POST', body: { allowedTexts }, timeoutMs: 0 }
|
||||
{ method: 'POST', body: { allowedTexts } }
|
||||
),
|
||||
repair: (
|
||||
shotId: string,
|
||||
|
||||
@@ -205,6 +205,40 @@ export interface KeyframeQualityStart {
|
||||
total: number
|
||||
}
|
||||
|
||||
/** 正式 Vision 后台受理回执,不表示质量已通过。 */
|
||||
export interface KeyframeValidationAccepted {
|
||||
/** 工作流执行编号。 */
|
||||
executionId: string
|
||||
/** 已保存的审核任务。 */
|
||||
validationTaskId: string
|
||||
/** 镜头编号。 */
|
||||
shotId: string
|
||||
/** 候选编号。 */
|
||||
keyframeId: string
|
||||
/** 正在等待执行。 */
|
||||
status: 'pending'
|
||||
}
|
||||
|
||||
/** 审核历史中公开的步骤证据。 */
|
||||
export interface KeyframeValidationStep {
|
||||
/** 审核范围。 */
|
||||
name: 'general' | 'physical' | 'gaze'
|
||||
/** 已保存的实际步骤状态。 */
|
||||
status: 'pending' | 'running' | 'received' | 'completed' | 'failed' | 'needs_review'
|
||||
/** 请求编号。 */
|
||||
requestId?: string
|
||||
/** 模型服务请求编号。 */
|
||||
providerRequestId?: string
|
||||
/** 开始时间。 */
|
||||
startedAt?: string
|
||||
/** 完成时间。 */
|
||||
finishedAt?: string
|
||||
/** 可取得的词元计量。 */
|
||||
usage?: Partial<Record<'inputTokens' | 'outputTokens' | 'totalTokens' | 'reasoningTokens', number>>
|
||||
/** 公开错误说明。 */
|
||||
error?: string
|
||||
}
|
||||
|
||||
/** 已保存的只读首帧校验任务记录。 */
|
||||
export interface KeyframeValidationHistoryItem {
|
||||
/** 校验任务编号 */
|
||||
@@ -213,6 +247,10 @@ export interface KeyframeValidationHistoryItem {
|
||||
status: string
|
||||
/** 数据库保存的 JSON 输出 */
|
||||
output: string | Record<string, unknown> | null
|
||||
/** 新版工作流执行编号。 */
|
||||
executionId?: string
|
||||
/** 公开步骤进度。 */
|
||||
steps?: KeyframeValidationStep[]
|
||||
/** 调用错误 */
|
||||
error: string | null
|
||||
/** 开始时间 */
|
||||
|
||||
@@ -142,6 +142,12 @@ export interface VideoReadiness {
|
||||
|
||||
/** 首帧生成记录;成功图片与失败历史都保留。 */
|
||||
export interface ShotKeyframe {
|
||||
/** 当前项目画幅与候选实际像素的诊断。 */
|
||||
canvasDiagnosis?: {
|
||||
/** 项目要求的画幅。 */ expected: string | null
|
||||
/** 候选实际画幅。 */ actual: string | null
|
||||
/** 服务端比较结论。 */ status: 'matched' | 'mismatch' | 'unknown'
|
||||
}
|
||||
/** 持久化的实际输入状态。 */
|
||||
inputSnapshotStatus?: 'recorded' | 'not-recorded' | 'invalid'
|
||||
/** 当次实际输入指纹。 */
|
||||
@@ -207,7 +213,11 @@ export interface KeyframeReference {
|
||||
subjectId: string
|
||||
subjectRef: string
|
||||
module: string
|
||||
role: 'identity-anchor' | 'form-primary'
|
||||
role: ImageReferenceRole
|
||||
/** 该机位参考绑定的场景几何版本。 */
|
||||
spatialLayoutVersion?: string
|
||||
/** 确认的机位说明。 */
|
||||
viewDescription?: string
|
||||
subjectFormId?: string
|
||||
imageId: string
|
||||
imageUrl: string
|
||||
@@ -216,6 +226,12 @@ export interface KeyframeReference {
|
||||
|
||||
/** 后端确定性编译的首帧生成规格,不会在查询时调用图片模型。 */
|
||||
export interface KeyframeSpec {
|
||||
/** 当前正式来源指纹。 */
|
||||
formalSourceFingerprint: string
|
||||
/** 项目交付画幅。 */
|
||||
deliveryCanvas?: string
|
||||
/** 只读相邻镜头依据。 */
|
||||
continuity?: import('../storyboard/generation-spec.types').ShotContinuityEvidence | null
|
||||
projectId: string
|
||||
shotId: string
|
||||
episodeNo: number
|
||||
@@ -257,6 +273,10 @@ export interface KeyframeSpecConsistencyIssue {
|
||||
|
||||
/** 正式镜头的最终图片输入与导演约束检查。 */
|
||||
export interface KeyframeGenerationPreview extends ImageGenerationPreview {
|
||||
/** 项目正式交付画幅。 */
|
||||
deliveryCanvas?: string
|
||||
/** 只读相邻镜头依据与待确认事项。 */
|
||||
continuity?: import('../storyboard/generation-spec.types').ShotContinuityEvidence | null
|
||||
specConsistencyIssues?: KeyframeSpecConsistencyIssue[]
|
||||
specConsistencySummary?: {
|
||||
warningCount: number
|
||||
@@ -328,9 +348,11 @@ export interface GenerateKeyframesInput {
|
||||
export interface GenerateKeyframeInput {
|
||||
/** 用户确认的最终输入版本。 */
|
||||
expectedPreviewFingerprint?: string
|
||||
setPrimary: boolean
|
||||
provider?: string
|
||||
generationOptions?: Record<string, string | number | boolean>
|
||||
/** 单镜头生成总是先生成候选。 */ setPrimary: boolean
|
||||
/** 图片模型供应方。 */ provider?: string
|
||||
/** 本次已核对的图片参数。 */ generationOptions?: Record<string, string | number | boolean>
|
||||
/** 旧版显式尺寸宽度,仍由项目画幅限制。 */ width?: number
|
||||
/** 旧版显式尺寸高度,仍由项目画幅限制。 */ height?: number
|
||||
}
|
||||
|
||||
/** 首帧批量生成回执;详细阻塞原因应配合 readiness 查看。 */
|
||||
|
||||
@@ -6,6 +6,8 @@ import { projectsApi } from '../projects/api'
|
||||
import { hasRunningWorkflow } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { productionApi } from './api'
|
||||
import { preparationApi } from '../storyboard-preparation/api'
|
||||
import { submitKeyframeVision } from './keyframe-vision'
|
||||
import { qualityApi } from './quality-api'
|
||||
import {
|
||||
isVisualValidation,
|
||||
@@ -160,6 +162,8 @@ export function useQuality(
|
||||
throw new Error('镜头就绪列表不完整,请刷新。')
|
||||
let receipt: QualityReceipt
|
||||
if (target.kind === 'batch') {
|
||||
const entry = await preparationApi.entry(projectId)
|
||||
if (entry.ready !== true) throw new Error(entry.reason || '项目制作条件尚未满足。')
|
||||
const targets = qualityTargets(readiness, input)
|
||||
if (!targets.length)
|
||||
throw new Error(
|
||||
@@ -203,6 +207,30 @@ export function useQuality(
|
||||
} else {
|
||||
if (!readiness.items.some(item => item.shotId === target.shotId))
|
||||
throw new Error('指定镜头不属于当前项目,未提交质量任务。')
|
||||
if (target.kind === 'keyframe' && action === 'validate') {
|
||||
const [images, history] = await Promise.all([
|
||||
productionApi.listKeyframes(target.shotId),
|
||||
qualityApi.keyframeHistory(target.shotId, target.assetId)
|
||||
])
|
||||
const image = images.find(item => item.id === target.assetId && item.shotId === target.shotId)
|
||||
if (
|
||||
!image ||
|
||||
image.status !== 'completed' ||
|
||||
!image.imageUrl ||
|
||||
image.canvasDiagnosis?.status === 'mismatch' ||
|
||||
image.inputSnapshotStatus === 'invalid'
|
||||
)
|
||||
throw new Error('首帧未完成、画幅不符或来源过期,不能执行质量检查。')
|
||||
if (!stillCurrent()) throw new Error('已离开原候选,未提交审核。')
|
||||
const result = await submitKeyframeVision(
|
||||
target.shotId,
|
||||
target.assetId,
|
||||
input.allowedTexts ?? [],
|
||||
history
|
||||
)
|
||||
if (result) receiptTarget.receipt = { kind: 'keyframe', result }
|
||||
return
|
||||
}
|
||||
if (target.kind === 'video') {
|
||||
const videos = await productionApi.listVideos(target.shotId)
|
||||
const video = videos.find(item => item.id === target.assetId && item.shotId === target.shotId)
|
||||
@@ -298,19 +326,7 @@ export function useQuality(
|
||||
throw new Error('修复回执不完整,请先核对首帧与主图状态,不要重复生图。')
|
||||
receipt = { kind: 'repair', result }
|
||||
} else {
|
||||
const result = await qualityApi.validateKeyframe(
|
||||
target.shotId,
|
||||
target.assetId,
|
||||
input.allowedTexts ?? []
|
||||
)
|
||||
if (
|
||||
!isVisualValidation(result) ||
|
||||
result.shotId !== target.shotId ||
|
||||
result.keyframeId !== target.assetId ||
|
||||
!result.validationTaskId
|
||||
)
|
||||
throw new Error('首帧检查结果不完整或与所选图片不一致,请刷新检查记录。')
|
||||
receipt = { kind: 'keyframe', result }
|
||||
throw new Error('当前质量操作不可用。')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user