Skip to content

Commit

Permalink
fix: fix the error of routing bar caused by invalid pageid (opentiny#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 authored Jan 16, 2025
1 parent d2fc9b1 commit bacd299
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/canvas/route-bar/src/CanvasRouteBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,20 @@ watch(
}
const ancestors = (await getAncestors(value, true)) || []
routes.value = ancestors.concat(value).map((id) => {
const { route, isPage } = pageSettingState.treeDataMapping[id]
return {
id,
route: route
.replace(/\/+/g, '/') // 替换连续的 '/' 为单个 '/'
.replace(/^\/|\/$/g, ''), // 去掉开头和结尾的 '/'
isPage
}
})
routes.value = ancestors
.concat(value)
.map((id) => pageSettingState.treeDataMapping[id])
.filter((item) => Boolean(item))
.map((pageData) => {
const { id, route, isPage } = pageData
return {
id,
route: route
.replace(/\/+/g, '/') // 替换连续的 '/' 为单个 '/'
.replace(/^\/|\/$/g, ''), // 去掉开头和结尾的 '/'
isPage
}
})
},
{ immediate: true }
)
Expand Down

0 comments on commit bacd299

Please sign in to comment.