Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
f8c683d4
Commit
f8c683d4
authored
Jun 25, 2021
by
zhujian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'fix'
parent
ffead757
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
src/modules/root/Menu.tsx
+22
-10
No files found.
src/modules/root/Menu.tsx
View file @
f8c683d4
import
React
,
{
Key
,
useContext
,
useEffect
,
useRef
,
useState
}
from
'react'
;
import
React
,
{
Key
,
useContext
,
useEffect
,
useRef
,
useState
,
useMemo
}
from
'react'
;
import
{
import
{
withRouter
,
withRouter
,
}
from
'react-router-dom'
;
}
from
'react-router-dom'
;
import
{
Menu
}
from
'antd'
;
import
{
Menu
}
from
'antd'
;
import
{
menuList
}
from
'../../routes//config/menuList'
import
{
menuList
}
from
'../../routes//config/menuList'
import
{
XMContext
}
from
'../../store/context'
;
import
{
XMContext
}
from
'../../store/context'
;
import
Service
from
"@/common/js/service"
;
import
Service
from
"@/common/js/service"
;
...
@@ -13,13 +13,14 @@ import "./Menu.less";
...
@@ -13,13 +13,14 @@ import "./Menu.less";
const
{
SubMenu
}
=
Menu
;
const
{
SubMenu
}
=
Menu
;
function
Aside
(
props
:
any
)
{
function
Aside
(
props
:
any
)
{
const
{
menuType
,
handleMenuType
}
=
props
const
{
menuType
,
handleMenuType
}
=
props
const
ctx
:
any
=
useContext
(
XMContext
);
const
ctx
:
any
=
useContext
(
XMContext
);
const
[
selectKey
,
setSelectKey
]
=
useState
();
const
[
selectKey
,
setSelectKey
]
=
useState
();
const
[
openKeys
,
setOpenKeys
]
=
useState
([
''
]);
const
[
openKeys
,
setOpenKeys
]
=
useState
([
''
]);
const
[
topLogoUrl
,
setTopLogoUrl
]
=
useState
(
""
)
const
[
topLogoUrl
,
setTopLogoUrl
]
=
useState
(
""
)
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
)
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
)
const
rootSubmenuKeys
=
_
.
pluck
(
menuList
,
'groupCode'
);
const
rootSubmenuKeys
=
_
.
pluck
(
menuList
,
'groupCode'
);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
link
=
props
.
location
.
pathname
;
const
link
=
props
.
location
.
pathname
;
menuList
.
map
((
item
:
any
,
index
:
any
)
=>
{
menuList
.
map
((
item
:
any
,
index
:
any
)
=>
{
...
@@ -36,13 +37,14 @@ function Aside(props: any) {
...
@@ -36,13 +37,14 @@ function Aside(props: any) {
return
item
;
return
item
;
})
})
},
[
props
.
location
.
pathname
])
},
[
props
.
location
.
pathname
])
useEffect
(()
=>
{
useEffect
(()
=>
{
getTopLeftLogo
()
getTopLeftLogo
()
},[])
},
[])
function
getTopLeftLogo
()
{
function
getTopLeftLogo
()
{
if
(
User
.
getToken
())
{
if
(
User
.
getToken
())
{
StoreService
.
getStoreDetail
({
storeId
:
User
.
getStoreId
()
})
StoreService
.
getStoreDetail
({
storeId
:
User
.
getStoreId
()
})
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
_
.
isEmpty
(
res
.
result
.
logo
))
{
if
(
_
.
isEmpty
(
res
.
result
.
logo
))
{
setTopLogoUrl
(
"https://image.xiaomaiketang.com/xm/fe4NCjr7XF.png"
)
setTopLogoUrl
(
"https://image.xiaomaiketang.com/xm/fe4NCjr7XF.png"
)
}
else
{
}
else
{
...
@@ -52,12 +54,14 @@ function Aside(props: any) {
...
@@ -52,12 +54,14 @@ function Aside(props: any) {
})
})
}
}
}
}
function
toggleMenu
(
item
:
any
)
{
function
toggleMenu
(
item
:
any
)
{
window
.
RCHistory
.
push
(
item
.
link
)
window
.
RCHistory
.
push
(
item
.
link
)
if
(
!
menuType
)
{
if
(
!
menuType
)
{
setOpenKeys
([])
setOpenKeys
([])
}
}
}
}
function
onOpenChange
(
key
:
Key
[])
{
function
onOpenChange
(
key
:
Key
[])
{
if
(
typeof
key
===
"string"
)
{
if
(
typeof
key
===
"string"
)
{
if
(
openKeys
.
includes
(
key
))
{
if
(
openKeys
.
includes
(
key
))
{
...
@@ -86,6 +90,13 @@ function Aside(props: any) {
...
@@ -86,6 +90,13 @@ function Aside(props: any) {
setCollapsed
(
!
collapsed
)
setCollapsed
(
!
collapsed
)
}
}
const
openKeysConstrol
=
useMemo
(()
=>
{
return
{
[
menuType
?
'openKeys '
:
'defaultOpenKeys'
]:
openKeys
};
},
[
menuType
,
openKeys
])
return
(
return
(
<
div
<
div
id=
"left-container"
id=
"left-container"
...
@@ -97,7 +108,7 @@ function Aside(props: any) {
...
@@ -97,7 +108,7 @@ function Aside(props: any) {
>
>
<
div
className=
"top-ctrl"
>
<
div
className=
"top-ctrl"
>
<
div
className=
"topLogo"
>
<
div
className=
"topLogo"
>
{
menuType
&&
<
img
src=
{
topLogoUrl
}
alt=
""
className=
"img1"
></
img
>
}
{
menuType
&&
<
img
src=
{
topLogoUrl
}
alt=
""
className=
"img1"
></
img
>
}
</
div
>
</
div
>
<
div
className=
"menu-type-icon"
onClick=
{
handleMenu
}
>
<
div
className=
"menu-type-icon"
onClick=
{
handleMenu
}
>
{
menuType
?
(
{
menuType
?
(
...
@@ -120,9 +131,10 @@ function Aside(props: any) {
...
@@ -120,9 +131,10 @@ function Aside(props: any) {
<
div
className=
"nav"
>
<
div
className=
"nav"
>
<
Menu
<
Menu
style=
{
menuType
?
{
minHeight
:
"100%"
,
background
:
'#0E1935'
}:{
minHeight
:
"100%"
,
background
:
'#0E1935'
,
width
:
"56px"
}
}
{
...
openKeysConstrol
}
style=
{
menuType
?
{
minHeight
:
"100%"
,
background
:
'#0E1935'
}
:
{
minHeight
:
"100%"
,
background
:
'#0E1935'
,
width
:
"56px"
}
}
selectedKeys=
{
selectKey
}
selectedKeys=
{
selectKey
}
openKeys=
{
menuType
?
openKeys
:
[]
}
onOpenChange=
{
onOpenChange
}
onOpenChange=
{
onOpenChange
}
inlineCollapsed=
{
collapsed
}
inlineCollapsed=
{
collapsed
}
mode=
{
menuType
?
"inline"
:
"vertical"
}
mode=
{
menuType
?
"inline"
:
"vertical"
}
...
...
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