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
shenshaokai
jinfa-platform
Commits
e77a6044
Commit
e77a6044
authored
Sep 21, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化菜单拉取
parent
b8ee832c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
BasicLayout.tsx
src/layouts/BasicLayout.tsx
+6
-9
No files found.
src/layouts/BasicLayout.tsx
View file @
e77a6044
...
...
@@ -94,12 +94,6 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
let
list
=
routes
.
filter
((
item
:
any
)
=>
pathname
.
indexOf
(
item
.
key
)
>
-
1
)
return
list
[
0
]
}
const
initOpendKeys
=
(
routes
:
any
)
=>
{
if
(
routes
)
{
return
routes
.
map
((
item
:
any
)
=>
item
.
key
)
}
return
[]
}
const
{
formatMessage
}
=
useIntl
();
const
basicInfo
=
getMenuData
(
props
.
route
.
routes
,
{
locale
:
true
},
formatMessage
)
...
...
@@ -107,6 +101,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
const
menuRouter
=
getMenuRouter
(
menuData
,
location
.
pathname
)
const
currentRouter
=
basicInfo
.
breadcrumb
[
location
.
pathname
];
useEffect
(()
=>
{
// if pathname can't match, use the nearest parent's key
const
keys
=
getSelectedMenuKeys
(
...
...
@@ -125,13 +121,13 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
if
(
collapsed
)
{
setOpenKeys
([])
}
else
{
setOpenKeys
(
initOpendKeys
(
menuRouter
.
children
))
// 优化默认打开的菜单
setOpenKeys
([...
openKeys
,
currentRouter
.
key
,
...
currentRouter
.
pro_layout_parentKeys
])
}
}
else
{
setOpenKeys
([])
}
},
[
location
.
pathname
,
collapsed
])
},
[
currentRouter
,
location
.
pathname
,
collapsed
])
return
(
<
ProLayout
style=
{
{
minHeight
:
'100vh'
}
}
...
...
@@ -145,6 +141,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
)
}
collapsed=
{
collapsed
}
onCollapse=
{
handleMenuCollapse
}
disableContentMargin=
{
currentRouter
.
noMargin
!==
undefined
}
breadcrumbRender=
{
(
routers
=
[])
=>
[
]
}
...
...
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