Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
e78d7128
Commit
e78d7128
authored
Oct 30, 2020
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善菜单 openKeys 逻辑
parent
87e75412
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
BasicLayout.tsx
src/layouts/BasicLayout.tsx
+7
-2
No files found.
src/layouts/BasicLayout.tsx
View file @
e78d7128
...
...
@@ -113,18 +113,23 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
},
[
location
.
pathname
]);
// 当 currentRouter 改变时(路由触发所致),设置 Menu openKeys 为 currentRouter 的祖先路由记录
// 当 菜单 收缩时 收起所有菜单,打开执行上面的逻辑
// 这里处理的逻辑都是由 路由改变 引起的,需要配合 点击 SubMenu 也是需要设置一遍 openKeys 一起达到理想的效果
// 注:点击 SubMenu 不会触发路由跳转
useEffect
(()
=>
{
if
(
menuRouter
&&
menuRouter
.
children
&&
currentRouter
)
{
if
(
collapsed
)
{
setOpenKeys
([])
}
else
{
// 优化默认打开的菜单
setOpenKeys
([...
openKeys
,
currentRouter
.
key
,
...
currentRouter
.
pro_layout_parentKeys
])
// setOpenKeys([...openKeys, currentRouter.key, ...currentRouter.pro_layout_parentKeys])
setOpenKeys
(
currentRouter
.
pro_layout_parentKeys
)
}
}
else
{
setOpenKeys
([])
}
},
[
currentRouter
,
location
.
pathname
,
collapsed
])
},
[
currentRouter
,
collapsed
])
return
(
<
ProLayout
...
...
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