LeftAside.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <el-menu
  3. :default-active="this.$route.path"
  4. router
  5. class="el-menu-vertical-demo"
  6. background-color="#334157"
  7. text-color="#fff"
  8. active-text-color="#ffd04b"
  9. :unique-opened="true"
  10. :collapse="collapsed"
  11. :collapse-transition="collapseTransition"
  12. >
  13. <div class="logobox">
  14. <a href="/bg" style="text-decoration-line: none">
  15. <img class="logoimg" src="@/assets/img/logo.png" alt="">
  16. </a>
  17. </div>
  18. <el-submenu v-for="item in menuList" :key="item.path" :index="item.path">
  19. <template slot="title">
  20. <i :class="item.icon" />
  21. <span>{{ item.title }}</span>
  22. </template>
  23. <el-menu-item-group>
  24. <el-menu-item v-for="child in item.children" :key="child.path" :index="child.path">
  25. <i :class="child.icon" />
  26. <span slot="title">{{ child.title }}</span>
  27. </el-menu-item>
  28. </el-menu-item-group>
  29. </el-submenu>
  30. </el-menu>
  31. </template>
  32. <script>
  33. import store from '@/store'
  34. export default {
  35. name: 'LeftAside',
  36. data() {
  37. return {
  38. collapsed: false,
  39. collapseTransition: false,
  40. menuList: []
  41. }
  42. },
  43. created() {
  44. for (const route of store.getters.addRoutes) {
  45. if (route.path === '/bg') {
  46. // devops 系统
  47. for (const route1 of route.children) {
  48. this.menuList.push(route1)
  49. }
  50. } else if (route.path.startsWith('/bg/')) {
  51. // tnb 系统
  52. this.menuList.push(route)
  53. }
  54. }
  55. // 钩子函数
  56. this.$root.Bus.$on('HandleSideMenu', value => {
  57. this.collapsed = value
  58. })
  59. },
  60. methods: {
  61. }
  62. }
  63. </script>
  64. <style>
  65. .el-menu-vertical-demo:not(.el-menu--collapse) {
  66. width: 180px;
  67. min-height: 720px;
  68. }
  69. .el-menu-vertical-demo:not(.el-menu--collapse) {
  70. border: none;
  71. text-align: left;
  72. }
  73. .logobox {
  74. height: 40px;
  75. line-height: 40px;
  76. color: #9d9d9d;
  77. font-size: 20px;
  78. text-align: center;
  79. padding: 20px 0px;
  80. }
  81. .logoimg {
  82. height: 40px;
  83. }
  84. </style>