小说小程序后端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.2 KiB

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