fix(layout): 🐛 修复 TopLayout 顶部横向菜单提前省略
TopLayout 顶部菜单仅渲染顶级可见路由(避免全量路由树导致 scrollWidth 过大) 顶部 header 拆分 logo/menu 容器并补齐 flex + min-width:0,确保横向菜单占满剩余宽度 common.scss 补充 Top/Mix 横向 el-menu 的全局 flex 规则,省略仅在真实溢出时触发 ISSUES has been processed #IDKBWO
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<BaseLayout>
|
<BaseLayout>
|
||||||
<!-- 顶部è<EFBFBD>œå<EFBFBD>•æ ?-->
|
<!-- 顶部菜单-->
|
||||||
<div class="layout__header">
|
<div class="layout__header">
|
||||||
<div class="layout__header-left">
|
<div class="layout__header-left">
|
||||||
<LayoutLogo v-if="showLogo" :collapse="isLogoCollapsed" />
|
<div v-if="showLogo" class="layout__header-logo">
|
||||||
<LayoutSidebar :data="routes" menu-mode="horizontal" base-path="" />
|
<LayoutLogo :collapse="isLogoCollapsed" />
|
||||||
|
</div>
|
||||||
|
<div class="layout__header-menu">
|
||||||
|
<LayoutSidebar :data="topMenuItems" menu-mode="horizontal" base-path="" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layout__header-right">
|
<div class="layout__header-right">
|
||||||
<LayoutToolbar />
|
<LayoutToolbar />
|
||||||
@@ -22,6 +26,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useWindowSize } from "@vueuse/core";
|
import { useWindowSize } from "@vueuse/core";
|
||||||
import { useLayout } from "./useLayout";
|
import { useLayout } from "./useLayout";
|
||||||
|
import { usePermissionStore } from "@/store";
|
||||||
import BaseLayout from "./BaseLayout.vue";
|
import BaseLayout from "./BaseLayout.vue";
|
||||||
import LayoutLogo from "./components/LayoutLogo.vue";
|
import LayoutLogo from "./components/LayoutLogo.vue";
|
||||||
import LayoutSidebar from "./components/LayoutSidebar.vue";
|
import LayoutSidebar from "./components/LayoutSidebar.vue";
|
||||||
@@ -29,9 +34,15 @@ import LayoutToolbar from "./components/LayoutToolbar.vue";
|
|||||||
import LayoutTagsView from "./components/LayoutTagsView.vue";
|
import LayoutTagsView from "./components/LayoutTagsView.vue";
|
||||||
import LayoutMain from "./components/LayoutMain.vue";
|
import LayoutMain from "./components/LayoutMain.vue";
|
||||||
|
|
||||||
const { showTagsView, showLogo, routes } = useLayout();
|
const { showTagsView, showLogo } = useLayout();
|
||||||
const { width } = useWindowSize();
|
const { width } = useWindowSize();
|
||||||
|
|
||||||
|
const permissionStore = usePermissionStore();
|
||||||
|
|
||||||
|
const topMenuItems = computed(() => {
|
||||||
|
return permissionStore.routes.filter((item) => !item.meta?.hidden);
|
||||||
|
});
|
||||||
|
|
||||||
const isLogoCollapsed = computed(() => width.value < 768);
|
const isLogoCollapsed = computed(() => width.value < 768);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -54,13 +65,71 @@ const isLogoCollapsed = computed(() => width.value < 768);
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-logo {
|
||||||
|
display: flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
:deep(.logo) {
|
:deep(.logo) {
|
||||||
flex-shrink: 0;
|
|
||||||
height: $navbar-height;
|
height: $navbar-height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-menu {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
:deep(.el-menu) {
|
||||||
|
height: 100%;
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-menu--horizontal) {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: $navbar-height;
|
||||||
|
overflow: hidden;
|
||||||
|
line-height: $navbar-height;
|
||||||
|
background-color: transparent;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
.el-menu-item {
|
||||||
|
height: $navbar-height;
|
||||||
|
line-height: $navbar-height;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-sub-menu {
|
||||||
|
.el-sub-menu__title {
|
||||||
|
height: $navbar-height;
|
||||||
|
line-height: $navbar-height;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.has-active-child {
|
||||||
|
.el-sub-menu__title {
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
border-bottom: 2px solid var(--el-color-primary) !important;
|
||||||
|
|
||||||
|
.menu-icon {
|
||||||
|
color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-menu--popup {
|
||||||
|
min-width: 160px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-right {
|
&-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -68,43 +137,6 @@ const isLogoCollapsed = computed(() => width.value < 768);
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-menu--horizontal) {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
height: $navbar-height;
|
|
||||||
overflow: hidden;
|
|
||||||
line-height: $navbar-height;
|
|
||||||
background-color: transparent;
|
|
||||||
border: none;
|
|
||||||
|
|
||||||
.el-menu-item {
|
|
||||||
height: $navbar-height;
|
|
||||||
line-height: $navbar-height;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-sub-menu {
|
|
||||||
.el-sub-menu__title {
|
|
||||||
height: $navbar-height;
|
|
||||||
line-height: $navbar-height;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.has-active-child {
|
|
||||||
.el-sub-menu__title {
|
|
||||||
color: var(--el-color-primary) !important;
|
|
||||||
border-bottom: 2px solid var(--el-color-primary) !important;
|
|
||||||
|
|
||||||
.menu-icon {
|
|
||||||
color: var(--el-color-primary) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-menu--popup {
|
|
||||||
min-width: 160px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__main {
|
&__main {
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ html.sidebar-color-blue .layout-mix .layout__sidebar--left .el-menu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Top layout: let horizontal menu fill the remaining header space */
|
||||||
|
.layout-top .layout__header-left .el-menu--horizontal,
|
||||||
|
.layout-mix .layout__header-menu .el-menu--horizontal {
|
||||||
|
display: flex;
|
||||||
|
flex: 1 1 0% !important;
|
||||||
|
align-items: center;
|
||||||
|
width: 100% !important;
|
||||||
|
min-width: 0 !important;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
/* 窄屏隐藏菜单文字,仅保留图标 */
|
/* 窄屏隐藏菜单文字,仅保留图标 */
|
||||||
.hideSidebar {
|
.hideSidebar {
|
||||||
&.layout-top .layout__header .el-menu--horizontal,
|
&.layout-top .layout__header .el-menu--horizontal,
|
||||||
|
|||||||
Reference in New Issue
Block a user