Layout.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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="{ name: menuInfo.pageName, params: menuInfo.params}">
  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: '10px', 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. pageName: 'UploadFile',
  60. params: {}
  61. },
  62. 'subMenu_2' : {
  63. title: '打开文件夹',
  64. pageName: 'FileOpenDir',
  65. params: {},
  66. }
  67. },
  68. 'menu_2' : {
  69. 'subMenu_1' : {
  70. title: '基础设置',
  71. pageName: 'Setting',
  72. params: {},
  73. }
  74. },
  75. },
  76. contentPage: ''
  77. };
  78. },
  79. mounted () {
  80. this.menuHandle({key: 'menu_1'})
  81. },
  82. methods: {
  83. menuHandle (item) {
  84. this.subMenu = this.subMenuList[item.key]
  85. this.subMenuKey = ['subMenu_1']
  86. const linkInfo = this.subMenu['subMenu_1']
  87. this.$router.push({ name: linkInfo.pageName, params: linkInfo.params})
  88. },
  89. },
  90. };
  91. </script>
  92. <style lang="less" scoped>
  93. // 嵌套
  94. #components-layout-demo-responsive {
  95. .logo {
  96. border-bottom: 1px solid #e8e8e8;
  97. }
  98. .pic-logo {
  99. height: 32px;
  100. //background: rgba(139, 137, 137, 0.2);
  101. margin: 10px;
  102. }
  103. .layout-sider {
  104. border-right: 1px solid #e8e8e8;
  105. }
  106. .menu-item {
  107. .ant-menu-item {
  108. background-color: #fff;
  109. margin-top: 0px;
  110. margin-bottom: 0px;
  111. }
  112. }
  113. .sub-layout-sider {
  114. background-color: #FAFAFA;
  115. }
  116. .sub-menu-item {
  117. .ant-menu-item {
  118. margin-top: 0px;
  119. margin-bottom: 0px;
  120. }
  121. .ant-menu-item::after {
  122. border-right: 3px solid #F2F2F2;
  123. }
  124. .ant-menu-item-selected {
  125. background-color:#F2F2F2;
  126. span {
  127. color: #111;
  128. }
  129. }
  130. }
  131. .sub-menu-item.ant-menu {
  132. background: #FAFAFA;
  133. }
  134. .sub-menu-item.ant-menu-inline {
  135. border-right: 0px solid #FAFAFA;
  136. }
  137. }
  138. // #components-layout-demo-responsive .logo {
  139. // height: 32px;
  140. // background: rgba(139, 137, 137, 0.2);
  141. // margin: 16px;
  142. // }
  143. // #components-layout-demo-responsive .menu-item .ant-menu-item {
  144. // background-color: #001529;
  145. // margin-top: 0px;
  146. // margin-bottom: 0px;
  147. // }
  148. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item {
  149. // margin-top: 0px;
  150. // margin-bottom: 0px;
  151. // }
  152. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item::after {
  153. // border-right: 3px solid #F2F2F2;
  154. // }
  155. // #components-layout-demo-responsive .sub-menu-item.ant-menu {
  156. // background: #FAFAFA;
  157. // }
  158. // #components-layout-demo-responsive .sub-menu-item.ant-menu-inline {
  159. // border-right: 0px solid #FAFAFA;
  160. // }
  161. // #components-layout-demo-responsive .sub-menu-item .ant-menu-item-selected {
  162. // background-color:#F2F2F2;
  163. // span {
  164. // color: #111;
  165. // }
  166. // }
  167. </style>