@@ -90,6 +90,8 @@ export default {
90
90
91
91
### getInitialState
92
92
93
+ - Type: ` getInitialState: () => Promise<DataType extends any> | any `
94
+
93
95
` getInitialState() ` 的返回值将成为全局初始状态。例如:
94
96
95
97
``` ts
@@ -124,21 +126,25 @@ export default function Page() {
124
126
125
127
### layout
126
128
129
+ - Type: ` RuntimeConfig | ProLayoutProps `
130
+
127
131
修改[ 内置布局] ( ../max/layout-menu ) 的配置,比如配置退出登陆、自定义导航暴露的渲染区域等。
128
132
129
133
> 注意:需要开启 [ layout] ( ../api/config#layout ) 插件,才能使用它的运行时配置。
130
134
131
135
``` tsx
132
136
import { RuntimeConfig } from ' umi' ;
133
137
134
- export const layout: RuntimeConfig = {
138
+ export const layout: RuntimeConfig = {
135
139
logout : () => {}, // do something
136
140
};
137
141
```
138
142
139
143
更多具体配置参考[ 插件文档] ( ../max/layout-menu#运行时配置 ) 。
140
144
141
- ### onRouteChange(\{ routes, clientRoutes, location, action, basename, isFirst \} )
145
+ ### onRouteChange
146
+
147
+ - type: ` (args: { routes: Routes; clientRoutes: Routes; location: Location; action: Action; basename: string; isFirst: boolean }) => void `
142
148
143
149
在初始加载和路由切换时做一些事情。
144
150
@@ -172,6 +178,8 @@ export function onRouteChange({ clientRoutes, location }) {
172
178
173
179
### patchRoutes
174
180
181
+ - type: ` (args: { routes: Routes; routeComponents }) => void `
182
+
175
183
``` ts
176
184
export function patchRoutes({ routes , routeComponents }) {
177
185
console .log (' patchRoutes' , routes , routeComponents );
@@ -186,6 +194,8 @@ export function patchRoutes({ routes, routeComponents }) {
186
194
187
195
### patchClientRoutes
188
196
197
+ - type: ` (args: { routes: Routes; }) => void `
198
+
189
199
修改被 react-router 渲染前的树状路由表,接收内容同 [ useRoutes] ( https://reactrouter.com/en/main/hooks/use-routes ) 。
190
200
191
201
比如在最前面添加一个 ` /foo ` 路由,
@@ -260,6 +270,8 @@ Umi 内置了 `qiankun` 插件来提供微前端的能力,具体参考[插件
260
270
261
271
### render
262
272
273
+ - Type: ` (oldRender: Function)=>void `
274
+
263
275
覆写 render。
264
276
265
277
比如用于渲染之前做权限校验,
@@ -282,6 +294,8 @@ export function render(oldRender) {
282
294
283
295
# ## rootContainer
284
296
297
+ - Type: ` (container: JSX.Element,args: { routes: Routes; plugin; history: History }) => JSX.Element; `
298
+
285
299
修改交给 react-dom 渲染时的根组件。
286
300
287
301
比如用于在外面包一个 Provider,
0 commit comments