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

docs: update layout docs #6131

Merged
merged 1 commit into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package.json
**/templates/**

# docs
**/*.md
# **/*.md

# coverage
/coverage
Expand Down
53 changes: 49 additions & 4 deletions docs/plugins/plugin-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,8 @@ export const routes: IBestAFSRoute[] = [
{
path: '/welcome',
component: 'IndexPage',
menu: {
name: 'Welcome', // compatible with this writing
icon: 'testicon',
},
name: 'Welcome', // compatible with this writing
icon: 'testicon',
// more features view
// https://beta-pro.ant.design/docs/advanced-menu
// ---
Expand All @@ -203,6 +201,8 @@ export const routes: IBestAFSRoute[] = [
hideChildrenInMenu: true,
// hide yourself and child nodes
hideInMenu: true,
// hide in breadcrumbs
hideInBreadcrumb: true,
// The child item is raised up and still displayed,
flatMenu: true,
},
Expand Down Expand Up @@ -235,3 +235,48 @@ The Icon displayed on the menu.
It takes effect when the Layout plugin is used in conjunction with the `@umijs/plugin-access` plugin.

The permission plugin will match the access string configured by the user here with all the permissions of the current user. If the same item is found and the value of the permission is false, the 403 page will be displayed by default when the user accesses the route.

#### locale

-Type: `string`

The internationalization configuration of the menu, the internationalization key is `menu.${submenu-name}.${name}`.

#### icon

-Type: `string`

The antd icon, in order to load the layout plug-in on demand, will automatically convert it to the dom of the Antd icon. Support types can be found in antd (https://ant.design/components/icon-cn/).

#### flatMenu

-Type: `boolean`

Flatten the menu. If you only want the child menu to not show yourself, you can configure it to true

```tsx
const before = [{ name: '111' }, { name: '222', children: [{ name: '333' }] }];
// flatMenu = true
const after = [{ name: '111' }, { name: '222' }, { name: '333' }];
```

#### xxxRender

-Type: `boolean`

If xxxRender is set to false, some layout modules will not be displayed

- `headerRender=false` does not show the top bar
- `footerRender=false` does not show footer
- `menuRender=false` does not show the menu
- `menuHeaderRender=false` does not display the title and logo of the menu

### hideInXXX

-Type: `boolean`

hideInXXX can manage the rendering of the menu.

- `hideChildrenInMenu=true` to hide the child menu
- `hideInMenu=true` hide yourself and submenus
- `hideInBreadcrumb=true` hide in breadcrumbs
63 changes: 51 additions & 12 deletions docs/plugins/plugin-layout.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@ Layout 插件会基于 umi 的路由,封装了更多的配置项,支持更
- 布局路由级别展示/隐藏相关配置。
- 与权限插件结合,配置式实现权限路由的功能。

新增如下配置项:

- menu
- layout
- access

示例如下:

```typescript
Expand All @@ -152,10 +146,8 @@ export const routes: IBestAFSRoute[] = [
{
path: '/welcome',
component: 'IndexPage',
menu: {
name: '欢迎', // 兼容此写法
icon: 'testicon',
},
name: '欢迎', // 兼容此写法
icon: 'testicon',
// 更多功能查看
// https://beta-pro.ant.design/docs/advanced-menu
// ---
Expand All @@ -171,10 +163,12 @@ export const routes: IBestAFSRoute[] = [
menuHeaderRender: false,
// 权限配置,需要与 plugin-access 插件配合使用
access: 'canRead',
// 隐藏子节点
// 隐藏子菜单
hideChildrenInMenu: true,
// 隐藏自己和子节点
// 隐藏自己和子菜单
hideInMenu: true,
// 在面包屑中隐藏
hideInBreadcrumb: true,
// 子项往上提,仍旧展示,
flatMenu: true,
},
Expand Down Expand Up @@ -207,3 +201,48 @@ export const routes: IBestAFSRoute[] = [
当 Layout 插件配合 `@umijs/plugin-access` 插件使用时生效。

权限插件会将用户在这里配置的 access 字符串与当前用户所有权限做匹配,如果找到相同的项,并当该权限的值为 false,则当用户访问该路由时,默认展示 403 页面。

#### locale

- Type: `string`

菜单的国际化配置,国际化的 key 是 `menu.${submenu-name}.${name}`。

#### icon

- Type: `string`

antd 的 icon,为了按需加载 layout 插件会帮你自动转化为 Antd icon 的 dom。支持类型可以在 antd 中[找到](https://ant.design/components/icon-cn/)。

#### flatMenu

- Type: `boolean`

打平菜单,如果只想要子级的 menu 不展示的自己,可以配置为 true

```tsx
const before = [{ name: '111' }, { name: '222', children: [{ name: '333' }] }];
// flatMenu = true
const after = [{ name: '111' }, { name: '222' }, { name: '333' }];
```

#### xxxRender

- Type: `boolean`

xxxRender 设置为 false,即可不展示部分 layout 模块

- `headerRender=false` 不显示顶栏
- `footerRender=false` 不显示页脚
- `menuRender=false` 不显示菜单
- `menuHeaderRender=false` 不显示菜单的 title 和 logo

### hideInXXX

- Type: `boolean`

hideInXXX 可以让管理 menu 的渲染。

- `hideChildrenInMenu=true` 隐藏子菜单
- `hideInMenu=true` 隐藏自己和子菜单
- `hideInBreadcrumb=true` 在面包屑中隐藏
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"bootstrap": "node ./scripts/bootstrap.js",
"build": "father-build",
"start": "npm run build && npm run docs:dev",
"debug": "node --inspect-brk packages/umi/bin/umi.js",
"docs": "node ./scripts/docs.js",
"docs:build": "node ./packages/umi/bin/umi.js build",
Expand Down