Layout.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <a-layout id="components-layout-demo-responsive">
  3. <a-layout-sider
  4. v-model="collapsed"
  5. theme="light"
  6. class="layout-sider"
  7. >
  8. <div class="logo"><img class="pic-logo" src="~@/assets/logo.png"></div>
  9. <a-menu class="menu-item" theme="light" mode="inline" @click="menuHandle" :default-selected-keys="['menu_1']">
  10. <a-menu-item :key="index" v-for="(menuInfo, index) in menu" :title="menuInfo.title">
  11. <a-icon :type="menuInfo.icon" />
  12. </a-menu-item>
  13. </a-menu>
  14. </a-layout-sider>
  15. <a-layout>
  16. <a-layout-sider
  17. theme="light"
  18. class="sub-layout-sider"
  19. >
  20. <a-menu class="sub-menu-item" theme="light" mode="inline" v-model="subMenuKey" :default-selected-keys="subMenuKey">
  21. <a-menu-item :key="subIndex" v-for="(menuInfo, subIndex) in subMenu">
  22. <router-link :to="{ path: menuInfo.page }">
  23. <span>{{ menuInfo.title }}</span>
  24. </router-link>
  25. </a-menu-item>
  26. </a-menu>
  27. </a-layout-sider>
  28. <a-layout-content :style="{}">
  29. <div :style="{ padding: '24px', background: '#fff', minHeight: '560px' }">
  30. <router-view />
  31. </div>
  32. </a-layout-content>
  33. </a-layout>
  34. </a-layout>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'Layout',
  39. data() {
  40. return {
  41. collapsed: true,
  42. menu: {
  43. 'menu_1' : {
  44. icon: 'home',
  45. title: ''
  46. },
  47. 'menu_2' : {
  48. icon: 'setting',
  49. title: ''
  50. },
  51. },
  52. menuKey: 'menu_1',
  53. subMenuKey: ['subMenu_1'],
  54. subMenu: {},
  55. subMenuList: {
  56. 'menu_1' : {
  57. 'subMenu_1' : {
  58. title: '上传文件到sm图床',
  59. page: 'uploadFile'
  60. },
  61. 'subMenu_2' : {
  62. title: '打开文件夹',
  63. page: 'fileOpenDir'
  64. }
  65. },
  66. 'menu_2' : {
  67. 'subMenu_1' : {
  68. title: '设置菜单1',
  69. page: '/setting1'
  70. },
  71. 'subMenu_2' : {
  72. title: '设置菜单2',
  73. page: '/setting2'
  74. },
  75. },
  76. },
  77. contentPage: ''
  78. };
  79. },
  80. mounted () {
  81. this.menuHandle({key: 'menu_1'})
  82. },
  83. methods: {
  84. menuHandle (item) {
  85. this.subMenu = this.subMenuList[item.key]
  86. this.subMenuKey = ['subMenu_1']
  87. const linkPage = this.subMenu['subMenu_1']['page']
  88. this.$router.push(linkPage)
  89. },
  90. },
  91. };
  92. </script>
  93. <style lang="less" scoped>
  94. // 嵌套
  95. #components-layout-demo-responsive {
  96. .logo {
  97. border-bottom: 1px solid #e8e8e8;
  98. }
  99. .pic-logo {
  100. height: 32px;
  101. //background: rgba(139, 137, 137, 0.2);
  102. margin: 10px;
  103. }
  104. .layout-sider {
  105. border-right: 1px solid #e8e8e8;
  106. }
  107. .menu-item {
  108. .ant-menu-item {
  109. background-color: #fff;
  110. margin-top: 0px;
  111. margin-bottom: 0px;
  112. }
  113. }
  114. .sub-layout-sider {
  115. background-color: #FAFAFA;
  116. }
  117. .sub-menu-item {
  118. .ant-menu-item {
  119. margin-top: 0px;
  120. margin-bottom: 0px;
  121. }
  122. .ant-menu-item::after {
  123. border-right: 3px solid #F2F2F2;
  124. }
  125. .ant-menu-item-selected {
  126. background-color:#F2F2F2;
  127. span {
  128. color: #111;
  129. }
  130. }
  131. }
  132. .sub-menu-item.ant-menu {
  133. background: #FAFAFA;
  134. }
  135. .sub-menu-item.ant-menu-inline {
  136. border-right: 0px solid #FAFAFA;
  137. }
  138. }
  139. // #components-layout-demo-responsive .logo {
  140. // height: 32px;
  141. // background: rgba(139, 137, 137, 0.2);
  142. // margin: 16px;
  143. // }
  144. // #components-layout-demo-responsive .menu-item .ant-menu-item {
  145. // background-color: #001529;
  146. // margin-top: 0px;
  147. // margin-bottom: 0px;
  148. // }
  149. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item {
  150. // margin-top: 0px;
  151. // margin-bottom: 0px;
  152. // }
  153. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item::after {
  154. // border-right: 3px solid #F2F2F2;
  155. // }
  156. // #components-layout-demo-responsive .sub-menu-item.ant-menu {
  157. // background: #FAFAFA;
  158. // }
  159. // #components-layout-demo-responsive .sub-menu-item.ant-menu-inline {
  160. // border-right: 0px solid #FAFAFA;
  161. // }
  162. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item-selected {
  163. // background-color:#F2F2F2;
  164. // span {
  165. // color: #111;
  166. // }
  167. // }
  168. </style>