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
cbf052c6
Commit
cbf052c6
authored
Sep 05, 2018
by
Tan90Qian
Committed by
陈帅
Sep 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复2.0权限问题
parent
7fde4e74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
src/pages/Authorized.js
src/pages/Authorized.js
+7
-6
src/utils/authority.js
src/utils/authority.js
+1
-1
No files found.
src/pages/Authorized.js
View file @
cbf052c6
import
React
from
'
react
'
;
import
RenderAuthorized
from
'
@/components/Authorized
'
;
import
Exception
from
'
@/components/Exception
'
;
import
{
getAuthority
}
from
'
@/utils/authority
'
;
import
{
matchRoutes
}
from
'
react-router-config
'
;
import
uniq
from
'
lodash/uniq
'
;
import
intersection
from
'
lodash/intersection
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
import
Link
from
'
umi/link
'
;
const
Authorized
=
RenderAuthorized
(
[
'
admin
'
,
'
user
'
]
);
const
Authorized
=
RenderAuthorized
(
getAuthority
()
);
export
default
({
children
,
route
,
location
})
=>
{
const
routes
=
matchRoutes
(
route
.
routes
,
location
.
pathname
);
let
authorities
=
[];
routes
.
forEach
(
item
=>
{
if
(
Array
.
isArray
(
item
.
route
.
authority
))
{
authorities
=
authorities
.
concat
(
item
.
route
.
authority
);
}
else
if
(
typeof
item
.
route
.
authority
===
'
string
'
)
{
if
(
Array
.
isArray
(
item
.
route
.
authority
)
&&
item
.
route
.
authority
.
length
)
{
authorities
.
push
(
item
.
route
.
authority
);
}
else
if
(
typeof
item
.
route
.
authority
===
'
string
'
&&
item
.
route
.
authority
)
{
authorities
.
push
([
item
.
route
.
authority
]);
}
});
const
noMatch
=
(
...
...
@@ -28,7 +29,7 @@ export default ({ children, route, location }) => {
);
return
(
<
Authorized
authority
=
{
authorities
.
length
===
0
?
undefined
:
uniq
(
authorities
)}
authority
=
{
authorities
.
length
===
0
?
undefined
:
intersection
(...
authorities
)}
noMatch
=
{
noMatch
}
>
{
children
}
...
...
src/utils/authority.js
View file @
cbf052c6
...
...
@@ -6,7 +6,7 @@ export function getAuthority() {
if
(
authority
.
includes
(
'
[
'
))
{
authority
=
JSON
.
parse
(
authority
);
}
else
{
authority
=
[
authority
];
authority
=
[
JSON
.
parse
(
authority
)
];
}
}
else
{
authority
=
[
'
admin
'
];
...
...
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