"use client";
/** 应用外壳:桌面左侧导航栏 + 窄屏顶栏与抽屉(usePathname 高亮当前页)。 */
import { useEffect, useState } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { Icon, type IconName } from "@/components/icons";
interface NavItem {
href: string;
label: string;
icon: IconName;
}
/**
* 导航分组:按「研究闭环」的真实使用顺序排列 ——
* 找标的(股票池)→ 出候选(筛选)→ 定规则(策略库)→ 验规则(回测)→ 复盘(实验)。
* 「交易信号」「因子研究」是可选支路,放在同组但靠后;单独建组会让闭环读起来断裂。
*/
const GROUPS: { title: string; items: NavItem[] }[] = [
{
title: "研究",
items: [
{ href: "/", label: "总览", icon: "grid" },
{ href: "/stocks", label: "股票池", icon: "candles" },
{ href: "/selection", label: "股票筛选", icon: "target" },
],
},
{
title: "策略",
items: [
{ href: "/strategies", label: "选股策略库", icon: "book" },
{ href: "/fields", label: "字段库", icon: "filter" },
{ href: "/backtest", label: "回测组合", icon: "gauge" },
{ href: "/experiments", label: "实验对比", icon: "archive" },
{ href: "/settings", label: "公共配置", icon: "database" },
],
},
{
title: "因子与信号",
items: [
{ href: "/factors", label: "因子研究", icon: "flask" },
{ href: "/factors/compose", label: "因子组合", icon: "layers" },
{ href: "/signals", label: "交易信号", icon: "scale" },
],
},
];
function isActive(href: string, pathname: string): boolean {
if (href === "/") return pathname === "/";
if (href === "/factors") return pathname === "/factors";
if (pathname === href || pathname.startsWith(href + "/")) return true;
return false;
}
function Brand() {
return (