feat(short-drama-agent-front): 完善质量规则确认与中文交互
This commit is contained in:
1 parent
190333d4f9
commit
c4b43b9725
85 files changed
+2059
-480
No files matched your search
@@ -24,7 +24,7 @@ const history = computed(() => workflowCheckpoints(props.checkpoints, props.work
|
||||
<h3 class="mb-1 flex items-center gap-2 text-sm font-semibold"><Clock3 :size="15" />执行记录</h3>
|
||||
<NButton class="history-close" text size="small" @click="emit('close')">关闭</NButton>
|
||||
</div>
|
||||
<p class="mb-6 text-xs leading-5 text-muted">最近 18 个 checkpoint · 自动刷新</p>
|
||||
<p class="mb-6 text-xs leading-5 text-muted">最近 18 条保存记录 · 自动更新</p>
|
||||
<NButton v-if="projectId" text size="small" class="mb-4" @click="diagnosticsOpen = true"
|
||||
>查看完整运行诊断</NButton
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed, ref, watch } from 'vue'
|
||||
@@ -6,7 +7,7 @@ import { NButton, NCollapse, NCollapseItem, NInput, NSelect, NTab, NTabs } from
|
||||
import { Download, Search } from '@lucide/vue'
|
||||
import { AppDialog, EmptyState } from '../../components/ui'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { downloadText, formatDate, nodeLabel } from '../../lib/format'
|
||||
import { downloadText, formatDate, nodeLabel, workflowLabel } from '../../lib/format'
|
||||
import { loadWorkflowDiagnostics } from './diagnostics'
|
||||
import type { Checkpoint } from './types'
|
||||
|
||||
@@ -21,8 +22,8 @@ const workflow = ref('all')
|
||||
const search = ref('')
|
||||
const checkpointMap = computed(() => new Map(props.checkpoints.map(item => [item.checkpointId, item])))
|
||||
const options = computed(() => [
|
||||
{ label: '全部工作流', value: 'all' },
|
||||
...[...new Set(props.checkpoints.map(item => item.workflowName))].map(value => ({ label: value, value }))
|
||||
{ label: '全部制作任务', value: 'all' },
|
||||
...[...new Set(props.checkpoints.map(item => item.workflowName))].map(value => ({ label: workflowLabel(value), value }))
|
||||
])
|
||||
const groups = computed(() =>
|
||||
(query.data.value?.groups ?? [])
|
||||
@@ -67,12 +68,12 @@ function exportReport() {
|
||||
<template>
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
title="工作流运行诊断"
|
||||
description="展示全项目已保存的 checkpoint 指标与完整时间线,不启动或恢复任务。"
|
||||
title="制作任务记录"
|
||||
description="查看这个项目的任务记录、耗时和处理顺序,不会启动或恢复任务。"
|
||||
wide
|
||||
>
|
||||
<ContextNotice type="info" :show-icon="false" class="mt-4 text-xs"
|
||||
>后端指标按保存记录累计;耗时之和不等于实际墙钟耗时,“completed”也不代表图片或视频成功。生产任务状态请以资产页面为准。</ContextNotice
|
||||
>这里统计的是已保存的处理记录,累计耗时可能与实际等待时间不同。步骤结束也不代表图片或视频已生成,请以素材页的实际结果为准。</ContextNotice
|
||||
>
|
||||
<ContextNotice v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mt-3"
|
||||
>{{ query.error.value }},当前保留上次数据。</ContextNotice
|
||||
@@ -105,11 +106,11 @@ function exportReport() {
|
||||
<NInput
|
||||
v-model:value="search"
|
||||
clearable
|
||||
placeholder="搜索节点或 checkpoint"
|
||||
placeholder="搜索制作步骤或保存记录"
|
||||
:input-props="{ 'aria-label': '搜索运行记录' }"
|
||||
><template #prefix><Search :size="14" /></template
|
||||
></NInput>
|
||||
<NSelect v-model:value="workflow" :options="options" aria-label="筛选工作流" />
|
||||
<NSelect v-model:value="workflow" :options="options" aria-label="筛选制作任务" />
|
||||
<span class="text-xs text-muted">{{ nodes.length }} 条记录</span>
|
||||
</div>
|
||||
<NTabs v-model:value="tab" type="line" class="mt-3"
|
||||
@@ -126,7 +127,7 @@ function exportReport() {
|
||||
>
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
{{ checkpointMap.get(node.checkpointId)?.workflowName || '未标注工作流' }} · {{ node.phase }} ·
|
||||
{{ workflowLabel(checkpointMap.get(node.checkpointId)?.workflowName) }} · {{ userFacingText(node.phase, '其他阶段') }} ·
|
||||
{{ node.durationText }} · {{ formatDate(node.createdAt) }}
|
||||
</p>
|
||||
<p class="mt-2 break-all font-mono text-[11px] text-muted">{{ node.checkpointId }}</p>
|
||||
@@ -137,13 +138,13 @@ function exportReport() {
|
||||
v-for="group in groups"
|
||||
:key="group.phase"
|
||||
:name="group.phase"
|
||||
:title="`${group.phase} · ${group.nodes.length} 条`"
|
||||
:title="`${userFacingText(group.phase, '其他阶段')} · ${group.nodes.length} 条`"
|
||||
>
|
||||
<div class="diagnostics-records">
|
||||
<article v-for="node in group.nodes" :key="node.checkpointId" class="surface-inset p-4">
|
||||
<p class="text-sm">{{ nodeLabel(node.nodeName) }} · {{ node.durationText }}</p>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
{{ checkpointMap.get(node.checkpointId)?.workflowName || '未标注工作流' }} ·
|
||||
{{ workflowLabel(checkpointMap.get(node.checkpointId)?.workflowName) }} ·
|
||||
{{ recordLabel(node.checkpointId) }}
|
||||
</p>
|
||||
<p class="mt-2 break-all font-mono text-[11px] text-muted">{{ node.checkpointId }}</p>
|
||||
@@ -154,7 +155,7 @@ function exportReport() {
|
||||
<EmptyState
|
||||
v-if="!query.loading.value && !nodes.length"
|
||||
title="暂无匹配的运行记录"
|
||||
description="可清空筛选后重试;尚未保存 checkpoint 的任务不会出现在时间线中。"
|
||||
description="可清空筛选后重试;尚未保存进度的任务不会出现在时间线中。"
|
||||
/>
|
||||
</AppDialog>
|
||||
</template>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed } from 'vue'
|
||||
@@ -323,7 +324,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
>目标 {{ keyframeCounts.targetCount }} · 通过 {{ keyframeCounts.passed }} · 修复未通过
|
||||
{{ keyframeCounts.repairFailed }} · 调用失败 {{ keyframeCounts.failed }}</template
|
||||
>
|
||||
<template v-else>后端首帧质量统计不完整,请查看任务详情并刷新核对。</template>
|
||||
<template v-else>首帧检查结果尚不完整,请刷新任务详情后核对。</template>
|
||||
</p>
|
||||
<p v-else-if="!videoQuality && !scriptCreation && !breakdownTask" class="mt-2 text-xs">
|
||||
共 {{ result.total ?? execution.total }} · 生成 {{ result.generated ?? execution.current }} · 跳过
|
||||
@@ -336,7 +337,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ execution.error || '制作任务执行失败。' }}</p>
|
||||
<p>{{ userFacingText(execution.error) || '制作任务执行失败。' }}</p>
|
||||
<p class="mt-2 text-xs">
|
||||
{{
|
||||
scriptCreation
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import { computed, onScopeDispose, reactive, ref, watch, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { workflowExecutionApi } from './execution-api'
|
||||
@@ -38,9 +39,13 @@ export function hasActiveWorkflowExecution(projectId: string) {
|
||||
return Object.values(executionActivity).some(record => record.projectId === projectId && record.active)
|
||||
}
|
||||
|
||||
/** 任务阶段短标签;未知后端阶段保留原值,避免静默隐藏新能力。 */
|
||||
/**
|
||||
* 已知任务阶段使用中文名称,未知阶段显示待确认,不猜测任务结果。
|
||||
* @param stage 当前任务阶段
|
||||
* @returns 普通用户可读的阶段名称
|
||||
*/
|
||||
export function executionStageLabel(stage: string | null) {
|
||||
if (!stage) return '等待后端开始'
|
||||
if (!stage) return '等待任务开始'
|
||||
const labels: Record<string, string> = {
|
||||
createProject: '初始化项目',
|
||||
generateCharacter: '生成角色设定',
|
||||
@@ -95,7 +100,7 @@ export function executionStageLabel(stage: string | null) {
|
||||
stale_motion_plan: '动作版本过期,质量流程已停止',
|
||||
failed: '执行失败'
|
||||
}
|
||||
return labels[stage] ?? stage
|
||||
return labels[stage] ?? userFacingText(stage, '状态待确认')
|
||||
}
|
||||
|
||||
/** 有总量时按真实计数展示进度;未知总量保持不确定进度。 */
|
||||
@@ -277,7 +282,7 @@ export function useWorkflowExecution(
|
||||
* @returns 保存句柄与可用观察器刷新完成
|
||||
*/
|
||||
async function track(id: string, targetProjectId = projectId.value) {
|
||||
if (typeof id !== 'string' || !id.trim()) throw new Error('后端未返回有效任务编号,请刷新状态,勿重复提交。')
|
||||
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)
|
||||
|
||||
@@ -10,6 +10,8 @@ export interface Operation {
|
||||
label: string
|
||||
/** 请求失败原因。 */
|
||||
error: string
|
||||
/** 原始错误只供恢复流程判断,不直接展示给用户。 */
|
||||
cause?: unknown
|
||||
/** 已确认的操作结果提示。 */
|
||||
notice: string
|
||||
/** 结果的实际语义;未指定时由工作区使用默认反馈。 */
|
||||
@@ -56,6 +58,7 @@ export function getOperation(projectId: string): Operation {
|
||||
},
|
||||
label: '',
|
||||
error: '',
|
||||
cause: null,
|
||||
notice: '',
|
||||
noticeType: null,
|
||||
recovery: null
|
||||
@@ -63,6 +66,16 @@ export function getOperation(projectId: string): Operation {
|
||||
return operations[projectId]
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务恢复使用原始错误,避免中文展示转换改变缺少首帧等恢复条件。
|
||||
* @param operation 当前项目操作状态
|
||||
* @returns 与当前展示错误匹配的原始说明,或手动设置的错误
|
||||
*/
|
||||
export function operationErrorText(operation: Operation): string {
|
||||
return operation.cause instanceof Error && errorMessage(operation.cause) === operation.error
|
||||
? operation.cause.message : operation.error
|
||||
}
|
||||
|
||||
/**
|
||||
* 只让当前操作对应的按钮加载,项目内其它按钮继续使用禁用状态。
|
||||
* @param operation 当前项目操作状态
|
||||
@@ -108,14 +121,15 @@ export async function runOperation<T>(
|
||||
) {
|
||||
const operation = getOperation(projectId)
|
||||
if (operation.pending) return false
|
||||
Object.assign(operation, { pending: true, label, error: '', notice: '', noticeType: null, recovery: null })
|
||||
Object.assign(operation, { pending: true, label, error: '', cause: null, notice: '', noticeType: null, recovery: null })
|
||||
try {
|
||||
const result = await action()
|
||||
const notice = typeof feedback === 'function' ? feedback(result) : feedback
|
||||
operation.noticeType = notice?.type ?? null
|
||||
operation.notice = notice?.content ?? '请求已返回,正在重新读取后端状态;最终结果以下方记录为准。'
|
||||
operation.notice = notice?.content ?? '操作已返回,正在更新任务状态;请以最新结果为准。'
|
||||
return true
|
||||
} catch (error) {
|
||||
operation.cause = error
|
||||
operation.error = errorMessage(error)
|
||||
return false
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user