zhanghua
2023-01-30 5173f8e31d106abd003e123c8679cf53c7940b33
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,7 +14,7 @@
          >
            <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>
@@ -64,7 +64,9 @@
</template>
<script>
let timer = null;
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"));
      if (info && info.menus) {
        window.clearInterval(timer);
        this.menuList = info.menus;
      } else {
        if (!timer) {
          timer = window.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) => {
      });
    },
    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>
</style>