From 8a5f7bf291136abc9d8a4d16ad0aaefd4a64e448 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Tue, 9 Dec 2025 15:08:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=AD=E6=94=BE=E9=A1=B5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B1=86=E7=93=A3=E8=AF=84=E5=88=86=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/play/page.tsx | 75 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-) 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() {
{/* 标题 */} -

- {videoTitle || '影片标题'} +

+ {videoTitle || '影片标题'} + {/* 豆瓣评分显示 */} + {doubanRating && doubanRating.value > 0 && ( +
+ {/* 星级显示 */} +
+ {[1, 2, 3, 4, 5].map((star) => { + const filled = star <= Math.round(doubanRating.value / 2); + return ( + + + + ); + })} +
+ {/* 评分数值 */} + + {doubanRating.value.toFixed(1)} + + {/* 评分人数 */} + + ({doubanRating.count.toLocaleString()}人评价) + +
+ )}

{/* 关键信息行 */}