import { Clover, Film, Filter, Home, Play, Radio, Search, Sparkles, Tv } from 'lucide-react'; import Link from 'next/link'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; import { useCallback, useEffect, useState } from 'react'; import { BackButton } from './BackButton'; import HubNotice from '@/components/HubNotice'; import MobileBottomNav from './MobileBottomNav'; import MobileHeader from './MobileHeader'; import { useSite } from './SiteProvider'; import { ThemeToggle } from './ThemeToggle'; import TopRightButtons from './TopRightButtons'; import { UserMenu } from './UserMenu'; interface PageLayoutProps { children: React.ReactNode; activePath?: string; } // 内联顶部导航栏组件 const TopNavbar = ({ activePath = '/' }: { activePath?: string }) => { const router = useRouter(); const pathname = usePathname(); const searchParams = useSearchParams(); const { siteName } = useSite(); const [active, setActive] = useState(activePath); useEffect(() => { // 优先使用传入的 activePath if (activePath) { setActive(activePath); } else { // 否则使用当前路径 const getCurrentFullPath = () => { const queryString = searchParams.toString(); return queryString ? `${pathname}?${queryString}` : pathname; }; const fullPath = getCurrentFullPath(); setActive(fullPath); } }, [activePath, pathname, searchParams]); const handleSearchClick = useCallback(() => { router.push('/search'); }, [router]); const menuItems = [ { icon: Home, label: '首页', href: '/', }, { icon: Search, label: '搜索', href: '/search', }, { icon: Film, label: '电影', href: '/douban?type=movie', }, { icon: Tv, label: '剧集', href: '/douban?type=tv', }, { icon: Sparkles, label: '动漫', href: '/anime', }, { icon: Clover, label: '综艺', href: '/douban?type=show', }, { icon: Play, label: 'AI短剧', href: '/search?q=AI%E7%9F%AD%E5%89%A7', }, { icon: Filter, label: '筛选', href: '/filter', }, { icon: Radio, label: '直播', href: '/live', }, ]; // 桌面端:顶部固定导航(fixed) // 移动端:不显示此组件,改由底部导航 + 轻量顶部条(非固定) return ( ); }; const PageLayout = ({ children, activePath = '/' }: PageLayoutProps) => { return (
{/* 移动端头部 (fixed) */} {/* 桌面端顶部导航栏 (fixed) */} {/* 主内容区域 - 预留桌面端顶部导航高度 64px */}
{/* 桌面端左上角返回按钮 */} {['/play'].includes(activePath) && (
)} {/* 主内容容器 - 为播放页面使用特殊布局(83.33%宽度),其他页面使用默认布局(66.67%宽度) */}
{/* 使用flex布局实现宽度控制 */}
{/* 左侧留白区域 - 播放页面占8.33%,其他页面占16.67% */}
{/* 主内容区 - 播放页面占83.33%,其他页面占66.67% */}
{children}
{/* 右侧留白区域 - 播放页面占8.33%,其他页面占16.67% */}
{/* 移动端底部导航 */}
{/* 授权中心公告/更新弹窗 */}
); }; export default PageLayout;