peng
2026-03-24 05c7478c26954ee6031f98fce6c8c9901abb98a0
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<template>
  <a-layout-sider
    :class="['sider', isDesktop() ? null : 'shadow', fixSidebar ? 'ant-fixed-side-menu' : null]"
    :collapsible="collapsible"
    v-model="collapsed"
    :trigger="null"
  >
    <logo :show-title="!collapsed" />
    <s-menu :collapsed="collapsed" :menu="menus" @select="onSelect" :mode="mode" :style="smenuStyle"></s-menu>
  </a-layout-sider>
</template>
 
<script>
import ALayoutSider from 'ant-design-vue/es/layout/Sider'
import Logo from '@/components/tools/Logo'
import SMenu from './index'
import { mixin, mixinDevice } from '@tievd/cube-block/lib/utils/mixin.js'
import skinLayoutMixin from '@/mixins/skin-layout-mixin'
 
export default {
  name: 'SideMenu',
 
  components: {
    ALayoutSider,
    Logo,
    SMenu,
  },
 
  mixins: [mixin, mixinDevice, skinLayoutMixin],
 
  props: {
    mode: {
      type: String,
      required: false,
      default: 'inline',
    },
    collapsible: {
      type: Boolean,
      required: false,
      default: false,
    },
    collapsed: {
      type: Boolean,
      required: false,
      default: false,
    },
    menus: {
      type: Array,
      required: true,
    },
  },
 
  computed: {
    smenuStyle() {
      let style = { padding: '0' }
      if (this.fixSidebar) {
        style['height'] = 'calc(100% - 59px)'
        style['overflow'] = 'auto'
        style['overflow-x'] = 'hidden'
      }
      return style
    },
  },
 
  methods: {
    onSelect(obj) {
      this.$emit('menuSelect', obj)
    },
  },
}
</script>
<style lang="less" scoped>
// 选中首页的时候不显示背景颜色
// /deep/.ant-menu.ant-menu-root {
//   & > .ant-menu-item:first-child {
//     background-color: transparent;
//   }
// }
.sider {
  max-width: @layout-sider-width !important;
  min-width: @layout-sider-width !important;
  width: @layout-sider-width !important;
  overflow: auto;
  height: 100vh;
  &.ant-layout-sider-collapsed {
    max-width: @layout-sider-collapsed-width !important;
    min-width: @layout-sider-collapsed-width !important;
    width: @layout-sider-collapsed-width !important;
  }
 
  .ant-menu {
    border-right: none;
 
    /deep/ .ant-menu-item {
      margin-top: 0;
    }
    /deep/ .ant-menu-item {
      height: 100px;
      background: #11151b;
      display: flex;
      align-items: center;
      justify-content: center;
      border-top: 1px solid #23262c !important;
      .anticon-home {
        display: block;
      }
      span {
        margin-right: 13px;
      }
    }
    /deep/ .ant-menu-submenu-vertical {
      height: 100px;
      border-top: 1px solid #23262c !important;
      display: flex;
      align-items: center;
      .ant-menu-submenu-title {
        height: auto;
        span {
          display: flex;
          justify-content: center;
          align-items: center;
          flex-direction: column;
          i {
            font-size: 20px;
            margin: 0;
          }
        }
        .ant-menu-submenu-arrow {
          display: none;
        }
      }
    }
  }
}
</style>