Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ff0566bb
authored
Mar 01, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2024-02-06 fix: 修复Menu组件缩略菜单弹窗内样式不统一问题
parent
db106834
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
51 deletions
+47
-51
src/layout/components/Menu/src/components/useRenderMenuItem.tsx
+40
-49
src/layout/components/Menu/src/components/useRenderMenuTitle.tsx
+7
-2
No files found.
src/layout/components/Menu/src/components/useRenderMenuItem.tsx
View file @
ff0566bb
import
{
ElSubMenu
,
ElMenuItem
}
from
'element-plus'
import
{
ElSubMenu
,
ElMenuItem
}
from
'element-plus'
import
type
{
RouteMeta
}
from
'vue-router'
import
{
hasOneShowingChild
}
from
'../helper'
import
{
hasOneShowingChild
}
from
'../helper'
import
{
isUrl
}
from
'@/utils/is'
import
{
isUrl
}
from
'@/utils/is'
import
{
useRenderMenuTitle
}
from
'./useRenderMenuTitle'
import
{
useRenderMenuTitle
}
from
'./useRenderMenuTitle'
import
{
useDesign
}
from
'@/hooks/web/useDesign'
import
{
pathResolve
}
from
'@/utils/routerHelper'
import
{
pathResolve
}
from
'@/utils/routerHelper'
export
const
useRenderMenuItem
=
(
const
{
renderMenuTitle
}
=
useRenderMenuTitle
()
// allRouters: AppRouteRecordRaw[] = [],
menuMode
:
'vertical'
|
'horizontal'
)
=>
{
const
renderMenuItem
=
(
routers
:
AppRouteRecordRaw
[],
parentPath
=
'/'
)
=>
{
return
routers
.
map
((
v
)
=>
{
const
meta
=
(
v
.
meta
??
{})
as
RouteMeta
if
(
!
meta
.
hidden
)
{
const
{
oneShowingChild
,
onlyOneChild
}
=
hasOneShowingChild
(
v
.
children
,
v
)
const
fullPath
=
isUrl
(
v
.
path
)
?
v
.
path
:
pathResolve
(
parentPath
,
v
.
path
)
// getAllParentPath<AppRouteRecordRaw>(allRouters, v.path).join('/')
const
{
renderMenuTitle
}
=
useRenderMenuTitle
()
if
(
export
const
useRenderMenuItem
=
()
=>
oneShowingChild
&&
// allRouters: AppRouteRecordRaw[] = [],
(
!
onlyOneChild
?.
children
||
onlyOneChild
?.
noShowingChildren
)
&&
{
!
meta
?.
alwaysShow
const
renderMenuItem
=
(
routers
:
AppRouteRecordRaw
[],
parentPath
=
'/'
)
=>
{
)
{
return
routers
return
(
.
filter
((
v
)
=>
!
v
.
meta
?.
hidden
)
<
ElMenuItem
index=
{
onlyOneChild
?
pathResolve
(
fullPath
,
onlyOneChild
.
path
)
:
fullPath
}
>
.
map
((
v
)
=>
{
{
{
const
meta
=
v
.
meta
??
{}
default
:
()
=>
renderMenuTitle
(
onlyOneChild
?
onlyOneChild
?.
meta
:
meta
)
const
{
oneShowingChild
,
onlyOneChild
}
=
hasOneShowingChild
(
v
.
children
,
v
)
}
}
const
fullPath
=
isUrl
(
v
.
path
)
?
v
.
path
:
pathResolve
(
parentPath
,
v
.
path
)
// getAllParentPath<AppRouteRecordRaw>(allRouters, v.path).join('/')
</
ElMenuItem
>
)
}
else
{
const
{
getPrefixCls
}
=
useDesign
()
const
preFixCls
=
getPrefixCls
(
'menu-popper'
)
if
(
return
(
oneShowingChild
&&
<
ElSubMenu
(
!
onlyOneChild
?.
children
||
onlyOneChild
?.
noShowingChildren
)
&&
index=
{
fullPath
}
!
meta
?.
alwaysShow
popperClass=
{
)
{
menuMode
===
'vertical'
?
`${preFixCls}--vertical`
:
`${preFixCls}--horizontal`
return
(
}
<
ElMenuItem
>
index=
{
onlyOneChild
?
pathResolve
(
fullPath
,
onlyOneChild
.
path
)
:
fullPath
}
{
{
>
title
:
()
=>
renderMenuTitle
(
meta
),
{
{
default
:
()
=>
renderMenuItem
(
v
.
children
!
,
fullPath
)
default
:
()
=>
renderMenuTitle
(
onlyOneChild
?
onlyOneChild
?.
meta
:
meta
)
}
}
}
}
</
ElSubMenu
>
</
ElMenuItem
>
)
)
}
}
else
{
}
return
(
})
<
ElSubMenu
index=
{
fullPath
}
>
}
{
{
title
:
()
=>
renderMenuTitle
(
meta
),
default
:
()
=>
renderMenuItem
(
v
.
children
!
,
fullPath
)
}
}
</
ElSubMenu
>
)
}
})
}
return
{
return
{
renderMenuItem
renderMenuItem
}
}
}
}
src/layout/components/Menu/src/components/useRenderMenuTitle.tsx
View file @
ff0566bb
import
type
{
RouteMeta
}
from
'vue-router'
import
type
{
RouteMeta
}
from
'vue-router'
import
{
Icon
}
from
'@/components/Icon'
import
{
Icon
}
from
'@/components/Icon'
import
{
useI18n
}
from
'@/hooks/web/useI18n'
export
const
useRenderMenuTitle
=
()
=>
{
export
const
useRenderMenuTitle
=
()
=>
{
const
renderMenuTitle
=
(
meta
:
RouteMeta
)
=>
{
const
renderMenuTitle
=
(
meta
:
RouteMeta
)
=>
{
...
@@ -9,10 +10,14 @@ export const useRenderMenuTitle = () => {
...
@@ -9,10 +10,14 @@ export const useRenderMenuTitle = () => {
return
icon
?
(
return
icon
?
(
<>
<>
<
Icon
icon=
{
meta
.
icon
}
></
Icon
>
<
Icon
icon=
{
meta
.
icon
}
></
Icon
>
<
span
class=
"v-menu__title"
>
{
t
(
title
as
string
)
}
</
span
>
<
span
class=
"v-menu__title overflow-hidden overflow-ellipsis whitespace-nowrap"
>
{
t
(
title
as
string
)
}
</
span
>
</>
</>
)
:
(
)
:
(
<
span
class=
"v-menu__title"
>
{
t
(
title
as
string
)
}
</
span
>
<
span
class=
"v-menu__title overflow-hidden overflow-ellipsis whitespace-nowrap"
>
{
t
(
title
as
string
)
}
</
span
>
)
)
}
}
...
...
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