From 5173f8e31d106abd003e123c8679cf53c7940b33 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期一, 30 一月 2023 11:54:12 +0800
Subject: [PATCH] 网格绘制

---
 src/views/layout/components/Menu/index.vue |   65 +++++++++++++++-----------------
 1 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/src/views/layout/components/Menu/index.vue b/src/views/layout/components/Menu/index.vue
index 6c339eb..5c71c7f 100644
--- a/src/views/layout/components/Menu/index.vue
+++ b/src/views/layout/components/Menu/index.vue
@@ -2,7 +2,7 @@
   <div>
     <!-- 渚ц竟瀵艰埅鏍� -->
     <el-aside width="200px">
-      <h2 class="siderbar-title">閬傛槍鎵ф硶骞冲彴</h2>
+      <h2 class="siderbar-title" @click="toHome()">閬傛槍鎵ф硶骞冲彴</h2>
       <el-scrollbar>
         <!-- 璺敱 -->
         <el-menu router class="el-menu-vertical" :default-active="$route.path">
@@ -14,15 +14,15 @@
           >
             <template slot="title">
               <span slot="prefix" class="icon-padding fisrtSpan">
-                <svg-icon :icon-class="menu.icon"></svg-icon>
+                <svg-icon class="icon-title" :icon-class="menu.icon"></svg-icon>
               </span>
               <span class="fisrtSpan">{{ menu.title }}</span>
             </template>
-            <template v-if="menu.children.length > 0">
-              <template v-for="secondMenu in menu.children">
+            <template v-if="menu.menuVoArrayList.length > 0">
+              <template v-for="secondMenu in menu.menuVoArrayList">
                 <el-submenu
                   :key="secondMenu.id"
-                  v-if="secondMenu.children.length > 0"
+                  v-if="secondMenu.menuVoArrayList.length > 0"
                   :index="
                     secondMenu.url ? secondMenu.url : secondMenu.id.toString()
                   "
@@ -32,7 +32,7 @@
                     <span class="secondSpan">{{ secondMenu.title }}</span>
                   </template>
                   <el-menu-item
-                    v-for="thirdMenu in secondMenu.children"
+                    v-for="thirdMenu in secondMenu.menuVoArrayList"
                     :key="thirdMenu.id"
                     :index="`${thirdMenu.id}`"
                     :route="{ name: thirdMenu.url }"
@@ -42,7 +42,6 @@
 
                 <el-menu-item
                   v-else
-                  :key="secondMenu.id"
                   :index="`${secondMenu.id}`"
                   :route="{ name: secondMenu.url }"
                   >{{ secondMenu.title }}</el-menu-item
@@ -65,6 +64,9 @@
 </template>
 
 <script>
+import users from "@/api/users";
+import router from "@/router";
+
 export default {
   data() {
     return {
@@ -72,33 +74,21 @@
     };
   },
   created() {
-    // this.getMenuList();
     this.loadMenu();
   },
   methods: {
     loadMenu() {
-      const info = JSON.parse(sessionStorage.getItem("user"));
-      var timer;
-      if (info && info.menus) {
-        clearTimeout(timer);
-        this.menuList = info.menus;
-        console.log(info.menus);
-      } else {
-        timer = setInterval(() => {
-          this.loadMenu();
-        }, 1000);
-      }
+      const userName = sessionStorage.getItem('name');
+      users.getMenu({ name: userName })
+          .then(res => {
+            this.menuList = res.menus;
+            sessionStorage.setItem('user', JSON.stringify(res));
+          })
+          .catch(err => this.$message.error(err))
     },
-    // 鑾峰彇鑿滃崟鍒楄〃
-    getMenuList() {
-      let arr;
-      this.$axios({
-        method: "get",
-        url: "sccg/system/portal/menu/search_myself",
-      }).then((res) => {
-        console.log(res);
-      });
-    },
+    toHome(){
+      router.push("/home")
+    }
   },
 };
 </script>
@@ -106,10 +96,14 @@
 <style lang="scss" scpoed>
 .icon-padding {
   padding-right: 10px;
+  .icon-title{
+    width: 36px;
+    height: 36px;
+  }
 }
 
 .el-aside {
-  background: #07162e;
+  background: #313350;
   color: #e9eef3;
   text-align: center;
   box-sizing: border-box;
@@ -126,6 +120,7 @@
     top: 0;
     left: 0;
     z-index: 999;
+    cursor: pointer;
   }
 
   .el-scrollbar {
@@ -134,11 +129,11 @@
     box-sizing: border-box;
 
     .el-menu {
-      background: linear-gradient(#07162e, #0f2b56);
+      background: linear-gradient(#313350, #0f2b56);
       border: 0;
 
       .firstMenu {
-        background: #07162e;
+        background: #313350;
         text-align: left;
 
         &:hover > .el-submenu__title {
@@ -156,7 +151,7 @@
 
         .el-menu-item {
           color: #e9eef3;
-          background-color: #07162e;
+          background-color: #313350;
         }
 
         .el-menu-item:hover {
@@ -165,7 +160,7 @@
         }
 
         .is-active {
-          background-color: #07162e;
+          background-color: #313350;
           color: #22d3eb;
         }
       }
@@ -200,4 +195,4 @@
     }
   }
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0