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
996f9e55
Commit
996f9e55
authored
Feb 09, 2018
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhanced meun response
parent
7c0550f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
14 deletions
+39
-14
src/routes/Userinfo/Info.js
src/routes/Userinfo/Info.js
+39
-14
No files found.
src/routes/Userinfo/Info.js
View file @
996f9e55
import
React
,
{
Pure
Component
}
from
'
react
'
;
import
React
,
{
Component
}
from
'
react
'
;
import
{
connect
}
from
'
dva
'
;
import
{
Route
,
routerRedux
,
Switch
,
Redirect
}
from
'
dva/router
'
;
import
{
Menu
}
from
'
antd
'
;
import
Debounce
from
'
lodash-decorators/debounce
'
;
import
Bind
from
'
lodash-decorators/bind
'
;
import
styles
from
'
./Info.less
'
;
import
{
getRoutes
}
from
'
../../utils/utils
'
;
...
...
@@ -17,7 +19,7 @@ const menuMap = {
@
connect
(({
user
})
=>
({
currentUser
:
user
.
currentUser
,
}))
export
default
class
Info
extends
Pure
Component
{
export
default
class
Info
extends
Component
{
constructor
(
props
)
{
super
(
props
);
const
{
match
,
location
}
=
props
;
...
...
@@ -25,10 +27,20 @@ export default class Info extends PureComponent {
key
=
menuMap
[
key
]
?
key
:
'
base
'
;
this
.
state
=
{
selectKey
:
key
,
meunMode
:
'
inline
'
,
};
}
componentDidMount
()
{
this
.
resize
();
window
.
addEventListener
(
'
resize
'
,
this
.
resize
);
}
componentWillUnmount
()
{
window
.
removeEventListener
(
'
resize
'
,
this
.
resize
);
}
getmenu
=
()
=>
{
return
Object
.
keys
(
menuMap
).
map
(
item
=>
<
Item
key
=
{
item
}
>
{
menuMap
[
item
]}
<
/Item>
)
;
return
Object
.
keys
(
menuMap
).
map
(
item
=>
(
<
Item
key
=
{
item
}
>
{
menuMap
[
item
]}
<
/Item
>
));
};
getRightTitle
=
()
=>
{
return
menuMap
[
this
.
state
.
selectKey
];
...
...
@@ -39,6 +51,19 @@ export default class Info extends PureComponent {
selectKey
:
key
,
});
};
@
Bind
()
@
Debounce
(
200
)
resize
()
{
if
(
window
.
innerWidth
>
768
||
window
.
innerWidth
<
454
)
{
this
.
setState
({
meunMode
:
'
inline
'
,
});
return
;
}
this
.
setState
({
meunMode
:
'
horizontal
'
,
});
}
render
()
{
const
{
match
,
routerData
,
currentUser
}
=
this
.
props
;
if
(
!
currentUser
.
userid
)
{
...
...
@@ -48,7 +73,7 @@ export default class Info extends PureComponent {
<
div
className
=
{
styles
.
main
}
>
<
div
className
=
{
styles
.
leftmenu
}
>
<
Menu
mode
=
{
window
.
innerWidth
<
769
?
'
horizontal
'
:
'
inline
'
}
mode
=
{
this
.
state
.
meunMode
}
selectedKeys
=
{[
this
.
state
.
selectKey
]}
onClick
=
{
this
.
selectKey
}
>
...
...
@@ -58,16 +83,16 @@ export default class Info extends PureComponent {
<
div
className
=
{
styles
.
right
}
>
<
div
className
=
{
styles
.
title
}
>
{
this
.
getRightTitle
()}
<
/div
>
<
Switch
>
{
getRoutes
(
match
.
path
,
routerData
).
map
(
item
=>
(
<
Route
key
=
{
item
.
key
}
path
=
{
item
.
path
}
render
=
{
props
=>
<
item
.
component
{...
props
}
currentUser
=
{
currentUser
}
/>
}
exact
=
{
item
.
exact
}
/
>
))
}
{
getRoutes
(
match
.
path
,
routerData
).
map
(
item
=>
(
<
Route
key
=
{
item
.
key
}
path
=
{
item
.
path
}
render
=
{
props
=>
(
<
item
.
component
{...
props
}
currentUser
=
{
currentUser
}
/
>
)
}
exact
=
{
item
.
exact
}
/
>
))
}
<
Redirect
exact
from
=
"
/userinfo
"
to
=
"
/userinfo/base
"
/>
<
Redirect
to
=
"
/exception/404
"
/>
<
/Switch
>
...
...
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