index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div :class="{ 'has-logo': showLogo }">
  3. <logo v-if="showLogo" :collapse="isCollapse" />
  4. <el-scrollbar wrap-class="scrollbar-wrapper">
  5. <el-menu
  6. class="navMenu"
  7. :default-active="activeMenu"
  8. :collapse="isCollapse"
  9. :background-color="variables.menusBg"
  10. :text-color="variables.menuText"
  11. :unique-opened="false"
  12. :active-text-color="variables.menuActiveText"
  13. :collapse-transition="false"
  14. mode="vertical"
  15. >
  16. <sidebar-item
  17. v-for="(route, index) in permission_routes"
  18. :key="index"
  19. :item="route"
  20. :base-path="route.path"
  21. :leup="leup"
  22. />
  23. </el-menu>
  24. </el-scrollbar>
  25. </div>
  26. </template>
  27. <script>
  28. import { mapGetters } from "vuex";
  29. import Logo from "./Logo";
  30. import SidebarItem from "./SidebarItem";
  31. import variables from "@/styles/variables.scss";
  32. export default {
  33. props: {
  34. // route object
  35. leup: {
  36. type: Boolean,
  37. default: false,
  38. },
  39. },
  40. components: { SidebarItem, Logo },
  41. computed: {
  42. ...mapGetters(["sidebar", "permission_routes"]),
  43. routes() {
  44. const power =
  45. typeof this.userPowerList == "string"
  46. ? JSON.parse(this.userPowerList)
  47. : this.userPowerList;
  48. return power;
  49. // const datas = this.$router.options.routes;
  50. // const arrs = [];
  51. // const menus = [];
  52. // if (power && power.length) {
  53. // for (const item of datas) {
  54. // if (item.meta) {
  55. // arrs.push(item);
  56. // }
  57. // }
  58. // arrs.forEach(item => {
  59. // power.forEach(p => {
  60. // if (item.meta.isModule == p) {
  61. // menus.push(item);
  62. // }
  63. // })
  64. // })
  65. // return menus;
  66. // } else {
  67. // return datas;
  68. // }
  69. },
  70. activeMenu() {
  71. const route = this.$route;
  72. const { meta, path } = route;
  73. // if set path, the sidebar will highlight the path you set
  74. if (meta.activeMenu) {
  75. return meta.activeMenu;
  76. }
  77. return path;
  78. },
  79. showLogo() {
  80. return this.$store.state.settings.sidebarLogo;
  81. },
  82. variables() {
  83. return variables;
  84. },
  85. isCollapse() {
  86. return !this.sidebar.opened;
  87. },
  88. },
  89. watch: {
  90. leup() {
  91. console.log(this.leup);
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. ::v-deep .navMenu {
  98. .router-link-active {
  99. .account {
  100. background: url("../../../assets/nav/ic_list_nav_account_check.png")
  101. no-repeat;
  102. }
  103. .role {
  104. background: url("../../../assets/nav/ic_list_nav_character_check.png")
  105. no-repeat;
  106. }
  107. .authority {
  108. background: url("../../../assets/nav/ic_list_nav_permissions_check.png")
  109. no-repeat;
  110. }
  111. .transfer {
  112. background: url("../../../assets/nav/ic_list_nav_transit_check.png")
  113. no-repeat;
  114. }
  115. .arrival {
  116. background: url("../../../assets/nav/ic_list_nav_arrive_check.png")
  117. no-repeat;
  118. }
  119. .departure {
  120. background: url("../../../assets/nav/ic_list_nav_leave_check.png")
  121. no-repeat;
  122. }
  123. .dataCollection {
  124. background: url("../../../assets/nav/ic_data_collection_check.png")
  125. no-repeat;
  126. }
  127. .dataParser {
  128. background: url("../../../assets/nav/ic_data_governance_check .png")
  129. no-repeat;
  130. }
  131. .dataStore {
  132. background: url("../../../assets/nav/ic_data_save_check.png") no-repeat;
  133. }
  134. .dashboard {
  135. background: url("../../../assets/nav/ic_setting_nav_check.png") no-repeat;
  136. }
  137. .advance {
  138. background: url("../../../assets/nav/ic_list_nav_search_check.png")
  139. no-repeat;
  140. }
  141. .integration {
  142. background: url("../../../assets/nav/ic_data_governance_check .png")
  143. no-repeat;
  144. }
  145. .protocol {
  146. background: url("../../../assets/nav/ic_list_nav_agreement_check.png")
  147. no-repeat;
  148. }
  149. .deployNode {
  150. background: url("../../../assets/nav/ic_list_nav_node_check.png")
  151. no-repeat;
  152. }
  153. .sourceDataItem {
  154. background: url("../../../assets/nav/ic_list_nav_source_check.png")
  155. no-repeat;
  156. }
  157. }
  158. }
  159. </style>