SideMenu.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <a-layout-sider
  3. :class="['sider', isDesktop() ? null : 'shadow', theme, fixSiderbar ? 'ant-fixed-sidemenu' : null]"
  4. width="150px"
  5. :collapsible="collapsible"
  6. v-model="collapsed"
  7. :trigger="null"
  8. >
  9. <logo />
  10. <s-menu :collapsed="collapsed" :menu="menus" :theme="theme" @select="onSelect" :mode="mode" :style="smenuStyle">
  11. </s-menu>
  12. </a-layout-sider>
  13. </template>
  14. <script>
  15. import ALayoutSider from 'ant-design-vue/es/layout/Sider'
  16. import Logo from '../tools/Logo'
  17. import SMenu from './index'
  18. import { mixin, mixinDevice } from '@/utils/mixin.js'
  19. export default {
  20. name: 'SideMenu',
  21. components: { ALayoutSider, Logo, SMenu },
  22. mixins: [mixin, mixinDevice],
  23. props: {
  24. mode: {
  25. type: String,
  26. required: false,
  27. default: 'inline',
  28. },
  29. theme: {
  30. type: String,
  31. required: false,
  32. default: 'dark',
  33. },
  34. collapsible: {
  35. type: Boolean,
  36. required: false,
  37. default: false,
  38. },
  39. collapsed: {
  40. type: Boolean,
  41. required: false,
  42. default: false,
  43. },
  44. menus: {
  45. type: Array,
  46. required: true,
  47. },
  48. },
  49. computed: {
  50. smenuStyle() {
  51. let style = { padding: '0' }
  52. if (this.fixSiderbar) {
  53. style['height'] = 'calc(100% - 59px)'
  54. style['overflow'] = 'auto'
  55. style['overflow-x'] = 'hidden'
  56. }
  57. return style
  58. },
  59. },
  60. methods: {
  61. onSelect(obj) {
  62. this.$emit('menuSelect', obj)
  63. },
  64. },
  65. }
  66. </script>
  67. <style lang="less" scoped>
  68. /* update_begin author:sunjianlei date:20190509 for: 修改侧边导航栏滚动条的样式 */
  69. .sider {
  70. @scrollBarSize: 10px;
  71. ul.ant-menu {
  72. /* 定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
  73. &::-webkit-scrollbar {
  74. width: @scrollBarSize;
  75. height: @scrollBarSize;
  76. background-color: transparent;
  77. display: none;
  78. }
  79. & .-o-scrollbar {
  80. display: none;
  81. }
  82. /* 兼容IE */
  83. -ms-overflow-style: none;
  84. -ms-scroll-chaining: chained;
  85. -ms-content-zooming: zoom;
  86. -ms-scroll-rails: none;
  87. -ms-content-zoom-limit-min: 100%;
  88. -ms-content-zoom-limit-max: 500%;
  89. -ms-scroll-snap-type: proximity;
  90. -ms-scroll-snap-points-x: snapList(100%, 200%, 300%, 400%, 500%);
  91. /* 定义滚动条轨道 */
  92. &::-webkit-scrollbar-track {
  93. background-color: transparent;
  94. }
  95. /* 定义滑块 */
  96. &::-webkit-scrollbar-thumb {
  97. border-radius: @scrollBarSize;
  98. background-color: #eee;
  99. box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1);
  100. &:hover {
  101. background-color: #dddddd;
  102. }
  103. &:active {
  104. background-color: #bbbbbb;
  105. }
  106. }
  107. }
  108. /** 暗色系滚动条样式 */
  109. &.dark ul.ant-menu {
  110. &::-webkit-scrollbar-thumb {
  111. background-color: #666666;
  112. &:hover {
  113. background-color: #808080;
  114. }
  115. &:active {
  116. background-color: #999999;
  117. }
  118. }
  119. }
  120. }
  121. /* update_end author:sunjianlei date:20190509 for: 修改侧边导航栏滚动条的样式 */
  122. </style>
  123. <!-- update_begin author:sunjianlei date:20190530 for: 选中首页的时候不显示背景颜色 -->
  124. <style lang="less">
  125. .ant-menu.ant-menu-root {
  126. & > .ant-menu-item:first-child {
  127. background-color: transparent;
  128. & > a,
  129. & > a:hover {
  130. color: rgba(0, 0, 0, 0.65);
  131. }
  132. &.ant-menu-item-selected {
  133. & > a,
  134. & > a:hover {
  135. color: @primary-color;
  136. }
  137. }
  138. }
  139. &.ant-menu-dark > .ant-menu-item:first-child {
  140. & > a,
  141. & > a:hover {
  142. color: rgba(255, 255, 255, 0.65);
  143. }
  144. &.ant-menu-item-selected {
  145. & > a,
  146. & > a:hover {
  147. color: rgba(255, 255, 255, 1);
  148. }
  149. }
  150. }
  151. }
  152. .ant-menu-submenu-selected{
  153. background-color: color(~`colorPalette("@{primary-color}", 3)`);
  154. }
  155. </style>
  156. <!-- update_end author:sunjianlei date:20190530 for: 选中首页的时候不显示背景颜色 -->