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
a9efb31b
Commit
a9efb31b
authored
Mar 08, 2019
by
kennylbj
Committed by
ιε°θͺ
Mar 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix authoriy inherit issue (#3679)
parent
8235142e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
20 deletions
+12
-20
src/pages/Authorized.js
src/pages/Authorized.js
+12
-20
No files found.
src/pages/Authorized.js
View file @
a9efb31b
...
@@ -6,28 +6,20 @@ import Authorized from '@/utils/Authorized';
...
@@ -6,28 +6,20 @@ import Authorized from '@/utils/Authorized';
function
AuthComponent
({
children
,
location
,
routerData
,
status
})
{
function
AuthComponent
({
children
,
location
,
routerData
,
status
})
{
const
isLogin
=
status
===
'
ok
'
;
const
isLogin
=
status
===
'
ok
'
;
const
getRouteAuthority
=
(
path
,
routeData
)
=>
{
let
authorities
;
routeData
.
forEach
(
route
=>
{
// match prefix
if
(
pathToRegexp
(
`
${
route
.
path
}
(.*)`
).
test
(
path
))
{
authorities
=
route
.
authority
||
authorities
;
const
getRouteAuthority
=
(
pathname
,
routeData
)
=>
{
// get children authority recursively
const
routes
=
routeData
.
slice
();
// clone
if
(
route
.
routes
)
{
authorities
=
getRouteAuthority
(
path
,
route
.
routes
)
||
authorities
;
const
getAuthority
=
(
routeDatas
,
path
)
=>
{
let
authorities
;
routeDatas
.
forEach
(
route
=>
{
// check partial route
if
(
pathToRegexp
(
`
${
route
.
path
}
(.*)`
).
test
(
path
))
{
if
(
route
.
authority
)
{
authorities
=
route
.
authority
;
}
// is exact route?
if
(
!
pathToRegexp
(
route
.
path
).
test
(
path
)
&&
route
.
routes
)
{
authorities
=
getAuthority
(
route
.
routes
,
path
);
}
}
}
});
}
return
authorities
;
});
};
return
authorities
;
return
getAuthority
(
routes
,
pathname
);
};
};
return
(
return
(
<
Authorized
<
Authorized
...
...
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