Skip to content
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

feat: support route wrappers #3189

Merged
merged 5 commits into from
May 12, 2020
Merged

Conversation

chenbin92
Copy link
Collaborator

No description provided.

@chenbin92 chenbin92 requested a review from ClarkXia May 11, 2020 01:56
let mergedRouteWrappers = routeWrappers;
if (route.wrappers && route.wrappers.length) {
mergedRouteWrappers = routeWrappers.concat(route.wrappers);
}
Copy link
Collaborator Author

@chenbin92 chenbin92 May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

验证 pageConfig 的功能

@imsobear 这里只是收集 wrappers 阶段,最后会在这里统一挂载 pageConfig

function wrapperRoute(component, routerWrappers) {

@chenbin92
Copy link
Collaborator Author

chenbin92 commented May 11, 2020

@ClarkXia 「约定式」和「配置式」都支持了 wrappers 属性,统一通过 pageConfig 进行配置:

HomePage.pageConfig = {
   // 支持多个
   wrappers: [],
}

@chenbin92 chenbin92 requested a review from imsobear May 11, 2020 04:03
title: 'Dashboard Page',
wrappers: [wrapperPage]
};

export default Dashboard;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

跟这种方式 export default wrapperPage(Dashboard) 对比,唯一的优势就是不需要处理 pageConfig

@chenbin92
Copy link
Collaborator Author

结论

  • 只支持配置式路由的 wrappers 属性,用于集中式管理和配置路由的 wrappers

@@ -39,9 +39,13 @@ function getRouteComponent(component, routerWrappers?: IRouteWrapper[]) {
function parseRoutes(routes: RouteItemProps[]) {
return routes.map((route) => {
const { children, component, routeWrappers, ...others } = route;
let mergedRouteWrappers = routeWrappers;
if (route.wrappers && route.wrappers.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrappers 跟 routeWrappers 类似应该没必要透传下去了,目前 others 中还包含这项内容?

@ClarkXia ClarkXia merged commit 9442e9b into release-next May 12, 2020
@delete-merged-branch delete-merged-branch bot deleted the feat/support-route-wrappers branch May 12, 2020 06:02
@chenbin92 chenbin92 mentioned this pull request May 14, 2020
6 tasks
chenbin92 pushed a commit that referenced this pull request May 14, 2020
* fix: compatible with the index page

* fix: create histroy when render root app

* feat: support promise function with useRequest (#3188)

* fix: repository url (#3192)

* feat: optimize webpackbar (#3187)

* feat: optimize webpackbar

* fix: rename eslintLoaderOptions to eslint

* fix: upgrate react-dev-utils (#3190)

* fix: upgrate react-dev-utils

* v1.2.2-alpha.1

* fix: set transportMode to ws

Co-authored-by: ClarkXia <xiawenwu41@gmail.com>

* feat: support route wrappers (#3189)

* feat: support route wrappers

* feat: support pageConfig wrappers

* refactor: wrappers api

* docs: add wrappers api to ruotes

* fix: destructuring routes

* feat: enhance use request types (#3195)

* feat: enhance useRequest types

* chore: remove comments

* docs: useRequest usage

* v1.2.2-alpha.2

* docs: add withFullResponse api

* docs: refactor request docs

* chore: typo

* chore: useRequest docs

* docs: fix typo

* docs: optimize title

* v1.2.2-alpha.3

* Fix/release bugs (#3205)

* fix: types & log

* v1.2.2-alpha.4

* fix: no match single page file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants