import { Clover, Film, Home, Search, 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 MobileBottomNav from './MobileBottomNav'; import MobileHeader from './MobileHeader'; import { useSite } from './SiteProvider'; import { ThemeToggle } from './ThemeToggle'; 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: Clover, label: '综艺', href: '/douban?type=show', }, ]; return ( ); }; const PageLayout = ({ children, activePath = '/' }: PageLayoutProps) => { return (
{/* 移动端头部 */} {/* 桌面端顶部导航栏 */}
{/* 主要布局容器 */}
{/* 主内容区域 */}
{/* 桌面端左上角返回按钮 */} {['/play'].includes(activePath) && (
)} {/* 主内容容器 - 为播放页面使用特殊布局(83.33%宽度),其他页面使用默认布局(66.67%宽度) */}
{/* 使用flex布局实现宽度控制 */}
{/* 左侧留白区域 - 播放页面占8.33%,其他页面占16.67% */}
{/* 主内容区 - 播放页面占83.33%,其他页面占66.67% */}
{children}
{/* 右侧留白区域 - 播放页面占8.33%,其他页面占16.67% */}
{/* 移动端底部导航 */}
); }; export default PageLayout;