From bef981d9036ccff1e57ba2aeebaf7772c9978a92 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 27 Feb 2026 12:12:24 +0000 Subject: [PATCH] fix: mobile header - merge auth into sidebar topbar, remove duplicate header --- frontend/components/AuthHeader.tsx | 67 +++++++++++------------------- frontend/components/Sidebar.tsx | 50 +++++++++++++++------- 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/frontend/components/AuthHeader.tsx b/frontend/components/AuthHeader.tsx index da80d39..efc44e9 100644 --- a/frontend/components/AuthHeader.tsx +++ b/frontend/components/AuthHeader.tsx @@ -6,49 +6,32 @@ import { useAuth } from "@/lib/auth"; export default function AuthHeader() { const { user, isLoggedIn, logout } = useAuth(); + // 手机端顶栏由 Sidebar 组件处理,这里只渲染桌面端顶栏 return ( - <> - {/* 桌面端顶栏 */} -
- {isLoggedIn ? ( - <> - {user?.email} - {user?.role === "admin" && ( - Admin - )} - - - ) : ( - <> - - 登录 - - - 注册 - - - )} -
- - {/* 手机端顶栏 */} -
- ⚡ ArbEngine -
- {isLoggedIn ? ( - - ) : ( - <> - 登录 - 注册 - +
+ {isLoggedIn ? ( + <> + {user?.email} + {user?.role === "admin" && ( + Admin )} -
-
- + + + ) : ( + <> + + 登录 + + + 注册 + + + )} + ); } diff --git a/frontend/components/Sidebar.tsx b/frontend/components/Sidebar.tsx index c3d7e45..ec0b243 100644 --- a/frontend/components/Sidebar.tsx +++ b/frontend/components/Sidebar.tsx @@ -3,10 +3,11 @@ import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; +import { useAuth } from "@/lib/auth"; import { LayoutDashboard, Info, Menu, X, Zap, LogIn, UserPlus, - ChevronLeft, ChevronRight, Activity + ChevronLeft, ChevronRight, Activity, LogOut } from "lucide-react"; const navItems = [ @@ -19,6 +20,7 @@ export default function Sidebar() { const pathname = usePathname(); const [collapsed, setCollapsed] = useState(false); const [mobileOpen, setMobileOpen] = useState(false); + const { user, isLoggedIn, logout } = useAuth(); const SidebarContent = ({ mobile = false }: { mobile?: boolean }) => (
@@ -45,17 +47,31 @@ export default function Sidebar() { ); })} - {/* 手机端:登录注册放在菜单里 */} + {/* 手机端:登录/登出放在菜单里 */} {mobile && (
- 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"> - 登录 - - 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"> - 注册 - + {isLoggedIn ? ( + <> + {user?.email && ( +
{user.email}
+ )} + + + ) : ( + <> + 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"> + 登录 + + 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"> + 注册 + + + )}
)} @@ -84,10 +100,16 @@ export default function Sidebar() { Arbitrage Engine
- 登录 - 注册 - + ) : ( + <> + 登录 + 注册 + + )} +