From 357c4314c7a7e702bb4f686ddf97543de96d267c Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期五, 24 二月 2023 10:21:50 +0800
Subject: [PATCH] 2023/2/24 肖辉 修改文字颜色
---
src/views/layout/components/Menu/index.vue | 230 ++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 168 insertions(+), 62 deletions(-)
diff --git a/src/views/layout/components/Menu/index.vue b/src/views/layout/components/Menu/index.vue
index 8ad84aa..fed08ae 100644
--- a/src/views/layout/components/Menu/index.vue
+++ b/src/views/layout/components/Menu/index.vue
@@ -1,19 +1,61 @@
<template>
- <div class="Menu">
- <!-- 鑿滃崟鏍� -->
- <el-aside width="200px" class="menu">
- <h2 class="siderbar-title">閬傛槍鎵ф硶骞冲彴</h2>
- <el-scrollbar class="MenuScroll">
+ <div>
+ <!-- 渚ц竟瀵艰埅鏍� -->
+ <el-aside width="200px">
+ <h2 class="siderbar-title" @click="toHome()">閬傛槍鎵ф硶骞冲彴</h2>
+ <el-scrollbar>
<!-- 璺敱 -->
- <el-menu class="el-menu-vertical">
- <el-menu-item v-for="item in menu" :key="item.name" class="firstMenu" @click="Jump(item.index)">
- <template slot="title" class="firstSpan">
+ <el-menu router
+ class="el-menu-vertical"
+ :default-active="$route.path.name"
+ @select="handleSelect">
+ <el-submenu
+ :index="String(menu.id)"
+ v-for="menu in menuList"
+ :key="menu.id"
+ class="firstMenu"
+ >
+ <template slot="title">
<span slot="prefix" class="icon-padding fisrtSpan">
- <svg-icon :icon-class="item.icon"></svg-icon>
+ <svg-icon class="icon-title" :icon-class="menu.icon"></svg-icon>
</span>
- <span class="fisrtSpan">{{item.name}}</span>
+ <span class="fisrtSpan">{{ menu.title }}</span>
</template>
- </el-menu-item>
+ <template v-if="menu.menuVoArrayList.length > 0">
+ <template v-for="secondMenu in menu.menuVoArrayList">
+ <el-submenu
+ :key="secondMenu.id"
+ v-if="secondMenu.menuVoArrayList.length > 0"
+ :index="secondMenu.url ? secondMenu.url : secondMenu.id.toString()"
+ class="secondMenu"
+ :class="secondMenu.menuVoArrayList.length > 0?'is-Active':'none-Active'"
+ >
+ <template slot="title">
+ <span class="secondSpan">{{ secondMenu.title }}</span>
+ </template>
+ <el-menu-item
+ v-for="thirdMenu in secondMenu.menuVoArrayList"
+ :key="thirdMenu.id"
+ :index="`${thirdMenu.id}`"
+ :route="{ name: thirdMenu.url }"
+ >{{ thirdMenu.title }}</el-menu-item
+ >
+ </el-submenu>
+ <el-menu-item
+ v-else
+ :index="`${secondMenu.id}`"
+ :route="{ name: secondMenu.url }"
+ >{{ secondMenu.title }}</el-menu-item>
+ </template>
+ </template>
+ <el-menu-item
+ v-else
+ :key="menu.id"
+ :index="`${menu.id}`"
+ :route="{ name: menu.url }"
+ >{{ menu.title }}</el-menu-item
+ >
+ </el-submenu>
</el-menu>
</el-scrollbar>
</el-aside>
@@ -21,48 +63,57 @@
</template>
<script>
+import users from "@/api/users";
+import router from "@/router";
+
export default {
data() {
return {
- menu: [
- {
- name: "绯荤粺璁剧疆", icon: "system", index: "/home/system",
- },
- {
- name: "杩愯惀绠$悊", icon: "operate", index: "/home/operate",
- },
- {
- name: "瑙嗛宸℃煡", icon: "video", index: "/home/video",
- },
- {
- name: "娌圭儫淇℃伅鏌ヨ", icon: "intelligence", index: "/home/lampblack",
- },
- {
- name: "鎵ф硶绠$悊", icon: "intelligence", index: "/home/law",
- },
- {
- name: "鏅鸿兘宸℃煡", icon: "intelligence", index: "/home/intellect",
- },
- {
- name: "骞冲彴鍩烘湰淇℃伅", icon: "intelligence", index: "/home/info",
- }
- ],
+ menuList: [],
+ isActive:''
+ };
+ },
+ created() {
+ this.loadMenu();
+ },
+ watch: {
+ $route(){
+ this.handleSelect(this.$route.fullPath)
+ console.log(this.$route)
}
},
- methods:{
- Jump(url){
- this.$router.push(url);
+ methods: {
+ handleSelect(path){
+ this.isActive = path
+ },
+ loadMenu() {
+ const userName = sessionStorage.getItem('name');
+ users.getMenu({ name: userName })
+ .then(res => {
+ // console.log(res)
+ // debugger
+ this.menuList = res.menus;
+ sessionStorage.setItem('user', JSON.stringify(res));
+ })
+ .catch(err => this.$message.error(err))
+ },
+ toHome(){
+ router.push("/home")
}
- }
+ },
};
</script>
<style lang="scss" scpoed>
.icon-padding {
padding-right: 10px;
+ .icon-title{
+ width: 36px;
+ height: 36px;
+ }
}
-.menu {
- background: #07162e;
+.el-aside {
+ background: #313350;
color: #e9eef3;
text-align: center;
box-sizing: border-box;
@@ -78,51 +129,106 @@
top: 0;
left: 0;
z-index: 999;
- background-color: #08162f;
+ cursor: pointer;
}
-
- .MenuScroll {
+ .el-scrollbar {
height: calc(100vh - 66px);
- box-sizing: border-box;
margin-top: 66px;
+ box-sizing: border-box;
.el-menu {
- background: linear-gradient(#07162e, #0f2b56);
+ background: linear-gradient(#313350, #0f2b56);
border: 0;
-
- .firstMenu {
- background: #07162e;
- text-align: left;
- &:hover .fisrtSpan {
- color: #fff;
+ font-size: 16px;
+ .is-opened{
+ .fisrtSpan{
+ color: #22d3eb;
}
-
+ }
+ .firstMenu {
+ background: #313350;
+ text-align: left;
+ //border-bottom:1px solid #ccc ;
+ &:hover > .el-submenu__title {
+ background-color: #092c4a;
+ }
+ &:hover .fisrtSpan {
+ color: #22d3eb;
+ }
+ span,
span {
color: #e9eef3;
+ font-size: 16px;
}
-
- .el-menu-item {
- color: #c3c3c4;
- background-color: #07162e;
- &:hover {
+ .el-menu{
+ .is-active {
+ background-color: #409EFF;
color: #fff;
- background-color: #0c2c4c;
+ }
+ .is-Active{
+ background-color: #092c4a;
+ color: #fff;
}
}
+ .el-menu-item {
+ color: #e9eef3;
+ background-color: #313350;
+ font-size: 16px;
+ // border-bottom: 0.5px solid #7c7979;
+ }
+ .el-menu-item:hover {
+ background-color: #409EFF;
+ color: #22d3eb;
+ }
+ .is-opened{
+ .secondSpan{
+ color: #22d3eb;
+ }
+ }
+ .secondMenu{
+ //border-bottom:1px solid #ccc ;
+ .is-active {
+ background-color: #409EFF;
+ color: #22d3eb;
+ }
+ }
+ }
+ .secondMenu {
+ &:hover > .el-submenu__title {
+ background-color: #092c4a;
+ }
+ .secondSpan{
+ }
+ &:hover .secondSpan {
+ color: #22d3eb;
+ }
+ .is-opened{
+ .el-submenu__title{
+ background-color: #fff;
+ }
+ }
.is-active {
- background-color: #07162e;
+ background-color: #409EFF;
+ color: #fff;
+ }
+ }
+ .thirdMenu {
+ &:hover > .el-submenu__title {
+ background-color: #092c4a;
+ }
+
+ &:hover .thirdSpan {
color: #22d3eb;
}
}
.is-active {
- background-color: #07162e;
+ background-color: #092c4a;
}
}
-
.el-scrollbar__wrap {
overflow-x: hidden;
}
}
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.8.0