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
f7fa3988
Commit
f7fa3988
authored
Sep 06, 2017
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only open current menu
parent
32693bbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/layouts/BasicLayout.js
src/layouts/BasicLayout.js
+15
-5
No files found.
src/layouts/BasicLayout.js
View file @
f7fa3988
...
@@ -24,6 +24,9 @@ class BasicLayout extends React.PureComponent {
...
@@ -24,6 +24,9 @@ class BasicLayout extends React.PureComponent {
super
(
props
);
super
(
props
);
// ζδΈηΊ§ Layout η children δ½δΈΊθει‘Ή
// ζδΈηΊ§ Layout η children δ½δΈΊθει‘Ή
this
.
menus
=
getNavData
().
reduce
((
arr
,
current
)
=>
arr
.
concat
(
current
.
children
),
[]);
this
.
menus
=
getNavData
().
reduce
((
arr
,
current
)
=>
arr
.
concat
(
current
.
children
),
[]);
this
.
state
=
{
openKeys
:
this
.
getDefaultCollapsedSubMenus
(
props
),
};
}
}
state
=
{
state
=
{
mode
:
'
inline
'
,
mode
:
'
inline
'
,
...
@@ -48,13 +51,13 @@ class BasicLayout extends React.PureComponent {
...
@@ -48,13 +51,13 @@ class BasicLayout extends React.PureComponent {
this
.
props
.
dispatch
(
routerRedux
.
push
(
'
/user/login
'
));
this
.
props
.
dispatch
(
routerRedux
.
push
(
'
/user/login
'
));
}
}
}
}
getDefaultCollapsedSubMenus
()
{
getDefaultCollapsedSubMenus
(
props
)
{
const
currentMenuSelectedKeys
=
[...
this
.
getCurrentMenuSelectedKeys
()];
const
currentMenuSelectedKeys
=
[...
this
.
getCurrentMenuSelectedKeys
(
props
)];
currentMenuSelectedKeys
.
splice
(
-
1
,
1
);
currentMenuSelectedKeys
.
splice
(
-
1
,
1
);
return
currentMenuSelectedKeys
;
return
currentMenuSelectedKeys
;
}
}
getCurrentMenuSelectedKeys
()
{
getCurrentMenuSelectedKeys
(
props
)
{
const
{
location
:
{
pathname
}
}
=
this
.
props
;
const
{
location
:
{
pathname
}
}
=
props
||
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
[
this
.
menus
[
0
].
key
];
return
[
this
.
menus
[
0
].
key
];
...
@@ -132,6 +135,12 @@ class BasicLayout extends React.PureComponent {
...
@@ -132,6 +135,12 @@ class BasicLayout extends React.PureComponent {
});
});
return
groupBy
(
newNotices
,
'
type
'
);
return
groupBy
(
newNotices
,
'
type
'
);
}
}
handleOpenChange
=
(
openKeys
)
=>
{
const
latestOpenKey
=
openKeys
.
find
(
key
=>
this
.
state
.
openKeys
.
find
(
key
));
this
.
setState
({
openKeys
:
latestOpenKey
?
[
latestOpenKey
]
:
[],
});
}
toggle
=
()
=>
{
toggle
=
()
=>
{
const
{
collapsed
}
=
this
.
props
;
const
{
collapsed
}
=
this
.
props
;
this
.
props
.
dispatch
({
this
.
props
.
dispatch
({
...
@@ -189,7 +198,8 @@ class BasicLayout extends React.PureComponent {
...
@@ -189,7 +198,8 @@ class BasicLayout extends React.PureComponent {
<
Menu
<
Menu
theme
=
"
dark
"
theme
=
"
dark
"
mode
=
"
inline
"
mode
=
"
inline
"
defaultOpenKeys
=
{
this
.
getDefaultCollapsedSubMenus
()}
openKeys
=
{
this
.
state
.
openKeys
}
onOpenChange
=
{
this
.
handleOpenChange
}
selectedKeys
=
{
this
.
getCurrentMenuSelectedKeys
()}
selectedKeys
=
{
this
.
getCurrentMenuSelectedKeys
()}
style
=
{{
margin
:
'
24px 0
'
,
width
:
'
100%
'
}}
style
=
{{
margin
:
'
24px 0
'
,
width
:
'
100%
'
}}
inlineIndent
=
{
32
}
inlineIndent
=
{
32
}
...
...
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