DemoMenu.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <a-layout id="app-demo-menu">
  3. <a-layout-sider
  4. theme="light"
  5. class="layout-sider"
  6. >
  7. <a-menu theme="light" mode="inline" :default-selected-keys="['menu_100']">
  8. <a-menu-item v-for="(menuInfo, subIndex) in menu" :key="subIndex">
  9. <router-link :to="{ name: menuInfo.pageName, params: menuInfo.params}">
  10. <span>{{ menuInfo.title }}</span>
  11. </router-link>
  12. </a-menu-item>
  13. </a-menu>
  14. </a-layout-sider>
  15. <a-layout>
  16. <a-layout-content>
  17. <router-view />
  18. </a-layout-content>
  19. </a-layout>
  20. </a-layout>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. menu: {
  27. 'menu_100' : {
  28. icon: 'profile',
  29. title: '文件',
  30. pageName: 'DemoFileIndex',
  31. params: {}
  32. },
  33. 'menu_300' : {
  34. icon: 'profile',
  35. title: '通信',
  36. pageName: 'DemoSocketIndex',
  37. params: {}
  38. },
  39. 'menu_301' : {
  40. icon: 'profile',
  41. title: '数据库',
  42. pageName: 'DemoDBIndex',
  43. params: {}
  44. },
  45. 'menu_400' : {
  46. icon: 'profile',
  47. title: '视图',
  48. pageName: 'DemoWindowViewIndex',
  49. params: {}
  50. },
  51. 'menu_401' : {
  52. icon: 'profile',
  53. title: '窗口',
  54. pageName: 'DemoWindowIndex',
  55. params: {}
  56. },
  57. 'menu_403' : {
  58. icon: 'profile',
  59. title: '扩展程序',
  60. pageName: 'DemoExtensionIndex',
  61. params: {}
  62. },
  63. 'menu_405' : {
  64. icon: 'profile',
  65. title: '桌面通知',
  66. pageName: 'DemoNotificationIndex',
  67. params: {}
  68. },
  69. 'menu_407' : {
  70. icon: 'profile',
  71. title: '电源监控',
  72. pageName: 'DemoPowerMonitorIndex',
  73. params: {}
  74. },
  75. 'menu_409' : {
  76. icon: 'profile',
  77. title: '屏幕信息',
  78. pageName: 'DemoScreenIndex',
  79. params: {}
  80. },
  81. 'menu_411' : {
  82. icon: 'profile',
  83. title: '系统主题',
  84. pageName: 'DemoThemeIndex',
  85. params: {}
  86. },
  87. 'menu_412' : {
  88. icon: 'profile',
  89. title: '自动更新',
  90. pageName: 'DemoUpdaterIndex',
  91. params: {}
  92. },
  93. 'menu_500' : {
  94. icon: 'profile',
  95. title: '软件调用',
  96. pageName: 'DemoSoftwareIndex',
  97. params: {}
  98. },
  99. 'menu_600' : {
  100. icon: 'profile',
  101. title: '系统',
  102. pageName: 'DemoSystemIndex',
  103. params: {}
  104. },
  105. 'menu_800' : {
  106. icon: 'profile',
  107. title: '快捷键',
  108. pageName: 'DemoShortcutIndex',
  109. params: {}
  110. },
  111. 'menu_900' : {
  112. icon: 'profile',
  113. title: '测试',
  114. pageName: 'DemoTestApiIndex',
  115. params: {}
  116. }
  117. }
  118. };
  119. },
  120. created () {
  121. },
  122. mounted () {
  123. this.menuHandle({key: 'menu_100'})
  124. },
  125. methods: {
  126. menuHandle (item) {
  127. const linkInfo = this.menu[item.key]
  128. this.$router.push({ name: linkInfo.pageName, params: linkInfo.params})
  129. }
  130. }
  131. };
  132. </script>
  133. <style lang="less" scoped>
  134. #app-demo-menu {
  135. height: 100%;
  136. text-align: center;
  137. .layout-sider {
  138. border-top: 1px solid #e8e8e8;
  139. border-right: 1px solid #e8e8e8;
  140. background-color: #FAFAFA;
  141. overflow: auto;
  142. }
  143. }
  144. </style>