feat(short-drama-agent-front): 支持母版复用并优化生成交互
This commit is contained in:
1 parent
49fb9c7a27
commit
ee5e49957a
28 files changed
+634
-326
No files matched your search
@@ -5,7 +5,8 @@ import { integerRule, fieldRule } from '../../lib/form-rules'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue'
|
||||
import { NScrollbar, NAlert, NButton, NCheckbox, NInputNumber, NProgress, NTab, NTable, NTabs } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { computed, h, onScopeDispose, ref, watch } from 'vue'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
@@ -27,7 +28,6 @@ const groupSize = ref(3)
|
||||
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
|
||||
const preview = ref<BreakdownPreview | null>(null)
|
||||
const previewBusy = ref(false)
|
||||
const previewError = ref('')
|
||||
const tab = ref('character')
|
||||
const toolsOpen = ref(false)
|
||||
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
|
||||
@@ -65,7 +65,54 @@ const configValid = computed(
|
||||
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
|
||||
)
|
||||
const input = computed<BreakdownInput>(() => ({ groupSize: groupSize.value, modules: [...modules.value] }))
|
||||
/** 后端就绪状态决定是否显示后续制作入口。 */
|
||||
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
|
||||
/** 拆解提示复用全局 NMessage,详细问题留在设置弹窗。 */
|
||||
const actionMessage = useActionMessage()
|
||||
/** 问题内容变化才通知,轮询取得相同快照时不会重复弹出。 */
|
||||
const issueSignature = computed(() =>
|
||||
JSON.stringify({
|
||||
error: execution.value?.errorMessage || '',
|
||||
issues: validation.value?.valid === false ? validation.value.issues : []
|
||||
})
|
||||
)
|
||||
/** 首次读取或问题变化时只显示一条汇总,保留可操作的详情入口。 */
|
||||
watch(
|
||||
issueSignature,
|
||||
() => {
|
||||
const executionError = execution.value?.errorMessage
|
||||
const invalid = validation.value?.valid === false
|
||||
if (!executionError && !invalid) return
|
||||
actionMessage?.warning(
|
||||
() =>
|
||||
h('div', { class: 'flex flex-wrap items-center gap-3' }, [
|
||||
h(
|
||||
'span',
|
||||
invalid
|
||||
? `分镜校验未通过,共 ${validation.value?.issues.length ?? 0} 项问题。`
|
||||
: '拆解任务未完成,请查看错误详情。'
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
onClick: () => {
|
||||
toolsOpen.value = true
|
||||
}
|
||||
},
|
||||
() => '查看详情与恢复操作'
|
||||
)
|
||||
]),
|
||||
{ duration: 6000, closable: true }
|
||||
)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/** 已加载的就绪状态由未完成变为完成时通知,不重放首次读取的历史结果。 */
|
||||
watch([() => stageReadiness.value, stageComplete], ([, ready], [previousReadiness, previous]) => {
|
||||
if (previousReadiness && ready && !previous)
|
||||
actionMessage?.success('剧本拆解已准备完成,可以继续视觉风格。', { duration: 4000, closable: true })
|
||||
})
|
||||
const canStart = computed(
|
||||
() =>
|
||||
!!project.value?.episodes.length &&
|
||||
@@ -86,7 +133,6 @@ function invalidatePreview() {
|
||||
previewController?.abort()
|
||||
preview.value = null
|
||||
previewBusy.value = false
|
||||
previewError.value = ''
|
||||
}
|
||||
watch(
|
||||
[
|
||||
@@ -115,7 +161,7 @@ async function loadPreview() {
|
||||
const data = await breakdownApi.preview(project.value.id, input.value, previewController.signal)
|
||||
if (version === previewVersion) preview.value = data
|
||||
} catch (cause) {
|
||||
if (version === previewVersion) previewError.value = errorMessage(cause)
|
||||
if (version === previewVersion) actionMessage?.error(errorMessage(cause), { duration: 6000, closable: true })
|
||||
} finally {
|
||||
if (version === previewVersion) previewBusy.value = false
|
||||
}
|
||||
@@ -132,11 +178,16 @@ async function run(action: BreakdownAction) {
|
||||
'resume-storyboard': '正在修复分镜绑定'
|
||||
}
|
||||
const id = project.value.id
|
||||
await runOperation(id, labels[action], async () => {
|
||||
const started = await breakdownApi.run(id, action, action === 'start' ? input.value : undefined)
|
||||
await backgroundExecution.track(started.executionId)
|
||||
return started
|
||||
})
|
||||
await runOperation(
|
||||
id,
|
||||
labels[action],
|
||||
async () => {
|
||||
const started = await breakdownApi.run(id, action, action === 'start' ? input.value : undefined)
|
||||
await backgroundExecution.track(started.executionId)
|
||||
return started
|
||||
},
|
||||
{ type: 'info', content: '拆解任务已提交,可在“拆解设置与恢复”中查看进度。' }
|
||||
)
|
||||
await refresh()
|
||||
}
|
||||
|
||||
@@ -159,15 +210,6 @@ const rules = {
|
||||
<template>
|
||||
<!-- 以下是手机完成提示自然滚走、分类导航与设置入口吸顶的拆解工作区 -->
|
||||
<WorkspacePage split compact mobile-scroll class="breakdown-workspace-page">
|
||||
<template #notice>
|
||||
<!-- 以下是拆解完成后的下一步提示模块 -->
|
||||
<NAlert v-if="stageComplete" type="success" :show-icon="false">
|
||||
剧本拆解已经准备完成,人物、场景、道具和正式镜头都可以进入后续制作。
|
||||
<RouterLink :to="`/projects/${projectId}/visual-style`" class="text-button ml-2"
|
||||
>继续视觉风格 →</RouterLink
|
||||
>
|
||||
</NAlert>
|
||||
</template>
|
||||
<template #header>
|
||||
<!-- 以下是拆解状态与设置 -->
|
||||
<div class="workspace-toolbar">
|
||||
@@ -188,7 +230,18 @@ const rules = {
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是轻量状态入口,详细问题与恢复操作统一放入弹窗 -->
|
||||
<div v-if="project?.episodes.length" class="toolbar-actions">
|
||||
<NButton
|
||||
v-if="execution?.errorMessage || validation?.valid === false"
|
||||
text
|
||||
type="error"
|
||||
@click="toolsOpen = true"
|
||||
>查看拆解问题</NButton
|
||||
>
|
||||
<RouterLink v-if="stageComplete" :to="`/projects/${projectId}/visual-style`" class="text-button"
|
||||
>继续视觉风格 →</RouterLink
|
||||
>
|
||||
<WorkspaceTools v-model:open="toolsOpen" title="拆解设置与恢复" label="拆解设置与恢复">
|
||||
<section class="panel workspace-panel breakdown-settings-panel">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
@@ -269,9 +322,6 @@ const rules = {
|
||||
</NButton>
|
||||
</div>
|
||||
</AppForm>
|
||||
<NAlert v-if="previewError" role="alert" type="error" :show-icon="false" class="mt-4">{{
|
||||
previewError
|
||||
}}</NAlert>
|
||||
<div v-if="preview" class="group-preview">
|
||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<p class="text-sm">
|
||||
@@ -309,6 +359,8 @@ const rules = {
|
||||
<WorkflowExecutionPanel
|
||||
v-if="backgroundExecution.executionId.value"
|
||||
title="剧本拆解任务"
|
||||
class="breakdown-execution-panel"
|
||||
:show-status-hint="false"
|
||||
:execution="backgroundExecution.query.data.value"
|
||||
:loading="backgroundExecution.query.loading.value"
|
||||
:error="backgroundExecution.query.error.value"
|
||||
@@ -433,15 +485,6 @@ const rules = {
|
||||
></EmptyState>
|
||||
</NScrollbar>
|
||||
<template v-else>
|
||||
<NScrollbar v-if="execution?.errorMessage || (validation && !validation.valid)" class="workspace-feedback">
|
||||
<NAlert v-if="execution?.errorMessage" role="alert" type="error" :show-icon="false">{{
|
||||
execution.errorMessage
|
||||
}}</NAlert>
|
||||
<NAlert v-if="validation && !validation.valid" role="alert" type="error" :show-icon="false">
|
||||
分镜校验未通过,共 {{ validation.issues.length }} 项问题。
|
||||
<NButton text @click="toolsOpen = true">查看详情与恢复操作</NButton>
|
||||
</NAlert>
|
||||
</NScrollbar>
|
||||
<section class="breakdown-results-section">
|
||||
<div class="result-toolbar tabs-toolbar">
|
||||
<NTabs v-model:value="tab" class="workspace-tabs" type="line" size="small" aria-label="拆解结果"
|
||||
@@ -561,6 +604,10 @@ const rules = {
|
||||
<style>
|
||||
/* 本组件专属布局与 Naive 内部结构覆盖。 */
|
||||
@reference "../../styles/styles.css";
|
||||
/* 任务卡片取消二次内缩,与快照、校验详情及设置卡片边缘对齐。 */
|
||||
.workspace-tools-body .breakdown-execution-panel {
|
||||
padding: 0;
|
||||
}
|
||||
.group-preview {
|
||||
@apply mt-6 pt-5;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user