完善后台布局

This commit is contained in:
2026-01-16 23:17:20 +08:00
parent 8cf5b446cf
commit b4c300bb32
9 changed files with 228 additions and 135 deletions

View File

@@ -22,7 +22,10 @@
v-if="selectedParentMenu && selectedParentMenu.children && selectedParentMenu.children.length > 0"
theme="light" :collapsed="sidebarCollapsed" :collapsible="true" @collapse="handleCollapse" width="200"
:collapsed-width="64" class="right-sidebar">
<div class="parent-title">{{ selectedParentMenu.meta?.title }}</div>
<div class="parent-title">
<component :is="getIconComponent(selectedParentMenu.meta?.icon)" />
<span v-if="!sidebarCollapsed">{{ selectedParentMenu.meta?.title }}</span>
</div>
<a-menu v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys" mode="inline"
:selected-keys="[route.path]">
<navMenu :menu-items="selectedParentMenu.children" :active-path="route.path" />
@@ -169,7 +172,7 @@ const menuList = computed(() => {
// 获取图标组件
const getIconComponent = (iconName) => {
return icons[iconName] || icons.MenuOutlined
return icons[iconName] || icons.FileTextOutlined
}
// 处理父菜单点击(默认布局的第一级菜单)
@@ -211,7 +214,6 @@ const updateMenuState = () => {
if (layoutMode.value === 'default') {
// 默认布局:找到当前路由对应的父菜单
const currentMenu = findMenuByPath(menuList.value, route.path)
console.log(currentMenu)
if (currentMenu) {
// 如果当前菜单有子菜单,设置为选中的父菜单
if (currentMenu.children && currentMenu.children.length > 0) {
@@ -276,7 +278,6 @@ watch(() => route.path, (newPath) => {
// 监听布局模式变化,确保菜单状态正确
watch(() => layoutMode.value, () => {
console.log('布局模式变化:', layoutMode.value)
updateMenuState()
})
@@ -315,7 +316,6 @@ onMounted(() => {
border-bottom: 1px solid #f0f0f0;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
height: 60px;
z-index: 9;
.header-left {
display: flex;
@@ -398,17 +398,6 @@ onMounted(() => {
color: #ffffff;
background-color: #1890ff;
border-left-color: #ffffff;
&::before {
content: '';
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
border-width: 6px;
border-style: solid;
border-color: transparent #ffffff transparent transparent;
}
}
:deep(.anticon) {
@@ -436,12 +425,13 @@ onMounted(() => {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
gap: 5px;
height: 60px;
font-size: 18px;
font-size: 16px;
font-weight: 500;
color: #262626;
border-bottom: 1px solid #f0f0f0;
background-color: #fafafa;
}
:deep(.ant-menu) {