fix(short-drama-agent-front): 统一全屏布局与问题处理交互

This commit is contained in:
GJ committed 2026-10-17 17:40:39 +08:00
1 parent db91a4b871
commit cc27d463e0
25 files changed
+838 -316

No files matched your search

+146 -95
View File
@@ -7,7 +7,7 @@ import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue
import { NScrollbar, NButton, NCheckbox, NInputNumber, NTab, NTable, NTabs } from 'naive-ui'
import { computed, h, nextTick, onScopeDispose, ref, watch } from 'vue'
import { useActionMessage } from '../../components/ui/useActionMessage'
import { Layers, LoaderCircle, Settings2 } from '@lucide/vue'
import { CircleAlert, Layers, LoaderCircle, Settings2 } from '@lucide/vue'
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
import { useProjectContext } from '../projects/context'
import { breakdownApi } from './api'
@@ -37,10 +37,21 @@ const previewBusy = ref(false)
const candidateOnly = ref(true)
const tab = ref('character')
const toolsOpen = ref(false)
/** 错误详情使用独立弹窗,不在设置区展开长文本。 */
/** 问题查看、人工修订和阶段恢复共用独立窗口。 */
const issuesOpen = ref(false)
/** 从设置切换时等待关闭动画结束,避免两层弹窗同时显示。 */
const pendingIssues = ref(false)
/** 问题入口统一使用红色文字、图标和柔和底色,交互时保持错误语义。 */
const issueButtonTheme = {
color: 'var(--app-danger-soft)',
colorHover: 'color-mix(in srgb, var(--app-danger-soft), var(--app-danger) 8%)',
colorPressed: 'color-mix(in srgb, var(--app-danger-soft), var(--app-danger) 14%)',
colorFocus: 'var(--app-danger-soft)',
textColor: 'var(--app-danger)',
textColorHover: 'var(--app-danger)',
textColorPressed: 'var(--app-danger)',
textColorFocus: 'var(--app-danger)'
}
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
{ value: 'character', label: '人物', description: '人物身份、外观与形态' },
{ value: 'scene', label: '场景', description: '故事空间与环境特征' },
@@ -177,8 +188,36 @@ watch(
void Promise.all([refresh(), refreshStageReadiness()])
}
)
/** 结构校验通过后仍可能存在服务端明确标记的质量待审剧集。 */
const pendingQuality = computed(() => !!latestCheckpoint.value?.state.storyboardPendingQualityEpisodeNos?.length)
/** 只在已有拆解结果且任务中断或校验待处理时提供阶段恢复。 */
const showRecovery = computed(
() => records.value.length > 0 && (execution.value?.status !== 'completed' || validation.value?.valid === false)
() =>
records.value.length > 0 &&
(execution.value?.status !== 'completed' || validation.value?.valid === false || pendingQuality.value)
)
/** 问题入口兼顾执行异常、结构错误、质量待审和已停止的恢复任务。 */
const hasBreakdownIssues = computed(() =>
Boolean(
execution.value?.errorMessage ||
validation.value?.valid === false ||
pendingQuality.value ||
(showRecovery.value && taskStopped.value)
)
)
/** 问题按钮按真实问题类型展示,不把质量待审或执行异常误称为结构校验失败。 */
const issueEntryLabel = computed(() =>
validation.value?.valid === false ? '分镜校验未通过' : pendingQuality.value ? '分镜质量待修订' : '拆解问题待处理'
)
/** 所有问题修改和恢复共用活动锁及后台状态读取限制,查看问题不受影响。 */
const issueActionsDisabled = computed(
() =>
project.value?.status !== 'completed' ||
!!error.value ||
operation.value.pending ||
breakdownBusy.value ||
backgroundExecution.discovering.value ||
!!backgroundExecution.discoveryError.value
)
const configValid = computed(
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
@@ -191,7 +230,7 @@ const input = computed<BreakdownInput>(() => ({
}))
/** 后端就绪状态用于拆解完成反馈。 */
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
/** 拆解提示复用全局 NMessage,详细问题留在设置弹窗。 */
/** 拆解提示复用全局 NMessage,详细问题与修订操作放在独立问题窗口。 */
const actionMessage = useActionMessage()
/** 问题内容变化才通知,轮询取得相同快照时不会重复弹出。 */
const issueSignature = computed(() =>
@@ -319,7 +358,7 @@ async function run(action: BreakdownAction) {
await backgroundExecution.track(started.executionId)
return started
},
{ type: 'info', content: '拆解任务已提交,可在“拆解设置与恢复”中查看进度。' }
{ type: 'info', content: '拆解任务已提交,可在“拆解设置”中查看进度。' }
)
await refresh()
}
@@ -387,22 +426,29 @@ const rules = {
><LoaderCircle :size="13" class="animate-spin" />最近阶段:{{ runningStage }}</span
>
</div>
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗;阶段切换使用侧栏 -->
<!-- 以下是独立的拆解入口与问题处理入口,避免混合生成和修订流程 -->
<div v-if="project?.episodes.length" class="toolbar-actions">
<NButton
v-if="execution?.errorMessage || validation?.valid === false"
text
type="error"
v-if="hasBreakdownIssues"
class="breakdown-issues-trigger breakdown-desktop-issues"
:theme-overrides="issueButtonTheme"
:aria-label="issueEntryLabel"
:title="issueEntryLabel"
aria-haspopup="dialog"
:aria-expanded="issuesOpen"
@click="openIssues"
>查看拆解问题</NButton
>
<template #icon><CircleAlert :size="15" aria-hidden="true" /></template>
<span class="breakdown-issues-label">{{ issueEntryLabel }}</span>
</NButton>
<WorkspaceTools
:pending="operation.pending"
:pending-label="operation.label"
v-model:open="toolsOpen"
title="拆解设置与恢复"
label="拆解设置与恢复"
title="拆解设置"
label="拆解设置"
fullscreen
@closed="finishOpeningIssues"
>
<section class="panel workspace-panel breakdown-settings-panel">
@@ -547,13 +593,6 @@ const rules = {
:disabled="!!error || operation.pending || backgroundExecution.active.value"
@refresh="refreshCandidate"
/>
<StoryboardQualityRepair
v-if="toolsOpen && snapshot"
:project-id="projectId"
:checkpoint="latestCheckpoint"
:disabled="!!error || operation.pending || backgroundExecution.active.value"
@refresh="refreshCandidate"
/>
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
title="剧本拆解任务"
@@ -565,71 +604,6 @@ const rules = {
@refresh="backgroundExecution.query.refresh"
@dismiss="backgroundExecution.dismiss"
/>
<!-- 以下是简洁的问题摘要与恢复操作,详细错误只在独立弹窗展示 -->
<section v-if="snapshot" class="space-y-4">
<div
v-if="execution?.errorMessage || validation?.valid === false"
class="workspace-panel problem-surface flex flex-wrap items-center justify-between gap-3"
>
<p class="text-sm">
{{ execution?.errorMessage ? '拆解执行异常' : '分镜校验未通过'
}}<span v-if="storyboardIssues.length" class="ml-2 text-xs text-muted"
>{{ storyboardIssues.length }} 项问题</span
>
</p>
<NButton text @click="openIssues">查看问题</NButton>
</div>
<div v-if="showRecovery" class="recovery-strip">
<div>
<p class="text-sm font-medium">从中断处继续</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
:loading="isOperationRunning(operation, '正在重试失败抽取')"
label="重试失败抽取"
description="只重试 character / scene / prop 抽取任务中的失败项。不能用于镜头阶段失败。"
acknowledgement
:disabled="
project?.status !== 'completed' ||
!recovery.retry ||
operation.pending ||
backgroundExecution.discovering.value ||
!!backgroundExecution.discoveryError.value ||
!!error
"
@confirm="run('retry')"
/><ConfirmAction
:loading="isOperationRunning(operation, '正在补齐镜头')"
label="补齐缺失镜头"
description="复用已完成剧集的镜头,仅生成尚未完成的 Episode Shot,再进行校验与入库。"
acknowledgement
:disabled="
project?.status !== 'completed' ||
!recovery.shots ||
operation.pending ||
backgroundExecution.discovering.value ||
!!backgroundExecution.discoveryError.value ||
!!error
"
@confirm="run('resume-shots')"
/><ConfirmAction
:loading="isOperationRunning(operation, '正在修复分镜绑定')"
label="修复分镜绑定"
description="复用已有镜头,修复 SubjectRef 与视觉 Form 绑定,再校验并保存。"
acknowledgement
:disabled="
project?.status !== 'completed' ||
!recovery.storyboard ||
operation.pending ||
backgroundExecution.discovering.value ||
!!backgroundExecution.discoveryError.value ||
!!error
"
@confirm="run('resume-storyboard')"
/>
</div>
</div>
</section>
</WorkspaceTools>
</div>
</div>
@@ -655,12 +629,25 @@ const rules = {
>
<template #suffix
><div class="tabs-toolbar-actions breakdown-toolbar-actions">
<!-- 以下是移动端校验问题入口,与设置图标并排且共用问题详情 -->
<NButton
v-if="hasBreakdownIssues"
class="icon-button breakdown-issues-trigger breakdown-mobile-issues"
:theme-overrides="issueButtonTheme"
:aria-label="issueEntryLabel"
:title="issueEntryLabel"
aria-haspopup="dialog"
:aria-expanded="issuesOpen"
@click="openIssues"
>
<template #icon><CircleAlert :size="15" aria-hidden="true" /></template>
</NButton>
<!-- 以下是手机分类导航中的拆解设置入口,共用原有设置弹窗 -->
<NButton
quaternary
class="icon-button breakdown-mobile-tools"
aria-label="拆解设置与恢复"
title="拆解设置与恢复"
aria-label="拆解设置"
title="拆解设置"
aria-haspopup="dialog"
:aria-expanded="toolsOpen"
@click="toolsOpen = true"
@@ -768,24 +755,73 @@ const rules = {
</section>
</template>
</WorkspacePage>
<!-- 以下是与拆解设置分离的问题详情弹窗 -->
<!-- 以下是与拆解设置分离的全屏问题详情抽屉 -->
<BreakdownIssuesDialog
v-model:open="issuesOpen"
:issues="storyboardIssues"
:workflow-error="execution?.errorMessage"
:locatable="!breakdownBusy && !!shots.length"
@locate="locateIssue"
@settings="toolsOpen = true"
/>
>
<!-- 以下是只属于问题处理的人工修订与阶段恢复,不混入拆解启动配置 -->
<template #repair>
<p v-if="breakdownBusy || operation.pending" role="status" class="text-xs leading-6 text-muted">
任务执行中,可查看问题,结束后再修订或恢复。
</p>
<p
v-else-if="backgroundExecution.discovering.value || backgroundExecution.discoveryError.value || error"
role="status"
class="text-xs leading-6 text-muted"
>
任务状态或结果尚未确认,请先重新读取状态与结果。
</p>
<StoryboardQualityRepair
v-if="issuesOpen && snapshot"
:project-id="projectId"
:checkpoint="latestCheckpoint"
:disabled="issueActionsDisabled"
@refresh="refreshCandidate"
/>
<div v-if="snapshot && showRecovery" class="recovery-strip">
<div>
<p class="text-sm font-medium">从中断处继续</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
:loading="isOperationRunning(operation, '正在重试失败抽取')"
label="重试失败抽取"
description="只重试 character / scene / prop 抽取任务中的失败项。不能用于镜头阶段失败。"
acknowledgement
:disabled="issueActionsDisabled || !recovery.retry"
@confirm="run('retry')"
/><ConfirmAction
:loading="isOperationRunning(operation, '正在补齐镜头')"
label="补齐缺失镜头"
description="复用已完成剧集的镜头,仅生成尚未完成的 Episode Shot,再进行校验与入库。"
acknowledgement
:disabled="issueActionsDisabled || !recovery.shots"
@confirm="run('resume-shots')"
/><ConfirmAction
:loading="isOperationRunning(operation, '正在修复分镜绑定')"
label="修复分镜绑定"
description="复用已有镜头,修复 SubjectRef 与视觉 Form 绑定,再校验并保存。"
acknowledgement
:disabled="issueActionsDisabled || !recovery.storyboard"
@confirm="run('resume-storyboard')"
/>
</div>
</div>
</template>
</BreakdownIssuesDialog>
</template>
<style>
/* 键盘聚焦仍有清晰提示,并与问题入口的红色语义保持一致。 */
.breakdown-workspace-page .breakdown-issues-trigger.n-button:focus-visible {
outline-color: var(--app-danger);
}
/* 本组件专属布局与 Naive 内部结构覆盖。 */
@reference "../../styles/styles.css";
/* 任务进度与设置面板共用水平边界,避免重复内缩。 */
.workspace-tools-body .breakdown-execution-panel {
padding: 0;
}
.group-preview {
@apply mt-6 pt-5;
}
@@ -887,7 +923,8 @@ const rules = {
.breakdown-workspace-page .breakdown-toolbar-actions {
gap: 0;
}
.breakdown-workspace-page .breakdown-mobile-tools.n-button {
.breakdown-workspace-page .breakdown-mobile-tools.n-button,
.breakdown-workspace-page .breakdown-mobile-issues.n-button {
display: none;
}
.breakdown-task-label-mobile {
@@ -908,7 +945,8 @@ const rules = {
.breakdown-workspace-page .workspace-tabs.n-tabs .n-tabs-nav .n-tabs-tab {
padding-inline: 8px;
}
.breakdown-workspace-page .breakdown-mobile-tools.n-button {
.breakdown-workspace-page .breakdown-mobile-tools.n-button,
.breakdown-workspace-page .breakdown-mobile-issues.n-button {
display: inline-flex;
width: 44px;
min-width: 44px;
@@ -963,6 +1001,19 @@ const rules = {
.breakdown-workspace-page .workspace-tools-label {
@apply hidden;
}
/* 窄屏问题入口与设置按钮保持同样的方形尺寸,仅隐藏可见文案。 */
.breakdown-workspace-page .breakdown-issues-label {
display: none;
}
.breakdown-workspace-page .breakdown-desktop-issues.n-button {
width: 32px;
min-width: 32px;
height: 32px;
padding: 0;
}
.breakdown-workspace-page .breakdown-issues-trigger .n-button__icon {
margin: 0;
}
.breakdown-workspace-page .workspace-tools-trigger {
@apply h-8 w-8 p-0;
min-width: 32px;
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { NButton } from 'naive-ui'
import { AppDialog } from '../../../components/ui'
import { AppDrawer } from '../../../components/ui'
import type { ShotValidation } from '../types'
/** 同一剧集、节拍和镜头的校验问题分组。 */
@@ -14,7 +14,7 @@ interface BreakdownIssueGroup {
messages: string[]
}
/** 拆解问题单独展示,设置弹窗不承载长错误正文。 */
/** 拆解问题及调用方提供的修订、恢复操作使用独立全屏抽屉展示。 */
const props = defineProps<{
/** 后端分镜校验问题,保留原始描述和位置。 */
issues: ShotValidation['issues']
@@ -23,10 +23,10 @@ const props = defineProps<{
/** 当前结果是否允许定位到分镜正文。 */
locatable: boolean
}>()
/** 独立问题弹窗显隐。 */
/** 独立问题抽屉显隐。 */
const open = defineModel<boolean>('open', { default: false })
/** 弹窗关闭后再定位正文或打开设置,避免叠加焦点陷阱。 */
const emit = defineEmits<{ locate: [issue: ShotValidation['issues'][number]]; settings: [] }>()
/** 抽屉关闭后再定位正文,避免焦点陷阱阻止定位。 */
const emit = defineEmits<{ locate: [issue: ShotValidation['issues'][number]] }>()
/** 相同镜头的问题合并为一组,重复消息不重复显示。 */
const groups = computed(() => {
const result = new Map<string, BreakdownIssueGroup>()
@@ -42,11 +42,9 @@ const groups = computed(() => {
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]) {
@@ -54,11 +52,6 @@ function locate(issue: ShotValidation['issues'][number]) {
pendingLocation.value = { ...issue }
open.value = false
}
/** 关闭当前弹窗后打开拆解设置,避免同时显示两个操作弹窗。 */
function settings() {
pendingSettings.value = true
open.value = false
}
/** 离场动画结束后再交接焦点。 */
function finish() {
if (pendingLocation.value) {
@@ -66,16 +59,12 @@ function finish() {
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">
<!-- 以下是全屏展示的拆解执行错误与分镜校验问题模块 -->
<AppDrawer v-model:open="open" title="拆解问题" @closed="finish">
<template #description
><span v-if="count">{{ count }} 项校验问题 · {{ groups.length }} 个位置</span
><span v-else>查看最近保存结果中的问题</span></template
@@ -105,12 +94,12 @@ function finish() {
</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>
<!-- 以下是独立的问题修订与阶段恢复模块,不承载生成配置或候选提交 -->
<div v-if="$slots.repair" class="mt-6 space-y-5" aria-label="问题修订与恢复"><slot name="repair" /></div>
<!-- 以下是灰底关闭操作,绿色主按钮仅用于提交或执行任务 -->
<template #footer><NButton type="default" @click="open = false">关闭</NButton></template>
</AppDrawer>
</template>
@@ -696,8 +696,9 @@ defineExpose({ open })
</div>
</div>
</NSpin>
<!-- 以下是固定底栏操作模块,正文滚动时仍可预览范围并进行费用确认 -->
<!-- 以下是固定底栏关闭、预览与确认模块,正文滚动时仍可退出 -->
<template #footer>
<NButton @click="dialogOpen = false">关闭</NButton>
<NButton
:loading="previewBusy"
:disabled="!dialogDataReady || dialogLoading || starting || execution.active.value"