diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index c38a241..da1b448 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -66,22 +66,8 @@ function SearchPageClient() { }); return res; })(); - const douban_id = (() => { - const idMap = new Map(); - group.forEach((g) => { - if (g.douban_id && g.douban_id !== 0) { - idMap.set(g.douban_id, (idMap.get(g.douban_id) || 0) + 1); - } - }); - let max = 0; - let res: number | undefined = undefined; - idMap.forEach((v, k) => { - if (v > max) { max = v; res = k; } - }); - return res; - })(); const source_names = Array.from(new Set(group.map((g) => g.source_name).filter(Boolean))) as string[]; - return { episodes, douban_id, source_names }; + return { episodes, source_names }; }; // 过滤器:非聚合与聚合 const [filterAll, setFilterAll] = useState<{ source: string; title: string; year: string; yearOrder: 'none' | 'asc' | 'desc' }>({ @@ -189,9 +175,6 @@ function SearchPageClient() { // 对比变化并调用对应的 set 方法 const ref = groupRefs.current.get(mapKey); if (ref && ref.current) { - if (prev.douban_id !== stats.douban_id) { - ref.current.setDoubanId(stats.douban_id); - } if (prev.episodes !== stats.episodes) { ref.current.setEpisodes(stats.episodes); } @@ -680,12 +663,12 @@ function SearchPageClient() { const title = group[0]?.title || ''; const poster = group[0]?.poster || ''; const year = group[0]?.year || 'unknown'; - const { episodes, douban_id, source_names } = computeGroupStats(group); + const { episodes, source_names } = computeGroupStats(group); const type = episodes === 1 ? 'movie' : 'tv'; // 如果该聚合第一次出现,写入初始统计 if (!groupStatsRef.current.has(mapKey)) { - groupStatsRef.current.set(mapKey, { episodes, douban_id, source_names }); + groupStatsRef.current.set(mapKey, { episodes, source_names }); } return ( @@ -698,7 +681,6 @@ function SearchPageClient() { poster={poster} year={year} episodes={episodes} - douban_id={douban_id} source_names={source_names} query={ searchQuery.trim() !== title diff --git a/src/components/VideoCard.tsx b/src/components/VideoCard.tsx index a8917ca..4a70401 100644 --- a/src/components/VideoCard.tsx +++ b/src/components/VideoCard.tsx @@ -47,7 +47,6 @@ export interface VideoCardProps { } export type VideoCardHandle = { - setDoubanId: (id?: number) => void; setEpisodes: (episodes?: number) => void; setSourceNames: (names?: string[]) => void; }; @@ -80,9 +79,6 @@ const VideoCard = forwardRef(function VideoCard const [isLoading, setIsLoading] = useState(false); // 可外部修改的可控字段 - const [dynamicDoubanId, setDynamicDoubanId] = useState( - douban_id - ); const [dynamicEpisodes, setDynamicEpisodes] = useState( episodes ); @@ -90,10 +86,6 @@ const VideoCard = forwardRef(function VideoCard source_names ); - useEffect(() => { - setDynamicDoubanId(douban_id); - }, [douban_id]); - useEffect(() => { setDynamicEpisodes(episodes); }, [episodes]); @@ -103,7 +95,6 @@ const VideoCard = forwardRef(function VideoCard }, [source_names]); useImperativeHandle(ref, () => ({ - setDoubanId: (id?: number) => setDynamicDoubanId(id), setEpisodes: (eps?: number) => setDynamicEpisodes(eps), setSourceNames: (names?: string[]) => setDynamicSourceNames(names), })); @@ -112,7 +103,7 @@ const VideoCard = forwardRef(function VideoCard const actualPoster = poster; const actualSource = source; const actualId = id; - const actualDoubanId = dynamicDoubanId; + const actualDoubanId = douban_id; const actualEpisodes = dynamicEpisodes; const actualYear = year; const actualQuery = query || ''; @@ -274,7 +265,7 @@ const VideoCard = forwardRef(function VideoCard }, }; return configs[from] || configs.search; - }, [from, isAggregate, actualDoubanId, rate]); + }, [from, isAggregate, douban_id, rate]); return (
(function VideoCard return (
-
+
{sourceCount}
@@ -420,14 +411,14 @@ const VideoCard = forwardRef(function VideoCard const remainingCount = sortedSources.length - maxDisplayCount; return ( -
-
+
+
{/* 单列布局 */} -
+
{displaySources.map((sourceName, index) => ( -
-
- +
+
+ {sourceName}
@@ -436,15 +427,15 @@ const VideoCard = forwardRef(function VideoCard {/* 显示更多提示 */} {hasMore && ( -
+
- +{remainingCount} 播放源 + +{remainingCount} 播放源
)} {/* 小箭头 */} -
+
);