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
39f7830d
Commit
39f7830d
authored
Jan 09, 2018
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update Authorized doc
parent
365ad517
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
59 deletions
+17
-59
src/components/Authorized/demo/basic.md
src/components/Authorized/demo/basic.md
+16
-58
src/components/Authorized/index.md
src/components/Authorized/index.md
+1
-1
No files found.
src/components/Authorized/demo/basic.md
View file @
39f7830d
...
@@ -5,25 +5,6 @@ title:
...
@@ -5,25 +5,6 @@ title:
en-US
:
Basic
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
,
);
```
user Array
```
jsx
```
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
import
{
Alert
}
from
'
antd
'
;
import
{
Alert
}
from
'
antd
'
;
...
@@ -31,54 +12,31 @@ import { Alert } from 'antd';
...
@@ -31,54 +12,31 @@ import { Alert } from 'antd';
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
ReactDOM
.
render
(
<
Authorized
authority
=
{
[
'
user
'
,
'
admin
'
]
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
mountNode
,
);
```
user Funtion
```
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
/>;
const
Havep
ermission
=
()
=>
{
const
haveP
ermission
=
()
=>
{
return
false
;
return
false
;
};
};
ReactDOM
.
render
(
const
havePermissionAsync
=
new
Promise
((
resolve
,
reject
)
=>
{
<
Authorized
authority
=
{
Havepermission
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
mountNode
,
);
```
user Promise
```
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
/>;
const
Havepermission
=
new
Promise
((
reslove
,
reject
)
=>
{
// Call reslove on behalf of passed
// Call reslove on behalf of passed
setTimeout
(()
=>
reslove
(),
1000
)
setTimeout
(()
=>
reslove
(),
1000
)
});
});
ReactDOM
.
render
(
ReactDOM
.
render
(
<
Authorized
authority
=
{
Havepermission
}
noMatch
=
{
noMatch
}
>
<
div
>
<
Alert
message
=
"Passed!"
type
=
"success"
showIcon
/>
<
Authorized
authority
=
"admin"
noMatch
=
{
noMatch
}
>
</
Authorized
>
<
Alert
message
=
"user Passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
Authorized
authority
=
{
[
'
user
'
,
'
admin
'
]
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use Array as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
Authorized
authority
=
{
Havepermission
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use function as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
<
Authorized
authority
=
{
havePermissionAsync
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use Promise as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>
</
div
>
mountNode
,
mountNode
,
);
);
```
```
src/components/Authorized/index.md
View file @
39f7830d
...
@@ -48,7 +48,7 @@ order: 15
...
@@ -48,7 +48,7 @@ order: 15
### Authorized.check
### Authorized.check
函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。
`Authorized.check(authority, target, Exception)`
函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。
`Authorized.check(authority, target, Exception)`
注意
:传入一个Promise时 无论正确还是错误返回的都是一个ReactNode.
注意
:传入一个 Promise 时,无论正确还是错误返回的都是一个 ReactClass。
| 参数 | 说明 | 类型 | 默认值 |
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
|----------|------------------------------------------|-------------|-------|
...
...
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