明树Git Lab

Commit 5765b85b authored by zhanghan's avatar zhanghan

解决左侧图标问题

parent 850d0bed
...@@ -231,27 +231,42 @@ const handleLogout = () => { ...@@ -231,27 +231,42 @@ const handleLogout = () => {
color: #666; color: #666;
font-size: 14px; font-size: 14px;
background-color: #fff; background-color: #fff;
height: 40px;
line-height: 40px;
} }
::v-deep .el-sub-menu { ::v-deep .el-sub-menu {
color: #666; color: #666;
font-size: 14px; font-size: 14px;
background-color: #fff; background-color: #fff;
.el-sub-menu__title { .el-sub-menu__title {
height: 100%; height: 40px;
line-height: 40px;
} }
} }
:deep(.el-menu-item.is-active) { :deep(.el-menu-item.is-active) {
color: #0084ff; color: #0084ff;
border-right: 4px solid #3d84ee;
background-color: #f1f7ff; background-color: #f1f7ff;
} }
/* 子菜单被激活时,父菜单也高亮 */
:deep(.el-sub-menu.is-active > .el-sub-menu__title) {
color: #0084ff !important;
// background-color: #b3d7ff !important;
}
/* 完全去掉系统管理子菜单的背景色 */ /* 完全去掉系统管理子菜单的背景色 */
:deep(.el-sub-menu__title) { :deep(.el-sub-menu__title) {
color: #666; color: #666;
background-color: #fff !important; background-color: #fff !important;
} }
/* 图标样式 */
:deep(.el-menu-item .el-icon),
:deep(.el-sub-menu__title .el-icon) {
font-size: 14px;
margin-right: 8px;
}
.city-header { .city-header {
width: 100%; width: 100%;
height: 48px; height: 48px;
...@@ -315,7 +330,7 @@ const handleLogout = () => { ...@@ -315,7 +330,7 @@ const handleLogout = () => {
.city-aside { .city-aside {
background-color: #fff; background-color: #fff;
width: 240px; width: 210px;
height: 100%; height: 100%;
box-shadow: 0 6px 10px 0 rgba(36, 36, 63, 0.05); box-shadow: 0 6px 10px 0 rgba(36, 36, 63, 0.05);
overflow: auto; overflow: auto;
......
<template> <template>
<el-menu <el-menu :default-active="$route.path" router>
:default-active="$route.path"
router
>
<template v-for="item in menuList"> <template v-for="item in menuList">
<template v-if="item.children && item.children.length"> <template v-if="item.children && item.children.length">
<left-menu-item :key="item.id?.toString()" :menuItem="item"></left-menu-item> <left-menu-item
:key="item.id?.toString()"
:menuItem="item"
></left-menu-item>
</template> </template>
<template v-else> <template v-else>
<el-menu-item :key="item.id?.toString()" :index="item.url"> <el-menu-item :key="item.id?.toString()" :index="item.url">
<el-icon><component :is="getIcon(item.name)" /></el-icon>
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
</el-menu-item> </el-menu-item>
</template> </template>
...@@ -17,8 +18,24 @@ ...@@ -17,8 +18,24 @@
</template> </template>
<script setup> <script setup>
import LeftMenuItem from "./leftMenuItem.vue"; import LeftMenuItem from "./leftMenuItem.vue";
const menuList = sessionStorage.getItem("userInfo") ? JSON.parse(sessionStorage.getItem("userInfo")).menus : []; import * as Icons from "@element-plus/icons-vue";
const menuList = sessionStorage.getItem("userInfo")
? JSON.parse(sessionStorage.getItem("userInfo")).menus
: [];
// 根据菜单名称获取对应图标
const getIcon = (name) => {
const iconMap = {
数据大屏: "DataLine",
消息中心: "Bell",
模板管理: "MagicStick",
};
const iconName = iconMap[name] || "Menu";
return Icons[iconName] || Icons.Menu;
};
</script> </script>
<style lang="less"></style> <style lang="less"></style>
<template> <template>
<el-sub-menu :index="menuItem.id?.toString()"> <el-sub-menu :index="menuItem.id?.toString()">
<template #title> <template #title>
<el-icon><component :is="getIcon(menuItem.name)" /></el-icon>
<span>{{ menuItem.name }}</span> <span>{{ menuItem.name }}</span>
</template> </template>
<template v-for="(child, index) in menuItem.children" :key="index"> <template v-for="(child, index) in menuItem.children" :key="index">
<left-menu-item v-if="child.children && child.children.length"></left-menu-item> <left-menu-item
<el-menu-item v-else v-if="child.children && child.children.length"
:index="child.url" :menuItem="child"
> ></left-menu-item>
<el-menu-item v-else :index="child.url">
<span>{{ child.name }}</span> <span>{{ child.name }}</span>
</el-menu-item> </el-menu-item>
</template> </template>
...@@ -15,14 +17,32 @@ ...@@ -15,14 +17,32 @@
</template> </template>
<script setup> <script setup>
import { defineProps } from 'vue'; import { defineProps } from "vue";
const props = defineProps({ import * as Icons from "@element-plus/icons-vue";
const props = defineProps({
menuItem: { menuItem: {
type: Object, type: Object,
default: {} default: {},
} },
}) });
// 根据菜单名称获取对应图标(仅用于父菜单,子菜单不显示图标)
const getIcon = (name) => {
const iconMap = {
系统管理: "Setting",
代码生成: "MagicStick",
投前管理: "Calendar",
投中管理: "Cloudy",
投后管理: "Wallet",
日常管理: "Document",
其他管理: "Files",
模板管理: "DocumentCopy",
};
const iconName = iconMap[name] || "Menu";
return Icons[iconName] || Icons.Menu;
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped></style>
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment