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
93cc3870
Commit
93cc3870
authored
Jun 17, 2018
by
陈帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize menu
parent
c9a09d85
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
src/common/menu.js
src/common/menu.js
+5
-2
src/components/SiderMenu/BaseMenu.js
src/components/SiderMenu/BaseMenu.js
+6
-8
src/components/SiderMenu/SliderMenu.js
src/components/SiderMenu/SliderMenu.js
+4
-5
src/locale/en-US.js
src/locale/en-US.js
+1
-1
No files found.
src/common/menu.js
View file @
93cc3870
...
...
@@ -371,19 +371,22 @@ const menuData = [
},
];
function
formatter
(
data
,
parentPath
=
'
/
'
,
parentAuthority
)
{
function
formatter
(
data
,
parentPath
=
'
/
'
,
parentAuthority
,
parentName
)
{
return
data
.
map
(
item
=>
{
let
{
path
}
=
item
;
const
id
=
parentName
?
`
${
parentName
}
.
${
item
.
name
}
`
:
`menu.
${
item
.
name
}
`
;
if
(
!
isUrl
(
path
))
{
path
=
parentPath
+
item
.
path
;
}
const
result
=
{
...
item
,
path
,
locale
:
id
,
authority
:
item
.
authority
||
parentAuthority
,
};
if
(
item
.
children
)
{
result
.
children
=
formatter
(
item
.
children
,
`
${
parentPath
}${
item
.
path
}
/`
,
item
.
authority
);
result
.
children
=
formatter
(
item
.
children
,
`
${
parentPath
}${
item
.
path
}
/`
,
item
.
authority
,
id
);
}
return
result
;
});
...
...
src/components/SiderMenu/BaseMenu.js
View file @
93cc3870
...
...
@@ -79,10 +79,9 @@ export default class BaseMenu extends PureComponent {
/**
* get SubMenu or Item
*/
getSubMenuOrItem
=
(
item
,
parent
)
=>
{
const
id
=
parent
?
`
${
parent
}
.
${
item
.
name
}
`
:
`menu.
${
item
.
name
}
`
;
getSubMenuOrItem
=
item
=>
{
if
(
item
.
children
&&
item
.
children
.
some
(
child
=>
child
.
name
))
{
const
name
=
<
FormattedMessage
defaultMessage
=
{
item
.
name
}
id
=
{
i
d
}
/>
;
const
name
=
<
FormattedMessage
defaultMessage
=
{
item
.
name
}
id
=
{
i
tem
.
locale
}
/>
;
return
(
<
SubMenu
title
=
{
...
...
@@ -97,11 +96,11 @@ export default class BaseMenu extends PureComponent {
}
key
=
{
item
.
path
}
>
{
this
.
getNavMenuItems
(
item
.
children
,
id
)}
{
this
.
getNavMenuItems
(
item
.
children
)}
<
/SubMenu
>
);
}
else
{
return
<
Menu
.
Item
key
=
{
item
.
path
}
>
{
this
.
getMenuItemPath
(
item
,
parent
)}
<
/Menu.Item>
;
return
<
Menu
.
Item
key
=
{
item
.
path
}
>
{
this
.
getMenuItemPath
(
item
)}
<
/Menu.Item>
;
}
};
...
...
@@ -110,9 +109,8 @@ export default class BaseMenu extends PureComponent {
* Judge whether it is http link.return a or Link
* @memberof SiderMenu
*/
getMenuItemPath
=
(
item
,
parent
)
=>
{
const
id
=
parent
?
`
${
parent
}
.
${
item
.
name
}
`
:
`menu.
${
item
.
name
}
`
;
const
name
=
<
FormattedMessage
defaultMessage
=
{
item
.
name
}
id
=
{
id
}
/>
;
getMenuItemPath
=
item
=>
{
const
name
=
<
FormattedMessage
defaultMessage
=
{
item
.
name
}
id
=
{
item
.
locale
}
/>
;
const
itemPath
=
this
.
conversionPath
(
item
.
path
);
const
icon
=
getIcon
(
item
.
icon
);
const
{
target
}
=
item
;
...
...
src/components/SiderMenu/SliderMenu.js
View file @
93cc3870
...
...
@@ -105,17 +105,16 @@ export default class SiderMenu extends PureComponent {
* @memberof SiderMenu
*/
getMenuItemPath
=
item
=>
{
console
.
log
(
item
);
const
itemPath
=
this
.
conversionPath
(
item
.
path
);
const
icon
=
getIcon
(
item
.
icon
);
const
{
target
,
name
}
=
item
;
const
{
target
,
name
,
locale
}
=
item
;
// Is it a http link
if
(
/^https
?
:
\/\/
/
.
test
(
itemPath
))
{
return
(
<
a
href
=
{
itemPath
}
target
=
{
target
}
>
{
icon
}
<
span
>
<
FormattedMessage
id
=
{
name
}
/
>
<
FormattedMessage
id
=
{
locale
}
defaultMessage
=
{
name
}
/
>
<
/span
>
<
/a
>
);
...
...
@@ -136,7 +135,7 @@ export default class SiderMenu extends PureComponent {
>
{
icon
}
<
span
>
<
FormattedMessage
id
=
{
name
}
/
>
<
FormattedMessage
id
=
{
locale
}
defaultMessage
=
{
name
}
/
>
<
/span
>
<
/Link
>
);
...
...
@@ -159,7 +158,7 @@ export default class SiderMenu extends PureComponent {
<
span
>
{
item
.
name
}
<
/span
>
<
/span
>
)
:
(
item
.
name
<
FormattedMessage
id
=
{
item
.
locale
}
defaultMessage
=
{
item
.
name
}
/
>
)
}
key
=
{
item
.
path
}
...
...
src/locale/en-US.js
View file @
93cc3870
...
...
@@ -7,7 +7,7 @@ export default {
data
:
appLocaleData
,
antd
:
antdEn
,
messages
:
{
'
menu.home
'
:
'
h
ome
'
,
'
menu.home
'
:
'
H
ome
'
,
'
menu.dashboard
'
:
'
Dashboard
'
,
'
menu.dashboard.analysis
'
:
'
Analysis
'
,
'
menu.dashboard.monitor
'
:
'
Monitor
'
,
...
...
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