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
P
pro-blocks
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
pro-blocks
Commits
ecef6259
Commit
ecef6259
authored
Jan 10, 2018
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify the document
parent
31b8213f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
75 deletions
+68
-75
src/components/Authorized/demo/AuthorizedArray.md
src/components/Authorized/demo/AuthorizedArray.md
+23
-0
src/components/Authorized/demo/AuthorizedFunction.md
src/components/Authorized/demo/AuthorizedFunction.md
+31
-0
src/components/Authorized/demo/basic.md
src/components/Authorized/demo/basic.md
+4
-23
src/components/Authorized/demo/secured.md
src/components/Authorized/demo/secured.md
+4
-51
src/routes/Dashboard/Monitor.js
src/routes/Dashboard/Monitor.js
+6
-1
No files found.
src/components/Authorized/demo/AuthorizedArray.md
0 → 100644
View file @
ecef6259
---
order
:
1
title
:
zh-CN
:
使用数组作为参数
en-US
:
Use Array as a parameter
---
Use Array as a parameter
```
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
=
{
[
'
user
'
,
'
admin
'
]
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use Array as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>,
mountNode
,
);
```
src/components/Authorized/demo/AuthorizedFunction.md
0 → 100644
View file @
ecef6259
---
order
:
2
title
:
zh-CN
:
使用方法作为参数
en-US
:
Use function as a parameter
---
Use Function as a parameter
```
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
=
()
=>
{
return
false
;
};
ReactDOM
.
render
(
<
Authorized
authority
=
{
havePermission
}
noMatch
=
{
noMatch
}
>
<
Alert
message
=
"Use Function as a parameter passed!"
type
=
"success"
showIcon
/>
</
Authorized
>,
mountNode
,
);
```
src/components/Authorized/demo/basic.md
View file @
ecef6259
---
order
:
0
title
:
zh-CN
:
基
础
en-US
:
Basic
zh-CN
:
基
本使用
en-US
:
Basic
use
---
Authorized demo used
Basic use
```
jsx
import
RenderAuthorized
from
'
ant-design-pro/lib/Authorized
'
;
...
...
@@ -14,31 +14,12 @@ import { Alert } from 'antd';
const
Authorized
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
const
havePermission
=
()
=>
{
return
false
;
};
const
havePermissionAsync
=
new
Promise
((
resolve
,
reject
)
=>
{
// Call resolve on behalf of passed
setTimeout
(
()
=>
resolve
()
,
1000
)
});
ReactDOM
.
render
(
<
div
>
<
Authorized
authority
=
"admin"
noMatch
=
{
noMatch
}
>
<
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/demo/secured.md
View file @
ecef6259
---
order
:
1
order
:
3
title
:
zh-CN
:
注解
en-US
:
secured
zh-CN
:
注解
基本使用
en-US
:
Basic use
secured
---
secured demo used
...
...
@@ -12,63 +12,16 @@ import RenderAuthorized from 'ant-design-pro/lib/Authorized';
import
{
Alert
}
from
'
antd
'
;
const
{
Secured
}
=
RenderAuthorized
(
'
user
'
);
const
noMatch
=
<
Alert
message
=
"No permission."
type
=
"error"
showIcon
/>;
const
havePermission
=
()
=>
{
return
false
;
};
const
havePermissionAsync
=
new
Promise
((
resolve
,
reject
)
=>
{
// Call resolve on behalf of passed
setTimeout
(()
=>
resolve
(),
1000
);
});
@
Secured
(
'
admin
'
,
noMatch
)
@
Secured
(
'
admin
'
)
class
TestSecuredString
extends
React
.
Component
{
render
()
{
<
Alert
message
=
"user Passed!"
type
=
"success"
showIcon
/>;
}
}
@
Secured
([
'
user
'
,
'
admin
'
],
noMatch
)
class
TestSecuredArray
extends
React
.
Component
{
render
()
{
<
Alert
message
=
"Use Array as a parameter passed!"
type
=
"success"
showIcon
/>;
}
}
@
Secured
(
havePermission
,
noMatch
)
class
TestSecuredFunction
extends
React
.
Component
{
render
()
{
<
Alert
message
=
"Use function as a parameter passed!"
type
=
"success"
showIcon
/>;
}
}
@
Secured
(
havePermissionAsync
,
noMatch
)
class
TestSecuredPromise
extends
React
.
Component
{
render
()
{
<
Alert
message
=
"Use Promise as a parameter passed!"
type
=
"success"
showIcon
/>;
}
}
ReactDOM
.
render
(
<
div
>
<
TestSecuredString
/>
<
TestSecuredArray
/>
<
TestSecuredFunction
/>
<
TestSecuredPromise
/>
</
div
>,
mountNode
,
);
...
...
src/routes/Dashboard/Monitor.js
View file @
ecef6259
...
...
@@ -13,7 +13,12 @@ const { Secured } = Authorized;
const
targetTime
=
new
Date
().
getTime
()
+
3900000
;
@
Secured
(
'
admin
'
)
// use permission as a parameter
const
havePermissionAsync
=
new
Promise
((
resolve
)
=>
{
// Call resolve on behalf of passed
setTimeout
(()
=>
resolve
(),
1000
);
});
@
Secured
(
havePermissionAsync
)
@
connect
(({
monitor
,
loading
})
=>
({
monitor
,
loading
:
loading
.
models
.
monitor
,
...
...
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