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
8b743adb
Commit
8b743adb
authored
Oct 22, 2018
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
menu decoupling umi/local
parent
f473b000
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
22 deletions
+21
-22
src/components/SiderMenu/BaseMenu.js
src/components/SiderMenu/BaseMenu.js
+2
-3
src/layouts/BasicLayout.js
src/layouts/BasicLayout.js
+19
-19
No files found.
src/components/SiderMenu/BaseMenu.js
View file @
8b743adb
...
@@ -3,7 +3,6 @@ import { Menu, Icon } from 'antd';
...
@@ -3,7 +3,6 @@ import { Menu, Icon } from 'antd';
import
Link
from
'
umi/link
'
;
import
Link
from
'
umi/link
'
;
import
isEqual
from
'
lodash/isEqual
'
;
import
isEqual
from
'
lodash/isEqual
'
;
import
memoizeOne
from
'
memoize-one
'
;
import
memoizeOne
from
'
memoize-one
'
;
import
{
formatMessage
}
from
'
umi/locale
'
;
import
pathToRegexp
from
'
path-to-regexp
'
;
import
pathToRegexp
from
'
path-to-regexp
'
;
import
{
urlToList
}
from
'
../_utils/pathTools
'
;
import
{
urlToList
}
from
'
../_utils/pathTools
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
...
@@ -83,7 +82,7 @@ export default class BaseMenu extends PureComponent {
...
@@ -83,7 +82,7 @@ export default class BaseMenu extends PureComponent {
getSubMenuOrItem
=
item
=>
{
getSubMenuOrItem
=
item
=>
{
// doc: add hideChildrenInMenu
// doc: add hideChildrenInMenu
if
(
item
.
children
&&
!
item
.
hideChildrenInMenu
&&
item
.
children
.
some
(
child
=>
child
.
name
))
{
if
(
item
.
children
&&
!
item
.
hideChildrenInMenu
&&
item
.
children
.
some
(
child
=>
child
.
name
))
{
const
name
=
item
.
locale
?
formatMessage
({
id
:
item
.
locale
})
:
item
.
name
;
const
{
name
}
=
item
;
return
(
return
(
<
SubMenu
<
SubMenu
title
=
{
title
=
{
...
@@ -111,7 +110,7 @@ export default class BaseMenu extends PureComponent {
...
@@ -111,7 +110,7 @@ export default class BaseMenu extends PureComponent {
* @memberof SiderMenu
* @memberof SiderMenu
*/
*/
getMenuItemPath
=
item
=>
{
getMenuItemPath
=
item
=>
{
const
name
=
item
.
locale
?
formatMessage
({
id
:
item
.
locale
})
:
item
.
name
;
const
{
name
}
=
item
;
const
itemPath
=
this
.
conversionPath
(
item
.
path
);
const
itemPath
=
this
.
conversionPath
(
item
.
path
);
const
icon
=
getIcon
(
item
.
icon
);
const
icon
=
getIcon
(
item
.
icon
);
const
{
target
}
=
item
;
const
{
target
}
=
item
;
...
...
src/layouts/BasicLayout.js
View file @
8b743adb
...
@@ -24,30 +24,30 @@ const { Content } = Layout;
...
@@ -24,30 +24,30 @@ const { Content } = Layout;
function
formatter
(
data
,
parentAuthority
,
parentName
)
{
function
formatter
(
data
,
parentAuthority
,
parentName
)
{
return
data
return
data
.
map
(
item
=>
{
.
map
(
item
=>
{
if
(
!
item
.
name
||
!
item
.
path
)
{
return
null
;
}
let
locale
=
'
menu
'
;
let
locale
=
'
menu
'
;
if
(
parentName
&&
item
.
name
)
{
if
(
parentName
)
{
locale
=
`
${
parentName
}
.
${
item
.
name
}
`
;
locale
=
`
${
parentName
}
.
${
item
.
name
}
`
;
}
else
if
(
item
.
name
)
{
}
else
{
locale
=
`menu.
${
item
.
name
}
`
;
locale
=
`menu.
${
item
.
name
}
`
;
}
else
if
(
parentName
)
{
locale
=
parentName
;
}
if
(
item
.
path
)
{
const
result
=
{
...
item
,
locale
,
authority
:
item
.
authority
||
parentAuthority
,
};
if
(
item
.
routes
)
{
const
children
=
formatter
(
item
.
routes
,
item
.
authority
,
locale
);
// Reduce memory usage
result
.
children
=
children
;
}
delete
result
.
routes
;
return
result
;
}
}
return
null
;
const
result
=
{
...
item
,
name
:
formatMessage
({
id
:
locale
,
defaultMessage
:
item
.
name
}),
locale
,
authority
:
item
.
authority
||
parentAuthority
,
};
if
(
item
.
routes
)
{
const
children
=
formatter
(
item
.
routes
,
item
.
authority
,
locale
);
// Reduce memory usage
result
.
children
=
children
;
}
delete
result
.
routes
;
return
result
;
})
})
.
filter
(
item
=>
item
);
.
filter
(
item
=>
item
);
}
}
...
...
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