We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aa29073 commit dbc0b7eCopy full SHA for dbc0b7e
packages/effects/access/src/accessible.ts
@@ -30,6 +30,9 @@ async function generateAccessible(
30
31
const root = router.getRoutes().find((item) => item.path === '/');
32
33
+ // 获取已有的路由名称列表
34
+ const names = root?.children?.map((item) => item.name) ?? [];
35
+
36
// 动态添加到router实例内
37
accessibleRoutes.forEach((route) => {
38
if (root && !route.meta?.noBasicLayout) {
@@ -38,7 +41,10 @@ async function generateAccessible(
41
if (route.children && route.children.length > 0) {
39
42
delete route.component;
40
43
}
- root.children?.push(route);
44
+ // 根据router name判断,如果路由已经存在,则不再添加
45
+ if (!names?.includes(route.name)) {
46
+ root.children?.push(route);
47
+ }
48
} else {
49
router.addRoute(route);
50
0 commit comments