feat: 同步精简接口并统一表单校验
This commit is contained in:
1 parent
82d7bde631
commit
2eea0ea72e
66 files changed
+1611
-1100
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { computed, onScopeDispose } from 'vue'
|
||||
import { projectsApi } from '../projects/api'
|
||||
import { hasRunningWorkflow } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import { productionApi } from './api'
|
||||
import { qualityApi } from './quality-api'
|
||||
@@ -9,8 +10,7 @@ import {
|
||||
qualitySession,
|
||||
qualityTargets,
|
||||
validQualityInput,
|
||||
savedVideoValidation,
|
||||
videoRepairInfo
|
||||
sessionVideoValidation
|
||||
} from './quality'
|
||||
import type { QualityAction, QualityInput, QualityReceipt, QualityTarget, RepairAttempt } from './quality.types'
|
||||
|
||||
@@ -58,6 +58,7 @@ export function useQuality(
|
||||
const receiptTarget = qualitySession(originalKey)
|
||||
receiptTarget.receipt = null
|
||||
receiptTarget.error = ''
|
||||
if (target.kind === 'video' && action === 'validate') delete receiptTarget.videoValidation
|
||||
const stillCurrent = () => !disposed && key.value === originalKey && visible()
|
||||
const ok = await runOperation(
|
||||
projectId,
|
||||
@@ -69,14 +70,14 @@ export function useQuality(
|
||||
: '首帧自动修复'
|
||||
: '视觉质量校验',
|
||||
async () => {
|
||||
const [project, readiness] = await Promise.all([
|
||||
const [project, readiness, checkpoints] = await Promise.all([
|
||||
projectsApi.detail(projectId),
|
||||
productionApi.keyframeReadiness(projectId, target.kind === 'batch' ? input.force : true)
|
||||
productionApi.keyframeReadiness(projectId, target.kind === 'batch' ? input.force : true),
|
||||
projectsApi.checkpoints(projectId)
|
||||
])
|
||||
if (project.id !== projectId || project.status !== 'completed')
|
||||
throw new Error('剧本未完成或项目已变化,未提交质量任务。')
|
||||
if (project.tasks.some(task => ['pending', 'queued', 'running', 'generating'].includes(task.status)))
|
||||
throw new Error('项目还有后台任务,请结束后再执行质量检查。')
|
||||
if (hasRunningWorkflow(checkpoints)) throw new Error('项目还有后台任务,请结束后再执行质量检查。')
|
||||
if (
|
||||
!Array.isArray(readiness.items) ||
|
||||
readiness.items.length !== readiness.total ||
|
||||
@@ -142,12 +143,10 @@ export function useQuality(
|
||||
)
|
||||
throw new Error('视频未完成、缺少视频地址或有效时长,不能执行抽样校验。')
|
||||
if (action === 'repair') {
|
||||
if (savedVideoValidation(video.rawJson)?.passed !== false)
|
||||
if (sessionVideoValidation(projectId, target.shotId, target.assetId)?.passed !== false)
|
||||
throw new Error('请先完成视频质量校验;只有未通过的视频才能创建修复候选。')
|
||||
if (videos.some(item => ['pending', 'queued', 'running'].includes(item.status)))
|
||||
throw new Error('此镜头仍有活动视频任务,请结束后再修复。')
|
||||
if ((videoRepairInfo(video.rawJson)?.attempt ?? 0) + 1 > input.maxRepairAttempts)
|
||||
throw new Error('当前视频修复链已达到次数上限,请核对后再调整。')
|
||||
if (!stillCurrent()) throw new Error('已离开原操作目标,未提交质量任务。')
|
||||
const result = await qualityApi.repairVideo(
|
||||
target.shotId,
|
||||
@@ -179,13 +178,15 @@ export function useQuality(
|
||||
!isVisualValidation(result) ||
|
||||
result.shotId !== target.shotId ||
|
||||
result.videoId !== target.assetId ||
|
||||
!Array.isArray(result.sampleFrames)
|
||||
!Array.isArray(result.sampleFrames) ||
|
||||
typeof result.isPrimary !== 'boolean'
|
||||
)
|
||||
throw new Error('视频校验结果与目标不匹配或不完整,请核对后端记录。')
|
||||
receiptTarget.videoValidation = result
|
||||
receipt = {
|
||||
kind: 'video',
|
||||
result,
|
||||
promoted: !!videoRepairInfo(video.rawJson) && result.passed && result.isPrimary
|
||||
promoted: !video.isPrimary && result.passed && result.isPrimary
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user