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
83df4267
Commit
83df4267
authored
Aug 31, 2018
by
afc163
Committed by
偏右
Aug 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix authority
parent
ff08655f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
src/pages/Authorized.js
src/pages/Authorized.js
+19
-6
No files found.
src/pages/Authorized.js
View file @
83df4267
...
@@ -3,22 +3,35 @@ import RenderAuthorized from '@/components/Authorized';
...
@@ -3,22 +3,35 @@ import RenderAuthorized from '@/components/Authorized';
import
Exception
from
'
@/components/Exception
'
;
import
Exception
from
'
@/components/Exception
'
;
import
{
matchRoutes
}
from
'
react-router-config
'
;
import
{
matchRoutes
}
from
'
react-router-config
'
;
import
uniq
from
'
lodash/uniq
'
;
import
uniq
from
'
lodash/uniq
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
import
Link
from
'
umi/link
'
;
const
Authorized
=
RenderAuthorized
([
'
admin
'
,
'
user
'
]);
const
Authorized
=
RenderAuthorized
([
'
admin
'
,
'
user
'
]);
const
noMatch
=
<
Exception
type
=
"
403
"
style
=
{{
minHeight
:
500
,
height
:
'
80%
'
}}
/>
;
export
default
({
children
,
route
,
location
})
=>
{
export
default
({
children
,
route
,
location
})
=>
{
const
routes
=
matchRoutes
(
route
.
routes
,
location
.
pathname
);
const
routes
=
matchRoutes
(
route
.
routes
,
location
.
pathname
);
let
authorities
=
[];
let
authorities
=
[];
routes
.
forEach
(
item
=>
{
routes
.
forEach
(
item
=>
{
if
(
Array
.
isArray
(
item
.
authority
))
{
if
(
Array
.
isArray
(
item
.
route
.
authority
))
{
authorities
=
authorities
.
concat
(
item
.
authority
);
authorities
=
authorities
.
concat
(
item
.
route
.
authority
);
}
else
if
(
typeof
item
.
authority
===
'
string
'
)
{
}
else
if
(
typeof
item
.
route
.
authority
===
'
string
'
)
{
authorities
.
push
(
item
.
authority
);
authorities
.
push
(
item
.
route
.
authority
);
}
}
});
});
const
noMatch
=
(
<
Exception
type
=
"
403
"
desc
=
{
formatMessage
({
id
:
'
app.exception.description.403
'
},
{})}
style
=
{{
minHeight
:
500
,
height
:
'
80%
'
}}
linkElement
=
{
Link
}
backText
=
{
formatMessage
({
id
:
'
app.exception.back
'
})}
/
>
);
return
(
return
(
<
Authorized
authority
=
{
uniq
(
authorities
)}
noMatch
=
{
noMatch
}
>
<
Authorized
authority
=
{
authorities
.
length
===
0
?
undefined
:
uniq
(
authorities
)}
noMatch
=
{
noMatch
}
>
{
children
}
{
children
}
<
/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