menus.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div id="menus">
  3. <el-row>
  4. <el-col :span="24">
  5. <!-- <el-menu :default-active="$route.path" background-color="#353852" text-color="#ffffff" active-text-color="#409eff" router>
  6. <el-menu-item index="/">
  7. <i class="iconfont iconshouye"></i>
  8. <span slot="title">后台首页</span>
  9. </el-menu-item>
  10. <el-menu-item index="/user/index">
  11. <i class="iconfont iconyonghu"></i>
  12. <span slot="title">用户管理</span>
  13. </el-menu-item>
  14. <el-menu-item index="/role/index">
  15. <i class="iconfont iconquanxian"></i>
  16. <span slot="title">权限管理</span>
  17. </el-menu-item>
  18. <el-menu-item index="/live/index">
  19. <i class="iconfont iconzhibo"></i>
  20. <span slot="title">直播管理</span>
  21. </el-menu-item>
  22. <el-menu-item index="/room/index">
  23. <i class="iconfont iconfangjian"></i>
  24. <span slot="title">房间管理</span>
  25. </el-menu-item>
  26. <el-menu-item index="/stat/index">
  27. <i class="iconfont icontongji"></i>
  28. <span slot="title">统计管理</span>
  29. </el-menu-item>
  30. </el-menu> -->
  31. <el-menu background-color="#353852" text-color="#ffffff" active-text-color="#409eff">
  32. <template v-for="item in menu">
  33. <template>
  34. <el-menu-item :index="item.path" @click="selectMenu(item.path)" :key="item.name">
  35. <i v-if="item.icon" :class="item.icon"></i>
  36. <span v-if="item.name" slot="title">{{ item.name }}</span>
  37. </el-menu-item>
  38. </template>
  39. </template>
  40. </el-menu>
  41. </el-col>
  42. </el-row>
  43. </div>
  44. </template>
  45. <script>
  46. import { index, user, role, live, room, stat } from '@/util/role_menu.js';
  47. import * as menus from '@/util/role_menu.js';
  48. import { mapState, createNamespacedHelpers } from 'vuex';
  49. export default {
  50. name: 'menus',
  51. props: {},
  52. components: {},
  53. data: function() {
  54. return {
  55. menu: [],
  56. };
  57. },
  58. created() {
  59. this.search();
  60. },
  61. methods: {
  62. search() {
  63. this.menu.push(index, user, role, live, room, stat);
  64. return;
  65. },
  66. selectMenu(path) {
  67. this.$router.push({ path: path });
  68. },
  69. },
  70. computed: {
  71. ...mapState(['user']),
  72. pageTitle() {
  73. return `${this.$route.meta.title}`;
  74. },
  75. },
  76. metaInfo() {
  77. return { title: this.$route.meta.title };
  78. },
  79. // watch: {
  80. // user: {
  81. // handler(val, oval) {
  82. // if (val && !_.isEqual(val, oval)) this.search();
  83. // },
  84. // immediate: true,
  85. // },
  86. // },
  87. };
  88. </script>
  89. <style lang="less" scoped>
  90. // .el-menu-vertical-demo:not(.el-menu--collapse) {
  91. // width: 200px;
  92. // min-height: 400px;
  93. // }
  94. /deep/.el-menu {
  95. border-right: none;
  96. }
  97. </style>