Skip to content

Commit

Permalink
fix:sort pro_layout_parentKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Apr 24, 2022
1 parent 6743cc4 commit 3feb2fb
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 108 deletions.
19 changes: 12 additions & 7 deletions src/transformRoute/transformRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,25 @@ function formatter(
...restParent
} = parent;

const item_pro_layout_parentKeys = new Set([
...pro_layout_parentKeys,
...(item.parentKeys || []),
]);

if (parent.key) {
item_pro_layout_parentKeys.add(parent.key);
}

const finallyItem: MenuDataItem = {
...restParent,
menu: undefined,
...item,
path,
locale,
key: item.key || getKeyByPath({ ...item, path }),
pro_layout_parentKeys: Array.from(
new Set([
...(item.parentKeys || []),
...pro_layout_parentKeys,
`/${parent.key || ''}`.replace(/\/\//g, '/').replace(/\/\//g, '/'),
]),
).filter((key) => key && key !== '/'),
pro_layout_parentKeys: Array.from(item_pro_layout_parentKeys).filter(
(key) => key && key !== '/',
),
};

if (localeName) {
Expand Down
Loading

0 comments on commit 3feb2fb

Please sign in to comment.