Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
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
ReactWeb5
CivWeb
Commits
06b476a4
Commit
06b476a4
authored
3 years ago
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复菜单没有加载情况
parent
6db8af2d
master
dev
devNew
feat/layout-flat
patch-1
soundai
test
zhongyi
No related merge requests found
Pipeline
#46834
passed with stages
in 9 minutes 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
43 deletions
+70
-43
BasicLayout1.js
src/layouts/BasicLayout1.js
+69
-42
micro.js
src/micro.js
+1
-1
No files found.
src/layouts/BasicLayout1.js
View file @
06b476a4
...
...
@@ -19,6 +19,7 @@ import {
Menu
,
Tooltip
,
ConfigProvider
,
Skeleton
}
from
'antd'
;
// import { RouteWithSubRoutes, renderRoutes } from '../utils/routes';
// import { renderRoutes } from 'react-router-config';
...
...
@@ -258,7 +259,7 @@ const BasicLayout = props => {
const
[
childrenRoutes
,
setChildrenRoutes
]
=
useState
([]);
const
[
selectedKeys
,
setSelectedKeys
]
=
useState
([]);
const
[
tabActiveKey
,
setTabActiveKey
]
=
useState
(
"1"
);
// const [currentRoutes, setCurrentRoutes] = useState([]
);
const
[
currentRoutes
,
setCurrentRoutes
]
=
useState
({}
);
const
[
siteAction
,
setSiteAction
]
=
useState
(
()
=>
new
Site
(
props
,
setSiteLoading
),
);
...
...
@@ -267,9 +268,21 @@ const BasicLayout = props => {
const
history
=
useHistory
();
// 处理隐藏菜单
let
currentRoutes
=
props
.
route
.
routes
.
filter
(
item
=>
!
item
.
hideInMenu
)[
props
.
currentMenuIndex
];
useEffect
(()
=>
{
const
newRoutes
=
props
.
route
.
routes
.
filter
(
item
=>
!
item
.
hideInMenu
)[
props
.
currentMenuIndex
]
||
{};
if
(
!
_
.
isEqual
(
currentRoutes
,
newRoutes
))
{
setCurrentRoutes
({})
setSelectIndex
(
-
1
);
setCurrentRoutes
(
newRoutes
)
}
},
[
props
.
route
]);
// let currentRoutes = props.route.routes.filter(item => !item.hideInMenu)[props.currentMenuIndex];
//props.currentMenuIndex
useEffect
(()
=>
{
const
initSelectRoute
=
findPathByLeafId
(
`
${
props
.
location
&&
props
.
location
.
pathname
||
''
}
`
,
[
currentRoutes
],
...
...
@@ -304,6 +317,7 @@ const BasicLayout = props => {
if
(
!
props
.
global
.
get
(
'home'
))
{
url
=
`civweb4/
${
url
.
replace
(
/^
\/
/
,
''
).
replace
(
/^civweb4
\/
/
,
''
)}
`
}
setSelectIndex
(
-
1
)
setChildrenRoutes
([
{
icon
:
<
HomeIcon
/>
,
...
...
@@ -383,7 +397,7 @@ const BasicLayout = props => {
* web4全屏退出,切换三级菜单高亮
*/
useEffect
(()
=>
{
if
(
selectIndex
!==
-
1
)
{
if
(
selectIndex
!==
-
1
&&
currentRoutes
&&
currentRoutes
.
hasOwnProperty
(
'routes'
)
)
{
const
routes
=
currentRoutes
.
routes
[
selectIndex
];
if
(
routes
)
{
if
(
routes
&&
routes
.
routes
)
{
...
...
@@ -471,7 +485,7 @@ const BasicLayout = props => {
}
const
handlerSelectMenu
=
({
item
,
key
,
keyPath
,
domEvent
})
=>
{
debugger
setSelectedKeys
([
key
]);
window
.
history
.
pushState
(
null
,
''
,
`/civbase
${
key
}
`
);
}
...
...
@@ -549,44 +563,57 @@ const BasicLayout = props => {
})}
>
<
div
className
=
{
layoutStyles
[
'layout-slider-childern'
]}
>
<
div
className
=
{
layoutStyles
.
sliderMenu
}
style
=
{{
flex
:
'1 1 0%'
,
overflow
:
'hidden auto'
}}
>
<
ul
className
=
{
classNames
(
layoutStyles
.
menu
)}
style
=
{{
minHeight
:
'0px'
,
marginBottom
:
'0px'
}}
>
<
li
className
=
{
classNames
(
layoutStyles
[
'menu-item'
])}
onClick
=
{
handleToggleSystem
}
>
<
Tooltip
placement
=
"right"
title
=
{
collapse
?
currentRoutes
.
name
:
''
}
>
<
a
>
{
(
currentRoutes
&&
currentRoutes
.
extData
&&
currentRoutes
.
extData
.
icon
)
&&
<
img
src
=
{
currentRoutes
.
extData
.
icon
}
/
>
}
{
collapse
?
null
:
<
span
className
=
{
classNames
(
layoutStyles
.
text
,
layoutStyles
.
currentText
)}
>
{
currentRoutes
&&
currentRoutes
.
name
}
<
/span
>
}
<
/a
>
<
/Tooltip
>
<
/li
>
<
/ul
>
<
div
className
=
{
layoutStyles
.
splitLine
}
><
/div
>
<
ul
className
=
{
classNames
(
layoutStyles
.
menu
,
'menu-vertical'
)}
>
{
currentRoutes
&&
(
currentRoutes
.
routes
||
[]).
filter
(
item
=>
!
item
.
hideInMenu
).
map
((
item
,
index
)
=>
{
return
(
<
React
.
Fragment
key
=
{
index
}
>
<
li
key
=
{
index
}
className
=
{
classNames
(
layoutStyles
[
'menu-item'
],
{
[
layoutStyles
[
'active'
]]:
index
===
selectIndex
})}
onClick
=
{()
=>
handlerSecond
(
item
,
index
)}
>
<
Tooltip
placement
=
"right"
title
=
{
collapse
?
item
.
name
:
''
}
>
<
a
>
{
item
.
icon
?
item
.
icon
:
item
.
extData
&&
/.svg/
.
test
(
item
.
extData
.
icon
)
?
<
ReactSVG
src
=
{
item
.
extData
.
icon
}
style
=
{{
width
:
'20px'
,
height
:
'20px'
}}
className
=
{
layoutStyles
.
icon
}
/> : item.extData && <img src={item.extData.icon} /
>
}
{
collapse
?
item
.
extData
&&
<
span
className
=
{
classNames
(
layoutStyles
.
text
)}
>
{(
item
.
extData
.
shortName
||
item
.
name
).
substr
(
0
,
2
)}
<
/span> : <span className={classNames
(
layoutStyles.text
)
}>{item.name}</
span
>
}
<
/a
>
<
/Tooltip
>
<
/li
>
<
Divider
style
=
{{
border
:
'1px solid rgb(49, 53, 62, 0.3)'
,
margin
:
'0 auto'
,
minWidth
:
'80%'
,
width
:
'80%'
}}
/
>
<
/React.Fragment
>
)
})
}
<
/ul
>
{
<
div
style
=
{{
padding
:
currentRoutes
&&
!
currentRoutes
.
routes
?
'20px 6px 6px 6px'
:
'0px'
}}
><
Skeleton
loading
=
{
currentRoutes
&&
!
currentRoutes
.
routes
}
active
title
=
{
false
}
paragraph
=
{{
rows
:
10
}}
/
>
{
currentRoutes
&&
currentRoutes
.
routes
&&
currentRoutes
.
routes
.
length
>
0
&&
<
React
.
Fragment
>
<
ul
className
=
{
classNames
(
layoutStyles
.
menu
)}
style
=
{{
minHeight
:
'0px'
,
marginBottom
:
'0px'
}}
>
<
li
className
=
{
classNames
(
layoutStyles
[
'menu-item'
])}
onClick
=
{
handleToggleSystem
}
>
<
Tooltip
placement
=
"right"
title
=
{
collapse
?
currentRoutes
.
name
:
''
}
>
<
a
>
{
(
currentRoutes
&&
currentRoutes
.
extData
&&
currentRoutes
.
extData
.
icon
)
&&
<
img
src
=
{
currentRoutes
.
extData
.
icon
}
/
>
}
{
collapse
?
null
:
<
span
className
=
{
classNames
(
layoutStyles
.
text
,
layoutStyles
.
currentText
)}
>
{
currentRoutes
&&
currentRoutes
.
name
}
<
/span
>
}
<
/a
>
<
/Tooltip
>
<
/li
>
<
/ul
>
<
div
className
=
{
layoutStyles
.
splitLine
}
><
/div
>
<
ul
className
=
{
classNames
(
layoutStyles
.
menu
,
'menu-vertical'
)}
>
{
currentRoutes
&&
(
currentRoutes
.
routes
||
[]).
filter
(
item
=>
!
item
.
hideInMenu
).
map
((
item
,
index
)
=>
{
return
(
<
React
.
Fragment
key
=
{
index
}
>
<
li
key
=
{
index
}
className
=
{
classNames
(
layoutStyles
[
'menu-item'
],
{
[
layoutStyles
[
'active'
]]:
index
===
selectIndex
})}
onClick
=
{()
=>
handlerSecond
(
item
,
index
)}
>
<
Tooltip
placement
=
"right"
title
=
{
collapse
?
item
.
name
:
''
}
>
<
a
>
{
item
.
icon
?
item
.
icon
:
item
.
extData
&&
/.svg/
.
test
(
item
.
extData
.
icon
)
?
<
ReactSVG
src
=
{
item
.
extData
.
icon
}
style
=
{{
width
:
'20px'
,
height
:
'20px'
}}
className
=
{
layoutStyles
.
icon
}
/> : item.extData && <img src={item.extData.icon} /
>
}
{
collapse
?
item
.
extData
&&
<
span
className
=
{
classNames
(
layoutStyles
.
text
)}
>
{(
item
.
extData
.
shortName
||
item
.
name
).
substr
(
0
,
2
)}
<
/span> : <span className={classNames
(
layoutStyles.text
)
}>{item.name}</
span
>
}
<
/a
>
<
/Tooltip
>
<
/li
>
<
Divider
style
=
{{
border
:
'1px solid rgb(49, 53, 62, 0.3)'
,
margin
:
'0 auto'
,
minWidth
:
'80%'
,
width
:
'80%'
}}
/
>
<
/React.Fragment
>
)
})
}
<
/ul
>
<
/React.Fragment
>
}
<
/div
>
}
<
/div
>
<
div
className
=
"ant-pro-sider-links"
>
<
ul
className
=
"ant-menu ant-menu-root ant-menu-inline ant-menu-dark ant-pro-sider-link-menu"
role
=
"menu"
tabIndex
=
"0"
>
...
...
This diff is collapsed.
Click to expand it.
src/micro.js
View file @
06b476a4
...
...
@@ -139,7 +139,7 @@ export const initMicroApps = () => {
loose
:
true
,
},
singular
:
false
,
scopedCSS
:
fals
e
,
scopedCSS
:
tru
e
,
prefetch
:
'all'
,
// eslint-disable-next-line no-underscore-dangle
// getPublicPath: window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__,
...
...
This diff is collapsed.
Click to expand it.
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