"use client"; import { useEffect, useRef } from "react"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { BarChart3, ShieldCheck, LogIn, LogOut, ScrollText, Settings, Sparkles, WalletCards } from "lucide-react"; import clsx from "clsx"; import { revealChildren, runScopedMotion } from "@/lib/ui/motion"; import { AccountUsageMenu } from "@/components/account-usage-menu"; import { useBrowserAuth } from "@/components/browser-auth"; const nav = [ { href: "/create", label: "创作", icon: Sparkles }, { href: "/logs", label: "日志", icon: ScrollText, requiredRole: "super" as const }, { href: "/settings", label: "设置", icon: Settings, requiredRole: "super" as const }, { href: "/accounts", label: "账号", icon: ShieldCheck }, { href: "/usage", label: "用量", icon: BarChart3, requiredRole: "admin" as const }, { href: "/billing", label: "计费", icon: WalletCards } ]; export function AppShell({ children }: { children: React.ReactNode }) { const { user, authRequired, isAdmin, isSuperAdmin } = useBrowserAuth(); const pathname = usePathname(); const shellRef = useRef(null); const isAuthPage = pathname.startsWith("/auth"); const isCreatePage = pathname === "/create"; useEffect(() => { return runScopedMotion(shellRef, (scope) => revealChildren(scope, "[data-shell-animate]")); }, []); return (
{!isAuthPage ? 跳到主要内容 : null} {!isAuthPage ? (
智念AIGC平台
{user ? ( <>
) : authRequired ? (
) : null}
{children}
); }