"use client"; import { LivePulse } from "@/components/ui"; import { useYouTubeLiveEntry, type YouTubeLiveEntry } from "@/lib/youtubeLive"; type Props = { /** e.g. group:uuid, shorts:uuid, channel:UCxxx */ refKey?: string; /** Direct entry override (probe tab, etc.) */ entry?: YouTubeLiveEntry | null; className?: string; /** Show stream title next to badge */ showTitle?: boolean; compact?: boolean; /** When not live, still show 离线/检测中 instead of hiding */ showOffline?: boolean; }; export function YouTubeLiveBadge({ refKey, entry, className = "", showTitle = false, compact = false, showOffline = false, }: Props) { const fromMap = useYouTubeLiveEntry(refKey); const live = entry ?? fromMap; if (!live) { if (!showOffline) return null; return ( YT·检测中 ); } if (!live.is_live) { if (!showOffline) return null; const tip = live.error ? String(live.error) : "YouTube 未开播"; return ( YT·离线 ); } const label = compact ? "YT·LIVE" : "YT·直播中"; const inner = ( <> {showTitle && live.title ? ( {live.title} ) : null} ); if (live.live_url) { return ( {inner} ); } return {inner}; }