feat: login/register to top-right, remove kline/signals from sidebar nav
This commit is contained in:
parent
24d9044d9d
commit
1f844b946e
@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import Sidebar from "@/components/Sidebar";
|
||||
import Link from "next/link";
|
||||
|
||||
const geistSans = Geist({ variable: "--font-geist-sans", subsets: ["latin"] });
|
||||
const geistMono = Geist_Mono({ variable: "--font-geist-mono", subsets: ["latin"] });
|
||||
@ -17,10 +18,23 @@ export default function RootLayout({ children }: Readonly<{ children: React.Reac
|
||||
<body className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen bg-slate-50 text-slate-900`}>
|
||||
<div className="flex min-h-screen">
|
||||
<Sidebar />
|
||||
<main className="flex-1 md:p-6 p-4 pt-16 md:pt-6 min-w-0">
|
||||
<div className="flex-1 flex flex-col min-w-0">
|
||||
{/* 桌面端顶栏:右上角登录注册 */}
|
||||
<header className="hidden md:flex items-center justify-end px-6 py-3 bg-white border-b border-slate-200 gap-3">
|
||||
<Link href="/login"
|
||||
className="text-sm text-slate-600 hover:text-blue-600 px-3 py-1.5 rounded-lg border border-slate-200 hover:border-blue-300 transition-colors">
|
||||
登录
|
||||
</Link>
|
||||
<Link href="/register"
|
||||
className="text-sm text-white bg-blue-600 hover:bg-blue-700 px-3 py-1.5 rounded-lg transition-colors font-medium">
|
||||
注册
|
||||
</Link>
|
||||
</header>
|
||||
<main className="flex-1 p-4 md:p-6 pt-16 md:pt-6">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@ -4,22 +4,16 @@ import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import {
|
||||
LayoutDashboard, TrendingUp, Bell, Info, LogIn, UserPlus,
|
||||
ChevronLeft, ChevronRight, Menu, X, Zap
|
||||
LayoutDashboard, Info,
|
||||
Menu, X, Zap, LogIn, UserPlus,
|
||||
ChevronLeft, ChevronRight
|
||||
} from "lucide-react";
|
||||
|
||||
const navItems = [
|
||||
{ href: "/", label: "仪表盘", icon: LayoutDashboard },
|
||||
{ href: "/kline", label: "K线大图", icon: TrendingUp },
|
||||
{ href: "/signals", label: "信号历史", icon: Bell },
|
||||
{ href: "/about", label: "说明", icon: Info },
|
||||
];
|
||||
|
||||
const authItems = [
|
||||
{ href: "/login", label: "登录", icon: LogIn },
|
||||
{ href: "/register", label: "注册", icon: UserPlus },
|
||||
];
|
||||
|
||||
export default function Sidebar() {
|
||||
const pathname = usePathname();
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
@ -28,7 +22,7 @@ export default function Sidebar() {
|
||||
const SidebarContent = ({ mobile = false }: { mobile?: boolean }) => (
|
||||
<div className={`flex flex-col h-full ${mobile ? "w-64" : collapsed ? "w-16" : "w-60"} transition-all duration-200`}>
|
||||
{/* Logo */}
|
||||
<div className={`flex items-center gap-2 px-4 py-5 border-b border-slate-100 ${collapsed && !mobile ? "justify-center px-0" : ""}`}>
|
||||
<div className={`flex items-center gap-2 px-4 py-5 border-b border-slate-100 ${collapsed && !mobile ? "justify-center" : ""}`}>
|
||||
<Zap className="w-6 h-6 text-blue-600 shrink-0" />
|
||||
{(!collapsed || mobile) && (
|
||||
<span className="font-bold text-slate-800 text-base leading-tight">Arbitrage<br/>Engine</span>
|
||||
@ -44,26 +38,26 @@ export default function Sidebar() {
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className={`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors
|
||||
${active ? "bg-blue-50 text-blue-700 font-medium" : "text-slate-600 hover:bg-slate-100 hover:text-slate-900"}
|
||||
${collapsed && !mobile ? "justify-center px-0" : ""}`}>
|
||||
${collapsed && !mobile ? "justify-center" : ""}`}>
|
||||
<Icon className={`shrink-0 ${active ? "text-blue-600" : "text-slate-400"}`} size={18} />
|
||||
{(!collapsed || mobile) && <span>{label}</span>}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* Auth */}
|
||||
<div className="border-t border-slate-100 py-3 px-2 space-y-1">
|
||||
{authItems.map(({ href, label, icon: Icon }) => (
|
||||
<Link key={href} href={href}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className={`flex items-center gap-3 px-3 py-2 rounded-lg text-sm text-slate-500 hover:bg-slate-100 hover:text-slate-800 transition-colors
|
||||
${collapsed && !mobile ? "justify-center px-0" : ""}`}>
|
||||
<Icon className="shrink-0 text-slate-400" size={16} />
|
||||
{(!collapsed || mobile) && <span>{label}</span>}
|
||||
{/* 手机端:登录注册放在菜单里 */}
|
||||
{mobile && (
|
||||
<div className="pt-4 border-t border-slate-100 mt-4 space-y-1">
|
||||
<Link href="/login" onClick={() => setMobileOpen(false)}
|
||||
className="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-slate-600 hover:bg-slate-100 transition-colors">
|
||||
<LogIn className="shrink-0 text-slate-400" size={18} /><span>登录</span>
|
||||
</Link>
|
||||
<Link href="/register" onClick={() => setMobileOpen(false)}
|
||||
className="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm text-white bg-blue-600 hover:bg-blue-700 transition-colors">
|
||||
<UserPlus className="shrink-0" size={18} /><span>注册</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</nav>
|
||||
|
||||
{/* Collapse toggle (desktop only) */}
|
||||
{!mobile && (
|
||||
@ -88,10 +82,14 @@ export default function Sidebar() {
|
||||
<Zap className="w-5 h-5 text-blue-600" />
|
||||
<span className="font-bold text-slate-800 text-sm">Arbitrage Engine</span>
|
||||
</div>
|
||||
<button onClick={() => setMobileOpen(!mobileOpen)} className="text-slate-600 p-1">
|
||||
{mobileOpen ? <X size={22} /> : <Menu size={22} />}
|
||||
<div className="flex items-center gap-2">
|
||||
<Link href="/login" className="text-xs text-slate-600 hover:text-blue-600 px-2 py-1 rounded border border-slate-200">登录</Link>
|
||||
<Link href="/register" className="text-xs text-white bg-blue-600 hover:bg-blue-700 px-2 py-1 rounded">注册</Link>
|
||||
<button onClick={() => setMobileOpen(!mobileOpen)} className="text-slate-600 p-1 ml-1">
|
||||
{mobileOpen ? <X size={20} /> : <Menu size={20} />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mobile drawer */}
|
||||
{mobileOpen && (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user