feat: 添加配置模块和更新管理员导航,优化钱包控制台加载逻辑
This commit is contained in:
50
src/modules/config/config-subnav.tsx
Normal file
50
src/modules/config/config-subnav.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const LINKS: { href: string; label: string; match?: "exact" | "prefix" }[] = [
|
||||
{ href: "/admin/config", label: "概览", match: "exact" },
|
||||
{ href: "/admin/config/plays", label: "玩法配置" },
|
||||
{ href: "/admin/config/odds", label: "赔率配置" },
|
||||
{ href: "/admin/config/rebate", label: "佣金 / 回水" },
|
||||
{ href: "/admin/config/risk-cap", label: "风控封顶" },
|
||||
];
|
||||
|
||||
function linkActive(pathname: string, href: string, match: "exact" | "prefix"): boolean {
|
||||
if (match === "exact") {
|
||||
return pathname === href || pathname === `${href}/`;
|
||||
}
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export function ConfigSubNav() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<nav
|
||||
className="flex flex-wrap gap-2 border-b border-border pb-3 mb-6"
|
||||
aria-label="运营配置子导航"
|
||||
>
|
||||
{LINKS.map(({ href, label, match = "prefix" }) => {
|
||||
const active = linkActive(pathname, href, match);
|
||||
return (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
className={cn(
|
||||
"rounded-md px-3 py-1.5 text-sm transition-colors",
|
||||
active
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user