index.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
  3. <logo v-if="showLogo" :collapse="isCollapse" />
  4. <el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
  5. <el-menu
  6. :default-active="activeMenu"
  7. :default-openeds ='[activeMenuT]'
  8. ref="menu"
  9. :collapse="isCollapse"
  10. :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg"
  11. :text-color="settings.sideTheme === 'theme-dark' ? variables.menuText : 'rgba(0,0,0,.65)'"
  12. :unique-opened="true"
  13. :active-text-color="settings.theme"
  14. :collapse-transition="false"
  15. mode="vertical"
  16. >
  17. <sidebar-item
  18. v-for="(route, index) in handleSide"
  19. :key="route.path + index"
  20. :item="route"
  21. :base-path="route.path"
  22. />
  23. </el-menu>
  24. </el-scrollbar>
  25. </div>
  26. </template>
  27. <script>
  28. import { mapGetters, mapState } from "vuex";
  29. import Logo from "./Logo";
  30. import SidebarItem from "./SidebarItem";
  31. import variables from "@/assets/styles/variables.scss";
  32. export default {
  33. // data() {
  34. // return {
  35. // indexs: 1,
  36. // srtw: [0],
  37. // showde:true
  38. // }
  39. // },
  40. components: {
  41. SidebarItem, Logo,
  42. },
  43. mounted() {
  44. console.log(this.sidebarRouters,this.sidebar,this.settings)
  45. },
  46. computed: {
  47. ...mapState(["settings"]),
  48. ...mapGetters(["sidebarRouters", "sidebar","tabIndex"]),
  49. activeMenu() {
  50. // const route = this.$route;
  51. // const { meta, path } = route;
  52. // // if set path, the sidebar will highlight the path you set
  53. // if (meta.activeMenu) {
  54. // return meta.activeMenu;
  55. // }
  56. // console.log(this.tabIndex)
  57. return this.tabIndex;
  58. },
  59. activeMenuT(){
  60. let tabshow = {}
  61. console.log(this.tabIndex,234)
  62. return this.tabIndex
  63. },
  64. handleSide() {
  65. let add = []
  66. for(let item of this.sidebarRouters){
  67. if(this.activeMenu.includes(item.path||item.redirect)){
  68. add.push(item)
  69. }
  70. }
  71. console.log(add)
  72. return add
  73. },
  74. showLogo() {
  75. return this.$store.state.settings.sidebarLogo;
  76. },
  77. variables() {
  78. return variables;
  79. },
  80. isCollapse() {
  81. return !this.sidebar.opened;
  82. },
  83. iejgu(){
  84. return [0]
  85. }
  86. }
  87. };
  88. </script>