feat(short-drama-agent-front): 适配故事规划并优化任务弹窗

This commit is contained in:
GJ committed 2026-10-28 11:47:05 +08:00
1 parent 48fce3975f
commit 5836b90934
12 files changed
+960 -133

No files matched your search

+100 -29
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { userFacingText } from '../../lib/user-facing-text'
import ContextNotice from '../../components/ui/ContextNotice.vue'
import WorkspaceSectionHeading from '../../components/ui/WorkspaceSectionHeading.vue'
import { computed } from 'vue'
import { NButton, NCollapse, NCollapseItem, NProgress, NTag } from 'naive-ui'
@@ -22,8 +23,10 @@ const props = withDefaults(
error: string
/** 是否展示运行、完成和错误详情;关闭后由调用方单独呈现问题。 */
showStatusHint?: boolean
/** 嵌入弹窗时使用扁平正文,标题、关闭及刷新操作由外层统一提供。 */
embedded?: boolean
}>(),
{ title: '制作任务', showStatusHint: true }
{ title: '制作任务', showStatusHint: true, embedded: false }
)
/** 刷新状态与隐藏任务记录事件。 */
const emit = defineEmits<{ refresh: []; dismiss: [] }>()
@@ -82,6 +85,10 @@ const progressLabel = computed(() =>
const statusLabel = computed(() => {
const labels = { pending: '等待开始', running: '执行中', completed: '已完成', failed: '失败' }
if (!props.execution) return ''
if (scriptCreation.value && props.execution.status === 'completed') {
if (result.value.projectStatus === 'need_review') return '执行结束 · 待修订'
if (result.value.projectStatus !== 'completed') return '执行结束 · 结果待确认'
}
if (breakdownTask.value && props.execution.status === 'completed') {
if (breakdownInvalid.value) return '执行结束 · 校验未通过'
if (breakdownNeedsReview.value) return '执行结束 · 待修订'
@@ -104,6 +111,12 @@ const staleMotionPlanCount = computed(() => {
})
/** 业务未通过或结果未知时,不把任务执行结束展示为全成功。 */
const statusType = computed(() => {
if (scriptCreation.value && props.execution?.status === 'completed')
return result.value.projectStatus === 'completed'
? 'success'
: result.value.projectStatus === 'need_review'
? 'warning'
: 'default'
if (diagnosisTask.value)
return props.execution?.status === 'failed'
? 'error'
@@ -199,15 +212,14 @@ function isInputMode(value: unknown, inputMode: string): boolean {
<template>
<section
v-if="execution || error"
class="panel mt-4 p-5"
:class="{ 'breakdown-execution-card': breakdownTask }"
:class="[embedded ? '' : 'panel mt-4 p-5', { 'breakdown-execution-card': breakdownTask }]"
:data-task-state="breakdownTask ? breakdownState : undefined"
:aria-label="title"
>
<div class="flex flex-wrap items-start justify-between gap-3">
<div v-if="!embedded" class="flex flex-wrap items-start justify-between gap-3">
<div>
<div class="flex flex-wrap items-center gap-2">
<h3 class="text-sm font-semibold">{{ title }}</h3>
<h3 v-if="!embedded" class="text-sm font-semibold">{{ title }}</h3>
<LoaderCircle v-if="!finished" :size="14" class="animate-spin text-muted" aria-hidden="true" />
<NTag v-if="execution" size="small" :type="statusType" :bordered="false">{{ statusLabel }}</NTag>
</div>
@@ -218,7 +230,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
</div>
<div class="flex items-center gap-2">
<NButton
v-if="finished || error"
v-if="!embedded && (finished || error)"
class="icon-button"
quaternary
aria-label="隐藏制作任务记录"
@@ -229,6 +241,33 @@ function isInputMode(value: unknown, inputMode: string): boolean {
</div>
</div>
<!-- 以下是弹窗内的任务状态与简洁元信息,用标题和对齐区分说明层级 -->
<template v-else>
<WorkspaceSectionHeading title="任务状态">
<template #actions>
<NTag v-if="execution" size="small" :type="statusType" :bordered="false">{{ statusLabel }}</NTag>
</template>
</WorkspaceSectionHeading>
<dl v-if="execution" class="mt-4 grid grid-cols-2 gap-x-6 gap-y-4">
<div v-if="!finished" class="col-span-2">
<dt class="text-xs text-muted">当前阶段</dt>
<dd class="mt-2 flex items-center gap-2 text-sm">
<LoaderCircle :size="14" class="animate-spin text-muted" aria-hidden="true" />{{
executionStageLabel(execution.stage)
}}
</dd>
</div>
<div>
<dt class="text-xs text-muted">更新时间</dt>
<dd class="mt-2 text-sm">{{ formatDate(execution.updatedAt) }}</dd>
</div>
<div>
<dt class="text-xs text-muted">处理范围</dt>
<dd class="mt-2 text-sm">{{ scopeLabel || '未提供范围' }}</dd>
</div>
</dl>
</template>
<template v-if="execution">
<!-- 以下是拆解任务的直接可见摘要,替代折叠详情和重复进度说明 -->
<dl v-if="breakdownTask" class="mt-4 grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4">
@@ -256,11 +295,12 @@ function isInputMode(value: unknown, inputMode: string): boolean {
v-if="execution.total > 0 && ((!breakdownTask && !diagnosisTask) || !finished)"
type="line"
:percentage="percentage"
:color="scriptCreation && result.projectStatus !== 'completed' ? 'var(--app-muted)' : undefined"
:height="5"
:show-indicator="false"
class="mt-4"
/>
<p v-if="!breakdownTask" class="mt-3 text-xs">
<p v-if="!breakdownTask && (!embedded || execution.total > 0)" class="mt-3 text-xs">
<template v-if="execution.total > 0"
>{{ progressLabel }} {{ execution.current }} / {{ execution.total }}</template
>
@@ -270,7 +310,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
: breakdownTask
? '拆解进行中,等待下一阶段结果'
: scriptCreation
? '正在创作剧本'
? execution.status === 'pending'
? '等待开始创作剧本'
: '正在创作剧本'
: '正在准备本次任务'
}}</template>
<template v-if="execution.currentResourceId && !scriptCreation && !breakdownTask">
@@ -280,7 +322,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
<ContextNotice
v-if="execution.status === 'running' && showStatusHint"
type="info"
:show-icon="false"
:show-icon="embedded"
:emphasized="embedded"
:title="embedded ? '任务进行中' : undefined"
class="mt-3"
>
{{
@@ -290,24 +334,40 @@ function isInputMode(value: unknown, inputMode: string): boolean {
<ContextNotice
v-else-if="execution.status === 'completed' && showStatusHint"
:type="
diagnosisTask
? 'info'
: breakdownInvalid
? 'warning'
: keyframeEdit
? result.passed === true
? 'success'
: result.validationSkipped === true
? 'info'
: 'warning'
: videoQuality && staleMotionPlanCount > 0
scriptCreation
? result.projectStatus === 'completed'
? 'success'
: result.projectStatus === 'need_review'
? 'warning'
: keyframeQuality &&
(!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
: 'info'
: diagnosisTask
? 'info'
: breakdownInvalid
? 'warning'
: keyframeEdit
? result.passed === true
? 'success'
: result.validationSkipped === true
? 'info'
: 'warning'
: videoQuality && staleMotionPlanCount > 0
? 'warning'
: 'success'
: keyframeQuality &&
(!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
? 'warning'
: 'success'
"
:show-icon="embedded"
:emphasized="embedded"
:title="
embedded
? scriptCreation && result.projectStatus === 'need_review'
? '审核仍需处理'
: scriptCreation && result.projectStatus !== 'completed'
? '结果待确认'
: '任务已完成'
: undefined
"
:show-icon="false"
class="mt-3"
>
<p>
@@ -317,7 +377,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
: breakdownTask
? '剧本拆解已结束,请查看候选与校验结果。'
: scriptCreation
? '剧本创作任务已结束,可查看最新剧本内容。'
? result.projectStatus === 'need_review'
? '剧本创作任务已结束,审核仍需处理,请查看当前审核结果。'
: '剧本创作任务已结束,可查看最新剧本内容。'
: '本轮任务已结束,可查看最新镜头资产状态。'
}}
</p>
@@ -361,7 +423,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
<ContextNotice
v-else-if="execution.status === 'failed' && showStatusHint"
type="error"
:show-icon="false"
:show-icon="embedded"
:emphasized="embedded"
:title="embedded ? '任务未完成' : undefined"
class="mt-3"
>
<p>{{ userFacingText(execution.error) || '制作任务执行失败。' }}</p>
@@ -395,7 +459,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
</p>
</div>
<!-- 以下是非拆解任务的 Naive 详情折叠模块 -->
<NCollapse v-if="!breakdownTask" class="mt-3 text-xs text-muted">
<NCollapse v-if="!breakdownTask && !embedded" class="mt-3 text-xs text-muted">
<NCollapseItem name="task-details" title="任务详情">
<p class="mt-2 break-all font-mono">任务编号 · {{ execution.id }}</p>
<!-- 以下是逐镜已结束质量任务的持久化状态模块 -->
@@ -420,9 +484,16 @@ function isInputMode(value: unknown, inputMode: string): boolean {
>
动作版本过期 {{ staleMotionPlanCount }} · 这些候选已停止质量流程,其余镜头继续处理。
</p>
<ContextNotice v-if="error" type="error" :show-icon="false" class="mt-3">
<ContextNotice
v-if="error"
type="error"
:show-icon="embedded"
:emphasized="embedded"
:title="embedded ? '状态读取失败' : undefined"
class="mt-3"
>
{{ error }}。任务可能仍在运行,请先重新读取状态;不要直接重复提交。
<NButton text class="ml-3" :loading="loading" @click="emit('refresh')">重试读取</NButton>
<NButton v-if="!embedded" text class="ml-3" :loading="loading" @click="emit('refresh')">重试读取</NButton>
</ContextNotice>
</section>
</template>