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
+4
-2
@@ -387,7 +387,9 @@ const menuOptions = computed<MenuOption[]>(() => {
|
||||
@apply block text-[8px] tracking-[1px] font-normal text-muted mt-[3px];
|
||||
}
|
||||
.admin-topbar {
|
||||
@apply relative z-10 flex items-center justify-between shrink-0 h-11 py-0 px-5 gap-3 bg-(--app-surface);
|
||||
@apply relative z-10 flex items-center justify-between shrink-0 h-11 py-0 pl-5 gap-3 bg-(--app-surface);
|
||||
/* 主题切换按钮与项目配置、内容工具栏共用右侧对齐线。 */
|
||||
padding-right: var(--app-content-padding);
|
||||
}
|
||||
.admin-sider .n-menu-divider {
|
||||
@apply h-3 bg-transparent;
|
||||
@@ -542,7 +544,7 @@ const menuOptions = computed<MenuOption[]>(() => {
|
||||
@apply flex mr-2;
|
||||
}
|
||||
.admin-topbar {
|
||||
@apply py-0 px-2.5;
|
||||
@apply py-0 pl-2.5;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
@@ -140,22 +140,6 @@ onBeforeUnmount(() => {
|
||||
@apply min-h-0;
|
||||
}
|
||||
|
||||
.app-dialog .n-card-header__close {
|
||||
@apply grid place-items-center w-10 h-10 -m-2 rounded-none bg-transparent;
|
||||
}
|
||||
|
||||
.app-dialog .n-card-header__close .n-base-icon {
|
||||
@apply p-2 box-content bg-(--app-subtle);
|
||||
}
|
||||
|
||||
.app-dialog .n-card-header__close:hover {
|
||||
@apply bg-transparent;
|
||||
}
|
||||
|
||||
.app-dialog .n-card-header__close:hover .n-base-icon {
|
||||
@apply bg-(--app-control-hover);
|
||||
}
|
||||
|
||||
.app-dialog .n-card__footer {
|
||||
@apply shrink-0 bg-(--app-surface);
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<script setup lang="ts">
|
||||
import { Download } from '@lucide/vue'
|
||||
import { NButton, NPopover } from 'naive-ui'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
/** 工作区标签栏的直接导出入口。 */
|
||||
interface Props {
|
||||
/** 悬浮说明与无障碍按钮名称。 */
|
||||
label: string
|
||||
/** 当前没有可导出的数据时禁用。 */
|
||||
disabled?: boolean
|
||||
}
|
||||
/** 导出按钮使用页面提供的说明与禁用状态。 */
|
||||
defineProps<Props>()
|
||||
/** 点击按钮时通知页面导出当前已读取的数据。 */
|
||||
const emit = defineEmits<{ export: [] }>()
|
||||
/** 导出容器跟随父标签栏的实际高度。 */
|
||||
const container = ref<HTMLElement | null>(null)
|
||||
/** 按钮边长首次测量前沿用标签栏默认高度。 */
|
||||
const buttonSize = ref(40)
|
||||
/** 标签栏尺寸变化时保持按钮为正方形,卸载后释放监听。 */
|
||||
watch(
|
||||
container,
|
||||
(element, _previous, onCleanup) => {
|
||||
if (!element) return
|
||||
buttonSize.value = element.getBoundingClientRect().height || 40
|
||||
if (typeof ResizeObserver === 'undefined') return
|
||||
const observer = new ResizeObserver(() => {
|
||||
const height = element.getBoundingClientRect().height
|
||||
if (height > 0) buttonSize.value = height
|
||||
})
|
||||
observer.observe(element)
|
||||
onCleanup(() => observer.disconnect())
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是随标签栏高度保持正方形的导出图标与悬浮说明模块 -->
|
||||
<div
|
||||
ref="container"
|
||||
class="tabs-toolbar-actions workspace-export-action"
|
||||
:style="{ '--export-button-size': `${buttonSize}px` }"
|
||||
>
|
||||
<NPopover trigger="hover" placement="bottom-end">
|
||||
<template #trigger>
|
||||
<NButton
|
||||
quaternary
|
||||
size="small"
|
||||
class="icon-button workspace-export-button"
|
||||
:aria-label="label"
|
||||
:disabled="disabled"
|
||||
@click="emit('export')"
|
||||
>
|
||||
<template #icon><Download :size="18" aria-hidden="true" /></template>
|
||||
</NButton>
|
||||
</template>
|
||||
{{ label }}
|
||||
</NPopover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@reference "../../styles/styles.css";
|
||||
.workspace-export-action {
|
||||
/* 与父标签栏一起拉伸,说明文字由 Popover 展示,不占按钮宽度。 */
|
||||
@apply items-stretch self-stretch shrink-0 flex-nowrap;
|
||||
}
|
||||
.workspace-export-action .n-button.workspace-export-button {
|
||||
width: var(--export-button-size);
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
align-self: stretch;
|
||||
}
|
||||
</style>
|
||||
@@ -3,7 +3,7 @@ import AppForm from '../../components/ui/AppForm.vue'
|
||||
import { NFormItem } from 'naive-ui'
|
||||
import { integerRule, fieldRule } from '../../lib/form-rules'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import ActionMenu from '../../components/ui/ActionMenu.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 { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
|
||||
@@ -14,7 +14,6 @@ import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview
|
||||
import { breakdownSnapshot, recoveryOptions, workflowCheckpoints } from '../workflows/selectors'
|
||||
import { getOperation, runOperation } from '../workflows/operations'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import HistoryPanel from '../workflows/HistoryPanel.vue'
|
||||
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import SubjectList from './components/SubjectList.vue'
|
||||
@@ -31,7 +30,6 @@ const previewBusy = ref(false)
|
||||
const previewError = ref('')
|
||||
const tab = ref('character')
|
||||
const toolsOpen = ref(false)
|
||||
const showHistory = ref(false)
|
||||
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
|
||||
{ value: 'character', label: '人物', description: '人物身份、外观与形态' },
|
||||
{ value: 'scene', label: '场景', description: '故事空间与环境特征' },
|
||||
@@ -447,16 +445,17 @@ const rules = {
|
||||
<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="拆解结果"
|
||||
><NTab v-for="option in moduleOptions" :key="option.value" :name="option.value"
|
||||
>{{ option.label
|
||||
}}<span>{{ subjects.filter(item => item.module === option.value).length }}</span></NTab
|
||||
><!-- 以下是仅显示分类名称的拆解标签模块,主体数量保留在搜索统计中 -->
|
||||
<NTab v-for="option in moduleOptions" :key="option.value" :name="option.value">{{
|
||||
option.label
|
||||
}}</NTab
|
||||
><NTab name="storyboard">分镜</NTab
|
||||
><NTab name="tasks"
|
||||
><span class="breakdown-task-label-desktop">任务明细</span
|
||||
><span class="breakdown-task-label-mobile">任务</span></NTab
|
||||
>
|
||||
<template #suffix
|
||||
><div class="tabs-toolbar-actions">
|
||||
><div class="tabs-toolbar-actions breakdown-toolbar-actions">
|
||||
<!-- 以下是手机分类导航中的拆解设置入口,共用原有设置弹窗 -->
|
||||
<NButton
|
||||
quaternary
|
||||
@@ -469,21 +468,17 @@ const rules = {
|
||||
>
|
||||
<template #icon><Settings2 :size="15" /></template>
|
||||
</NButton>
|
||||
<!-- 以下是桌面低频操作入口,手机不显示省略号菜单 -->
|
||||
<span class="breakdown-more-actions"
|
||||
><ActionMenu
|
||||
label="拆解更多操作"
|
||||
:items="[
|
||||
{ key: 'history', label: showHistory ? '收起执行记录' : '执行记录' },
|
||||
{ key: 'export', label: '导出 JSON', disabled: !snapshot }
|
||||
]"
|
||||
@select="$event === 'history' ? (showHistory = !showHistory) : exportResult()"
|
||||
/></span></div
|
||||
<!-- 以下是拆解快照直接导出模块,与剧本创作共用图标和悬浮说明 -->
|
||||
<WorkspaceExportButton
|
||||
label="导出拆解结果"
|
||||
:disabled="!snapshot"
|
||||
@export="exportResult"
|
||||
/></div
|
||||
></template>
|
||||
</NTabs>
|
||||
</div>
|
||||
<div class="content-with-history panel" :class="{ 'history-hidden': !showHistory }">
|
||||
<main class="min-w-0">
|
||||
<div class="breakdown-content panel">
|
||||
<main class="min-w-0 min-h-0 overflow-hidden">
|
||||
<!-- 所有结果标签共用有界的内容滚动;切换标签回到顶部,不继承上一列表的位置。 -->
|
||||
<NScrollbar :key="tab" class="panel-scroll breakdown-results-scroll">
|
||||
<template v-for="option in moduleOptions" :key="option.value"
|
||||
@@ -557,13 +552,6 @@ const rules = {
|
||||
</div>
|
||||
</NScrollbar>
|
||||
</main>
|
||||
<HistoryPanel
|
||||
v-if="showHistory"
|
||||
:project-id="project?.id"
|
||||
:checkpoints="checkpoints"
|
||||
workflow="breakdown"
|
||||
@close="showHistory = false"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -650,8 +638,9 @@ const rules = {
|
||||
.breakdown-results-section > .result-toolbar {
|
||||
@apply shrink-0;
|
||||
}
|
||||
.breakdown-results-section > .content-with-history {
|
||||
@apply flex-1 h-auto min-h-0 grid-rows-[minmax(0,_1fr)];
|
||||
.breakdown-results-section > .breakdown-content {
|
||||
/* 移除执行记录分栏,结果独占剩余宽高。 */
|
||||
@apply grid flex-1 h-auto min-h-0 grid-cols-[minmax(0,_1fr)] grid-rows-[minmax(0,_1fr)];
|
||||
/* 外层透明,搜索框和各条目使用自身背景,模块间距不再铺底色。 */
|
||||
background: transparent;
|
||||
}
|
||||
@@ -665,8 +654,13 @@ const rules = {
|
||||
.breakdown-result-pad .subject-list-toolbar {
|
||||
margin-bottom: var(--app-content-gap);
|
||||
}
|
||||
.breakdown-results-section > .content-with-history.history-hidden {
|
||||
@apply grid-cols-[minmax(0,_1fr)] grid-rows-[minmax(0,_1fr)];
|
||||
.breakdown-workspace-page .workspace-tabs .n-tabs-nav__suffix,
|
||||
.breakdown-workspace-page .breakdown-toolbar-actions {
|
||||
/* 设置与导出入口共用标签栏高度,导出按钮保持正方形。 */
|
||||
align-items: stretch;
|
||||
}
|
||||
.breakdown-workspace-page .breakdown-toolbar-actions {
|
||||
gap: 0;
|
||||
}
|
||||
.breakdown-workspace-page .breakdown-mobile-tools.n-button {
|
||||
display: none;
|
||||
@@ -679,7 +673,6 @@ const rules = {
|
||||
.breakdown-workspace-page .workspace-heading-scroll.n-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
.breakdown-more-actions,
|
||||
.breakdown-task-label-desktop {
|
||||
display: none;
|
||||
}
|
||||
@@ -709,8 +702,8 @@ const rules = {
|
||||
flex: none;
|
||||
overflow: visible;
|
||||
}
|
||||
.breakdown-workspace-page .content-with-history,
|
||||
.breakdown-workspace-page .content-with-history > main,
|
||||
.breakdown-workspace-page .breakdown-content,
|
||||
.breakdown-workspace-page .breakdown-content > main,
|
||||
.breakdown-workspace-page .breakdown-results-scroll,
|
||||
.breakdown-workspace-page .breakdown-results-scroll > .n-scrollbar-container {
|
||||
height: auto;
|
||||
@@ -768,13 +761,5 @@ const rules = {
|
||||
.breakdown-results-section .tabs-toolbar-actions {
|
||||
@apply min-h-0 flex-nowrap;
|
||||
}
|
||||
.breakdown-results-section .content-with-history:not(.history-hidden) {
|
||||
@apply relative;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
}
|
||||
.breakdown-results-section .content-with-history:not(.history-hidden) .history-panel {
|
||||
@apply absolute inset-0 z-30;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,149 @@
|
||||
<script setup lang="ts">
|
||||
import { NScrollbar, NSkeleton } from 'naive-ui'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<WorkspacePage
|
||||
split
|
||||
compact
|
||||
mobile-scroll
|
||||
class="breakdown-skeleton"
|
||||
role="status"
|
||||
aria-label="正在读取剧本拆解内容"
|
||||
aria-busy="true"
|
||||
>
|
||||
<template #header>
|
||||
<!-- 以下是拆解状态与设置占位模块,不展示未经读取的统计或完成状态 -->
|
||||
<div class="breakdown-skeleton-summary" aria-hidden="true">
|
||||
<NSkeleton class="breakdown-skeleton-heading" :width="80" :height="18" />
|
||||
<NSkeleton :width="108" :height="12" />
|
||||
<NSkeleton :width="132" :height="12" />
|
||||
<NSkeleton :width="86" :height="22" />
|
||||
<NSkeleton class="breakdown-skeleton-settings" :width="34" :height="34" />
|
||||
</div>
|
||||
</template>
|
||||
<div class="breakdown-skeleton-results" aria-hidden="true">
|
||||
<!-- 以下是分类标签与操作入口占位模块 -->
|
||||
<div class="breakdown-skeleton-tabs">
|
||||
<NSkeleton v-for="tab in 5" :key="tab" :width="28" :height="14" />
|
||||
<NSkeleton class="breakdown-skeleton-mobile-settings" :width="44" :height="44" />
|
||||
<NSkeleton class="breakdown-skeleton-settings" :width="40" :height="40" />
|
||||
</div>
|
||||
<NScrollbar class="breakdown-skeleton-scroll">
|
||||
<!-- 以下是搜索框与主体统计占位模块 -->
|
||||
<div class="breakdown-skeleton-search">
|
||||
<NSkeleton class="breakdown-skeleton-input" :height="34" />
|
||||
<NSkeleton :width="70" :height="12" />
|
||||
</div>
|
||||
<!-- 以下是主体名称、描述、关联入口与形态折叠区占位模块 -->
|
||||
<div class="breakdown-skeleton-records">
|
||||
<div v-for="record in 3" :key="record" class="breakdown-skeleton-record">
|
||||
<div class="breakdown-skeleton-record-heading">
|
||||
<NSkeleton :width="96" :height="16" />
|
||||
<NSkeleton :width="56" :height="18" />
|
||||
</div>
|
||||
<div class="breakdown-skeleton-description">
|
||||
<NSkeleton :width="'96%'" :height="14" />
|
||||
<NSkeleton :width="'72%'" :height="14" />
|
||||
</div>
|
||||
<div class="breakdown-skeleton-links">
|
||||
<NSkeleton :width="112" :height="12" />
|
||||
<NSkeleton :width="100" :height="12" />
|
||||
</div>
|
||||
<NSkeleton :width="124" :height="14" />
|
||||
</div>
|
||||
</div>
|
||||
</NScrollbar>
|
||||
</div>
|
||||
</WorkspacePage>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 拆解占位沿用工作区留白和主题配色,手机与真实页面使用同一断点。 */
|
||||
@reference "../../styles/styles.css";
|
||||
.breakdown-skeleton-summary {
|
||||
@apply flex items-center flex-wrap gap-x-4 gap-y-2 min-h-[34px];
|
||||
}
|
||||
.breakdown-skeleton-settings {
|
||||
@apply ml-auto shrink-0;
|
||||
}
|
||||
.breakdown-skeleton-mobile-settings {
|
||||
/* 手机标签栏右侧保留设置和导出两个独立图标位置。 */
|
||||
@apply hidden shrink-0;
|
||||
}
|
||||
.breakdown-skeleton-results {
|
||||
@apply flex flex-col flex-1 min-h-0 min-w-0;
|
||||
gap: var(--app-content-gap);
|
||||
}
|
||||
.breakdown-skeleton-tabs {
|
||||
@apply flex items-center shrink-0 gap-8 pl-4 min-h-10 bg-(--app-surface);
|
||||
}
|
||||
:root:not([data-theme='dark']) .breakdown-skeleton-tabs {
|
||||
@apply bg-(--app-subtle);
|
||||
}
|
||||
.breakdown-skeleton-scroll {
|
||||
@apply flex-1 min-h-0 min-w-0;
|
||||
}
|
||||
.breakdown-skeleton-search {
|
||||
@apply flex items-center gap-3;
|
||||
margin-bottom: var(--app-content-gap);
|
||||
}
|
||||
.breakdown-skeleton-input {
|
||||
@apply basis-[260px] shrink min-w-0;
|
||||
}
|
||||
.breakdown-skeleton-record {
|
||||
@apply p-5 min-w-0 bg-(--app-control);
|
||||
}
|
||||
.breakdown-skeleton-record:nth-child(even) {
|
||||
@apply bg-(--app-subtle);
|
||||
}
|
||||
.breakdown-skeleton-record :deep(.n-skeleton) {
|
||||
/* 占位条与斑马纹底色保持层次,避免浅色卡片内的默认骨架颜色融入背景。 */
|
||||
--n-color-start: var(--app-border) !important;
|
||||
--n-color-end: var(--app-field-hover) !important;
|
||||
}
|
||||
.breakdown-skeleton-record-heading {
|
||||
@apply flex flex-wrap items-center gap-3 mb-3;
|
||||
}
|
||||
.breakdown-skeleton-description {
|
||||
@apply flex flex-col gap-3 mb-4;
|
||||
}
|
||||
.breakdown-skeleton-links {
|
||||
@apply flex flex-wrap items-center gap-4 mb-4;
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
.breakdown-skeleton-heading {
|
||||
@apply hidden;
|
||||
}
|
||||
.breakdown-skeleton-summary {
|
||||
@apply flex-nowrap overflow-hidden;
|
||||
}
|
||||
.breakdown-skeleton-input {
|
||||
@apply flex-1;
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.breakdown-skeleton :deep(.workspace-heading-scroll) {
|
||||
@apply hidden;
|
||||
}
|
||||
.breakdown-skeleton-tabs {
|
||||
@apply gap-2 pl-2 min-h-11;
|
||||
}
|
||||
.breakdown-skeleton-mobile-settings {
|
||||
@apply block;
|
||||
}
|
||||
.breakdown-skeleton-tabs .breakdown-skeleton-settings {
|
||||
@apply w-11! h-11!;
|
||||
}
|
||||
.breakdown-skeleton-results,
|
||||
.breakdown-skeleton-scroll {
|
||||
@apply flex-none overflow-visible;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.breakdown-skeleton :deep(.n-skeleton) {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,190 @@
|
||||
<script setup lang="ts">
|
||||
import { NSkeleton } from 'naive-ui'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
|
||||
/** 正文段落占位宽度;只描述排版,不推测实际剧集数量和内容。 */
|
||||
const paragraphs = [
|
||||
['100%', '96%', '100%', '92%', '62%'],
|
||||
['100%', '94%', '100%', '72%'],
|
||||
['96%', '100%', '92%', '100%', '56%']
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<WorkspacePage
|
||||
split
|
||||
compact
|
||||
class="create-drama-skeleton"
|
||||
role="status"
|
||||
aria-label="正在读取剧本内容"
|
||||
aria-busy="true"
|
||||
>
|
||||
<template #header>
|
||||
<!-- 以下是创作阶段进度占位模块 -->
|
||||
<div class="drama-skeleton-stages" aria-hidden="true">
|
||||
<div v-for="stage in 5" :key="stage" class="drama-skeleton-stage">
|
||||
<NSkeleton circle :width="14" :height="14" />
|
||||
<NSkeleton :width="60" :height="11" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="drama-skeleton-section" aria-hidden="true">
|
||||
<!-- 以下是剧本内容标签与导出按钮占位模块 -->
|
||||
<div class="drama-skeleton-tabs">
|
||||
<NSkeleton v-for="(width, tab) in [56, 56, 48, 56]" :key="tab" :width="width" :height="14" />
|
||||
<NSkeleton class="drama-skeleton-action" :width="40" :height="40" />
|
||||
</div>
|
||||
<div class="drama-skeleton-reader panel">
|
||||
<!-- 以下是剧集目录占位模块 -->
|
||||
<div class="drama-skeleton-directory">
|
||||
<div class="drama-skeleton-directory-heading">
|
||||
<NSkeleton :width="64" :height="14" />
|
||||
<NSkeleton :width="28" :height="11" />
|
||||
</div>
|
||||
<div v-for="episode in 5" :key="episode" class="drama-skeleton-episode">
|
||||
<NSkeleton class="drama-skeleton-episode-number" :height="13" />
|
||||
<NSkeleton
|
||||
class="drama-skeleton-episode-title"
|
||||
:width="episode % 2 ? '80%' : '64%'"
|
||||
:height="12"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是剧集标题、摘要与正文占位模块 -->
|
||||
<div class="drama-skeleton-page">
|
||||
<div class="drama-skeleton-content">
|
||||
<div class="drama-skeleton-chapter-heading">
|
||||
<NSkeleton :width="60" :height="13" />
|
||||
<NSkeleton :width="'46%'" :height="28" />
|
||||
</div>
|
||||
<div class="drama-skeleton-summary">
|
||||
<NSkeleton :width="'94%'" :height="12" />
|
||||
<NSkeleton :width="'72%'" :height="12" />
|
||||
</div>
|
||||
<div v-for="(lines, paragraph) in paragraphs" :key="paragraph" class="drama-skeleton-paragraph">
|
||||
<NSkeleton v-for="(width, line) in lines" :key="line" :width="width" :height="14" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是手机底部章节导航占位模块 -->
|
||||
<div class="drama-skeleton-mobile-navigation">
|
||||
<NSkeleton :width="44" :height="14" />
|
||||
<NSkeleton :width="80" :height="12" />
|
||||
<NSkeleton :width="64" :height="18" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</WorkspacePage>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 骨架布局与剧本阅读器保持一致,颜色由 Naive UI 跟随当前主题。 */
|
||||
@reference "../../styles/styles.css";
|
||||
.drama-skeleton-stages {
|
||||
@apply flex items-center gap-7;
|
||||
}
|
||||
.drama-skeleton-stage {
|
||||
@apply flex shrink-0 items-center gap-[7px];
|
||||
}
|
||||
.drama-skeleton-section {
|
||||
@apply flex flex-col flex-1 min-h-0;
|
||||
}
|
||||
.drama-skeleton-tabs {
|
||||
@apply flex shrink-0 items-center gap-6 min-h-10;
|
||||
/* 骨架屏与真实标签栏共用上下模块间距。 */
|
||||
margin-bottom: var(--app-content-gap);
|
||||
}
|
||||
.drama-skeleton-action {
|
||||
/* 对齐方形导出图标按钮,右侧不添加额外留白。 */
|
||||
@apply ml-auto shrink-0;
|
||||
}
|
||||
.drama-skeleton-reader {
|
||||
@apply grid grid-cols-[clamp(190px,_22%,_240px)_minmax(0,_1fr)] flex-1 min-h-0 overflow-hidden;
|
||||
}
|
||||
.drama-skeleton-directory {
|
||||
@apply min-w-0 overflow-hidden bg-(--app-subtle);
|
||||
}
|
||||
:root:not([data-theme='dark']) .drama-skeleton-directory {
|
||||
/* 占位目录沿用正式导航的浅色底色,保留左右分栏层次。 */
|
||||
@apply bg-(--app-control);
|
||||
}
|
||||
:root:not([data-theme='dark']) .drama-skeleton-directory :deep(.n-skeleton) {
|
||||
/* 导航底色加深后,浅色占位条仍需清晰可见。 */
|
||||
--n-color-start: var(--app-border) !important;
|
||||
--n-color-end: var(--app-field-hover) !important;
|
||||
}
|
||||
.drama-skeleton-directory-heading {
|
||||
/* 占位标题与剧集条目使用同一左侧对齐线。 */
|
||||
@apply flex items-center justify-between gap-2 pt-[22px] px-3.5 pb-3.5;
|
||||
}
|
||||
.drama-skeleton-episode {
|
||||
@apply flex flex-col justify-center gap-2 min-h-16 py-3 px-3.5 mb-1.5;
|
||||
}
|
||||
.drama-skeleton-episode-number {
|
||||
@apply w-12;
|
||||
}
|
||||
.drama-skeleton-page {
|
||||
@apply min-w-0 overflow-hidden;
|
||||
}
|
||||
:root:not([data-theme='dark']) .drama-skeleton-page {
|
||||
/* 浅色占位区域沿用正文底色,加载完成时保持背景一致。 */
|
||||
@apply bg-(--app-subtle);
|
||||
}
|
||||
.drama-skeleton-mobile-navigation {
|
||||
display: none;
|
||||
}
|
||||
.drama-skeleton-content {
|
||||
@apply p-8 max-w-[900px];
|
||||
}
|
||||
.drama-skeleton-chapter-heading {
|
||||
@apply flex flex-col gap-3 pt-3.5 pb-[18px] mb-6;
|
||||
}
|
||||
.drama-skeleton-summary {
|
||||
@apply flex flex-col gap-3 pt-[17px] pb-[22px] mb-[23px];
|
||||
}
|
||||
.drama-skeleton-paragraph {
|
||||
@apply flex flex-col gap-4 mb-7;
|
||||
}
|
||||
@media (max-width: 1000px) {
|
||||
.drama-skeleton-reader {
|
||||
@apply grid-cols-[180px_minmax(0,_1fr)];
|
||||
}
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
.drama-skeleton-reader {
|
||||
@apply flex flex-col;
|
||||
}
|
||||
.drama-skeleton-directory {
|
||||
@apply hidden;
|
||||
}
|
||||
.drama-skeleton-page {
|
||||
@apply flex-1 min-h-0;
|
||||
}
|
||||
.drama-skeleton-mobile-navigation {
|
||||
@apply flex items-center justify-between min-h-11 shrink-0 px-3 bg-(--app-subtle);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.drama-skeleton-content {
|
||||
@apply px-[18px] py-3;
|
||||
}
|
||||
.drama-skeleton-chapter-heading {
|
||||
@apply gap-1 py-2 mb-3;
|
||||
}
|
||||
.drama-skeleton-summary {
|
||||
@apply pt-0 pb-4 mb-4;
|
||||
}
|
||||
.drama-skeleton-tabs {
|
||||
@apply gap-3;
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.create-drama-skeleton :deep(.workspace-heading-scroll) {
|
||||
@apply hidden;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.create-drama-skeleton :deep(.n-skeleton) {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NScrollbar, type ScrollbarInst } from 'naive-ui'
|
||||
import { NButton, NDrawer, NDrawerContent, NScrollbar, type ScrollbarInst } from 'naive-ui'
|
||||
import { ChevronLeft, ChevronRight, List } from '@lucide/vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, useId, watch } from 'vue'
|
||||
import type { Episode } from '../projects/types'
|
||||
|
||||
/** 连续剧本阅读器:目录与正文独立滚动,导航仅影响本阅读器。 */
|
||||
/** 连续剧本阅读器:宽屏目录与正文独立滚动,手机采用全宽正文与底部目录。 */
|
||||
const props = defineProps<{ episodes: Episode[] }>()
|
||||
const orderedEpisodes = computed(() => props.episodes.toSorted((a, b) => a.episode - b.episode))
|
||||
const active = ref(orderedEpisodes.value[0]?.episode)
|
||||
@@ -13,7 +14,14 @@ const directoryContent = ref<HTMLElement>()
|
||||
const readerContent = ref<HTMLElement>()
|
||||
const viewportHeight = ref(400)
|
||||
const readerId = useId()
|
||||
const readingInset = 32
|
||||
/** 手机目录抽屉仅在用户点击目录时打开,不占用正文宽度。 */
|
||||
const directoryOpen = ref(false)
|
||||
/** 抽屉目录根节点,用于打开时定位到当前集。 */
|
||||
const sheetContent = ref<HTMLElement>()
|
||||
/** 当前集在有序目录中的位置,支持不连续的剧集编号。 */
|
||||
const activeIndex = computed(() => orderedEpisodes.value.findIndex(item => item.episode === active.value))
|
||||
/** 缓存正文顶部留白,目录跳转与当前集判断使用同一阅读线。 */
|
||||
let readingInset = 32
|
||||
let viewport: HTMLElement | null = null
|
||||
let directoryViewport: HTMLElement | null = null
|
||||
let observer: ResizeObserver | undefined
|
||||
@@ -51,10 +59,11 @@ function syncActive() {
|
||||
active.value = current
|
||||
}
|
||||
|
||||
/** 内容或面板尺寸变化时重测;隐藏标签不覆盖缓存和已有阅读位置。 */
|
||||
/** 内容或尺寸变化时同步实际顶部留白与章节位置;隐藏标签不覆盖已有阅读位置。 */
|
||||
function measure() {
|
||||
if (!viewport?.clientHeight || !readerContent.value) return
|
||||
viewportHeight.value = viewport.clientHeight
|
||||
readingInset = parseFloat(getComputedStyle(readerContent.value).paddingTop) || 32
|
||||
const origin = viewport.getBoundingClientRect().top - viewport.scrollTop
|
||||
positions = [...readerContent.value.querySelectorAll<HTMLElement>('[data-episode]')].map(item => ({
|
||||
episode: Number(item.dataset.episode),
|
||||
@@ -63,16 +72,39 @@ function measure() {
|
||||
syncActive()
|
||||
}
|
||||
|
||||
/** 点击目录使用组件公开方法即时定位,避免长距离平滑滚动经过多集时高亮闪烁。 */
|
||||
/**
|
||||
* 即时定位所选剧集并关闭手机目录,避免长距离平滑滚动造成高亮闪烁。
|
||||
* @param episode 需要定位的剧集编号
|
||||
*/
|
||||
function selectEpisode(episode: number) {
|
||||
measure()
|
||||
const position = positions.find(item => item.episode === episode)
|
||||
if (!position) return
|
||||
reader.value?.scrollTo({ top: Math.max(0, position.top - readingInset), behavior: 'auto' })
|
||||
active.value = episode
|
||||
directoryOpen.value = false
|
||||
revealActive()
|
||||
}
|
||||
|
||||
/**
|
||||
* 按目录顺序切换相邻剧集,首集和末集不越界。
|
||||
* @param offset 上一集或下一集的相对位置
|
||||
*/
|
||||
function selectRelativeEpisode(offset: -1 | 1) {
|
||||
const episode = orderedEpisodes.value[activeIndex.value + offset]
|
||||
if (episode) selectEpisode(episode.episode)
|
||||
}
|
||||
|
||||
/** 目录抽屉展开后露出当前集,只滚动抽屉内部列表。 */
|
||||
function revealSheetActive() {
|
||||
const item = sheetContent.value?.querySelector<HTMLElement>('[aria-current="location"]')
|
||||
const scroll = scrollContainer(sheetContent.value)
|
||||
if (!item || !scroll) return
|
||||
scroll.scrollTo({
|
||||
top: scroll.scrollTop + item.getBoundingClientRect().top - scroll.getBoundingClientRect().top - 8
|
||||
})
|
||||
}
|
||||
|
||||
watch(active, revealActive, { flush: 'post' })
|
||||
watch(
|
||||
orderedEpisodes,
|
||||
@@ -83,6 +115,7 @@ watch(
|
||||
{ flush: 'post', deep: true }
|
||||
)
|
||||
|
||||
/** 挂载后测量阅读区域,尺寸变化时更新章节位置并关闭宽屏下的手机目录。 */
|
||||
onMounted(() => {
|
||||
viewport = scrollContainer(readerContent.value)
|
||||
directoryViewport = scrollContainer(directoryContent.value)
|
||||
@@ -96,6 +129,8 @@ onMounted(() => {
|
||||
observer = new ResizeObserver(() => {
|
||||
measure()
|
||||
revealActive()
|
||||
// 恢复宽屏布局时关闭手机目录,避免遮罩继续覆盖正文。
|
||||
if (window.innerWidth > 800) directoryOpen.value = false
|
||||
})
|
||||
if (viewport) observer.observe(viewport)
|
||||
if (readerContent.value) observer.observe(readerContent.value)
|
||||
@@ -107,6 +142,7 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
|
||||
<template>
|
||||
<div class="episode-reader">
|
||||
<!-- 以下是宽屏分集目录模块 -->
|
||||
<nav class="reader-directory" aria-label="剧集目录">
|
||||
<div class="reader-directory-heading">
|
||||
<h3>分集剧本</h3>
|
||||
@@ -164,6 +200,79 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
</div>
|
||||
</NScrollbar>
|
||||
</div>
|
||||
<!-- 以下是手机底部章节导航模块,正文与导航分别占用独立空间 -->
|
||||
<nav class="reader-mobile-navigation" aria-label="章节导航">
|
||||
<NButton
|
||||
quaternary
|
||||
class="reader-directory-trigger"
|
||||
aria-label="打开剧集目录"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="directoryOpen"
|
||||
@click="directoryOpen = true"
|
||||
>
|
||||
<template #icon><List :size="18" aria-hidden="true" /></template>
|
||||
目录
|
||||
</NButton>
|
||||
<span class="reader-mobile-position">第 {{ active }} 集 / 共 {{ orderedEpisodes.length }} 集</span>
|
||||
<NButton
|
||||
quaternary
|
||||
class="icon-button reader-chapter-control"
|
||||
aria-label="上一集"
|
||||
:disabled="activeIndex <= 0"
|
||||
@click="selectRelativeEpisode(-1)"
|
||||
>
|
||||
<template #icon><ChevronLeft :size="20" aria-hidden="true" /></template>
|
||||
</NButton>
|
||||
<NButton
|
||||
quaternary
|
||||
class="icon-button reader-chapter-control"
|
||||
aria-label="下一集"
|
||||
:disabled="activeIndex < 0 || activeIndex >= orderedEpisodes.length - 1"
|
||||
@click="selectRelativeEpisode(1)"
|
||||
>
|
||||
<template #icon><ChevronRight :size="20" aria-hidden="true" /></template>
|
||||
</NButton>
|
||||
</nav>
|
||||
<!-- 以下是手机分集目录抽屉模块,保留完整标题方便查找和跳转 -->
|
||||
<NDrawer
|
||||
v-model:show="directoryOpen"
|
||||
placement="bottom"
|
||||
height="min(70dvh, 560px)"
|
||||
class="reader-directory-sheet"
|
||||
@after-enter="revealSheetActive"
|
||||
>
|
||||
<!-- 列表正文取消左右内边距,让目录项背景铺满抽屉宽度 -->
|
||||
<NDrawerContent
|
||||
title="分集剧本"
|
||||
closable
|
||||
:native-scrollbar="false"
|
||||
:body-content-style="{ padding: '0 0 max(12px, env(safe-area-inset-bottom))' }"
|
||||
>
|
||||
<!-- 以下是垂直居中的目录标题与总集数模块 -->
|
||||
<template #header>
|
||||
<div class="reader-sheet-heading">
|
||||
<span class="reader-sheet-title">分集剧本</span>
|
||||
<span class="reader-sheet-count">/ 共 {{ orderedEpisodes.length }} 集</span>
|
||||
</div>
|
||||
</template>
|
||||
<div ref="sheetContent" class="reader-sheet-directory" role="navigation" aria-label="手机剧集目录">
|
||||
<NButton
|
||||
v-for="item in orderedEpisodes"
|
||||
:key="item.episode"
|
||||
quaternary
|
||||
block
|
||||
class="reader-episode-link reader-sheet-episode-link"
|
||||
:class="{ active: active === item.episode }"
|
||||
:aria-current="active === item.episode ? 'location' : undefined"
|
||||
:aria-controls="`${readerId}-episode-${item.episode}`"
|
||||
@click="selectEpisode(item.episode)"
|
||||
>
|
||||
<span class="reader-episode-label">第 {{ item.episode }} 集</span>
|
||||
<span class="reader-episode-title">{{ item.title || '未命名剧集' }}</span>
|
||||
</NButton>
|
||||
</div>
|
||||
</NDrawerContent>
|
||||
</NDrawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -186,14 +295,25 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
@apply text-muted leading-[1.8] mb-[15px];
|
||||
}
|
||||
.episode-reader {
|
||||
/* 正文与吸顶标题共用底色,切换主题后保持连续的阅读背景。 */
|
||||
--reader-background: var(--app-surface);
|
||||
@apply grid grid-cols-[clamp(190px,_22%,_240px)_minmax(0,_1fr)] h-full min-h-0 min-w-0 overflow-hidden;
|
||||
container-type: inline-size;
|
||||
}
|
||||
:root:not([data-theme='dark']) .episode-reader {
|
||||
/* 浅色正文增加浅灰底色,与白色页面区分。 */
|
||||
--reader-background: var(--app-subtle);
|
||||
}
|
||||
.reader-directory {
|
||||
@apply flex flex-col min-h-0 min-w-0 bg-(--app-subtle);
|
||||
}
|
||||
:root:not([data-theme='dark']) .reader-directory {
|
||||
/* 浅色目录比正文深一级,明确区分章节导航和阅读区域。 */
|
||||
@apply bg-(--app-control);
|
||||
}
|
||||
.reader-directory-heading {
|
||||
@apply flex justify-between items-center shrink-0 gap-2 pt-[22px] px-5 pb-3.5 text-[13px];
|
||||
/* 目录标题与剧集条目统一左侧留白。 */
|
||||
@apply flex justify-between items-center shrink-0 gap-2 pt-[22px] px-3.5 pb-3.5 text-[13px];
|
||||
}
|
||||
.reader-directory-heading h3 {
|
||||
@apply font-semibold;
|
||||
@@ -223,7 +343,28 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
@apply bg-(--app-selected) text-accent shadow-[inset_3px_0_var(--app-accent)];
|
||||
}
|
||||
.reader-page {
|
||||
@apply min-w-0 min-h-0 overflow-hidden bg-(--app-surface);
|
||||
@apply min-w-0 min-h-0 overflow-hidden bg-(--reader-background);
|
||||
}
|
||||
/* 手机导航只在窄屏显示,抽屉内容复用同一目录条目样式。 */
|
||||
.reader-mobile-navigation {
|
||||
display: none;
|
||||
}
|
||||
.reader-sheet-heading {
|
||||
/* 标题与总集数共用一条垂直居中线,避免不同字号按基线错位。 */
|
||||
@apply flex items-center gap-2 min-w-0;
|
||||
}
|
||||
.reader-sheet-title {
|
||||
@apply text-sm leading-5;
|
||||
}
|
||||
.reader-sheet-count {
|
||||
@apply text-xs leading-5 text-muted font-normal;
|
||||
}
|
||||
.reader-sheet-directory {
|
||||
@apply flex flex-col gap-1.5 py-2;
|
||||
}
|
||||
.n-button.reader-sheet-episode-link {
|
||||
/* 条目背景铺满整行,文字与抽屉标题保持同一左侧对齐线。 */
|
||||
padding-inline: 24px;
|
||||
}
|
||||
.reader-scroll .n-scrollbar-container:focus-visible {
|
||||
@apply outline-[2px_solid_var(--app-accent)] outline-offset-[-3px];
|
||||
@@ -242,7 +383,7 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
min-height: max(160px, calc(var(--reader-height) - 64px));
|
||||
}
|
||||
.reader-chapter-heading {
|
||||
@apply sticky top-0 z-[2] mb-6 bg-(--app-surface);
|
||||
@apply sticky top-0 z-[2] mb-6 bg-(--reader-background);
|
||||
margin-inline: calc(var(--reader-gutter) * -1);
|
||||
padding: 14px var(--reader-gutter) 18px;
|
||||
}
|
||||
@@ -259,29 +400,54 @@ onBeforeUnmount(() => observer?.disconnect())
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
.episode-reader {
|
||||
@apply grid-cols-[72px_minmax(0,_1fr)];
|
||||
@apply flex flex-col;
|
||||
}
|
||||
.reader-directory-heading {
|
||||
@apply flex-col items-start gap-0 pt-2.5 px-1.5 pb-2;
|
||||
}
|
||||
.reader-directory-heading h3 {
|
||||
.reader-directory {
|
||||
@apply hidden;
|
||||
}
|
||||
.n-button.reader-episode-link {
|
||||
@apply min-h-11 py-2 px-1;
|
||||
.reader-page {
|
||||
@apply flex-1;
|
||||
}
|
||||
.n-button.reader-episode-link .n-button__content {
|
||||
@apply items-center text-center;
|
||||
.reader-mobile-navigation {
|
||||
@apply flex items-center shrink-0 min-w-0 bg-(--app-subtle);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.reader-episode-title {
|
||||
@apply hidden;
|
||||
.reader-mobile-position {
|
||||
@apply flex-1 min-w-0 truncate text-center text-xs text-muted px-1;
|
||||
}
|
||||
.reader-episode-label {
|
||||
@apply text-[11px];
|
||||
.n-button.reader-directory-trigger {
|
||||
@apply h-11 px-3 text-xs;
|
||||
}
|
||||
.n-button.reader-chapter-control {
|
||||
@apply w-11 min-w-11 h-11;
|
||||
}
|
||||
.n-button.reader-chapter-control:disabled,
|
||||
.n-button.reader-chapter-control:disabled svg {
|
||||
/* 首集与末集的边界按钮保留禁用行为,并明确以灰色图标显示。 */
|
||||
color: var(--app-disabled-text);
|
||||
}
|
||||
.reader-content {
|
||||
--reader-gutter: 18px;
|
||||
@apply px-[18px];
|
||||
/* 缩小手机阅读顶部留白,保持左右文字间距。 */
|
||||
@apply px-[18px] py-3;
|
||||
}
|
||||
.reader-chapter + .reader-chapter {
|
||||
@apply mt-8 pt-0;
|
||||
}
|
||||
.reader-chapter:last-child {
|
||||
/* 与手机正文上下 12px 留白配合,短末集仍能定位到阅读线。 */
|
||||
min-height: max(160px, calc(var(--reader-height) - 24px));
|
||||
}
|
||||
.reader-chapter-heading {
|
||||
@apply mb-3;
|
||||
padding-block: 8px;
|
||||
}
|
||||
.reader-chapter-heading p {
|
||||
@apply mb-1;
|
||||
}
|
||||
.episode-reader .script-summary {
|
||||
/* 标题后立即进入摘要,减少摘要与正文之间的空白。 */
|
||||
@apply pt-0 pb-4 mb-4;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -14,6 +14,8 @@ import { productionMessage } from '../production/production-messages'
|
||||
import ProjectSettingsDialog from '../generation-config/components/ProjectSettingsDialog.vue'
|
||||
import { projectGenerationRevisionKey } from '../generation-config/context'
|
||||
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import CreateDramaSkeleton from '../create-drama/CreateDramaSkeleton.vue'
|
||||
import BreakdownSkeleton from '../breakdown/BreakdownSkeleton.vue'
|
||||
|
||||
/** 项目标题只保留名称;下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
|
||||
const route = useRoute()
|
||||
@@ -101,6 +103,14 @@ const currentAccess = computed(() => {
|
||||
return section ? stageAccess.sections.value[section] : null
|
||||
})
|
||||
const isCreation = computed(() => currentSection.value === 'create-drama')
|
||||
/** 剧本首次读取或切换项目时显示骨架;刷新已有项目时保留正文与阅读位置。 */
|
||||
const isCreationInitialLoading = computed(
|
||||
() => isCreation.value && context.loading.value && context.project.value?.id !== id.value
|
||||
)
|
||||
/** 拆解页只在首次读取或切换项目时占位,刷新已有结果时保留内容与分类。 */
|
||||
const isBreakdownInitialLoading = computed(
|
||||
() => currentSection.value === 'breakdown' && context.loading.value && context.project.value?.id !== id.value
|
||||
)
|
||||
type OperationGuide = {
|
||||
title: string
|
||||
description: string
|
||||
@@ -220,13 +230,13 @@ onScopeDispose(() => {
|
||||
<template>
|
||||
<section class="project-frame">
|
||||
<header class="project-header">
|
||||
<!-- 以下是项目标题与全局配置入口模块 -->
|
||||
<!-- 以下是项目标题与全局配置入口模块,读取完成前标题留空 -->
|
||||
<NPageHeader @back="router.push('/projects')">
|
||||
<template #title
|
||||
><NEllipsis class="project-title" :tooltip="false">{{
|
||||
context.project.value?.title || context.project.value?.topic || '读取项目'
|
||||
}}</NEllipsis></template
|
||||
>
|
||||
<template #title>
|
||||
<NEllipsis class="project-title" :tooltip="false">{{
|
||||
context.project.value?.title || context.project.value?.topic || ''
|
||||
}}</NEllipsis>
|
||||
</template>
|
||||
<template #extra>
|
||||
<NButton size="small" :disabled="!context.project.value" @click="settingsOpen = true"
|
||||
>项目配置</NButton
|
||||
@@ -300,6 +310,10 @@ onScopeDispose(() => {
|
||||
>刷新项目状态</NButton
|
||||
>
|
||||
</EmptyState>
|
||||
<!-- 以下是剧本创作首次读取的骨架屏模块 -->
|
||||
<CreateDramaSkeleton v-else-if="isCreationInitialLoading" />
|
||||
<!-- 以下是剧本拆解首次读取的骨架屏模块 -->
|
||||
<BreakdownSkeleton v-else-if="isBreakdownInitialLoading" />
|
||||
<NSpin v-else-if="context.loading.value" class="workspace-loading" description="正在读取项目内容…" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -78,6 +78,31 @@ body {
|
||||
.n-button.icon-button .n-button__icon {
|
||||
margin: 0;
|
||||
}
|
||||
/* 全局弹窗与章节目录抽屉共用关闭图标的尺寸、底色和悬停反馈。 */
|
||||
.app-dialog .n-card-header__close,
|
||||
.n-drawer.reader-directory-sheet .n-drawer-content .n-drawer-header .n-drawer-header__close {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin: -8px;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.app-dialog .n-card-header__close .n-base-icon,
|
||||
.n-drawer.reader-directory-sheet .n-drawer-content .n-drawer-header .n-drawer-header__close .n-base-icon {
|
||||
padding: 8px;
|
||||
box-sizing: content-box;
|
||||
background: var(--app-subtle);
|
||||
}
|
||||
.app-dialog .n-card-header__close:hover,
|
||||
.n-drawer.reader-directory-sheet .n-drawer-content .n-drawer-header .n-drawer-header__close:hover {
|
||||
background: transparent;
|
||||
}
|
||||
.app-dialog .n-card-header__close:hover .n-base-icon,
|
||||
.n-drawer.reader-directory-sheet .n-drawer-content .n-drawer-header .n-drawer-header__close:hover .n-base-icon {
|
||||
background: var(--app-control-hover);
|
||||
}
|
||||
.n-button:focus-visible {
|
||||
outline: 2px solid var(--app-accent-text);
|
||||
outline-offset: 2px;
|
||||
|
||||
@@ -79,16 +79,16 @@ describe('管理后台组件边界', () => {
|
||||
expect(css).toMatch(/\.casting-item-status\s*\{[^}]*flex-shrink:\s*0/)
|
||||
expect(css).toMatch(/\.n-button\.casting-item\.selected\s*\{[^}]*var\(--app-selected\)[^}]*var\(--app-accent\)/)
|
||||
})
|
||||
it('拆解分栏跟随剩余高度收缩,移动端历史区不挤出结果区', () => {
|
||||
// DOM 环境不计算几何,保护完整的 flex → grid → NScrollbar 高度链。
|
||||
it('拆解结果独占剩余高度,手机正文交给项目内容区滚动', () => {
|
||||
// 执行记录移除后,桌面保留有界滚动,手机结果容器随正文自然伸展。
|
||||
const css = readAllStyles()
|
||||
expect(css).toMatch(/\.breakdown-results-section\s*\{[^}]*flex:\s*1;[^}]*min-height:\s*0/)
|
||||
expect(css).toMatch(/\.breakdown-results-section > \.result-toolbar\s*\{[^}]*flex-shrink:\s*0/)
|
||||
expect(css).toMatch(
|
||||
/\.breakdown-results-section > \.content-with-history\s*\{[^}]*flex:\s*1;[^}]*height:\s*auto;[^}]*min-height:\s*0;[^}]*grid-template-rows:\s*minmax\(0, 1fr\)/
|
||||
/\.breakdown-results-section > \.breakdown-content\s*\{[^}]*flex:\s*1;[^}]*height:\s*auto;[^}]*min-height:\s*0;[^}]*grid-template-columns:\s*minmax\(0, 1fr\);[^}]*grid-template-rows:\s*minmax\(0, 1fr\)/
|
||||
)
|
||||
expect(css).toMatch(
|
||||
/@media \(max-width: 800px\)[\s\S]*?\.breakdown-results-section \.content-with-history:not\(\.history-hidden\) \.history-panel\s*\{[^}]*inset:\s*0/
|
||||
/@media \(max-width: 760px\)[\s\S]*?\.breakdown-workspace-page \.breakdown-content,[^{]*\{[^}]*height:\s*auto;[^}]*max-height:\s*none;[^}]*overflow:\s*visible/
|
||||
)
|
||||
expect(css).toMatch(/\.panel-scroll\.n-scrollbar\s*\{[^}]*height:\s*100%;[^}]*min-height:\s*0/)
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ import { projectContextKey, type useProjectData } from '@/features/projects/cont
|
||||
import type { ProjectDetail } from '@/features/projects/types'
|
||||
import type { Checkpoint } from '@/features/workflows/types'
|
||||
import type { BreakdownModule, EpisodePlan } from '@/features/breakdown/types'
|
||||
import { drawerPanel, selectMenu } from '@/testing/naive'
|
||||
import { drawerPanel } from '@/testing/naive'
|
||||
import { readAllStyles } from '@/testing/styles'
|
||||
|
||||
let wrapper: VueWrapper | undefined
|
||||
@@ -212,7 +212,6 @@ describe('拆解页内容滚动', () => {
|
||||
mountPage()
|
||||
await selectTab(label)
|
||||
expect(wrapper!.find('.history-panel').exists()).toBe(false)
|
||||
await selectMenu('拆解更多操作', '执行记录')
|
||||
const list = wrapper!.get('.subject-record-list')
|
||||
expect(list.classes()).toContain('record-list')
|
||||
expect(list.findAll(':scope > article')).toHaveLength(30)
|
||||
@@ -393,26 +392,22 @@ describe('拆解页内容滚动', () => {
|
||||
])('%s 的末项始终放在独立结果滚动容器内', async (label, lastItem) => {
|
||||
mountPage()
|
||||
await selectTab(label)
|
||||
await selectMenu('拆解更多操作', '执行记录')
|
||||
expect(wrapper!.find('.workspace-scroll').exists()).toBe(false)
|
||||
const results = wrapper!.get('.breakdown-results-scroll .n-scrollbar-container')
|
||||
expect(results.text()).toContain(lastItem)
|
||||
expect(results.find('.result-toolbar').exists()).toBe(false)
|
||||
expect(results.find('.history-panel').exists()).toBe(false)
|
||||
expect(wrapper!.get('.history-panel .n-scrollbar-container').text()).toContain('执行记录')
|
||||
expect(wrapper!.find('.history-panel').exists()).toBe(false)
|
||||
expect(wrapper!.get('[data-workspace-tools]').attributes('aria-expanded')).toBe('false')
|
||||
expect(results.find('.table-scroll').exists()).toBe(label === '任务明细')
|
||||
})
|
||||
|
||||
it('刷新和开关配置保留阅读位置,切换标签只重置结果区,不改变执行记录位置', async () => {
|
||||
it('刷新和开关配置保留阅读位置,切换标签只重置结果区', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>()
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const provided = mountPage()
|
||||
await selectMenu('拆解更多操作', '执行记录')
|
||||
const results = wrapper!.get<HTMLElement>('.breakdown-results-scroll .n-scrollbar-container').element
|
||||
const history = wrapper!.get<HTMLElement>('.history-panel .n-scrollbar-container').element
|
||||
results.scrollTop = 900
|
||||
history.scrollTop = 120
|
||||
await wrapper!.get('[data-workspace-tools]').trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().element.closest('.workspace-split')).toBeNull()
|
||||
@@ -426,8 +421,7 @@ describe('拆解页内容滚动', () => {
|
||||
const next = wrapper!.get<HTMLElement>('.breakdown-results-scroll .n-scrollbar-container').element
|
||||
expect(next).not.toBe(results)
|
||||
expect(next.scrollTop).toBe(0)
|
||||
expect(wrapper!.get('.history-panel .n-scrollbar-container').element).toBe(history)
|
||||
expect(history.scrollTop).toBe(120)
|
||||
expect(wrapper!.find('.history-panel').exists()).toBe(false)
|
||||
await wrapper!.get('[data-workspace-tools]').trigger('click')
|
||||
await flushPromises()
|
||||
expect(drawerPanel().get<HTMLInputElement>('#group-size').element.value).toBe('2')
|
||||
|
||||
@@ -72,14 +72,13 @@ describe('连续剧本阅读器', () => {
|
||||
expect(content).toContain('text-align: left')
|
||||
expect(content).not.toContain('auto')
|
||||
expect(css).toMatch(
|
||||
/\.reader-chapter-heading\s*\{[^}]*position:\s*sticky;[^}]*top:\s*0;[^}]*z-index:\s*2;[^}]*background:\s*var\(--app-surface\)/
|
||||
/\.reader-chapter-heading\s*\{[^}]*position:\s*sticky;[^}]*top:\s*0;[^}]*z-index:\s*2;[^}]*background:\s*var\(--reader-background\)/
|
||||
)
|
||||
expect(css).toMatch(
|
||||
/\.reader-chapter-heading\s*\{[^}]*margin-inline:\s*calc\(var\(--reader-gutter\) \* -1\);[^}]*padding:\s*14px var\(--reader-gutter\) 18px;/
|
||||
)
|
||||
expect(css).toMatch(/@media \(max-width: 800px\)[\s\S]*?\.reader-content\s*\{[^}]*padding-inline:\s*18px/)
|
||||
expect(css).toMatch(/@media \(max-width: 800px\)[\s\S]*?\.reader-content\s*\{[^}]*--reader-gutter:\s*18px/)
|
||||
expect(css).toMatch(/@media \(max-width: 800px\)[\s\S]*?\.episode-reader\s*\{[^}]*72px/)
|
||||
})
|
||||
|
||||
it('按编号连续渲染全部剧集、元数据和空正文,标题不截断,模型内容只按文本显示', () => {
|
||||
@@ -119,6 +118,22 @@ describe('连续剧本阅读器', () => {
|
||||
expect(pageScroll).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('手机上下集按目录顺序切换,跳过缺号并禁用首尾边界', async () => {
|
||||
const { reader } = await mountReader()
|
||||
await wrapper!.setProps({ episodes: [episodes[0]!, episodes[2]!] })
|
||||
const previous = wrapper!.get('button[aria-label="上一集"]')
|
||||
const next = wrapper!.get('button[aria-label="下一集"]')
|
||||
expect(previous.attributes('disabled')).toBeDefined()
|
||||
await next.trigger('click')
|
||||
expect(currentEpisode()).toBe(3)
|
||||
expect(reader.scrollTop).toBe(1448)
|
||||
expect(next.attributes('disabled')).toBeDefined()
|
||||
await previous.trigger('click')
|
||||
expect(currentEpisode()).toBe(1)
|
||||
expect(reader.scrollTop).toBe(0)
|
||||
expect(previous.attributes('disabled')).toBeDefined()
|
||||
})
|
||||
|
||||
it('正文双向滚动同步当前集,目录项离开可见区时自动露出', async () => {
|
||||
const { reader, directory, directoryScroll } = await mountReader()
|
||||
reader.scrollTop = 1450
|
||||
|
||||
@@ -106,6 +106,49 @@ async function openProject(initialPath: string) {
|
||||
}
|
||||
|
||||
describe('剧本完成前的下游访问限制', () => {
|
||||
it('拆解首次读取显示骨架,刷新保留已有内容,切换项目完成后仍遵守访问限制', async () => {
|
||||
/** 延迟真实查询入口,覆盖初次读取、后台刷新和跨项目读取三个阶段。 */
|
||||
let resolveDetail!: (value: ProjectDetail) => void
|
||||
let pending = new Promise<ProjectDetail>(resolve => {
|
||||
resolveDetail = resolve
|
||||
})
|
||||
vi.spyOn(projectsApi, 'detail').mockImplementation(() => pending)
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
vi.mocked(projectsApi.stageReadiness).mockImplementation(async id => readiness(id, id === 'skeleton-first'))
|
||||
const { router, mounted } = await openProject('/projects/skeleton-first/breakdown')
|
||||
expect(wrapper!.get('.breakdown-skeleton').attributes('aria-busy')).toBe('true')
|
||||
expect(wrapper!.find('.workspace-loading').exists()).toBe(false)
|
||||
expect(wrapper!.get('.project-title').text()).toBe('')
|
||||
expect(mounted).not.toHaveBeenCalled()
|
||||
|
||||
resolveDetail(project('skeleton-first', 'completed'))
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.breakdown-skeleton').exists()).toBe(false)
|
||||
expect(wrapper!.get('.workspace-probe').text()).toBe('breakdown')
|
||||
|
||||
pending = new Promise<ProjectDetail>(resolve => {
|
||||
resolveDetail = resolve
|
||||
})
|
||||
await wrapper!.get('.probe-refresh').trigger('click')
|
||||
expect(wrapper!.find('.breakdown-skeleton').exists()).toBe(false)
|
||||
expect(wrapper!.get('.workspace-probe').text()).toBe('breakdown')
|
||||
resolveDetail(project('skeleton-first', 'completed'))
|
||||
await flushPromises()
|
||||
|
||||
pending = new Promise<ProjectDetail>(resolve => {
|
||||
resolveDetail = resolve
|
||||
})
|
||||
await router.push('/projects/skeleton-second/breakdown')
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.breakdown-skeleton').exists()).toBe(true)
|
||||
expect(wrapper!.find('.workspace-probe').exists()).toBe(false)
|
||||
resolveDetail(project('skeleton-second', 'draft'))
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.breakdown-skeleton').exists()).toBe(false)
|
||||
expect(wrapper!.get('.project-access-gate').text()).toContain('请先完成剧本创作')
|
||||
expect(mounted).toHaveBeenCalledExactlyOnceWith('breakdown')
|
||||
})
|
||||
|
||||
it('切换图库与其他工作区不自动重复读取项目状态', async () => {
|
||||
vi.useFakeTimers()
|
||||
const detail = vi.spyOn(projectsApi, 'detail').mockResolvedValue(project('manual-gallery', 'completed'))
|
||||
|
||||
@@ -30,7 +30,7 @@ import SubjectIdentityPage from '@/features/subject-identity/SubjectIdentityPage
|
||||
import { styleFixture, styleImageFixture } from '@/features/visual-style/testing/fixtures'
|
||||
import { identityFixture, identityImageFixture } from '@/features/subject-identity/testing/fixtures'
|
||||
import { getIdentitySession } from '@/features/subject-identity/model'
|
||||
import { drawerPanel, expandSections, selectControl, selectMenu } from '@/testing/naive'
|
||||
import { drawerPanel, expandSections, selectControl } from '@/testing/naive'
|
||||
import ProductionPage from '@/features/production/ProductionPage.vue'
|
||||
import { getProductionSession } from '@/features/production/model'
|
||||
|
||||
@@ -917,7 +917,7 @@ describe('工作台页面交互', () => {
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
|
||||
it('拆解更多菜单位于 Tabs suffix,空快照时导出仍禁用', async () => {
|
||||
it('拆解导出图标位于 Tabs suffix,空快照时禁用且不再提供执行记录', async () => {
|
||||
wrapper = mount(BreakdownPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
|
||||
@@ -925,13 +925,13 @@ describe('工作台页面交互', () => {
|
||||
const toolbar = wrapper.get('.result-toolbar')
|
||||
expect(toolbar.find('[aria-label="拆解结果"]').exists()).toBe(true)
|
||||
expect(toolbar.find(':scope > button').exists()).toBe(false)
|
||||
expect(toolbar.find('.n-tabs-nav__suffix [aria-label="拆解更多操作"]').exists()).toBe(true)
|
||||
await toolbar.get('.n-tabs-nav__suffix [aria-label="拆解更多操作"]').trigger('click')
|
||||
await flushPromises()
|
||||
const exportItem = [...document.querySelectorAll('.n-dropdown-option-body')].find(
|
||||
item => item.textContent?.trim() === '导出 JSON'
|
||||
)!
|
||||
expect(exportItem.className).toContain('disabled')
|
||||
const exportButton = toolbar.get<HTMLButtonElement>('.n-tabs-nav__suffix [aria-label="导出拆解结果"]')
|
||||
expect(exportButton.element.disabled).toBe(true)
|
||||
expect(exportButton.text()).toBe('')
|
||||
expect(exportButton.get('svg').attributes('width')).toBe('18')
|
||||
expect(toolbar.find('[aria-label="拆解更多操作"]').exists()).toBe(false)
|
||||
expect(wrapper.find('.history-panel').exists()).toBe(false)
|
||||
expect(wrapper.text()).not.toContain('执行记录')
|
||||
})
|
||||
|
||||
it('形态图库自动显示后端已有图片,不需要再次生图;筛选只改变显示', async () => {
|
||||
@@ -1613,13 +1613,17 @@ describe('工作台页面交互', () => {
|
||||
expect(provided.refresh).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('切换剧本标签保留阅读容器和位置,执行记录按需展开', async () => {
|
||||
it('切换剧本标签保留阅读容器和位置,右侧只保留直接导出', async () => {
|
||||
wrapper = mount(CreateDramaPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
|
||||
})
|
||||
const suffix = wrapper.get('.script-section .n-tabs-nav__suffix')
|
||||
expect(suffix.findAll('button').map(item => item.attributes('aria-label'))).toEqual(['剧本更多操作'])
|
||||
expect(suffix.findAll('button').map(item => item.text())).toEqual([''])
|
||||
expect(suffix.get('button').attributes('aria-label')).toBe('导出剧本')
|
||||
expect(suffix.get('button').classes()).toContain('icon-button')
|
||||
expect(suffix.findAll('svg')).toHaveLength(1)
|
||||
expect(suffix.get('svg').attributes('width')).toBe('18')
|
||||
expect(suffix.find('router-link-stub').exists()).toBe(false)
|
||||
expect(suffix.text()).not.toContain('进入拆解')
|
||||
const reader = wrapper.get<HTMLElement>('.reader-scroll .n-scrollbar-container').element
|
||||
@@ -1637,11 +1641,8 @@ describe('工作台页面交互', () => {
|
||||
expect(wrapper.get('.episode-reader').isVisible()).toBe(true)
|
||||
expect(wrapper.get('.reader-scroll .n-scrollbar-container').element).toBe(reader)
|
||||
expect(reader.scrollTop).toBe(120)
|
||||
await selectMenu('剧本更多操作', '执行记录')
|
||||
expect(wrapper.find('.history-panel').exists()).toBe(true)
|
||||
expect(wrapper.get('.content-with-history').classes()).not.toContain('history-hidden')
|
||||
await selectMenu('剧本更多操作', '收起执行记录')
|
||||
expect(wrapper.find('.history-panel').exists()).toBe(false)
|
||||
expect(wrapper.text()).not.toContain('执行记录')
|
||||
})
|
||||
|
||||
it('剧本文本按纯文本显示,不执行模型输出的 HTML', () => {
|
||||
|
||||
@@ -9,6 +9,8 @@ export default defineConfig({
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
restoreMocks: true,
|
||||
/** 限制同时挂载的页面测试数量,避免 Naive UI 渲染争抢资源造成超时。 */
|
||||
maxWorkers: 2,
|
||||
/** 只收集正式测试目录,避免把包管理缓存中的旧项目快照作为当前测试。 */
|
||||
include: ['tests/**/*.test.ts'],
|
||||
/** 只检查当前 checkout,避免收集其它隔离 worktree 中的重复测试。 */
|
||||
|
||||
Reference in new issue
Block a user