fix: header personal page link and login flow
This commit is contained in:
+15
-11
@@ -51,7 +51,7 @@ export function Header() {
|
|||||||
const [mobileOpen, setMobileOpen] = useState(false)
|
const [mobileOpen, setMobileOpen] = useState(false)
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { isAuthenticated, currentRole, switchRole, login, logout } = useAuthStore()
|
const { isAuthenticated, currentRole, switchRole, logout } = useAuthStore()
|
||||||
|
|
||||||
const unreadCount = mockNotifications.filter((n) => !n.read).length
|
const unreadCount = mockNotifications.filter((n) => !n.read).length
|
||||||
|
|
||||||
@@ -142,12 +142,14 @@ export function Header() {
|
|||||||
<DropdownMenuLabel>{currentUser.nickname}</DropdownMenuLabel>
|
<DropdownMenuLabel>{currentUser.nickname}</DropdownMenuLabel>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem asChild>
|
{currentRole === "player" && (
|
||||||
<Link href={`/player/${currentUser.id}`}>
|
<DropdownMenuItem asChild>
|
||||||
<User className="mr-2 h-4 w-4" />
|
<Link href={`/player/${currentUser.id}`}>
|
||||||
个人主页
|
<User className="mr-2 h-4 w-4" />
|
||||||
</Link>
|
个人主页
|
||||||
</DropdownMenuItem>
|
</Link>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
<DropdownMenuItem asChild>
|
<DropdownMenuItem asChild>
|
||||||
<Link href="/orders">
|
<Link href="/orders">
|
||||||
<ShoppingBag className="mr-2 h-4 w-4" />
|
<ShoppingBag className="mr-2 h-4 w-4" />
|
||||||
@@ -191,8 +193,8 @@ export function Header() {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="hidden md:flex items-center gap-2">
|
<div className="hidden md:flex items-center gap-2">
|
||||||
<Button variant="ghost" size="sm" onClick={login}>
|
<Button variant="ghost" size="sm" asChild>
|
||||||
登录
|
<Link href="/login">登录</Link>
|
||||||
</Button>
|
</Button>
|
||||||
<Button size="sm" asChild>
|
<Button size="sm" asChild>
|
||||||
<Link href="/register">注册</Link>
|
<Link href="/register">注册</Link>
|
||||||
@@ -301,8 +303,10 @@ export function Header() {
|
|||||||
|
|
||||||
{!isAuthenticated && (
|
{!isAuthenticated && (
|
||||||
<div className="border-t pt-4 flex gap-2 px-3">
|
<div className="border-t pt-4 flex gap-2 px-3">
|
||||||
<Button variant="outline" className="flex-1" onClick={login}>
|
<Button variant="outline" className="flex-1" asChild>
|
||||||
登录
|
<Link href="/login" onClick={() => setMobileOpen(false)}>
|
||||||
|
登录
|
||||||
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
<Button className="flex-1" asChild>
|
<Button className="flex-1" asChild>
|
||||||
<Link href="/register" onClick={() => setMobileOpen(false)}>
|
<Link href="/register" onClick={() => setMobileOpen(false)}>
|
||||||
|
|||||||
Reference in New Issue
Block a user