feat(short-drama-agent-front): 补齐后端生产与质量功能

This commit is contained in:
GJ committed 2026-10-08 18:28:35 +08:00
1 parent 967c4ebea1
commit 470b52e26d
52 files changed
+3754 -1075

No files matched your search

@@ -0,0 +1,114 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { NAlert, NTag } from 'naive-ui'
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
import { useQuery } from '../../../composables/useQuery'
import { formatDate } from '../../../lib/format'
import { videoDiagnosticsApi } from '../diagnostics-api'
import { videoQualityStatusLabel } from '../model'
import type { VideoQualityRollbackTarget } from '../diagnostics.types'
/** 视频诊断始终绑定当前正式镜头。 */
const props = defineProps<{ /** 正式镜头 ID。 */ shotId: string }>()
/** 仅用户展开后查询,关闭后取消旧请求。 */
const open = ref(false)
/** 镜头和展开状态共同决定查询目标。 */
const key = computed(() => (open.value ? props.shotId : ''))
/** 切换镜头时取消查询,先读取链状态,耗尽时再查询独立归因。 */
const query = useQuery(key, async (shotId, signal) => {
if (!shotId) return null
const detail = await videoDiagnosticsApi.qualityDetail(shotId, signal)
if (detail.shotId !== shotId || !Array.isArray(detail.chain)) throw new Error('质量记录与当前镜头不匹配,请刷新。')
const analysis =
detail.status === 'exhausted'
? await videoDiagnosticsApi.exhaustionAnalysis(shotId, signal)
: detail.exhaustionAnalysis
if (analysis && analysis.shotId !== shotId) throw new Error('失败归因与当前镜头不匹配,请刷新。')
return { detail, analysis }
})
/** 当前请求返回的权威质量链。 */
const detail = computed(() => query.data.value?.detail)
/** 当前链对应的后端确定性归因。 */
const analysis = computed(() => query.data.value?.analysis)
/**
* 将后端回退层级转成业务标签,未知值保持原文。
* @param target 后端建议回退层级
* @returns 中文标签
*/
function rollbackLabel(target: VideoQualityRollbackTarget) {
const labels: Record<VideoQualityRollbackTarget, string> = {
identity_reference: '主体身份母版',
subject_reference: '形态参考图',
keyframe: '主首帧',
motion_plan: '运动计划',
video_prompt: '视频提示词',
provider: '视频模型'
}
return labels[target] ?? target
}
</script>
<template>
<!-- 以下是只读视频质量详情与自动修复失败归因模块 -->
<ReadonlyInspection
v-model:open="open"
title="视频质量详情"
description="读取已有校验链和失败归因,不重新校验或生成视频。"
:loading="query.loading.value"
:error="query.error.value"
@refresh="query.refresh"
>
<template v-if="detail">
<p>
<strong>{{ videoQualityStatusLabel(detail.status) }}</strong> · 修复 {{ detail.repairAttempt }} /
{{ detail.maxRepairAttempts ?? '未设置' }} · 候选 {{ detail.chain.length }}
</p>
<p v-if="!detail.chain.length" class="mt-2 text-muted">当前镜头尚无质量链记录。</p>
<article v-for="item in detail.chain" :key="item.videoId" class="surface-inset mt-3 p-3">
<div class="flex flex-wrap items-center gap-2">
<code>{{ item.videoId }}</code>
<NTag size="small" :bordered="false">第 {{ item.repairAttempt }} 代</NTag>
<span
>{{ item.providerStatus }} ·
{{
item.validationPassed === true
? '校验通过'
: item.validationPassed === false
? '校验未通过'
: '尚未校验'
}}</span
>
<span class="text-muted">{{ formatDate(item.updatedAt) }}</span>
</div>
<ul v-if="item.issues.length" class="mt-2 space-y-1">
<li
v-for="(issue, index) in item.issues"
:key="index"
:class="issue.severity === 'error' ? 'text-danger' : 'text-muted'"
>
{{ issue.frameLabel ? `${issue.frameLabel} · ` : '' }}{{ issue.description }}
</li>
</ul>
</article>
<NAlert
v-if="analysis"
class="mt-3"
:type="analysis.requiresManualReview ? 'warning' : 'info'"
:show-icon="false"
>
{{ analysis.summary }}
<p v-if="analysis.recommendedRollback.length" class="mt-1">
建议检查:{{ analysis.recommendedRollback.map(rollbackLabel).join('、') }}
</p>
</NAlert>
<article v-for="issue in analysis?.persistentIssues ?? []" :key="issue.type" class="mt-3">
<strong>{{ issue.type }} · 出现 {{ issue.occurrences }} 次</strong>
<p>{{ issue.suspectedCause }}</p>
<ul class="text-muted">
<li v-for="description in issue.descriptions" :key="description">{{ description }}</li>
</ul>
</article>
</template>
</ReadonlyInspection>
</template>