mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-17 19:27:29 +08:00
feat: add doubanlink in search page
This commit is contained in:
@@ -67,7 +67,23 @@ function SearchPageClient() {
|
||||
return res;
|
||||
})();
|
||||
const source_names = Array.from(new Set(group.map((g) => g.source_name).filter(Boolean))) as string[];
|
||||
return { episodes, source_names };
|
||||
|
||||
const douban_id = (() => {
|
||||
const countMap = new Map<number, number>();
|
||||
group.forEach((g) => {
|
||||
if (g.douban_id && g.douban_id > 0) {
|
||||
countMap.set(g.douban_id, (countMap.get(g.douban_id) || 0) + 1);
|
||||
}
|
||||
});
|
||||
let max = 0;
|
||||
let res: number | undefined;
|
||||
countMap.forEach((v, k) => {
|
||||
if (v > max) { max = v; res = k; }
|
||||
});
|
||||
return res;
|
||||
})();
|
||||
|
||||
return { episodes, source_names, douban_id };
|
||||
};
|
||||
// 过滤器:非聚合与聚合
|
||||
const [filterAll, setFilterAll] = useState<{ source: string; title: string; year: string; yearOrder: 'none' | 'asc' | 'desc' }>({
|
||||
@@ -183,6 +199,9 @@ function SearchPageClient() {
|
||||
if (prevNames !== nextNames) {
|
||||
ref.current.setSourceNames(stats.source_names);
|
||||
}
|
||||
if (prev.douban_id !== stats.douban_id) {
|
||||
ref.current.setDoubanId(stats.douban_id);
|
||||
}
|
||||
groupStatsRef.current.set(mapKey, stats);
|
||||
}
|
||||
});
|
||||
@@ -748,12 +767,12 @@ function SearchPageClient() {
|
||||
const title = group[0]?.title || '';
|
||||
const poster = group[0]?.poster || '';
|
||||
const year = group[0]?.year || 'unknown';
|
||||
const { episodes, source_names } = computeGroupStats(group);
|
||||
const { episodes, source_names, douban_id } = computeGroupStats(group);
|
||||
const type = episodes === 1 ? 'movie' : 'tv';
|
||||
|
||||
// 如果该聚合第一次出现,写入初始统计
|
||||
if (!groupStatsRef.current.has(mapKey)) {
|
||||
groupStatsRef.current.set(mapKey, { episodes, source_names });
|
||||
groupStatsRef.current.set(mapKey, { episodes, source_names, douban_id });
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -767,6 +786,7 @@ function SearchPageClient() {
|
||||
year={year}
|
||||
episodes={episodes}
|
||||
source_names={source_names}
|
||||
douban_id={douban_id}
|
||||
query={
|
||||
searchQuery.trim() !== title
|
||||
? searchQuery.trim()
|
||||
|
||||
Reference in New Issue
Block a user