From 204cf25aaaa872642d280338e1e0f775bb2433b0 Mon Sep 17 00:00:00 2001 From: GouJ Date: Sat, 26 Sep 2026 20:16:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=A7=E6=9C=AC=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=8C=81=E4=B9=85=E5=B1=95=E7=A4=BA=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/create-drama/CreateDramaPage.vue | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/features/create-drama/CreateDramaPage.vue b/src/features/create-drama/CreateDramaPage.vue index 963f835..7d7fe02 100644 --- a/src/features/create-drama/CreateDramaPage.vue +++ b/src/features/create-drama/CreateDramaPage.vue @@ -2,7 +2,7 @@ import WorkspacePage from '../../components/ui/WorkspacePage.vue' import ActionMenu from '../../components/ui/ActionMenu.vue' import { NScrollbar, NCollapse, NCollapseItem, NProgress, NTab, NTabs, NTag } from 'naive-ui' -import { computed, ref } from 'vue' +import { computed, ref, watch } from 'vue' import { ArrowRight, Check, Circle } from '@lucide/vue' import { EmptyState } from '../../components/ui' import { useProjectContext } from '../projects/context' @@ -13,6 +13,8 @@ import HistoryPanel from '../workflows/HistoryPanel.vue' import ConfirmAction from '../workflows/ConfirmAction.vue' import { downloadText } from '../../lib/format' import EpisodeReader from './EpisodeReader.vue' +import { useWorkflowExecution } from '../workflows/execution' +import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue' /** 剧本创作工作区,正式数据库内容为准,checkpoint 只补充计划与恢复信息。 */ const { project, checkpoints, refresh, error } = useProjectContext() @@ -22,7 +24,15 @@ const dramaRecords = computed(() => workflowCheckpoints(checkpoints.value, 'crea const state = computed(() => dramaRecords.value.at(-1)?.state) const episodes = computed(() => project.value?.episodes ?? []) const total = computed(() => state.value?.episodeCount) -const operation = computed(() => getOperation(project.value!.id)) +const projectId = computed(() => project.value?.id ?? '') +const operation = computed(() => getOperation(projectId.value)) +const backgroundExecution = useWorkflowExecution(projectId, 'create-drama') +watch( + () => backgroundExecution.query.data.value?.status, + (status, previous) => { + if ((status === 'completed' || status === 'failed') && status !== previous) void refresh() + } +) const complete = computed(() => project.value?.status === 'completed') const hasCheckpoint = computed(() => dramaRecords.value.length > 0) const canGenerate = computed( @@ -52,9 +62,11 @@ const stages = computed(() => [ async function resume(action: 'resume-generation' | 'resume-rewrite') { if (!project.value || operation.value.pending || error.value) return const id = project.value.id - await runOperation(id, action === 'resume-generation' ? '恢复剧集生成' : '恢复剧本改写', () => - projectsApi.resume(id, action) - ) + await runOperation(id, action === 'resume-generation' ? '恢复剧集生成' : '恢复剧本改写', async () => { + const started = await projectsApi.resume(id, action) + await backgroundExecution.track(started.executionId) + return started + }) await refresh() } @@ -85,6 +97,15 @@ function exportScript() { +

已写入 {{ episodes.length }} / {{ total }} 集 @@ -98,13 +119,13 @@ function exportScript() { label="恢复生成" description="用于剧集尚未写完的情况。后端会检查角色、世界观与 checkpoint,并继续处理剧集。" acknowledgement - :disabled="!canGenerate || operation.pending || !!error" + :disabled="!canGenerate || operation.pending || backgroundExecution.active.value || !!error" @confirm="resume('resume-generation')" />