import React, { useState, useEffect } from "react"; import { useNavigate, useLocation } from "react-router-dom"; import { Logo } from "@/components/icons"; import { siteConfig } from "@/config/site"; import { getAdminFlag } from "@/utils/session"; import { useScrollTopOnPathChange } from "@/hooks/useScrollTopOnPathChange"; interface TabItem { path: string; label: string; icon: React.ReactNode; adminOnly?: boolean; } export default function H5Layout({ children }: { children: React.ReactNode }) { const navigate = useNavigate(); const location = useLocation(); const [isAdmin, setIsAdmin] = useState(false); useScrollTopOnPathChange(); // Tabbar配置 const tabItems: TabItem[] = [ { path: "/dashboard", label: "首页", icon: ( ), }, { path: "/forward", label: "转发", icon: ( ), }, { path: "/tunnel", label: "隧道", icon: ( ), adminOnly: true, }, { path: "/node", label: "节点", icon: ( ), adminOnly: true, }, { path: "/profile", label: "我的", icon: ( ), }, ]; useEffect(() => { setIsAdmin(getAdminFlag()); }, []); // Tab点击处理 const handleTabClick = (path: string) => { navigate(path); }; // 过滤tab项(根据权限) const filteredTabItems = tabItems.filter( (item) => !item.adminOnly || isAdmin, ); return (
{/* 顶部导航栏 */}

{siteConfig.name}

{/* 主内容区域 */}
{children}
{/* 用于给固定 Tabbar 腾出空间的占位元素 */}
{/* 底部Tabbar */}
); }