-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add config.disableRedirectHoist (#1091)
出于一些原因的考虑,我们在处理路由时把所有 redirect 声明提到路由最前面进行匹配,但这导致了一些问题,所以添加了这个配置项,禁用 redirect 上提。 比如: 1. ant-design/ant-design-pro#2259 2. 下面的路由配置,访问 `/console` 会访问到 `/console/overview`,因为 redirect 规则往前提了。 ``` routes: [{ path: '/', component: 'Index/App', indexRoute: { redirect: '/console' }, routes: [ { path: '/', component: '../components/layout/Default', routes: [ { path: '/console', component: 'Index/Dashboard', }, { path: '/:productName', indexRoute: { redirect: '/:productName/overview' }, routes: [ { path: '/:productName/overview', component: 'Index/product/Overview' }, ] }, ] } ], }], ```
- Loading branch information
Showing
6 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/umi-build-dev/src/getConfig/configPlugins/disableRedirectHoist.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import assert from 'assert'; | ||
|
||
export default function(api) { | ||
return { | ||
name: 'disableRedirectHoist', | ||
validate(val) { | ||
assert( | ||
typeof val === 'boolean', | ||
`disableRedirectHoist should be Boolean, but got ${val.toString()}.`, | ||
); | ||
}, | ||
onChange() { | ||
api.service.rebuildTmpFiles(); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters