fix(short-drama-agent-front): 修复拆解进度展示与问题交互

This commit is contained in:
GJ committed 2026-10-17 10:21:44 +08:00
1 parent 3414cc8232
commit db91a4b871
19 files changed
+870 -150

No files matched your search

@@ -0,0 +1,116 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { NButton } from 'naive-ui'
import { AppDialog } from '../../../components/ui'
import type { ShotValidation } from '../types'
/** 同一剧集、节拍和镜头的校验问题分组。 */
interface BreakdownIssueGroup {
/** 稳定的位置键。 */
key: string
/** 后端提供的原始位置。 */
location: ShotValidation['issues'][number]
/** 去重后的原始错误描述。 */
messages: string[]
}
/** 拆解问题单独展示,设置弹窗不承载长错误正文。 */
const props = defineProps<{
/** 后端分镜校验问题,保留原始描述和位置。 */
issues: ShotValidation['issues']
/** 工作流执行异常,空值表示没有执行异常。 */
workflowError?: string
/** 当前结果是否允许定位到分镜正文。 */
locatable: boolean
}>()
/** 独立问题弹窗显隐。 */
const open = defineModel<boolean>('open', { default: false })
/** 弹窗关闭后再定位正文或打开设置,避免叠加焦点陷阱。 */
const emit = defineEmits<{ locate: [issue: ShotValidation['issues'][number]]; settings: [] }>()
/** 相同镜头的问题合并为一组,重复消息不重复显示。 */
const groups = computed(() => {
const result = new Map<string, BreakdownIssueGroup>()
for (const issue of props.issues) {
const key = `${issue.episodeNo}:${issue.beatNo ?? ''}:${issue.shotNo ?? ''}`
const group = result.get(key) ?? { key, location: issue, messages: [] }
if (!group.messages.includes(issue.message)) group.messages.push(issue.message)
result.set(key, group)
}
return [...result.values()]
})
/** 当前去重后的问题总数,不把多个位置合为一个错误。 */
const count = computed(() => groups.value.reduce((total, group) => total + group.messages.length, 0))
/** 等待离场后执行的定位。 */
const pendingLocation = ref<ShotValidation['issues'][number] | null>(null)
/** 等待离场后打开设置。 */
const pendingSettings = ref(false)
/**
* 关闭问题弹窗后定位到对应剧集、节拍或镜头。
* @param issue 后端提供的问题位置
*/
function locate(issue: ShotValidation['issues'][number]) {
if (!props.locatable) return
pendingLocation.value = { ...issue }
open.value = false
}
/** 关闭当前弹窗后打开拆解设置,避免同时显示两个操作弹窗。 */
function settings() {
pendingSettings.value = true
open.value = false
}
/** 离场动画结束后再交接焦点。 */
function finish() {
if (pendingLocation.value) {
const issue = pendingLocation.value
pendingLocation.value = null
emit('locate', issue)
}
if (pendingSettings.value) {
pendingSettings.value = false
emit('settings')
}
}
</script>
<template>
<!-- 以下是独立的拆解执行错误与分镜校验问题模块 -->
<AppDialog v-model:open="open" title="拆解问题" wide @closed="finish">
<template #description
><span v-if="count">{{ count }} 项校验问题 · {{ groups.length }} 个位置</span
><span v-else>查看最近保存结果中的问题</span></template
>
<div class="space-y-4">
<section v-if="workflowError" class="workspace-panel problem-surface space-y-3" aria-label="执行异常">
<h3 class="text-sm font-medium">执行异常</h3>
<p class="whitespace-pre-wrap break-words text-sm leading-6">{{ workflowError }}</p>
</section>
<article
v-for="group in groups"
:key="group.key"
class="workspace-panel problem-surface breakdown-issue-group space-y-3"
>
<div class="flex flex-wrap items-center justify-between gap-3">
<h3 class="text-sm font-medium">
第 {{ group.location.episodeNo }} 集<span v-if="group.location.beatNo">
· 节拍 {{ group.location.beatNo }}</span
><span v-if="group.location.shotNo"> · 镜头 {{ group.location.shotNo }}</span>
</h3>
<NButton v-if="locatable" size="small" text @click="locate(group.location)">{{
group.location.beatNo ? '定位分镜' : '查看本集'
}}</NButton>
</div>
<p v-for="message in group.messages" :key="message" class="break-words text-sm leading-6">
{{ message }}
</p>
</article>
<p v-if="!groups.length && !workflowError" class="py-5 text-sm text-muted">
后端尚未返回具体问题,请刷新拆解结果后查看。
</p>
</div>
<template #footer
><NButton @click="settings">拆解设置</NButton
><NButton type="primary" @click="open = false">关闭</NButton></template
>
</AppDialog>
</template>