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
8cd95b36
Commit
8cd95b36
authored
Sep 24, 2021
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 优化
parent
07468e06
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
27 deletions
+48
-27
index.js
src/pages/commonMenu/index.js
+43
-27
index.less
src/pages/commonMenu/index.less
+5
-0
No files found.
src/pages/commonMenu/index.js
View file @
8cd95b36
...
@@ -2,9 +2,11 @@
...
@@ -2,9 +2,11 @@
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
;
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
;
import
{
Link
}
from
'react-router-dom'
;
import
{
Link
}
from
'react-router-dom'
;
import
{
Input
,
Button
,
Tree
,
notification
,
Spin
,
message
}
from
'antd'
;
import
{
Input
,
Button
,
Tree
,
notification
,
Spin
,
message
}
from
'antd'
;
import
{
connect
}
from
'react-redux'
;
import
classnames
from
'classnames'
;
import
classnames
from
'classnames'
;
import
{
appService
}
from
'@/api'
;
import
{
appService
}
from
'@/api'
;
import
{
useHistory
}
from
'@wisdom-utils/runtime'
;
import
{
savePagePartInfo
}
from
'@/api/service/base'
;
import
{
savePagePartInfo
}
from
'@/api/service/base'
;
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
thumbnail
from
'../../assets/images/commonMenu/常用菜单.png'
;
import
thumbnail
from
'../../assets/images/commonMenu/常用菜单.png'
;
...
@@ -15,13 +17,15 @@ const isNeedFilterIcon = (icon = '') => {
...
@@ -15,13 +17,15 @@ const isNeedFilterIcon = (icon = '') => {
return
!
icon
.
includes
(
'一级'
)
&&
!
icon
.
includes
(
'ios/'
);
return
!
icon
.
includes
(
'一级'
)
&&
!
icon
.
includes
(
'ios/'
);
};
};
const
CommonMenu
=
()
=>
{
const
CommonMenu
=
props
=>
{
const
history
=
useHistory
();
const
[
menus
,
setMenus
]
=
useState
([]);
// 常用菜单信息
const
[
menus
,
setMenus
]
=
useState
([]);
// 常用菜单信息
const
[
widgets
,
setWidgets
]
=
useState
([]);
// 菜单列表信息
const
[
widgets
,
setWidgets
]
=
useState
([]);
// 菜单列表信息
const
[
showMenuInfo
,
setShowMenuInfo
]
=
useState
(
false
);
// 菜单列表显示隐藏
const
[
showMenuInfo
,
setShowMenuInfo
]
=
useState
(
false
);
// 菜单列表显示隐藏
const
[
loading
,
setLoading
]
=
useState
(
true
);
// loading显示隐藏
const
[
loading
,
setLoading
]
=
useState
(
true
);
// loading显示隐藏
const
[
searchInfo
,
setSearchInfo
]
=
useState
(
''
);
const
[
searchInfo
,
setSearchInfo
]
=
useState
(
''
);
const
page
=
useRef
(
null
);
const
page
=
useRef
(
null
);
const
searchBox
=
useRef
(
null
);
const
defaultSubmitMenu
=
()
=>
{
const
defaultSubmitMenu
=
()
=>
{
let
submitData
=
[];
let
submitData
=
[];
...
@@ -253,35 +257,45 @@ const CommonMenu = () => {
...
@@ -253,35 +257,45 @@ const CommonMenu = () => {
});
});
};
};
return
(
const
linkToMenu
=
menu
=>
{
<
div
const
{
menuUrl
}
=
menu
;
className
=
{
styles
.
commonMenu
}
console
.
log
(
props
);
ref
=
{
page
}
history
.
push
(
`civweb4/
${
menuUrl
}
`
);
onClick
=
{
e
=>
{
};
const
focusOutSearchInfo
=
e
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
if
(
e
.
target
===
page
.
current
)
setShowMenuInfo
(
false
);
let
element
=
e
.
target
;
}}
// 事件对象逐层网上找,只要不是菜单搜索信息内的就隐藏起来
>
while
(
element
&&
element
!==
page
.
current
)
{
if
(
element
===
searchBox
.
current
)
return
;
element
=
element
.
parentNode
;
}
setShowMenuInfo
(
false
);
};
return
(
<
div
className
=
{
styles
.
commonMenu
}
ref
=
{
page
}
onClick
=
{
focusOutSearchInfo
}
>
<
Spin
spinning
=
{
loading
}
>
<
Spin
spinning
=
{
loading
}
>
<
div
className
=
{
styles
.
searchWrapper
}
>
<
div
className
=
{
styles
.
searchWrapper
}
>
<
div
className
=
{
styles
.
searchBox
}
>
<
div
className
=
{
styles
.
searchBox
}
ref
=
{
searchBox
}
>
<
div
className
=
{
styles
.
searchTitle
}
>
<
div
className
=
{
styles
.
searchTitle
}
>
<
i
className
=
"iconfont"
>&
#
xe611
;
<
/i
>
<
i
className
=
"iconfont"
>&
#
xe611
;
<
/i
>
<
span
>
我的常用菜单
<
/span
>
<
span
>
我的常用菜单
<
/span
>
<
span
>
(
{
menus
.
length
}
)
<
/span
>
<
span
>
(
{
menus
.
length
}
)
<
/span
>
<
/div
>
<
/div
>
<
div
>
<
div
className
=
{
styles
.
searchInput
}
>
<
div
className
=
{
styles
.
searchInput
}
>
<
Input
.
Search
<
Input
maxLength
=
{
50
}
width
=
{
400
}
placeholder
=
"搜索功能菜单"
placeholder
=
"搜索功能菜单"
// onFocus={() => setShowMenuInfo(true)}
onChange
=
{
e
=>
{
onSearch
=
{
info
=>
{
setShowMenuInfo
(
true
);
setShowMenuInfo
(
true
);
setSearchInfo
(
info
);
setSearchInfo
(
e
.
target
.
value
);
}}
}}
onFocus
=
{()
=>
setShowMenuInfo
(
true
)}
/
>
/
>
<
/div
>
<
/div
>
<
/div
>
<
div
<
div
className
=
{
classnames
(
className
=
{
classnames
(
styles
.
searchInfoBox
,
styles
.
searchInfoBox
,
...
@@ -304,7 +318,7 @@ const CommonMenu = () => {
...
@@ -304,7 +318,7 @@ const CommonMenu = () => {
<
/div
>
<
/div
>
<
div
className
=
{
styles
.
menuCardWrapper
}
>
<
div
className
=
{
styles
.
menuCardWrapper
}
>
{
menus
.
map
(
item
=>
(
{
menus
.
map
(
item
=>
(
<
MenuCard
menu
=
{
item
}
/
>
<
MenuCard
menu
=
{
item
}
linkToMenu
=
{
linkToMenu
}
/
>
))}
))}
<
/div
>
<
/div
>
<
div
className
=
{
styles
.
pageLogo
}
>
<
div
className
=
{
styles
.
pageLogo
}
>
...
@@ -315,16 +329,12 @@ const CommonMenu = () => {
...
@@ -315,16 +329,12 @@ const CommonMenu = () => {
);
);
};
};
const
MenuCard
=
({
menu
})
=>
{
const
MenuCard
=
({
menu
,
linkToMenu
})
=>
{
const
{
menuIcon
,
menuName
,
menuGroup
,
menuID
,
menuUrl
,
menuPic
}
=
menu
;
const
{
menuIcon
,
menuName
,
menuGroup
,
menuID
,
menuUrl
,
menuPic
}
=
menu
;
return
(
return
(
<
div
className
=
{
styles
.
menuCard
}
>
<
div
className
=
{
styles
.
menuCard
}
onClick
=
{()
=>
linkToMenu
(
menu
)}
>
<
Link
to
=
{
menuUrl
}
title
=
{
menuName
}
>
{
/* <Link to={menuUrl} title={menuName}> */
}
<
img
<
img
className
=
{
styles
.
cardThumbnail
}
src
=
{
menuPic
||
thumbnail
}
alt
=
""
/>
className
=
{
styles
.
cardThumbnail
}
src
=
{
menuPic
||
thumbnail
}
alt
=
""
/>
<
div
className
=
{
styles
.
cardLabel
}
>
<
div
className
=
{
styles
.
cardLabel
}
>
<
div
<
div
className
=
{
classnames
(
className
=
{
classnames
(
...
@@ -339,9 +349,15 @@ const MenuCard = ({ menu }) => {
...
@@ -339,9 +349,15 @@ const MenuCard = ({ menu }) => {
<
/div
>
<
/div
>
<
div
className
=
{
styles
.
cardGroup
}
>
{
menuGroup
}
<
/div
>
<
div
className
=
{
styles
.
cardGroup
}
>
{
menuGroup
}
<
/div
>
<
/div
>
<
/div
>
<
/Link
>
{
/* </Link> */
}
<
/div
>
<
/div
>
);
);
};
};
export
default
CommonMenu
;
const
mapStateToProps
=
state
=>
({
menu
:
state
.
getIn
([
'global'
,
'menu'
]),
});
export
default
connect
(
mapStateToProps
,
null
,
)(
CommonMenu
);
src/pages/commonMenu/index.less
View file @
8cd95b36
...
@@ -55,6 +55,11 @@
...
@@ -55,6 +55,11 @@
color: #3B7FDF;
color: #3B7FDF;
}
}
}
}
.searchInput {
flex: 1;
overflow: hidden;
margin-left: 50px;
}
.searchInfoBox {
.searchInfoBox {
width: 100%;
width: 100%;
height: 400px;
height: 400px;
...
...
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