Blame view

HHECS.Web/src/layout/components/Sidebar/index.vue 1.44 KB
胡菁 authored
1
<template>
2
  <div :class="{ 'has-logo': showLogo }">
胡菁 authored
3
4
5
6
7
8
9
10
11
12
13
14
    <logo v-if="showLogo" :collapse="isCollapse" />
    <el-scrollbar wrap-class="scrollbar-wrapper">
      <el-menu
        :default-active="activeMenu"
        :collapse="isCollapse"
        :background-color="variables.menuBg"
        :text-color="variables.menuText"
        :unique-opened="false"
        :active-text-color="variables.menuActiveText"
        :collapse-transition="false"
        mode="vertical"
      >
15
16
17
18
19
20
        <sidebar-item
          v-for="route in routes"
          :key="route.path"
          :item="route"
          :base-path="route.path"
        />
胡菁 authored
21
22
23
24
25
26
      </el-menu>
    </el-scrollbar>
  </div>
</template>

<script>
胡菁 authored
27
import variables from "@/styles/variables.scss";
28
29
30
import { mapGetters } from "vuex";
import Logo from "./Logo";
import SidebarItem from "./SidebarItem";
胡菁 authored
31
32
33
34

export default {
  components: { SidebarItem, Logo },
  computed: {
35
    ...mapGetters(["sidebar"]),
胡菁 authored
36
    routes() {
37
      return this.$router.options.routes;
胡菁 authored
38
39
    },
    activeMenu() {
40
41
      const route = this.$route;
      const { meta, path } = route;
胡菁 authored
42
43
      // if set path, the sidebar will highlight the path you set
      if (meta.activeMenu) {
44
        return meta.activeMenu;
胡菁 authored
45
      }
46
      return path;
胡菁 authored
47
48
    },
    showLogo() {
49
      return this.$store.state.settings.sidebarLogo;
胡菁 authored
50
51
    },
    variables() {
52
      return variables;
胡菁 authored
53
54
    },
    isCollapse() {
55
56
57
58
      return !this.sidebar.opened;
    },
  },
};
胡菁 authored
59
</script>