feat(web): 允许收起左侧菜单以让出内容宽度。

顶栏提供收起按钮,收起后侧栏宽度为 0,不再保留被挤压的图标条。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-11-05 09:39:47 +08:00
1 parent 8e9536332a
commit 13cf2e216d
9 files changed
+63 -7

No files matched your search

@@ -27,6 +27,9 @@
icon="fold"
class="ml-3 max-sm:ml-[7px] menu-fold-btn"
:class="{ 'is-menu-collapsed': !menuOpen }"
:title="menuOpen ? '收起菜单' : '展开菜单'"
:aria-label="menuOpen ? '收起菜单' : '展开菜单'"
:aria-expanded="menuOpen"
@click="visibleMenu"
/>
@@ -63,7 +63,7 @@
<div
v-show="menuList.length > 0"
class="menu-left"
:class="`menu-left-${getMenuTheme.theme} menu-left-${!menuOpen ? 'close' : 'open'}`"
:class="`menu-left-${getMenuTheme.theme} menu-left-${showIconRail ? 'close' : 'open'}`"
:style="{ background: getMenuTheme.background }"
>
<!-- 非双列:Logo + 系统名称(门户顶栏已展示则侧栏隐藏) -->
@@ -91,7 +91,7 @@
<ElScrollbar :style="scrollbarStyle">
<ElMenu
:class="'el-menu-' + getMenuTheme.theme"
:collapse="!menuOpen"
:collapse="showIconRail"
:default-active="routerPath"
:text-color="getMenuTheme.textColor"
:unique-opened="false"
@@ -181,6 +181,8 @@
menuType.value === MenuTypeEnum.PORTAL
)
const isDualMenu = computed(() => menuType.value === MenuTypeEnum.DUAL_MENU)
/** 单列侧栏收起时整栏隐藏;仅双列菜单仍使用图标窄栏 */
const showIconRail = computed(() => isDualMenu.value && !menuOpen.value)
// 移动端屏幕判断(使用 computed 避免重复计算)
const isMobileScreen = computed(() => width.value < MOBILE_BREAKPOINT)
@@ -306,6 +306,38 @@
box-shadow: none !important;
}
// 桌面收起:只留 Logo 与一级图标,名称由折叠菜单弹出层展示
.menu-left-close {
.header {
padding: 0 4px;
.header-brand-title {
display: none;
}
}
.el-menu.el-menu--collapse {
width: 100%;
padding-right: 4px;
padding-left: 4px;
> .el-menu-item,
> .el-sub-menu > .el-sub-menu__title {
justify-content: center;
padding-right: 0 !important;
padding-left: 0 !important;
}
.menu-icon {
margin: 0 !important;
}
.el-sub-menu__icon-arrow {
display: none;
}
}
}
.el-menu {
box-sizing: border-box;
// 防止菜单内的滚动影响整个页面滚动