From 87463f343c448a2c6283e1913db77fbd39b2dfb6 Mon Sep 17 00:00:00 2001 From: shinya Date: Wed, 6 Aug 2025 19:36:18 +0800 Subject: [PATCH] feat: add play page douban link --- VERSION.txt | 2 +- src/app/douban/page.tsx | 2 +- src/app/page.tsx | 6 ++--- src/app/play/page.tsx | 43 +++++++++++++++++++++++++++++++----- src/app/search/page.tsx | 4 ++-- src/components/VideoCard.tsx | 18 ++++++--------- src/lib/version.ts | 2 +- 7 files changed, 52 insertions(+), 25 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index f78d75c..bfe4f16 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -20250806191001 \ No newline at end of file +20250806193618 \ No newline at end of file diff --git a/src/app/douban/page.tsx b/src/app/douban/page.tsx index efd99ba..1d78b09 100644 --- a/src/app/douban/page.tsx +++ b/src/app/douban/page.tsx @@ -427,7 +427,7 @@ function DoubanPageClient() { from='douban' title={item.title} poster={item.poster} - douban_id={item.id} + douban_id={Number(item.id)} rate={item.rate} year={item.year} type={type === 'movie' ? 'movie' : ''} // 电影类型严格控制,tv 不控 diff --git a/src/app/page.tsx b/src/app/page.tsx index ebe21e4..fa8dcc5 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -251,7 +251,7 @@ function HomeClient() { from='douban' title={movie.title} poster={movie.poster} - douban_id={movie.id} + douban_id={Number(movie.id)} rate={movie.rate} year={movie.year} type='movie' @@ -299,7 +299,7 @@ function HomeClient() { from='douban' title={show.title} poster={show.poster} - douban_id={show.id} + douban_id={Number(show.id)} rate={show.rate} year={show.year} /> @@ -346,7 +346,7 @@ function HomeClient() { from='douban' title={show.title} poster={show.poster} - douban_id={show.id} + douban_id={Number(show.id)} rate={show.rate} year={show.year} /> diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 790b4f3..9b2e9bb 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -92,6 +92,7 @@ function PlayPageClient() { const [videoTitle, setVideoTitle] = useState(searchParams.get('title') || ''); const [videoYear, setVideoYear] = useState(searchParams.get('year') || ''); const [videoCover, setVideoCover] = useState(''); + const [videoDoubanId, setVideoDoubanId] = useState(0); // 当前源和ID const [currentSource, setCurrentSource] = useState( searchParams.get('source') || '' @@ -715,6 +716,7 @@ function PlayPageClient() { setVideoYear(detailData.year); setVideoTitle(detailData.title || videoTitleRef.current); setVideoCover(detailData.poster); + setVideoDoubanId(detailData.douban_id || 0); setDetail(detailData); if (currentEpisodeIndex >= detailData.episodes.length) { setCurrentEpisodeIndex(0); @@ -868,6 +870,7 @@ function PlayPageClient() { setVideoTitle(newDetail.title || newTitle); setVideoYear(newDetail.year); setVideoCover(newDetail.poster); + setVideoDoubanId(newDetail.douban_id || 0); setCurrentSource(newSource); setCurrentId(newId); setDetail(newDetail); @@ -1932,13 +1935,41 @@ function PlayPageClient() { {/* 封面展示 */}
-
+
{videoCover ? ( - {videoTitle} + <> + {videoTitle} + + {/* 豆瓣链接按钮 */} + {videoDoubanId !== 0 && ( + +
+ + + + +
+
+ )} + ) : ( 封面图片 diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index 34b289c..7d2a3cf 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -322,12 +322,12 @@ function SearchPageClient() { > void; rate?: string; items?: SearchResult[]; @@ -63,7 +63,7 @@ export default function VideoCard({ const aggregateData = useMemo(() => { if (!isAggregate || !items) return null; - const countMap = new Map(); + const countMap = new Map(); const episodeCountMap = new Map(); items.forEach((item) => { if (item.douban_id && item.douban_id !== 0) { @@ -75,11 +75,9 @@ export default function VideoCard({ } }); - const getMostFrequent = ( - map: Map - ) => { + const getMostFrequent = (map: Map) => { let maxCount = 0; - let result: T | undefined; + let result: number | undefined; map.forEach((cnt, key) => { if (cnt > maxCount) { maxCount = cnt; @@ -100,9 +98,7 @@ export default function VideoCard({ const actualPoster = aggregateData?.first.poster ?? poster; const actualSource = aggregateData?.first.source ?? source; const actualId = aggregateData?.first.id ?? id; - const actualDoubanId = String( - aggregateData?.mostFrequentDoubanId ?? douban_id - ); + const actualDoubanId = aggregateData?.mostFrequentDoubanId ?? douban_id; const actualEpisodes = aggregateData?.mostFrequentEpisodes ?? episodes; const actualYear = aggregateData?.first.year ?? year; const actualQuery = query || ''; @@ -340,9 +336,9 @@ export default function VideoCard({ )} {/* 豆瓣链接 */} - {config.showDoubanLink && actualDoubanId && ( + {config.showDoubanLink && actualDoubanId && actualDoubanId !== 0 && ( e.stopPropagation()} diff --git a/src/lib/version.ts b/src/lib/version.ts index 478196a..42546e5 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -2,7 +2,7 @@ 'use client'; -const CURRENT_VERSION = '20250806191001'; +const CURRENT_VERSION = '20250806193618'; // 版本检查结果枚举 export enum UpdateStatus {