"use client"; import { useEffect, useState } from "react"; import { useRouter, usePathname } from "next/navigation"; import { useAuthStore } from "@/stores/auth"; import { Header } from "@/components/layout/header"; import Link from "next/link"; import { cn } from "@/lib/utils"; import { LayoutDashboard, Building2, UsersRound, Boxes, ScrollText, Cpu, Gauge, ShieldAlert, Menu, X, } from "lucide-react"; import type { LucideIcon } from "lucide-react"; const platformNavItems: { href: string; label: string; icon: LucideIcon }[] = [ { href: "/platform/overview", label: "平台总览", icon: LayoutDashboard }, { href: "/platform/orgs", label: "机构管理", icon: Building2 }, { href: "/platform/users", label: "全局用户", icon: UsersRound }, { href: "/platform/apps", label: "全局应用", icon: Boxes }, { href: "/platform/audit", label: "全局审计", icon: ScrollText }, { href: "/platform/providers", label: "模型提供商", icon: Cpu }, { href: "/platform/quotas", label: "配额管理", icon: Gauge }, ]; export default function PlatformLayout({ children }: { children: React.ReactNode }) { const user = useAuthStore((s) => s.user); const isAuthenticated = useAuthStore((s) => s.isAuthenticated); const isLoading = useAuthStore((s) => s.isLoading); const router = useRouter(); const pathname = usePathname(); const [sidebarOpen, setSidebarOpen] = useState(false); useEffect(() => { if (!isLoading && (!isAuthenticated || user?.role !== "super_admin")) { router.replace("/store"); } }, [isAuthenticated, isLoading, user, router]); if (isLoading) { return (
); } if (!isAuthenticated || user?.role !== "super_admin") return null; return (
{/* 平台管理区身份标识条 */}
{/* 手机端侧边栏切换按钮 */} {sidebarOpen && (
setSidebarOpen(false)} /> )}
{children}
); }