Skip to content

Commit

Permalink
feat: add getChildren api in usePage
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Jan 22, 2025
1 parent 641db30 commit 2700e9a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/plugins/page/src/composable/usePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ const getAncestors = async (id, withFolders) => {
return ancestors.filter(predicate).map((item) => item.id)
}

const getChildren = async (id) => {
if (pageSettingState.pages.length === 0) {
await getPageList()
}

const pageNode = pageSettingState.treeDataMapping[id]

if (!Array.isArray(pageNode?.children)) {
return pageNode.children
}

return pageNode.children
}

const clearCurrentState = () => {
const { pageState } = useCanvas()

Expand Down Expand Up @@ -366,6 +380,7 @@ export default () => {
isChangePageData,
getPageList,
getAncestors,
getChildren,
switchPage,
switchPageWithConfirm,
getFamily,
Expand Down

0 comments on commit 2700e9a

Please sign in to comment.