Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
b372626c
Commit
b372626c
authored
Jan 07, 2018
by
ddcat1115
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Authorized doc & demo
parent
61c60a29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
src/components/Authorized/demo/basic.md
src/components/Authorized/demo/basic.md
+22
-0
src/components/Authorized/index.md
src/components/Authorized/index.md
+56
-0
No files found.
src/components/Authorized/demo/basic.md
0 → 100644
View file @
b372626c
---
order
:
0
title
:
zh-CN
:
基础
en-US
:
Basic
---
Simplest of usage.
````
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
{
Alert
}
from
'
antd
'
;
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>
ReactDOM
.
render
(
<
Authorized
authority
=
'admin'
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
,
mountNode
);
````
src/components/Authorized/index.md
0 → 100644
View file @
b372626c
---
title
:
en-US
:
Authorized
zh-CN
:
Authorized
subtitle
:
权限
cols
:
1
order
:
15
---
权限组件,通过比对现有权限与准入权限,决定相关元素的展示。
## API
### RenderAuthorized
`RenderAuthorized: (currentAuthority: string | () => string) => Authorized`
权限组件默认 export RenderAuthorized 函数,它接收当前权限作为参数,返回一个权限对象,该对象提供以下几种使用方式。
### Authorized
最基础的权限控制。
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
| children | 正常渲染的元素,权限判断通过时展示 | ReactNode | - |
| authority | 准入权限/权限判断 |
`string | array | Promise | () => boolean`
| - |
| noMatch | 权限异常渲染元素,权限判断不通过时展示 | ReactNode | - |
### Authorized.AuthorizedRoute
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
| authority | 准入权限/权限判断 |
`string | array | Promise | () => boolean`
| - |
| redirectPath | 权限异常时重定向的页面路由 | string | - |
其余参数与
`Route`
相同。
### Authorized.Secured
注解方式,
`@Authorized.Secured(authority, error)`
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
| authority | 准入权限/权限判断 |
`string | Promise | () => boolean`
| - |
| error | 权限异常时渲染元素 | ReactNode |
<Exception
type=
"403"
/>
|
### Authorized.check
函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。
`Authorized.check(authority, target, Exception)`
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
| authority | 准入权限/权限判断 |
`string | Promise | () => boolean`
| - |
| target | 权限判断通过时渲染的元素 |
`string | array | Promise | () => boolean`
| - |
| Exception | 权限异常时渲染元素 | ReactNode | - |
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment