"use client";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { LogoButton } from "@/components/easter-egg/LogoButton";
import {
AdminIcon,
ArchiveIcon,
MemoryIcon,
ChatIcon,
CharacterIcon,
ModelIcon,
SettingsIcon,
ToolsIcon,
WorldIcon,
} from "@/components/ui/Icons";
import { Badge } from "@/components/ui/Badge";
import { FEATURE_FLAGS } from "@/lib/config";
import { useAuthStore } from "@/lib/stores/auth-store";
import {
NEXT_THEME_LABEL,
useSettingsStore,
} from "@/lib/stores/settings-store";
import { cn } from "@/lib/utils/cn";
import type { ReactNode } from "react";
interface NavItem {
href: string;
label: string;
icon: ReactNode;
enabled?: boolean;
}
interface NavGroup {
title: string;
items: NavItem[];
}
/**
* 主导航分组:灵台(镜树)、法身(灵胚/人物)、内景(世界)、
* 藏识(记忆/归档)、百工(工具/神识阁/设置)。
* 旧人格/内驱力/五行/灵枢/轨迹页随 M6 退役(人格=道体锚点+缘契,轨迹并入镜树)。
*/
const NAV_GROUPS: NavGroup[] = [
{
title: "灵台",
items: [{ href: "/trees", label: "镜树", icon: }],
},
{
title: "法身",
items: [
{ href: "/embryos", label: "灵胚", icon: },
{ href: "/characters", label: "人物", icon: },
],
},
{
title: "内景",
items: [
{
href: "/world",
label: "世界",
icon: ,
enabled: FEATURE_FLAGS.worldPanel,
},
],
},
{
title: "藏识",
items: [
{ href: "/memories", label: "记忆", icon: },
{ href: "/archive", label: "归档", icon: },
],
},
{
title: "百工",
items: [
{ href: "/tools", label: "工具", icon: },
{ href: "/models", label: "神识阁", icon: },
{ href: "/settings", label: "设置", icon: },
],
},
];
export function Sidebar({
expanded = true,
onToggleFold,
onNavigate,
}: {
expanded?: boolean;
onToggleFold?: () => void;
onNavigate?: () => void;
}) {
const pathname = usePathname();
const router = useRouter();
const theme = useSettingsStore((s) => s.theme);
const toggleTheme = useSettingsStore((s) => s.toggleTheme);
const user = useAuthStore((s) => s.user);
const logout = useAuthStore((s) => s.logout);
const handleLogout = () => {
logout();
router.push("/login");
};
return (
{/* 品牌 + 折叠钮:窄态居中、宽态两端对齐(设计稿 sidebar-topbar 同源) */}
{onToggleFold && (
)}
{/* 分组导航 */}
{/* 底部:用户卡片常驻 + 管理入口 */}
{user && (
{user.username.charAt(0).toUpperCase()}
{expanded && (
{user.username}
{user.is_admin ? "管理员" : user.email}
)}
)}
{user?.is_admin && FEATURE_FLAGS.adminPanel && (
{expanded && "司命台"}
{expanded && (
管理
)}
)}
);
}
/** 侧栏折叠钮图标:面板 + 左竖线(设计稿 sidebar-foldbtn 同源) */
function FoldIcon() {
return (
);
}