Layout.vue 4.3 KB

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