import { useEffect, useState } from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { BrandMark, LivePulse } from "@/components/ui"; import { GlobalEventAlerts } from "@/components/GlobalEventAlerts"; import { fetchJson } from "@/lib/api"; import { DouyinLiveContextProvider, useDouyinLiveCount, useDouyinLiveProviderValue } from "@/lib/douyinLive"; import { YouTubeLiveContextProvider, useYouTubeLiveCount, useYouTubeLiveMap, useYouTubeLiveProviderValue } from "@/lib/youtubeLive"; import { Link } from "react-router-dom"; const NAV = [ { href: "/", label: "概览", emoji: "📡" }, { href: "/slots", label: "时段", emoji: "🕐" }, { href: "/sessions", label: "场次", emoji: "🎬" }, { href: "/anchors", label: "主播", emoji: "👤" }, { href: "/covers", label: "截图", emoji: "🖼️" }, { href: "/events", label: "事件", emoji: "⚡" }, { href: "/rooms", label: "直播间", emoji: "🏠" }, { href: "/groups", label: "分组", emoji: "📺" }, { href: "/youtube", label: "YouTube", emoji: "▶️" }, { href: "/shorts", label: "Shorts", emoji: "📱" }, { href: "/blacklist", label: "黑名单", emoji: "🚫" }, { href: "/settings", label: "设置", emoji: "⚙️" }, ]; const MOBILE_PRIMARY = ["/", "/groups", "/shorts", "/youtube", "/settings"]; export function Shell({ children }: { children: React.ReactNode }) { const ytCtx = useYouTubeLiveProviderValue(); const dyCtx = useDouyinLiveProviderValue(); return ( {children} ); } function ShellFrame({ children }: { children: React.ReactNode }) { const pathname = useLocation().pathname; const navigate = useNavigate(); const ytLiveCount = useYouTubeLiveCount(); const dyLiveCount = useDouyinLiveCount(); const { map: ytLiveMap } = useYouTubeLiveMap(); const [username, setUsername] = useState(""); useEffect(() => { void fetchJson("/api/auth/status") .then((d) => setUsername(String(d.username || ""))) .catch(() => setUsername("")); }, [pathname]); async function logout() { try { await fetchJson("/api/auth/logout", { method: "POST" }); } catch { /* ignore */ } navigate("/login"); } return (

Live Radar

直播监控中心

抖音 + YouTube · 开播捕捉 · 停播结场 · 时长统计 · 截图存证 · Windows 客户端

{(dyLiveCount > 0 || ytLiveCount > 0) ? (
{dyLiveCount > 0 ? ( ) : null} {ytLiveCount > 0 ? ( ) : null} {ytLiveMap?.checked_at ? ( 轮询 {Math.max(0, Math.round(Date.now() / 1000 - Number(ytLiveMap.checked_at)))}s 前 ) : null}
) : (
抖音 / YouTube 直播轮询中 {ytLiveMap?.checked_at ? ( · {Math.max(0, Math.round(Date.now() / 1000 - Number(ytLiveMap.checked_at)))}s 前刷新 ) : null}
)}
{username ? ( {username} ) : null}
{/* 手机:顶部横向可滑导航 */}
{children}
Douyin + YouTube Monitor · realtime radar
{/* 手机底部快捷栏 */}
); }