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
e2f62c6d
Commit
e2f62c6d
authored
Sep 05, 2017
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor menu data
parent
eb9881d6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
137 deletions
+134
-137
src/common/nav.js
src/common/nav.js
+123
-134
src/layouts/BasicLayout.js
src/layouts/BasicLayout.js
+11
-3
No files found.
src/common/nav.js
View file @
e2f62c6d
...
@@ -30,38 +30,11 @@ import Login from '../routes/User/Login';
...
@@ -30,38 +30,11 @@ import Login from '../routes/User/Login';
import
Register
from
'
../routes/User/Register
'
;
import
Register
from
'
../routes/User/Register
'
;
import
RegisterResult
from
'
../routes/User/RegisterResult
'
;
import
RegisterResult
from
'
../routes/User/RegisterResult
'
;
function
userAdapter
(
userData
)
{
const
data
=
[{
userData
.
children
.
forEach
((
item
)
=>
{
component
:
BasicLayout
,
if
(
item
.
children
)
{
name
:
'
ι¦ι‘΅
'
,
// for breadcrumb
userAdapter
(
item
);
path
:
''
,
}
else
{
const
userItem
=
item
;
userItem
.
noRoute
=
true
;
}
});
return
userData
;
}
export
const
user
=
[{
name
:
'
εΈζ·
'
,
icon
:
'
user
'
,
path
:
'
user
'
,
children
:
[{
children
:
[{
name
:
'
η»ε½
'
,
path
:
'
login
'
,
component
:
Login
,
},
{
name
:
'
注ε
'
,
path
:
'
register
'
,
component
:
Register
,
},
{
name
:
'
注εη»ζ
'
,
path
:
'
register-result
'
,
component
:
RegisterResult
,
}],
}];
export
const
menus
=
[{
name
:
'
Dashboard
'
,
name
:
'
Dashboard
'
,
icon
:
'
dashboard
'
,
icon
:
'
dashboard
'
,
path
:
'
dashboard
'
,
path
:
'
dashboard
'
,
...
@@ -78,7 +51,7 @@ export const menus = [{
...
@@ -78,7 +51,7 @@ export const menus = [{
path
:
'
workplace
'
,
path
:
'
workplace
'
,
component
:
Workplace
,
component
:
Workplace
,
}],
}],
},
{
},
{
name
:
'
葨ει‘΅
'
,
name
:
'
葨ει‘΅
'
,
path
:
'
form
'
,
path
:
'
form
'
,
icon
:
'
form
'
,
icon
:
'
form
'
,
...
@@ -102,7 +75,7 @@ export const menus = [{
...
@@ -102,7 +75,7 @@ export const menus = [{
path
:
'
advanced-form
'
,
path
:
'
advanced-form
'
,
component
:
AdvancedForm
,
component
:
AdvancedForm
,
}],
}],
},
{
},
{
name
:
'
ε葨鑡
'
,
name
:
'
ε葨鑡
'
,
path
:
'
list
'
,
path
:
'
list
'
,
icon
:
'
table
'
,
icon
:
'
table
'
,
...
@@ -131,12 +104,12 @@ export const menus = [{
...
@@ -131,12 +104,12 @@ export const menus = [{
path
:
'
search
'
,
path
:
'
search
'
,
component
:
SearchList
,
component
:
SearchList
,
}],
}],
},
{
},
{
name
:
'
θ―¦ζ ι‘΅
'
,
name
:
'
θ―¦ζ ι‘΅
'
,
path
:
'
profile
'
,
path
:
'
profile
'
,
component
:
Profile
,
component
:
Profile
,
icon
:
'
profile
'
,
icon
:
'
profile
'
,
},
{
},
{
name
:
'
η»ζ
'
,
name
:
'
η»ζ
'
,
path
:
'
result
'
,
path
:
'
result
'
,
icon
:
'
check-circle-o
'
,
icon
:
'
check-circle-o
'
,
...
@@ -149,7 +122,7 @@ export const menus = [{
...
@@ -149,7 +122,7 @@ export const menus = [{
path
:
'
fail
'
,
path
:
'
fail
'
,
component
:
Error
,
component
:
Error
,
}],
}],
},
{
},
{
name
:
'
ιθ――
'
,
name
:
'
ιθ――
'
,
path
:
'
error
'
,
path
:
'
error
'
,
icon
:
'
warning
'
,
icon
:
'
warning
'
,
...
@@ -166,15 +139,31 @@ export const menus = [{
...
@@ -166,15 +139,31 @@ export const menus = [{
path
:
'
500
'
,
path
:
'
500
'
,
component
:
Exception500
,
component
:
Exception500
,
}],
}],
},
userAdapter
(
JSON
.
parse
(
JSON
.
stringify
(
user
[
0
])))];
}],
export
default
[{
component
:
BasicLayout
,
name
:
'
ι¦ι‘΅
'
,
children
:
menus
,
path
:
''
,
},
{
},
{
component
:
UserLayout
,
component
:
UserLayout
,
name
:
'
账ζ·
'
,
children
:
[{
children
:
user
,
name
:
'
εΈζ·
'
,
icon
:
'
user
'
,
path
:
'
user
'
,
children
:
[{
name
:
'
η»ε½
'
,
path
:
'
login
'
,
component
:
Login
,
},
{
name
:
'
注ε
'
,
path
:
'
register
'
,
component
:
Register
,
},
{
name
:
'
注εη»ζ
'
,
path
:
'
register-result
'
,
component
:
RegisterResult
,
}],
}],
}];
}];
export
function
getNavData
()
{
return
data
;
}
export
default
data
;
src/layouts/BasicLayout.js
View file @
e2f62c6d
...
@@ -10,7 +10,7 @@ import styles from './BasicLayout.less';
...
@@ -10,7 +10,7 @@ import styles from './BasicLayout.less';
import
HeaderSearch
from
'
../components/HeaderSearch
'
;
import
HeaderSearch
from
'
../components/HeaderSearch
'
;
import
NoticeIcon
from
'
../components/NoticeIcon
'
;
import
NoticeIcon
from
'
../components/NoticeIcon
'
;
import
GlobalFooter
from
'
../components/GlobalFooter
'
;
import
GlobalFooter
from
'
../components/GlobalFooter
'
;
import
{
menus
}
from
'
../common/nav
'
;
import
{
getNavData
}
from
'
../common/nav
'
;
const
{
Header
,
Sider
,
Content
}
=
Layout
;
const
{
Header
,
Sider
,
Content
}
=
Layout
;
const
{
SubMenu
}
=
Menu
;
const
{
SubMenu
}
=
Menu
;
...
@@ -20,6 +20,11 @@ class BasicLayout extends React.PureComponent {
...
@@ -20,6 +20,11 @@ class BasicLayout extends React.PureComponent {
routes
:
PropTypes
.
array
,
routes
:
PropTypes
.
array
,
params
:
PropTypes
.
object
,
params
:
PropTypes
.
object
,
}
}
constructor
(
props
)
{
super
(
props
);
// ζδΈηΊ§ Layout η children δ½δΈΊθει‘Ή
this
.
menus
=
getNavData
().
reduce
((
arr
,
current
)
=>
arr
.
concat
(
current
.
children
),
[]);
}
state
=
{
state
=
{
mode
:
'
inline
'
,
mode
:
'
inline
'
,
};
};
...
@@ -52,11 +57,14 @@ class BasicLayout extends React.PureComponent {
...
@@ -52,11 +57,14 @@ class BasicLayout extends React.PureComponent {
const
{
location
:
{
pathname
}
}
=
this
.
props
;
const
{
location
:
{
pathname
}
}
=
this
.
props
;
const
keys
=
pathname
.
split
(
'
/
'
).
slice
(
1
);
const
keys
=
pathname
.
split
(
'
/
'
).
slice
(
1
);
if
(
keys
.
length
===
1
&&
keys
[
0
]
===
''
)
{
if
(
keys
.
length
===
1
&&
keys
[
0
]
===
''
)
{
return
[
menus
[
0
].
key
];
return
[
this
.
menus
[
0
].
key
];
}
}
return
keys
;
return
keys
;
}
}
getNavMenuItems
(
menusData
,
parentPath
=
''
)
{
getNavMenuItems
(
menusData
,
parentPath
=
''
)
{
if
(
!
menusData
)
{
return
[];
}
return
menusData
.
map
((
item
)
=>
{
return
menusData
.
map
((
item
)
=>
{
if
(
!
item
.
name
)
{
if
(
!
item
.
name
)
{
return
null
;
return
null
;
...
@@ -186,7 +194,7 @@ class BasicLayout extends React.PureComponent {
...
@@ -186,7 +194,7 @@ class BasicLayout extends React.PureComponent {
style
=
{{
margin
:
'
24px 0
'
,
width
:
'
100%
'
}}
style
=
{{
margin
:
'
24px 0
'
,
width
:
'
100%
'
}}
inlineIndent
=
{
32
}
inlineIndent
=
{
32
}
>
>
{
this
.
getNavMenuItems
(
menus
)}
{
this
.
getNavMenuItems
(
this
.
menus
)}
<
/Menu
>
<
/Menu
>
<
/Sider
>
<
/Sider
>
<
Layout
>
<
Layout
>
...
...
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