Skip to content

Commit 5d64b5c

Browse files
committed
优化文档方便检索
1 parent 0a666fc commit 5d64b5c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docs/docs/docs/api/runtime-config.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export default {
9090

9191
### getInitialState
9292

93+
- Type: `getInitialState: () => Promise<DataType extends any> | any`
94+
9395
`getInitialState()` 的返回值将成为全局初始状态。例如:
9496

9597
```ts
@@ -124,21 +126,25 @@ export default function Page() {
124126

125127
### layout
126128

129+
- Type: `RuntimeConfig | ProLayoutProps`
130+
127131
修改[内置布局](../max/layout-menu)的配置,比如配置退出登陆、自定义导航暴露的渲染区域等。
128132

129133
> 注意:需要开启 [layout](../api/config#layout) 插件,才能使用它的运行时配置。
130134
131135
```tsx
132136
import { RuntimeConfig } from 'umi';
133137

134-
export const layout:RuntimeConfig = {
138+
export const layout: RuntimeConfig = {
135139
logout: () => {}, // do something
136140
};
137141
```
138142

139143
更多具体配置参考[插件文档](../max/layout-menu#运行时配置)
140144

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`
142148

143149
在初始加载和路由切换时做一些事情。
144150

@@ -172,6 +178,8 @@ export function onRouteChange({ clientRoutes, location }) {
172178

173179
### patchRoutes
174180

181+
- type: `(args: { routes: Routes; routeComponents }) => void`
182+
175183
```ts
176184
export function patchRoutes({ routes, routeComponents }) {
177185
console.log('patchRoutes', routes, routeComponents);
@@ -186,6 +194,8 @@ export function patchRoutes({ routes, routeComponents }) {
186194

187195
### patchClientRoutes
188196

197+
- type: `(args: { routes: Routes; }) => void`
198+
189199
修改被 react-router 渲染前的树状路由表,接收内容同 [useRoutes](https://reactrouter.com/en/main/hooks/use-routes)
190200

191201
比如在最前面添加一个 `/foo` 路由,
@@ -260,6 +270,8 @@ Umi 内置了 `qiankun` 插件来提供微前端的能力,具体参考[插件
260270

261271
### render
262272

273+
- Type: `(oldRender: Function)=>void`
274+
263275
覆写 render。
264276

265277
比如用于渲染之前做权限校验,
@@ -282,6 +294,8 @@ export function render(oldRender) {
282294
283295
### rootContainer
284296
297+
- Type: `(container: JSX.Element,args: { routes: Routes; plugin; history: History }) => JSX.Element;`
298+
285299
修改交给 react-dom 渲染时的根组件。
286300
287301
比如用于在外面包一个 Provider,

0 commit comments

Comments
 (0)