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
608d5998
Commit
608d5998
authored
Sep 14, 2018
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #2291 Increase authority judgment
parent
9fff7f84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
src/layouts/BasicLayout.js
src/layouts/BasicLayout.js
+17
-9
No files found.
src/layouts/BasicLayout.js
View file @
608d5998
...
...
@@ -16,6 +16,7 @@ import logo from '../assets/logo.svg';
import
Footer
from
'
./Footer
'
;
import
Header
from
'
./Header
'
;
import
Context
from
'
./MenuContext
'
;
import
Exception403
from
'
../pages/Exception/403
'
;
const
{
Content
}
=
Layout
;
...
...
@@ -76,6 +77,7 @@ class BasicLayout extends React.PureComponent {
this
.
getPageTitle
=
memoizeOne
(
this
.
getPageTitle
);
this
.
getBreadcrumbNameMap
=
memoizeOne
(
this
.
getBreadcrumbNameMap
,
isEqual
);
this
.
breadcrumbNameMap
=
this
.
getBreadcrumbNameMap
();
this
.
matchParamsPath
=
memoizeOne
(
this
.
matchParamsPath
,
isEqual
);
}
state
=
{
...
...
@@ -156,14 +158,16 @@ class BasicLayout extends React.PureComponent {
return
routerMap
;
}
matchParamsPath
=
pathname
=>
{
const
pathKey
=
Object
.
keys
(
this
.
breadcrumbNameMap
).
find
(
key
=>
pathToRegexp
(
key
).
test
(
pathname
)
);
return
this
.
breadcrumbNameMap
[
pathKey
];
};
getPageTitle
=
pathname
=>
{
let
currRouterData
=
null
;
// match params path
Object
.
keys
(
this
.
breadcrumbNameMap
).
forEach
(
key
=>
{
if
(
pathToRegexp
(
key
).
test
(
pathname
))
{
currRouterData
=
this
.
breadcrumbNameMap
[
key
];
}
});
const
currRouterData
=
this
.
matchParamsPath
(
pathname
);
if
(
!
currRouterData
)
{
return
'
Ant Design Pro
'
;
}
...
...
@@ -221,6 +225,7 @@ class BasicLayout extends React.PureComponent {
const
{
isMobile
}
=
this
.
state
;
const
isTop
=
PropsLayout
===
'
topmenu
'
;
const
menuData
=
this
.
getMenuData
();
const
routerConfig
=
this
.
matchParamsPath
(
pathname
);
const
layout
=
(
<
Layout
>
{
isTop
&&
!
isMobile
?
null
:
(
...
...
@@ -247,12 +252,15 @@ class BasicLayout extends React.PureComponent {
isMobile
=
{
isMobile
}
{...
this
.
props
}
/
>
<
Content
style
=
{
this
.
getContentStyle
()}
>
{
children
}
<
/Content
>
<
Content
style
=
{
this
.
getContentStyle
()}
>
<
Authorized
authority
=
{
routerConfig
.
authority
}
noMatch
=
{
<
Exception403
/>
}
>
{
children
}
<
/Authorized
>
<
/Content
>
<
Footer
/>
<
/Layout
>
<
/Layout
>
);
return
(
<
React
.
Fragment
>
<
DocumentTitle
title
=
{
this
.
getPageTitle
(
pathname
)}
>
...
...
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