Skip to content

Commit

Permalink
fix: 左侧菜单收起后,组件菜单的子菜单显示不全
Browse files Browse the repository at this point in the history
  • Loading branch information
sumile-ting committed Jun 26, 2024
1 parent b523c28 commit 574055c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/Menu/src/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default defineComponent({
>
{{
default: () => {
const { renderMenuItem } = useRenderMenuItem()
const { renderMenuItem } = useRenderMenuItem(menuMode)
return renderMenuItem(unref(routers))
}
}}
Expand Down Expand Up @@ -257,4 +257,9 @@ export default defineComponent({
}
}
}
@submenu-prefix-cls: ~'@{adminNamespace}-submenu-popper';
.@{submenu-prefix-cls}--vertical {
overflow-y: auto;
max-height: 100%;
}
</style>
13 changes: 11 additions & 2 deletions src/components/Menu/src/components/useRenderMenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { ElSubMenu, ElMenuItem } from 'element-plus'
import { unref } from 'vue'
import { hasOneShowingChild } from '../helper'
import { isUrl } from '@/utils/is'
import { useRenderMenuTitle } from './useRenderMenuTitle'
import { pathResolve } from '@/utils/routerHelper'
import { useDesign } from '@/hooks/web/useDesign'

const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('submenu')

const { renderMenuTitle } = useRenderMenuTitle()

export const useRenderMenuItem = () =>
export const useRenderMenuItem = (menuMode) =>
// allRouters: AppRouteRecordRaw[] = [],
{
const renderMenuItem = (routers: AppRouteRecordRaw[], parentPath = '/') => {
Expand All @@ -33,7 +38,11 @@ export const useRenderMenuItem = () =>
)
} else {
return (
<ElSubMenu index={fullPath}>
<ElSubMenu
index={fullPath}
popper-append-to-body
popperClass={unref(menuMode) === 'vertical' ? `${prefixCls}-popper--vertical` : ''}
>
{{
title: () => renderMenuTitle(meta),
default: () => renderMenuItem(v.children!, fullPath)
Expand Down

0 comments on commit 574055c

Please sign in to comment.