feat(short-drama-agent-front): 完善分镜审核与制作准备流程

This commit is contained in:
GJ committed 2026-10-19 21:59:22 +08:00
1 parent c4b43b9725
commit 1da56e0d46
72 files changed
+2801 -528

No files matched your search

@@ -0,0 +1,120 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
import { RefreshCw, History } from '@lucide/vue'
import { preparationApi } from '../../storyboard-preparation/api'
import type { StoryboardHandRepairHistory } from '../types'
import { breakdownApi } from '../api'
import { diagnosisReason, diagnosisStatusLabels } from '../diagnosis'
import type { DiagnosisHistory, DiagnosisRepairReadiness } from '../diagnosis.types'
import type { LegacyActionDiagnosisResults } from '../types'
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
import { errorMessage } from '../../../lib/http'
import { userFacingText } from '../../../lib/user-facing-text'
import { formatDate } from '../../../lib/format'
/** 单镜头按需核对修订条件和历史,不从诊断建议拼装可写草稿。 */
const props = defineProps<{
/** 所属正式项目。 */
projectId: string
/** 当前列表记录,切换版本后旧请求失效。 */
shot: LegacyActionDiagnosisResults['shots'][number]
}>()
/** 默认收起,避免对全项目每个镜头预先发起请求。 */
const expanded = ref<string[]>([])
/** 明确的按钮控制 Naive 折叠,折叠标题不再伪装成卡片操作。 */
const showDetails = computed(() => expanded.value.includes('review'))
/** 当前真实诊断历史。 */
const history = ref<DiagnosisHistory | null>(null)
/** 正式动作和主体修订共用的不可变记录。 */
const revisions = ref<StoryboardHandRepairHistory | null>(null)
/** 当前诊断对应的修订资格。 */
const readiness = ref<DiagnosisRepairReadiness | null>(null)
/** 当前列表与资格必须同时有效,不能把旧诊断或直接应用标记解释成修订许可。 */
const repairEligible = computed(() => readiness.value?.eligible === true && readiness.value.requiresManualReview === true &&
readiness.value.canApplyDirectly === false && readiness.value.willCallModel === false && readiness.value.willModifyAssets === false &&
props.shot.status === 'conflict_found' && props.shot.policyStatus === 'current' && props.shot.shotStale === false)
/** 只读请求加载,始终允许关闭主窗口。 */
const loading = ref(false)
/** 保留可重试的查询错误。 */
const error = ref('')
/** 同镜头诊断和版本状态组成请求身份。 */
const target = computed(() => JSON.stringify([props.projectId, props.shot.shotId, props.shot.diagnosisId, props.shot.policyStatus, props.shot.shotStale, props.shot.latestRepairId]))
/** 请求代次用于拦截迟到结果。 */
let version = 0
/** 只读请求关闭时取消。 */
let controller: AbortController | undefined
/** 读取指定镜头历史与对应诊断资格,始终验证返回归属。 */
async function load() {
if (loading.value) return
const current = ++version
const id = props.projectId, shotId = props.shot.shotId, diagnosisId = props.shot.diagnosisId
controller?.abort(); controller = new AbortController()
loading.value = true; error.value = ''
try {
const [records, checked, changes] = await Promise.all([
breakdownApi.diagnosisHistory(id, shotId, controller.signal),
diagnosisId ? breakdownApi.diagnosisRepairReadiness(id, shotId, diagnosisId, controller.signal) : Promise.resolve(null),
preparationApi.revisions(id, shotId, controller.signal)
])
if (current !== version) return
if (changes.projectId !== id || changes.shotId !== shotId || !Array.isArray(changes.revisions) || records.projectId !== id || records.shotId !== shotId || !Array.isArray(records.revisions) ||
checked && (checked.projectId !== id || checked.shotId !== shotId || checked.diagnosisId !== diagnosisId))
throw new Error('记录与当前镜头不一致,请重新读取。')
history.value = records; readiness.value = checked; revisions.value = changes
} catch (cause) { if (current === version) error.value = errorMessage(cause) }
finally { if (current === version) loading.value = false }
}
/** 收起或切换上下文时废弃旧请求,不把旧资格沿用到新版本。 */
function reset() { version++; controller?.abort(); loading.value = false; history.value = null; readiness.value = null; revisions.value = null; error.value = '' }
watch(expanded, value => { if (value.includes('review')) void load(); else reset() })
watch(target, () => { reset(); if (expanded.value.includes('review')) void load() })
onScopeDispose(reset)
</script>
<template>
<!-- 以下是指定诊断的只读修订条件与历史记录,普通列表不暴露内部编号 -->
<div class="diagnosis-shot-tools">
<NButton size="small" :aria-label="showDetails ? '收起修订条件与历史' : '修订条件与诊断历史'" :title="showDetails ? '收起修订条件与历史' : '修订条件与诊断历史'" :aria-expanded="showDetails" @click="expanded = showDetails ? [] : ['review']"><template #icon><History :size="15" aria-hidden="true" /></template><span class="diagnosis-action-label">{{ showDetails ? '收起修订条件与历史' : '修订条件与诊断历史' }}</span></NButton>
<NCollapse v-show="showDetails" v-model:expanded-names="expanded" class="diagnosis-shot-details">
<NCollapseItem name="review" title="修订条件与诊断历史">
<div class="space-y-3 text-xs leading-6">
<NButton size="small" :loading="loading" @click="load"><template #icon><RefreshCw :size="14" aria-hidden="true" /></template>刷新记录</NButton>
<p v-if="error" class="text-danger" role="alert">{{ error }}</p>
<p v-if="loading" role="status" class="text-muted">正在核对当前镜头记录…</p>
<section v-if="readiness" class="space-y-2" aria-label="当前诊断修订条件">
<p>{{ repairEligible ? '已满足人工修订的前提,仍需人工核对完整动作。' : '当前暂不能按这份诊断修订镜头。' }}</p>
<p v-for="reason in readiness.blockingReasons" :key="reason" class="text-muted">{{ diagnosisReason(reason) }}</p>
<p v-if="repairEligible" class="text-muted">可点击“查看并修订动作”,读取当前正式规划后再明确保存。</p>
<article v-for="(candidate, index) in readiness.repairCandidates" :key="index" class="space-y-1">
<p>阶段 {{ candidate.phaseNo }} · {{ candidate.characterRef }}</p><p>{{ userFacingText(candidate.suggestion) }}</p>
</article>
</section>
<section v-if="revisions" class="space-y-3" aria-label="正式修订历史">
<p class="font-medium">正式修订 · {{ revisions.count }} 条</p>
<p v-if="!revisions.revisions.length" class="text-muted">尚无保存的正式修订。</p>
<article v-for="record in revisions.revisions" :key="record.id" class="space-y-1"><p class="text-muted">{{ formatDate(record.createdAt) }}</p><p>{{ record.reason }}</p></article>
</section>
<section v-if="history" class="space-y-3" aria-label="诊断历史">
<p v-if="!history.revisions.length" class="text-muted">尚无保存的诊断记录。</p>
<article v-for="record in history.revisions" :key="record.id" class="space-y-1">
<p>{{ formatDate(record.createdAt) }} · {{ diagnosisStatusLabels[record.effectiveStatus as keyof typeof diagnosisStatusLabels] || '结果待核对' }}</p>
<p class="text-muted">{{ record.shotStale ? '镜头已变化' : '镜头内容一致' }} · {{ record.policyStatus === 'current' ? '规则版本一致' : record.policyStatus === 'stale' ? '规则版本已变化' : '缺少规则版本' }}</p>
<RawDataDetails :value="record" title="完整诊断证据(高级)" />
</article>
</section>
</div>
</NCollapseItem>
</NCollapse>
</div>
</template>
<style scoped>
.diagnosis-shot-tools { display: contents; }
.diagnosis-shot-tools > .n-button { min-height: 34px; }
/* 展开仍由 Naive 组件管理;入口使用独立可聚焦按钮,避免重复折叠标题。 */
.diagnosis-shot-details { flex-basis: 100%; min-width: 0; }
.diagnosis-shot-details :deep(.n-collapse-item__header) { display: none; }
.diagnosis-shot-details :deep(.n-collapse-item__content-wrapper) { padding-top: 16px; }
</style>