feat: 同步动作与首帧编辑能力并统一工作区反馈
接入动作时间轴、密度审计、人工视线目标和后台首帧编辑;独立读取已保存提示词,并在首帧晋升前重新核对持久化质量状态。 统一 NMessage 结果反馈、局部 loading 和业务说明间距,保留真实长任务进度与部分失败语义。 验证:pnpm check(49 个文件、393 项测试)、pnpm build;当前环境无法完成 localhost 浏览器验收及真实后端联调。
This commit is contained in:
1 parent
83482a70c5
commit
7a60db3ced
76 files changed
+2485
-457
No files matched your search
@@ -1,6 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NAlert, NButton, NCollapse, NCollapseItem, NInput, NSelect, NTab, NTabs } from 'naive-ui'
|
||||
import { NButton, NCollapse, NCollapseItem, NInput, NSelect, NTab, NTabs } from 'naive-ui'
|
||||
import { Download, Search } from '@lucide/vue'
|
||||
import { AppDialog, EmptyState } from '../../components/ui'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
@@ -69,20 +71,20 @@ function exportReport() {
|
||||
description="展示全项目已保存的 checkpoint 指标与完整时间线,不启动或恢复任务。"
|
||||
wide
|
||||
>
|
||||
<NAlert type="info" :show-icon="false" class="mt-4 text-xs"
|
||||
>后端指标按保存记录累计;耗时之和不等于实际墙钟耗时,“completed”也不代表图片或视频成功。生产任务状态请以资产页面为准。</NAlert
|
||||
<ContextNotice type="info" :show-icon="false" class="mt-4 text-xs"
|
||||
>后端指标按保存记录累计;耗时之和不等于实际墙钟耗时,“completed”也不代表图片或视频成功。生产任务状态请以资产页面为准。</ContextNotice
|
||||
>
|
||||
<NAlert v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mt-3"
|
||||
>{{ query.error.value }},当前保留上次数据。</NAlert
|
||||
<ContextNotice v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mt-3"
|
||||
>{{ query.error.value }},当前保留上次数据。</ContextNotice
|
||||
>
|
||||
<NAlert
|
||||
<ContextNotice
|
||||
v-for="error in query.data.value?.errors"
|
||||
:key="error"
|
||||
role="alert"
|
||||
type="error"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
>{{ error }}</NAlert
|
||||
>{{ error }}</ContextNotice
|
||||
>
|
||||
<div class="mt-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex flex-wrap items-center gap-4 text-sm">
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed } from 'vue'
|
||||
import { NAlert, NButton, NProgress, NTag } from 'naive-ui'
|
||||
import { X } from '@lucide/vue'
|
||||
import { NButton, NProgress, NTag } from 'naive-ui'
|
||||
import { LoaderCircle, X } from '@lucide/vue'
|
||||
import { formatDate } from '../../lib/format'
|
||||
import { executionPercentage, executionStageLabel } from './execution'
|
||||
import type { WorkflowExecution } from './execution.types'
|
||||
@@ -39,6 +41,8 @@ const scriptCreation = computed(() => props.execution?.workflowName === 'create-
|
||||
const videoQuality = computed(() => props.execution?.workflowName === 'video-quality')
|
||||
/** 首帧质量后台任务使用独立的通过与修复失败统计,不套用普通生图字段。 */
|
||||
const keyframeQuality = computed(() => props.execution?.workflowName === 'keyframe-quality')
|
||||
/** 首帧编辑复用质量工作流,最终回执不属于批量质量统计。 */
|
||||
const keyframeEdit = computed(() => props.execution?.metadata?.action === 'edit-keyframe')
|
||||
/** 只接受后端完整的质量计数,畸形或缺失结果不显示全成功。 */
|
||||
const keyframeCounts = computed(() => {
|
||||
const fields = ['targetCount', 'passed', 'repairFailed', 'failed'] as const
|
||||
@@ -94,6 +98,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h3 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>
|
||||
<p v-if="execution" class="mt-2 text-xs text-muted">
|
||||
@@ -132,17 +137,29 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
· 当前镜头 <code>{{ execution.currentResourceId }}</code></template
|
||||
>
|
||||
</p>
|
||||
<NAlert v-if="execution.status === 'running' && showStatusHint" type="info" :show-icon="false" class="mt-3">
|
||||
<ContextNotice
|
||||
v-if="execution.status === 'running' && showStatusHint"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
>
|
||||
{{
|
||||
videoQuality ? '系统会继续生成、检查并按需修复。' : '系统会继续处理剩余内容并保存已完成结果。'
|
||||
}}可以离开或刷新页面,返回后会继续显示本次任务进度,请勿重复提交。
|
||||
</NAlert>
|
||||
<NAlert
|
||||
</ContextNotice>
|
||||
<ContextNotice
|
||||
v-else-if="execution.status === 'completed' && showStatusHint"
|
||||
:type="
|
||||
keyframeQuality && (!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
|
||||
? 'warning'
|
||||
: 'success'
|
||||
keyframeEdit
|
||||
? result.passed === true
|
||||
? 'success'
|
||||
: result.validationSkipped === true
|
||||
? 'info'
|
||||
: 'warning'
|
||||
: keyframeQuality &&
|
||||
(!keyframeCounts || keyframeCounts.repairFailed + keyframeCounts.failed > 0)
|
||||
? 'warning'
|
||||
: 'success'
|
||||
"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
@@ -150,8 +167,8 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<p>
|
||||
{{
|
||||
scriptCreation
|
||||
? '剧本创作任务已结束,页面正在重新读取剧本内容。'
|
||||
: '本轮任务已结束,页面正在重新读取镜头资产状态。'
|
||||
? '剧本创作任务已结束,可查看最新剧本内容。'
|
||||
: '本轮任务已结束,可查看最新镜头资产状态。'
|
||||
}}
|
||||
</p>
|
||||
<p v-if="videoQuality" class="mt-2 text-xs">
|
||||
@@ -163,6 +180,16 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
输入规划:首帧模式 {{ inputPlanCounts.firstFrame }} · 全模态参考
|
||||
{{ inputPlanCounts.omniReference }}
|
||||
</p>
|
||||
<p v-else-if="keyframeEdit" class="mt-2 text-xs">
|
||||
{{
|
||||
result.validationSkipped === true
|
||||
? '编辑候选已生成,尚未进行质量校验。'
|
||||
: result.passed === true
|
||||
? '编辑结果质量通过。'
|
||||
: '编辑结果未通过质量校验。'
|
||||
}}
|
||||
{{ result.primaryChanged === true ? '已更新主首帧。' : '主首帧未替换。' }}
|
||||
</p>
|
||||
<p v-else-if="keyframeQuality" class="mt-2 text-xs">
|
||||
<template v-if="keyframeCounts"
|
||||
>目标 {{ keyframeCounts.targetCount }} · 通过 {{ keyframeCounts.passed }} · 修复未通过
|
||||
@@ -174,8 +201,8 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
|
||||
{{ result.skipped ?? 0 }} · 阻塞 {{ result.blocked ?? 0 }} · 失败 {{ result.failed ?? 0 }}
|
||||
</p>
|
||||
</NAlert>
|
||||
<NAlert v-else-if="execution.status === 'failed'" type="error" :show-icon="false" class="mt-3">
|
||||
</ContextNotice>
|
||||
<ContextNotice v-else-if="execution.status === 'failed'" type="error" :show-icon="false" class="mt-3">
|
||||
<p>{{ execution.error || '制作任务执行失败。' }}</p>
|
||||
<p class="mt-2 text-xs">
|
||||
{{
|
||||
@@ -184,15 +211,15 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
|
||||
}}
|
||||
</p>
|
||||
</NAlert>
|
||||
</ContextNotice>
|
||||
<details class="mt-3 text-[10px] text-muted">
|
||||
<summary class="cursor-pointer">任务详情</summary>
|
||||
<p class="mt-2 break-all font-mono">任务编号 · {{ execution.id }}</p>
|
||||
</details>
|
||||
</template>
|
||||
<NAlert v-if="error" type="error" :show-icon="false" class="mt-3">
|
||||
<ContextNotice v-if="error" type="error" :show-icon="false" class="mt-3">
|
||||
{{ error }}。任务可能仍在运行,请先重新读取状态;不要直接重复提交。
|
||||
<NButton text class="ml-3" :loading="loading" @click="emit('refresh')">重试读取</NButton>
|
||||
</NAlert>
|
||||
</ContextNotice>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,6 +1,7 @@
|
||||
import { computed, onScopeDispose, reactive, ref, watch, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { workflowExecutionApi } from './execution-api'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
|
||||
const storagePrefix = 'short-drama:workflow-execution'
|
||||
|
||||
@@ -17,6 +18,8 @@ interface ExecutionActivity {
|
||||
}
|
||||
/** 活动状态按项目和工作流共同隔离。 */
|
||||
const executionActivity = reactive<Record<string, ExecutionActivity>>({})
|
||||
/** 同任务可能有页面和弹窗多个观察器,真实终态仅通知一次。 */
|
||||
const announcedExecutions = new Set<string>()
|
||||
|
||||
/**
|
||||
* 检查项目是否仍有已跟踪且未结束的后台任务。
|
||||
@@ -46,6 +49,7 @@ export function executionStageLabel(stage: string | null) {
|
||||
storyboardDirection: '生成导演设计',
|
||||
storyboardVisualState: '生成即时状态',
|
||||
keyframe_generation: '生成普通首帧',
|
||||
editKeyframe: '编辑并检查首帧',
|
||||
videoPrompt: '生成视频提示词',
|
||||
breakdownRetry: '重试失败拆解任务',
|
||||
breakdownResumeShots: '补齐分镜镜头',
|
||||
@@ -93,6 +97,10 @@ function savedExecutionId(projectId: string, workflowName: string) {
|
||||
|
||||
/** 跟踪一个项目最近的持久化任务;刷新页面后从本地句柄恢复,状态仍从后端读取。 */
|
||||
export function useWorkflowExecution(projectId: Ref<string>, workflowName: string) {
|
||||
/** 状态反馈与应用其它操作共用消息层。 */
|
||||
const message = useActionMessage()
|
||||
/** 仅通知本会话观察到运行或主动启动的任务,不重放旧完成记录。 */
|
||||
const observedActive = new Set<string>()
|
||||
/** 卸载后仍保存原项目返回的句柄,但不再更新已销毁的观察器。 */
|
||||
let disposed = false
|
||||
onScopeDispose(() => {
|
||||
@@ -155,6 +163,47 @@ export function useWorkflowExecution(projectId: Ref<string>, workflowName: strin
|
||||
terminal.value = status === 'completed' || status === 'failed'
|
||||
}
|
||||
)
|
||||
watch(
|
||||
() => query.data.value,
|
||||
record => {
|
||||
if (!record || record.projectId !== projectId.value) return
|
||||
if (record.status === 'pending' || record.status === 'running') {
|
||||
observedActive.add(record.id)
|
||||
return
|
||||
}
|
||||
if (!observedActive.has(record.id) || announcedExecutions.has(record.id) || !message) return
|
||||
announcedExecutions.add(record.id)
|
||||
if (record.status === 'failed') {
|
||||
message.error(record.error || '后台任务失败,请查看任务记录。', { duration: 8000, closable: true })
|
||||
return
|
||||
}
|
||||
const result = record.result ?? {}
|
||||
if (record.metadata?.action === 'edit-keyframe') {
|
||||
const content =
|
||||
result.validationSkipped === true
|
||||
? '首帧编辑候选已生成,请另行完成质量检查。'
|
||||
: result.passed === true
|
||||
? result.primaryChanged === true
|
||||
? '编辑首帧已通过校验并设为主首帧。'
|
||||
: '编辑首帧已通过校验,请核对主图状态。'
|
||||
: '编辑首帧未通过校验,候选已保留。'
|
||||
message[result.validationSkipped === true ? 'info' : result.passed === true ? 'success' : 'warning'](
|
||||
content,
|
||||
{ duration: 6000, closable: true }
|
||||
)
|
||||
return
|
||||
}
|
||||
const failures = ['failed', 'repairFailed', 'exhausted', 'providerFailed', 'submissionFailed'].some(
|
||||
field => typeof result[field] === 'number' && Number(result[field]) > 0
|
||||
)
|
||||
message[failures ? 'warning' : 'info'](
|
||||
failures
|
||||
? '本轮任务已结束,部分结果未通过或执行失败,请查看任务记录。'
|
||||
: '本轮后台任务已结束,请查看最新结果。',
|
||||
{ duration: 5000, closable: true }
|
||||
)
|
||||
}
|
||||
)
|
||||
const active = computed(() => {
|
||||
const activity = executionActivity[storageKey(projectId.value, workflowName)]
|
||||
return activity?.id === executionId.value
|
||||
@@ -171,6 +220,7 @@ export function useWorkflowExecution(projectId: Ref<string>, workflowName: strin
|
||||
async function track(id: string, targetProjectId = projectId.value) {
|
||||
if (typeof id !== 'string' || !id.trim()) throw new Error('后端未返回有效任务编号,请刷新状态,勿重复提交。')
|
||||
if (!targetProjectId) return
|
||||
observedActive.add(id)
|
||||
if (typeof localStorage !== 'undefined') localStorage.setItem(storageKey(targetProjectId, workflowName), id)
|
||||
if (executionActivity[storageKey(targetProjectId, workflowName)]?.id !== id)
|
||||
executionActivity[storageKey(targetProjectId, workflowName)] = {
|
||||
|
||||
@@ -63,6 +63,35 @@ export function getOperation(projectId: string): Operation {
|
||||
return operations[projectId]
|
||||
}
|
||||
|
||||
/**
|
||||
* 只让当前操作对应的按钮加载,项目内其它按钮继续使用禁用状态。
|
||||
* @param operation 当前项目操作状态
|
||||
* @param label 当前按钮实际提交的操作名称或唯一片段
|
||||
* @returns 当前按钮是否对应运行中的请求
|
||||
*/
|
||||
export function isOperationRunning(operation: Operation, label: string) {
|
||||
return operation.pending && !!label && operation.label.includes(label)
|
||||
}
|
||||
|
||||
/**
|
||||
* 按后端真实批量统计反馈部分失败,不把 HTTP 200 当作全部成功。
|
||||
* @param result 后端已返回的批量统计
|
||||
* @param label 当前批量操作名称
|
||||
* @returns 适用于 NMessage 的结果级别和摘要
|
||||
*/
|
||||
export function batchResultNotice(
|
||||
result: { generated: number; failed: number; blocked?: number },
|
||||
label: string
|
||||
): OperationNotice {
|
||||
if (![result.generated, result.failed].every(value => Number.isSafeInteger(value) && value >= 0))
|
||||
return { type: 'info', content: `${label}已返回,请查看详细回执。` }
|
||||
const blocked = typeof result.blocked === 'number' && result.blocked > 0 ? result.blocked : 0
|
||||
return {
|
||||
type: result.failed > 0 || blocked > 0 ? 'warning' : 'success',
|
||||
content: `${label}本轮处理结束:生成 ${result.generated} 项${result.failed ? `,失败 ${result.failed} 项` : ''}${blocked ? `,阻塞 ${blocked} 项` : ''}。`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 只提交一次,并按真实业务回执生成反馈;断网不自动重试。
|
||||
* @param projectId 当前项目编号
|
||||
|
||||
Reference in new issue
Block a user