DemoMenu.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_400' : {
  40. icon: 'profile',
  41. title: '视图',
  42. pageName: 'DemoWindowViewIndex',
  43. params: {}
  44. },
  45. 'menu_401' : {
  46. icon: 'profile',
  47. title: '窗口',
  48. pageName: 'DemoWindowIndex',
  49. params: {}
  50. },
  51. 'menu_402' : {
  52. icon: 'profile',
  53. title: '通知',
  54. pageName: 'DemoNotificationIndex',
  55. params: {}
  56. },
  57. 'menu_500' : {
  58. icon: 'profile',
  59. title: '软件',
  60. pageName: 'DemoSoftwareIndex',
  61. params: {}
  62. },
  63. 'menu_600' : {
  64. icon: 'profile',
  65. title: '系统',
  66. pageName: 'DemoSystemIndex',
  67. params: {}
  68. },
  69. 'menu_800' : {
  70. icon: 'profile',
  71. title: '快捷键',
  72. pageName: 'DemoShortcutIndex',
  73. params: {}
  74. },
  75. 'menu_900' : {
  76. icon: 'profile',
  77. title: '测试',
  78. pageName: 'DemoTestApiIndex',
  79. params: {}
  80. }
  81. }
  82. };
  83. },
  84. created () {
  85. },
  86. mounted () {
  87. this.menuHandle({key: 'menu_100'})
  88. },
  89. methods: {
  90. menuHandle (item) {
  91. const linkInfo = this.menu[item.key]
  92. this.$router.push({ name: linkInfo.pageName, params: linkInfo.params})
  93. }
  94. }
  95. };
  96. </script>
  97. <style lang="less" scoped>
  98. #app-demo-menu {
  99. height: 100%;
  100. text-align: center;
  101. .layout-sider {
  102. border-top: 1px solid #e8e8e8;
  103. border-right: 1px solid #e8e8e8;
  104. background-color: #FAFAFA;
  105. overflow: auto;
  106. }
  107. }
  108. </style>