-
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): copy routes to children #9567
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
packages/plugins/src/access.ts
Outdated
@@ -129,7 +129,7 @@ export const useAccessMarkedRoutes = (routes: IRoute[]) => { | |||
} | |||
|
|||
return routes.map(route => process(route)); | |||
}, [routes.length, access]); |
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修改了一定重新计算一份layout
packages/plugins/src/layout.ts
Outdated
@@ -197,7 +199,7 @@ const { formatMessage } = useIntl(); | |||
}, | |||
}); | |||
|
|||
const matchedRoute = useMemo(() => matchRoutes(clientRoutes, location.pathname).pop()?.route, [location.pathname]); | |||
const matchedRoute = useMemo(() => matchRoutes(clientRoutes, 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.
防止没match的时候项目死掉
packages/plugins/src/layout.ts
Outdated
@@ -165,6 +166,7 @@ const mapRoutes = (routes: IRoute[]) => { | |||
|
|||
if (Array.isArray(route.routes)) { | |||
newRoute.routes = mapRoutes(route.routes); | |||
newRoute.children = newRoute.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.
copy了一份一样的给 children
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.
这里copy 会印象对引用的修改,导致权限不生效,有时间了好好改改。应该使用不可变数据
@@ -144,6 +144,7 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) => | |||
newRoutes.push(route); | |||
if (Array.isArray(route.routes)) { | |||
route.routes = filterRoutes(route.routes, filterFn); | |||
route.children = route.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.
copy了一份一样的给children
Size Change: +10 B (0%) Total Size: 9.95 MB
ℹ️ View Unchanged
|
Codecov ReportBase: 29.28% // Head: 29.28% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #9567 +/- ##
=======================================
Coverage 29.28% 29.28%
=======================================
Files 419 419
Lines 11609 11609
Branches 2775 2775
=======================================
Hits 3400 3400
Misses 7690 7690
Partials 519 519
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. |
ff9b7f7
to
53766d5
Compare
No description provided.