Skip to content

Commit

Permalink
feat: add pageid to url when app init
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejay97 committed Nov 5, 2024
1 parent 8b16275 commit faec041
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/controller/src/useResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,21 @@ const initPageOrBlock = async () => {
return
}

const updateUrlPageId = (id) => {
const url = new URL(window.location)

url.searchParams.delete('blockid')
url.searchParams.set('pageid', id)
window.history.replaceState({}, '', url)
}
// url 没有 pageid 或 blockid,到页面首页或第一页
const pageInfo = resState.pageTree.find((page) => page?.meta?.isHome) ||
resState.pageTree.find(
(page) => page.componentName === COMPONENT_NAME.Page && page?.meta?.group !== 'publicPages'
) || {
componentName: COMPONENT_NAME.Page
}
updateUrlPageId(pageInfo.meta.id)
initPage(pageInfo)
}

Expand Down

0 comments on commit faec041

Please sign in to comment.