import React, { useState } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import type { Asset, NovelChapter } from '@/types'; import { mockAssets } from '@/mock/data'; import './NovelPreviewPage.css'; const NovelPreviewPage: React.FC = () => { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); const [activeChapter, setActiveChapter] = useState(''); const [rightTab, setRightTab] = useState<'worldview' | 'characters' | 'hooks'>('worldview'); const novel: Asset | undefined = mockAssets.find(a => a.id === id && a.category === 'novel'); const chapters = novel?.chapters || []; const meta = novel?.novelMeta; const currentChapter: NovelChapter | undefined = chapters.find(c => c.id === (activeChapter || chapters[0]?.id)); if (!novel) { return (

未找到该小说

); } return (
{/* Top: Novel Intro */}

{novel.name}

{novel.description}

{chapters.length} 章 · {chapters.reduce((s, c) => s + c.wordCount, 0).toLocaleString()} 字
{/* Left: Chapter List */} {/* Center: Content */}
{currentChapter ? ( <>

{currentChapter.title}

{currentChapter.content.split('\n\n').map((para, i) => (

{para}

))}
本章字数:{currentChapter.wordCount.toLocaleString()} 字
) : (

暂无章节内容

)}
{/* Right: World View, Characters, Hooks & Anchors */}
); }; export default NovelPreviewPage;