bugfix: 面包屑导航

This commit is contained in:
2026-04-29 15:41:20 +08:00
parent d6a07e7fc7
commit 64844105b5
4 changed files with 77 additions and 24 deletions

View File

@@ -403,11 +403,25 @@
if (status === "draft") {
// save draft logic
// console.log("Saving draft...", currentListing.value)
ROUTER.push({ name: "Status", params: { status: "draft" } })
ROUTER.push({
name: "Status",
params: { status: "draft" },
state: {
type: history.state?.type,
collectionId: history.state?.collectionId
}
})
} else if (status === "publish") {
// publish logic
// console.log("Publishing...", currentListing.value)
ROUTER.push({ name: "Status", params: { status: "publish" } })
ROUTER.push({
name: "Status",
params: { status: "publish" },
state: {
type: history.state?.type,
collectionId: history.state?.collectionId
}
})
}
}

View File

@@ -50,7 +50,8 @@ const next = ()=>{
path:'/home/seller/myListings/edit',
state: {
designItemIds,
type:'create'
type:'create',
collectionId: route.params.collectionId
}
})
}

View File

@@ -41,7 +41,7 @@
| {
title?: RouteMetaValue<string>
titleKey?: RouteMetaValue<string>
to?: RouteMetaValue<RouteLocationRaw>
to?: RouteMetaValue<RouteLocationRaw | undefined>
name?: string
path?: string
}
@@ -49,6 +49,7 @@
title: string
to?: RouteLocationRaw
}
type SellerBreadcrumbsSource = RouteMetaValue<SellerBreadcrumbSource[]>
const props = withDefaults(
defineProps<{
@@ -113,7 +114,9 @@
const autoBreadcrumbs = computed(() => {
const currentRecord = route.matched[route.matched.length - 1]
const customBreadcrumbs = currentRecord?.meta?.sellerBreadcrumbs
const customBreadcrumbs = resolveMetaValue(
currentRecord?.meta?.sellerBreadcrumbs as SellerBreadcrumbsSource | undefined
)
if (Array.isArray(customBreadcrumbs)) {
return customBreadcrumbs
@@ -165,13 +168,33 @@
const onBreadcrumbClick = (breadcrumb: SellerBreadcrumbItem, index: number) => {
if (index >= breadcrumbList.value.length - 1) return
if (breadcrumb.to) {
router.push(breadcrumb.to)
const historyIndex = -(breadcrumbList.value.length - index - 1)
if (canUseBreadcrumbHistory(Math.abs(historyIndex))) {
router.go(historyIndex)
return
}
const historyIndex = -(breadcrumbList.value.length - index - 1)
if (historyIndex < 0) router.go(historyIndex)
if (breadcrumb.to) {
router.replace(breadcrumb.to)
}
}
const canUseBreadcrumbHistory = (steps: number) => {
if (steps <= 0 || typeof history === "undefined") return false
const state = history.state as {
back?: unknown
position?: unknown
} | null
const backPath = state?.back
return (
typeof state?.position === "number" &&
state.position >= steps &&
typeof backPath === "string" &&
backPath.startsWith("/home/seller/myListings")
)
}
</script>
<style scoped lang="less">