Files
short-drama-agent-front/src/features/storyboard/components/SubjectCoverageAudit.vue
T

78 lines
3.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { NAlert, NButton } from 'naive-ui'
import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue'
import { useQuery } from '../../../composables/useQuery'
import { auditSubjectCoverage } from '../coverage-api'
import type { SubjectCoverageIssue } from '../coverage.types'
/** 审计范围始终是当前正式项目。 */
const props = defineProps<{ /** 项目 ID。 */ projectId: string }>()
/** 定位只交给当前分镜页处理,不自行拼接猜测的镜头 ID。 */
const emit = defineEmits<{ locate: [issue: SubjectCoverageIssue] }>()
/** 展开才会读取零费用审计结果。 */
const open = ref(false)
/** 项目或展开状态变化时清空旧审计。 */
const key = computed(() => (open.value ? props.projectId : ''))
/** 请求取消和迟到响应保护复用公共查询。 */
const query = useQuery(key, async (projectId, signal) => {
if (!projectId) return null
const result = await auditSubjectCoverage(projectId, signal)
if (result.projectId !== projectId || !Array.isArray(result.issues) || typeof result.valid !== 'boolean')
throw new Error('覆盖检查返回了不匹配的项目或无效结果,请刷新。')
return result
})
/** 当前后端实际审计汇总。 */
const result = computed(() => query.data.value)
</script>
<template>
<!-- 以下是零费用主体引用覆盖审计模块 -->
<ReadonlyInspection
v-model:open="open"
title="主体引用覆盖检查"
description="检查分镜文本与主体绑定是否一致,只读取数据,不自动生成或修改分镜。"
:loading="query.loading.value"
:error="query.error.value"
@refresh="query.refresh"
>
<template v-if="result">
<NAlert :type="result.valid ? 'success' : 'warning'" :show-icon="false">
{{ result.valid ? '未发现主体引用遗漏' : `发现 ${result.issueCount} 项引用遗漏` }} ·
{{ result.episodeCount }} 集 / {{ result.beatCount }} 个 Beat / {{ result.shotCount }} 镜
</NAlert>
<p class="mt-2 text-muted">
检查主体 {{ result.subjectSummary.total }} · 人物 {{ result.subjectSummary.character }} / 场景
{{ result.subjectSummary.scene }} / 道具 {{ result.subjectSummary.prop }}
</p>
<article
v-for="(issue, index) in result.issues"
:key="`${issue.level}:${issue.episodeNo}:${issue.beatNo}:${issue.shotNo}:${issue.subjectRef}:${index}`"
class="surface-inset mt-3 p-3"
>
<div class="flex flex-wrap items-center justify-between gap-3">
<strong
>第 {{ issue.episodeNo }} 集 · Beat {{ issue.beatNo
}}{{ issue.shotNo !== null ? ` · 镜头 ${issue.shotNo}` : '' }} · {{ issue.subjectName }}
{{ issue.subjectRef }}</strong
>
<NButton text size="small" @click="emit('locate', issue)">{{
issue.shotNo === null ? '查看所在剧集' : '定位镜头'
}}</NButton>
</div>
<p>{{ issue.message }}</p>
<p class="text-muted">
原文匹配:{{ issue.matchedTerm }} ·
{{
issue.level === 'visual_state'
? '即时状态'
: issue.level === 'beat'
? 'Beat 主体引用'
: '镜头主体绑定'
}}
</p>
</article>
</template>
</ReadonlyInspection>
</template>