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
80dc0567
Commit
80dc0567
authored
Jun 14, 2018
by
guowenfh
Committed by
陈帅
Jun 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: add <Authorized/> authority function
After performing return Promise is render <PromiseRender/> component
parent
6c1b112a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
src/components/Authorized/CheckPermissions.js
src/components/Authorized/CheckPermissions.js
+4
-0
src/components/Authorized/index.md
src/components/Authorized/index.md
+5
-5
No files found.
src/components/Authorized/CheckPermissions.js
View file @
80dc0567
...
@@ -52,6 +52,10 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
...
@@ -52,6 +52,10 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
if
(
bool
)
{
if
(
bool
)
{
return
target
;
return
target
;
}
}
// 函数执行后返回值是 Promise
if
(
isPromise
(
bool
))
{
return
<
PromiseRender
ok
=
{
target
}
error
=
{
Exception
}
promise
=
{
bool
}
/>
;
}
return
Exception
;
return
Exception
;
}
catch
(
error
)
{
}
catch
(
error
)
{
throw
error
;
throw
error
;
...
...
src/components/Authorized/index.md
View file @
80dc0567
...
@@ -25,14 +25,14 @@ order: 15
...
@@ -25,14 +25,14 @@ order: 15
| 参数 | 说明 | 类型 | 默认值 |
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
|----------|------------------------------------------|-------------|-------|
| children | 正常渲染的元素,权限判断通过时展示 | ReactNode | - |
| children | 正常渲染的元素,权限判断通过时展示 | ReactNode | - |
| authority | 准入权限/权限判断 |
`string | array | Promise | (currentAuthority) => boolean`
| - |
| authority | 准入权限/权限判断 |
`string | array | Promise | (currentAuthority) => boolean
| Promise
`
| - |
| noMatch | 权限异常渲染元素,权限判断不通过时展示 | ReactNode | - |
| noMatch | 权限异常渲染元素,权限判断不通过时展示 | ReactNode | - |
### Authorized.AuthorizedRoute
### Authorized.AuthorizedRoute
| 参数 | 说明 | 类型 | 默认值 |
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
|----------|------------------------------------------|-------------|-------|
| authority | 准入权限/权限判断 |
`string | array | Promise | (currentAuthority) => boolean`
| - |
| authority | 准入权限/权限判断 |
`string | array | Promise | (currentAuthority) => boolean
| Promise
`
| - |
| redirectPath | 权限异常时重定向的页面路由 | string | - |
| redirectPath | 权限异常时重定向的页面路由 | string | - |
其余参数与
`Route`
相同。
其余参数与
`Route`
相同。
...
@@ -43,7 +43,7 @@ order: 15
...
@@ -43,7 +43,7 @@ order: 15
| 参数 | 说明 | 类型 | 默认值 |
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
|----------|------------------------------------------|-------------|-------|
| authority | 准入权限/权限判断 |
`string | Promise | (currentAuthority) => boolean`
| - |
| authority | 准入权限/权限判断 |
`string | Promise | (currentAuthority) => boolean
| Promise
`
| - |
| error | 权限异常时渲染元素 | ReactNode |
<Exception
type=
"403"
/>
|
| error | 权限异常时渲染元素 | ReactNode |
<Exception
type=
"403"
/>
|
### Authorized.check
### Authorized.check
...
@@ -53,6 +53,6 @@ order: 15
...
@@ -53,6 +53,6 @@ order: 15
| 参数 | 说明 | 类型 | 默认值 |
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
|----------|------------------------------------------|-------------|-------|
| authority | 准入权限/权限判断 |
`string | Promise | (currentAuthority) => boolean`
| - |
| authority | 准入权限/权限判断 |
`string | Promise | (currentAuthority) => boolean
| Promise
`
| - |
| target | 权限判断通过时渲染的元素 | ReactNode | - |
| target | 权限判断通过时渲染的元素 | ReactNode | - |
| Exception | 权限异常时渲染元素 | ReactNode | - |
| 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