52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
|
|
import { LivePulse } from "@/components/ui";
|
|
import { useYouTubeLiveMap } from "@/lib/youtubeLive";
|
|
|
|
/** Home ticker: all live YouTube groups + Shorts channels from live-map. */
|
|
export function YouTubeLiveTicker() {
|
|
const { map } = useYouTubeLiveMap();
|
|
const entries = map?.entries || {};
|
|
const live = Object.entries(entries).filter(
|
|
([k, v]) => (k.startsWith("group:") || k.startsWith("shorts:")) && v?.is_live,
|
|
);
|
|
if (!live.length) return null;
|
|
|
|
const items = live.map(([key, v]) => ({
|
|
key,
|
|
title: v.title || key.replace(/^(group|shorts):/, ""),
|
|
url: v.live_url || "#",
|
|
source: v.source,
|
|
}));
|
|
|
|
return (
|
|
<div className="mb-6 overflow-hidden rounded-2xl border border-red-500/25 bg-red-500/5">
|
|
<div className="flex items-center gap-2 border-b border-white/5 px-4 py-2 text-xs text-red-100/90">
|
|
<LivePulse label={`YouTube ${items.length} 路在播`} />
|
|
<Link href="/groups" className="ml-auto text-teal-300 hover:underline">
|
|
分组 →
|
|
</Link>
|
|
</div>
|
|
<div className="relative overflow-hidden py-3">
|
|
<div className="ticker-track gap-8 px-4 text-sm text-slate-200">
|
|
{[...items, ...items].map((item, idx) => (
|
|
<a
|
|
key={`${item.key}-${idx}`}
|
|
href={item.url}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="inline-flex items-center gap-2 whitespace-nowrap hover:text-white"
|
|
>
|
|
<span className="live-dot" />
|
|
<span className="font-medium">{item.title}</span>
|
|
{item.source ? <span className="text-[10px] text-slate-500">{item.source}</span> : null}
|
|
</a>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|