feat(short-drama-agent-front): 补齐后端生产与质量功能
This commit is contained in:
1 parent
967c4ebea1
commit
470b52e26d
52 files changed
+3754
-1075
No files matched your search
@@ -1,7 +1,14 @@
|
||||
import { reactive } from 'vue'
|
||||
import { validOptionalSize } from './model'
|
||||
import type { KeyframeReadiness } from './types'
|
||||
import type { QualityInput, QualityReceipt, QualityTarget, VisualValidation, VideoValidation } from './quality.types'
|
||||
import type {
|
||||
QualityBatchResult,
|
||||
QualityInput,
|
||||
QualityReceipt,
|
||||
QualityTarget,
|
||||
VisualValidation,
|
||||
VideoValidation
|
||||
} from './quality.types'
|
||||
|
||||
/** 未返回的操作不显示上次成功结论;网络失败不会自动重发。 */
|
||||
const sessions = reactive<
|
||||
@@ -13,7 +20,7 @@ export function qualityKey(projectId: string, target: QualityTarget | null) {
|
||||
return JSON.stringify([
|
||||
projectId,
|
||||
target?.kind,
|
||||
target && ('assetId' in target ? [target.shotId, target.assetId] : target.episodeNo)
|
||||
target && ('assetId' in target ? [target.shotId, target.assetId] : [target.episodeNo, target.shotId])
|
||||
])
|
||||
}
|
||||
|
||||
@@ -44,21 +51,56 @@ export function validQualityInput(input: QualityInput) {
|
||||
)
|
||||
}
|
||||
|
||||
/** 与后端保持同一优先级:全项目有过期项时先筛过期,再按当前集筛选。 */
|
||||
/**
|
||||
* 按真实后端就绪结果、剧集与指定镜头过滤,过期与缺失项均保留。
|
||||
* @param readiness 后端就绪列表
|
||||
* @param input 已确认的批次参数
|
||||
* @returns 实际候选镜头
|
||||
*/
|
||||
export function qualityTargets(readiness: KeyframeReadiness, input: QualityInput) {
|
||||
return readiness.items
|
||||
.filter(
|
||||
item =>
|
||||
item.status === 'ready' &&
|
||||
(input.force ||
|
||||
(readiness.stalePrimaryKeyframe > 0
|
||||
? item.primaryKeyframeStale === true
|
||||
: !item.primaryKeyframeId)) &&
|
||||
item.episodeNo === input.episodeNo
|
||||
item.episodeNo === input.episodeNo &&
|
||||
(!input.shotId || item.shotId === input.shotId)
|
||||
)
|
||||
.slice(0, input.limit)
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析数据库 JSON 校验结论;原始模型文字不能代替真实结构化结果。
|
||||
* @param output 历史任务输出
|
||||
* @returns 完整视觉结论或空值
|
||||
*/
|
||||
export function parseKeyframeValidationOutput(output: unknown): VisualValidation | null {
|
||||
try {
|
||||
const value: unknown = typeof output === 'string' ? JSON.parse(output) : output
|
||||
return isVisualValidation(value) ? value : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 区分最终逐镜回执与 202 句柄,防止后台开始被显示为完成。
|
||||
* @param value 后端任务最终结果
|
||||
* @returns 是否具有完整计数和逐镜结果
|
||||
*/
|
||||
export function isQualityBatchResult(value: unknown): value is QualityBatchResult {
|
||||
if (!value || typeof value !== 'object') return false
|
||||
const item = value as QualityBatchResult
|
||||
return (
|
||||
Array.isArray(item.results) &&
|
||||
[item.targetCount, item.selected, item.passed, item.repairFailed, item.failed].every(
|
||||
number => Number.isSafeInteger(number) && number >= 0
|
||||
) &&
|
||||
item.results.length === item.targetCount &&
|
||||
item.passed + item.repairFailed + item.failed === item.targetCount &&
|
||||
item.results.every(result => typeof result.shotId === 'string' && typeof result.success === 'boolean')
|
||||
)
|
||||
}
|
||||
|
||||
/** 最小响应校验,避免畸形响应或仅 HTTP 200 被显示成视觉通过。 */
|
||||
export function isVisualValidation(value: unknown): value is VisualValidation {
|
||||
if (!value || typeof value !== 'object') return false
|
||||
@@ -90,11 +132,9 @@ export function sessionVideoValidation(projectId: string, shotId: string, assetI
|
||||
return qualitySession(qualityKey(projectId, { kind: 'video', shotId, assetId, title: '' })).videoValidation ?? null
|
||||
}
|
||||
|
||||
/** 首帧暂无质量历史 GET,只用本会话后端真实回执决定是否允许人工晋升。 */
|
||||
/** 手动晋升仍只使用本会话实际校验回执,读取历史不改变晋升政策。 */
|
||||
export function sessionKeyframePassed(projectId: string, shotId: string, assetId: string): boolean | null {
|
||||
const receipt = qualitySession(
|
||||
qualityKey(projectId, { kind: 'keyframe', shotId, assetId, title: '' })
|
||||
).receipt
|
||||
const receipt = qualitySession(qualityKey(projectId, { kind: 'keyframe', shotId, assetId, title: '' })).receipt
|
||||
if (receipt?.kind === 'keyframe' && receipt.result.keyframeId === assetId) return receipt.result.passed
|
||||
if (receipt?.kind !== 'repair') return null
|
||||
if (receipt.result.finalKeyframeId === assetId) return receipt.result.passed
|
||||
|
||||
Reference in new issue
Block a user