arbitrage-engine/frontend/components/Navbar.tsx

67 lines
2.6 KiB
TypeScript

"use client";
import Link from "next/link";
import { useState } from "react";
const navLinks = [
{ href: "/", label: "仪表盘" },
{ href: "/live", label: "实时变动" },
{ href: "/history", label: "历史" },
{ href: "/signals", label: "信号" },
{ href: "/about", label: "说明" },
];
export default function Navbar() {
const [open, setOpen] = useState(false);
return (
<nav className="border-b border-slate-200 bg-white sticky top-0 z-50 shadow-sm">
<div className="max-w-6xl mx-auto px-4 h-14 flex items-center">
<Link href="/" className="font-bold text-blue-600 tracking-tight text-lg shrink-0">
Arbitrage Engine
</Link>
{/* Desktop nav */}
<div className="hidden md:flex items-center gap-6 text-sm ml-8">
{navLinks.map(l => (
<Link key={l.href} href={l.href} className="text-slate-600 hover:text-blue-600 transition-colors">
{l.label}
</Link>
))}
</div>
<div className="hidden md:flex items-center gap-3 text-sm ml-auto">
<Link href="/login" className="text-slate-500 hover:text-slate-800 transition-colors"></Link>
<Link href="/register" className="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1.5 rounded-lg transition-colors"></Link>
</div>
{/* Mobile */}
<div className="md:hidden ml-auto flex items-center gap-2">
<Link href="/login" className="text-slate-500 text-sm"></Link>
<Link href="/register" className="bg-blue-600 text-white px-2 py-1 rounded text-sm"></Link>
<button onClick={() => setOpen(!open)} className="ml-1 p-2 text-slate-500" aria-label="菜单">
{open ? (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
) : (
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
</svg>
)}
</button>
</div>
</div>
{open && (
<div className="md:hidden border-t border-slate-100 bg-white px-4 py-3 space-y-1">
{navLinks.map(l => (
<Link key={l.href} href={l.href} onClick={() => setOpen(false)}
className="block py-2 text-slate-600 hover:text-blue-600 transition-colors text-sm">
{l.label}
</Link>
))}
</div>
)}
</nav>
);
}