'use client'; import { Film, Heart, Home, MonitorPlay, Radio, Search, Sparkles, Tv, User, } from 'lucide-react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { ReactNode, useEffect } from 'react'; import TVVirtualRemote from './TVVirtualRemote'; const navItems = [ { label: '搜索', href: '/tv/search', icon: Search }, { label: '主页', href: '/tv', icon: Home }, { label: '电影', href: '/tv/movie', icon: Film }, { label: '剧集', href: '/tv/series', icon: Tv }, { label: '动漫', href: '/tv/anime', icon: Sparkles }, { label: '综艺', href: '/tv/variety', icon: MonitorPlay }, { label: '直播', href: '/tv/live', icon: Radio }, { label: '私人影库', href: '/tv/private', icon: Heart }, { label: '我的', href: '/tv/me', icon: User }, ]; export default function TVLayout({ children, showNav = true, }: { children: ReactNode; showNav?: boolean; }) { const pathname = usePathname(); useEffect(() => { if (!showNav || pathname !== '/tv') return; window.requestAnimationFrame(() => { const active = document.activeElement; if (active instanceof HTMLElement && active !== document.body) return; document .querySelector('[data-tv-home-nav="true"]') ?.focus({ preventScroll: true }); }); }, [pathname, showNav]); return (
{showNav && (
)}
{children}
); }