"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useCallback } from "react"; import type { ReactNode } from "react"; import { AdminIcon, AgentIcon, AuditIcon, GoalIcon, MemoryIcon, PerceptionIcon, PlanIcon, TenantIcon, ToolsIcon, TraceIcon, UserIcon, WorldIcon, } from "@/components/ui/Icons"; import { cn } from "@/lib/utils/cn"; type AdminNavItem = { href: string; label: string; icon: ReactNode }; /** * 司命台治理导航(横向 — 设计稿 topbar-nav)。 */ const ADMIN_NAV: AdminNavItem[] = [ { href: "/admin", label: "概览", icon: }, { href: "/admin/audit", label: "起居注", icon: }, { href: "/admin/traces", label: "链路追踪", icon: }, { href: "/admin/users", label: "用户管理", icon: }, { href: "/admin/tenants", label: "多租户", icon: }, { href: "/admin/characters/templates", label: "人物模板", icon: , }, ]; /** 九枢治理导航(设计稿 pivot nav)。与 pivots/[pivot] 路由对齐 */ const PIVOT_NAV: AdminNavItem[] = [ { href: "/admin/goals", label: "太一", icon: }, { href: "/admin/safety", label: "司命", icon: }, { href: "/admin/perception", label: "烛照", icon: }, { href: "/admin/world", label: "河图", icon: }, { href: "/admin/plans", label: "洛书", icon: }, { href: "/admin/memory", label: "息壤", icon: }, { href: "/admin/tools", label: "百工", icon: }, { href: "/admin/agents", label: "天工阁", icon: }, ]; /** * 司命台外壳:独立冷色壳层(admin-shell → slate 色温分化)。 * 设计稿 admin-preview.html §4 AdminShell 完全对齐。 * * 壳层特性: * - 独立冷色 CSS 变量(.admin-shell 激活 `--slate` 色系) * - 顶部横向双层导航(治理 nav + 九枢 pivot nav) * - 主题切换 + 返回主域入口 * - iOS safe-area 适配 */ export function AdminShell({ children }: { children: ReactNode }) { const pathname = usePathname(); /** 设计稿 toggleTheme — 通过触发表单更改 / 自定义事件 */ const toggleTheme = useCallback(() => { const root = document.documentElement; const isDark = root.classList.contains("dark"); if (isDark) { root.classList.remove("dark"); } else { root.classList.add("dark"); } // 持久化到 settings try { const raw = localStorage.getItem("hunjing-settings"); if (raw) { const parsed = JSON.parse(raw); if (parsed.state) { parsed.state.theme = isDark ? "light" : "dark"; localStorage.setItem("hunjing-settings", JSON.stringify(parsed)); } } } catch { // silent } }, []); const navItemClass = (href: string, opts?: { pivot?: boolean }) => cn( "inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium transition-colors shrink-0", opts?.pivot ? "text-xs" : "text-sm", pathname === href || pathname.startsWith(`${href}/`) ? "bg-patina-wash text-patina" : "text-muted hover:bg-overlay-hover hover:text-fg", ); return (
{/* 品牌标志 — 设计稿 topbar-brand */} {/* 设计稿 SVG knob:描边铜镜无极标记 */} 司命台 {/* 分隔符 */} / {/* 司命治理导航 — 设计稿 topbar-nav */} {/* 九枢分隔 + 导航 — 设计稿中金色竖线 | 分隔 */} | {/* 弹性间隔 */} {/* 返回主域 — 设计稿 topbar-back */} 主域 {/* 主题切换 — 设计稿 topbar-back 风格 */}
{children}
); }