Blame view

frontend/front/src/views/app/sidebar/SidebarItem.vue 2.27 KB
8ea9c133   陈威   初始化提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
  <component :is="menuComponent" :item="item" :index="item.id" :level="level">
    <template v-if="item.menuType === 'category'" slot="title">
      <div
        class="title-container"
        :style="{ 'margin-left': (level - 1) * 15 + 'px' }"
      >
        <i v-show="item.icon" class="ht-fa-icon" :class="item.icon"></i>
        <span
          class="sub-menu-title"
          :class="item.parentId === '0' ? '' : 'second-level-menu'"
        >
          {{ item.name }}
        </span>
      </div>
    </template>
    <template v-else>
      <div
        class="title-container"
        :style="{ 'margin-left': (level - 1) * 15 + 'px' }"
      >
        <i
          v-show="item.icon && level === 1"
          class="ht-fa-icon"
          :class="item.icon"
        ></i>
        <span
          slot="title"
          class="sub-menu-title"
          :class="item.parentId === '0' ? '' : 'second-level-menu'"
        >
          {{ item.name }}
        </span>
      </div>
    </template>
    <template
      v-if="
        item.children && item.children.length && item.menuType === 'category'
      "
    >
      <sidebar-item
        v-for="route in item.children"
        :key="route.id"
        :item="route"
        :level="level + 1"
      />
    </template>
  </component>
</template>

<script>
  import SidebarItem from './SidebarItem'

  export default {
    name: 'SidebarItem',
    components: { SidebarItem },
    props: {
      item: {
        type: Object,
        required: true,
      },
      index: {
        type: String,
        default: '',
      },
      level: {
        type: Number,
        default: 1,
      },
    },
    computed: {
      menuComponent() {
        if (this.item.menuType === 'category') {
          return 'ElSubmenu'
        } else {
          return 'ElMenuItem'
        }
      },
    },
  }
</script>

<style lang="scss" scoped>
  ::v-deep {
    .el-tooltip {
      padding-left: 28px !important;
      display: flex !important;
      align-items: center !important;
    }
    .el-icon-arrow-down {
      transform: rotate(-90deg);
      color: var(--menuColor);
    }
  }

  .second-level-menu {
    font-size: 14px;
  }
  .ht-fa-icon {
    width: 18px;
    height: 18px;
  }
  .title-container {
    display: flex;
    align-items: center;
  }
</style>