diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index a1cb0b6..9e11094 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -7,7 +7,7 @@ import { useRouter, useSearchParams } from 'next/navigation'; import { Suspense, useEffect, useRef, useState } from 'react'; import { usePlaySync } from '@/hooks/usePlaySync'; - +import { getDoubanDetail } from '@/lib/douban.client'; import { deleteFavorite, @@ -311,6 +311,12 @@ function PlayPageClient() { const [videoYear, setVideoYear] = useState(searchParams.get('year') || ''); const [videoCover, setVideoCover] = useState(''); const [videoDoubanId, setVideoDoubanId] = useState(0); + // 豆瓣评分数据 + const [doubanRating, setDoubanRating] = useState<{ + value: number; + count: number; + star_count: number; + } | null>(null); // 当前源和ID const [currentSource, setCurrentSource] = useState( searchParams.get('source') || '' @@ -401,6 +407,34 @@ function PlayPageClient() { } }, [currentEpisodeIndex]); + // 获取豆瓣评分数据 + useEffect(() => { + const fetchDoubanRating = async () => { + if (!videoDoubanId || videoDoubanId === 0) { + setDoubanRating(null); + return; + } + + try { + const doubanData = await getDoubanDetail(videoDoubanId.toString()); + if (doubanData.rating) { + setDoubanRating({ + value: doubanData.rating.value, + count: doubanData.rating.count, + star_count: doubanData.rating.star_count, + }); + } else { + setDoubanRating(null); + } + } catch (error) { + console.error('获取豆瓣评分失败:', error); + setDoubanRating(null); + } + }; + + fetchDoubanRating(); + }, [videoDoubanId]); + // 视频播放地址 const [videoUrl, setVideoUrl] = useState(''); @@ -3836,17 +3870,50 @@ function PlayPageClient() {