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>
|
||||
@@ -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>
|
||||
Reference in new issue
Block a user