diff --git a/qwen3-tts-frontend/src/pages/Audiobook.tsx b/qwen3-tts-frontend/src/pages/Audiobook.tsx index 0a35674..60d6430 100644 --- a/qwen3-tts-frontend/src/pages/Audiobook.tsx +++ b/qwen3-tts-frontend/src/pages/Audiobook.tsx @@ -11,6 +11,22 @@ import { AudioPlayer } from '@/components/AudioPlayer' import { audiobookApi, type AudiobookProject, type AudiobookProjectDetail, type AudiobookCharacter, type AudiobookSegment } from '@/lib/api/audiobook' import apiClient, { formatApiError } from '@/lib/api' +function LazyAudioPlayer({ audioUrl, jobId }: { audioUrl: string; jobId: number }) { + const [visible, setVisible] = useState(false) + const ref = useRef(null) + useEffect(() => { + const el = ref.current + if (!el) return + const observer = new IntersectionObserver( + ([entry]) => { if (entry.isIntersecting) { setVisible(true); observer.disconnect() } }, + { rootMargin: '120px' } + ) + observer.observe(el) + return () => observer.disconnect() + }, []) + return
{visible && }
+} + const STATUS_LABELS: Record = { pending: '待分析', analyzing: '分析中', @@ -776,7 +792,7 @@ function ProjectCard({ project, onRefresh }: { project: AudiobookProject; onRefr {seg.status === 'error' && 出错} {seg.status === 'done' && ( - + )} ))}