-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin-layout): 修复 children 和 layout 混用导致的权限失效问题 #9587
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@@ -125,6 +125,20 @@ export const useAccessMarkedRoutes = (routes: IRoute[]) => { | |||
} | |||
} | |||
|
|||
// check children access code | |||
if (route.routes?.length) { | |||
const isNoAccessibleChild = !route.routes.reduce((hasAccessibleChild, child) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只设置了 children 的权限,导致 children=routes 权限就会失效
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这几个地方处理的都是 routes ,pro-layout 又不取 routes 了,这好绕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是为了兼容性,保证有一份一样的children 和 routes
// 现在的 layout 及 wrapper 实现是通过父路由的形式实现的, 会导致路由数据多了冗余层级, proLayout 消费时, 无法正确展示菜单, 这里对冗余数据进行过滤操作 | ||
const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => { | ||
return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper; | ||
}) | ||
const [route] = useAccessMarkedRoutes(mapRoutes(newRoutes)); | ||
|
||
const matchedRoute = useMemo(() => matchRoutes(route.children, location.pathname)?.pop?.()?.route, [location.pathname]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
国际化应该处理处理过的 route,不然会需要修改引用才能让 matchedRoute 的值被 useAccessMarkedRoutes 修改
Size Change: +1.96 kB (0%) Total Size: 9.95 MB
ℹ️ View Unchanged
|
Codecov ReportBase: 29.19% // Head: 29.05% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #9587 +/- ##
==========================================
- Coverage 29.19% 29.05% -0.14%
==========================================
Files 419 420 +1
Lines 11649 11704 +55
Branches 2790 2804 +14
==========================================
Hits 3401 3401
- Misses 7723 7773 +50
- Partials 525 530 +5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -136,16 +136,17 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) => | |||
|
|||
let newRoutes = [] | |||
for (const route of routes) { | |||
const newRoute = {...route }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要修改原来的路由数据了,不然会导致 react routers 的路由生成出问题,丢失层级
No description provided.