mirror of
https://github.com/rustfs/console.git
synced 2026-09-01 15:17:45 +08:00
fix: breadcrumb navigation broken after page refresh in bucket browser (#97)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as React from "react"
|
||||
import Link from "next/link"
|
||||
import { usePathname, useSearchParams } from "next/navigation"
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import {
|
||||
Breadcrumb,
|
||||
@@ -26,6 +26,7 @@ function getLabelByPath(pathSegment: string, t: (k: string) => string): string {
|
||||
export function TopNavBreadcrumb() {
|
||||
const pathname = usePathname()
|
||||
const searchParams = useSearchParams()
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const segments = pathname?.split("/").filter(Boolean) ?? []
|
||||
@@ -98,7 +99,15 @@ export function TopNavBreadcrumb() {
|
||||
<BreadcrumbItem>
|
||||
{item.href ? (
|
||||
<BreadcrumbLink asChild>
|
||||
<Link href={item.href}>{item.label}</Link>
|
||||
<Link
|
||||
href={item.href}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
if (item.href) router.push(item.href)
|
||||
}}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
</BreadcrumbLink>
|
||||
) : (
|
||||
<BreadcrumbPage>{item.label}</BreadcrumbPage>
|
||||
|
||||
Reference in New Issue
Block a user