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
cafec890
Commit
cafec890
authored
Jan 30, 2018
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #843 Modify permissions component logic
parent
c2d19798
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
11 deletions
+8
-11
src/components/Authorized/CheckPermissions.js
src/components/Authorized/CheckPermissions.js
+1
-3
src/components/Authorized/PromiseRender.js
src/components/Authorized/PromiseRender.js
+3
-3
src/components/Authorized/Secured.js
src/components/Authorized/Secured.js
+1
-1
src/router.js
src/router.js
+3
-4
No files found.
src/components/Authorized/CheckPermissions.js
View file @
cafec890
...
...
@@ -38,9 +38,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
// Promise ε€η
if
(
isPromise
(
authority
))
{
return
()
=>
(
<
PromiseRender
ok
=
{
target
}
error
=
{
Exception
}
promise
=
{
authority
}
/
>
);
return
<
PromiseRender
ok
=
{
target
}
error
=
{
Exception
}
promise
=
{
authority
}
/>
;
}
// Function ε€η
...
...
src/components/Authorized/PromiseRender.js
View file @
cafec890
...
...
@@ -3,9 +3,9 @@ import { Spin } from 'antd';
export
default
class
PromiseRender
extends
React
.
PureComponent
{
state
=
{
component
:
false
,
component
:
null
,
};
async
componentDidMount
()
{
componentDidMount
()
{
this
.
props
.
promise
.
then
(()
=>
{
this
.
setState
({
...
...
@@ -14,7 +14,7 @@ export default class PromiseRender extends React.PureComponent {
})
.
catch
(()
=>
{
this
.
setState
({
component
:
this
.
props
.
error
,
component
:
()
=>
this
.
props
.
error
,
});
});
}
...
...
src/components/Authorized/Secured.js
View file @
cafec890
...
...
@@ -38,7 +38,7 @@ const authorize = (authority, error) => {
throw
new
Error
(
'
authority is required
'
);
}
return
function
decideAuthority
(
targer
)
{
return
CheckPermissions
(
return
()
=>
CheckPermissions
(
authority
,
targer
,
classError
||
Exception403
...
...
src/router.js
View file @
cafec890
import
React
from
'
react
'
;
import
{
routerRedux
,
Switch
}
from
'
dva/router
'
;
import
{
routerRedux
,
Route
,
Switch
}
from
'
dva/router
'
;
import
{
LocaleProvider
,
Spin
}
from
'
antd
'
;
import
zhCN
from
'
antd/lib/locale-provider/zh_CN
'
;
import
dynamic
from
'
dva/dynamic
'
;
...
...
@@ -21,10 +21,9 @@ function RouterConfig({ history, app }) {
<
LocaleProvider
locale
=
{
zhCN
}
>
<
ConnectedRouter
history
=
{
history
}
>
<
Switch
>
<
Authorized
Route
<
Route
path
=
"
/user
"
render
=
{
props
=>
<
UserLayout
{...
props
}
/>
}
redirectPath
=
"
/
"
component
=
{
UserLayout
}
/
>
<
AuthorizedRoute
path
=
"
/
"
...
...
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