feat(short-drama-agent-front): 新增剧本骨架屏并优化阅读导出
This commit is contained in:
1 parent
54a381ebd3
commit
3cc65aa056
16 files changed
+792
-167
No files matched your search
@@ -1,15 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
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, watch } from 'vue'
|
||||
import { ArrowRight, Check, Circle } from '@lucide/vue'
|
||||
import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue'
|
||||
import { EmptyState } from '../../components/ui'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { projectsApi } from '../projects/api'
|
||||
import { workflowCheckpoints } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import HistoryPanel from '../workflows/HistoryPanel.vue'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import EpisodeReader from './EpisodeReader.vue'
|
||||
@@ -19,7 +18,6 @@ import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
/** 剧本创作工作区,正式数据库内容为准,checkpoint 只补充计划与恢复信息。 */
|
||||
const { project, checkpoints, refresh, refreshStageReadiness, error } = useProjectContext()
|
||||
const tab = ref('episodes')
|
||||
const showHistory = ref(false)
|
||||
const dramaRecords = computed(() => workflowCheckpoints(checkpoints.value, 'create-drama'))
|
||||
const state = computed(() => dramaRecords.value.at(-1)?.state)
|
||||
const episodes = computed(() => project.value?.episodes ?? [])
|
||||
@@ -71,9 +69,9 @@ async function resume(action: 'resume-generation' | 'resume-rewrite') {
|
||||
await refresh()
|
||||
}
|
||||
|
||||
/** 导出当前数据库中的完整正文,方便本地校对。 */
|
||||
/** 导出已读取的完整剧集正文;没有剧集时不生成空文件。 */
|
||||
function exportScript() {
|
||||
if (!project.value) return
|
||||
if (!project.value || !episodes.value.length) return
|
||||
const content = episodes.value
|
||||
.map(item => `第 ${item.episode} 集 ${item.title}\n\n${item.content}`)
|
||||
.join('\n\n————————————\n\n')
|
||||
@@ -105,7 +103,8 @@ function exportScript() {
|
||||
:loading="backgroundExecution.query.loading.value"
|
||||
:error="backgroundExecution.query.error.value"
|
||||
@refresh="backgroundExecution.query.refresh"
|
||||
@dismiss="backgroundExecution.dismiss" />
|
||||
@dismiss="backgroundExecution.dismiss"
|
||||
/>
|
||||
<div v-if="!complete" class="mt-5 flex flex-wrap items-center justify-between gap-4">
|
||||
<p class="text-sm text-muted">
|
||||
已写入 {{ episodes.length }}<span v-if="total"> / {{ total }}</span> 集<span v-if="!total">
|
||||
@@ -142,34 +141,26 @@ function exportScript() {
|
||||
class="mt-4"
|
||||
></NProgress>
|
||||
<div class="script-section">
|
||||
<!-- 以下是剧本内容标签与直接导出模块 -->
|
||||
<div class="tabs-toolbar">
|
||||
<NTabs v-model:value="tab" class="workspace-tabs" type="line" size="small" aria-label="剧本内容"
|
||||
><NTab name="episodes"
|
||||
>剧集正文 <span>{{ episodes.length }}</span></NTab
|
||||
><NTab name="characters">角色设定</NTab><NTab name="world">世界观</NTab
|
||||
><NTab name="review">审核记录</NTab>
|
||||
><NTab name="episodes">剧集正文</NTab><NTab name="characters">角色设定</NTab
|
||||
><NTab name="world">世界观</NTab><NTab name="review">审核记录</NTab>
|
||||
<template #suffix>
|
||||
<div class="tabs-toolbar-actions">
|
||||
<ActionMenu
|
||||
label="剧本更多操作"
|
||||
:items="[
|
||||
{ key: 'history', label: showHistory ? '收起执行记录' : '执行记录' },
|
||||
{ key: 'export', label: '导出剧本', disabled: !episodes.length }
|
||||
]"
|
||||
@select="$event === 'history' ? (showHistory = !showHistory) : exportScript()"
|
||||
/>
|
||||
</div>
|
||||
<!-- 以下是剧本正文直接导出模块 -->
|
||||
<WorkspaceExportButton label="导出剧本" :disabled="!episodes.length" @export="exportScript" />
|
||||
</template>
|
||||
</NTabs>
|
||||
</div>
|
||||
<div class="content-with-history panel mt-2" :class="{ 'history-hidden': !showHistory }">
|
||||
<main class="min-w-0">
|
||||
<!-- 以下是剧本正文、角色设定、世界观与审核内容模块 -->
|
||||
<div class="script-content panel">
|
||||
<main class="h-full min-h-0 min-w-0">
|
||||
<div v-show="tab === 'episodes'" class="h-full">
|
||||
<EpisodeReader v-if="episodes.length" :episodes="episodes" />
|
||||
<EmptyState
|
||||
v-else
|
||||
title="剧本正在酝酿"
|
||||
description="剧集写入数据库后会自动出现在这里。角色与世界观生成期间,可展开执行记录查看进度。"
|
||||
description="剧集写入数据库后会自动出现在这里,角色与世界观生成期间请等待状态更新。"
|
||||
/>
|
||||
</div>
|
||||
<NScrollbar v-if="tab !== 'episodes'" class="panel-scroll"
|
||||
@@ -238,7 +229,7 @@ function exportScript() {
|
||||
<EmptyState
|
||||
v-else
|
||||
title="暂无可用审核结果"
|
||||
description="项目详情不再提供审核记录;可在执行记录中查看工作流状态。"
|
||||
description="工作流返回审核结果后会在这里显示。"
|
||||
/><NCollapse
|
||||
v-if="state?.rewriteSuggestion"
|
||||
class="mt-5 text-sm"
|
||||
@@ -255,15 +246,9 @@ function exportScript() {
|
||||
</div>
|
||||
</NScrollbar>
|
||||
</main>
|
||||
<HistoryPanel
|
||||
v-if="showHistory"
|
||||
:project-id="project?.id"
|
||||
:checkpoints="checkpoints"
|
||||
workflow="create-drama"
|
||||
@close="showHistory = false"
|
||||
/>
|
||||
</div></div
|
||||
></WorkspacePage>
|
||||
</div>
|
||||
</div></WorkspacePage
|
||||
>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@@ -324,14 +309,6 @@ function exportScript() {
|
||||
.script-section .tabs-toolbar-actions {
|
||||
@apply min-h-0 flex-nowrap;
|
||||
}
|
||||
.script-section .content-with-history:not(.history-hidden) {
|
||||
@apply relative;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
}
|
||||
.script-section .content-with-history:not(.history-hidden) .history-panel {
|
||||
@apply absolute inset-0 z-30;
|
||||
}
|
||||
}
|
||||
.script-section {
|
||||
@apply flex-1 flex flex-col min-h-0;
|
||||
@@ -339,16 +316,18 @@ function exportScript() {
|
||||
.script-section > :first-child {
|
||||
@apply shrink-0;
|
||||
}
|
||||
.script-section .content-with-history {
|
||||
@apply flex-1 h-auto min-h-0;
|
||||
/* 导出操作铺满标签栏高度,按钮宽度同步容器实测高度。 */
|
||||
.script-section .workspace-tabs .n-tabs-nav__suffix,
|
||||
.script-section .tabs-toolbar-actions {
|
||||
align-items: stretch;
|
||||
}
|
||||
.script-content {
|
||||
/* 内容独占剩余高度,目录和正文继续在各自的容器内滚动。 */
|
||||
@apply flex-1 min-h-0 overflow-hidden;
|
||||
/* 标签栏下方使用与页面上方相同的模块间距。 */
|
||||
margin-top: var(--app-content-gap);
|
||||
}
|
||||
.script-workspace-page .workspace-split > :not(.script-section) {
|
||||
@apply shrink-0;
|
||||
}
|
||||
.script-section .n-tabs-tab__label {
|
||||
@apply inline-flex items-center gap-2;
|
||||
}
|
||||
.script-section .content-with-history.history-hidden {
|
||||
@apply grid-cols-[minmax(0,_1fr)] grid-rows-[minmax(0,_1fr)];
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user