index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="max-box" :class="{'has-logo':showLogo}"
  3. :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
  4. <!--<logo :collapse="isCollapse" />-->
  5. <el-scrollbar class="router-button-box" :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
  6. <el-menu
  7. :default-active="activeMenu"
  8. :collapse="isCollapse"
  9. :background-color="settings.sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg"
  10. :text-color="settings.sideTheme === 'theme-dark' ? variables.menuText : 'rgba(0,0,0,.65)'"
  11. :unique-opened="true"
  12. :active-text-color="settings.theme"
  13. :collapse-transition="false"
  14. mode="vertical"
  15. >
  16. <sidebar-item
  17. v-for="(route, index) in sidebarRouters"
  18. :key="route.path + index"
  19. :item="route"
  20. :base-path="route.path"
  21. />
  22. </el-menu>
  23. </el-scrollbar>
  24. <!--个人信息/修改密码/退出登录-->
  25. <!--<el-dropdown class="user-box" trigger="click">-->
  26. <!--<div class="avatar-wrapper color_one">-->
  27. <!--<img v-if="avatar" :src="avatar" class="user-avatar">-->
  28. <!--<img v-if="!avatar" src="@/assets/ZDimages/tx_cion.png" class="user-avatar">-->
  29. <!--<p class="color_33">{{name}}</p>-->
  30. <!--<i class="el-icon-more"/>-->
  31. <!--</div>-->
  32. <!--<el-dropdown-menu slot="dropdown">-->
  33. <!--<router-link to="/user/profile">-->
  34. <!--<el-dropdown-item>个人中心</el-dropdown-item>-->
  35. <!--</router-link>-->
  36. <!--&lt;!&ndash;<el-dropdown-item @click.native="setting = true">&ndash;&gt;-->
  37. <!--&lt;!&ndash;<span>布局设置</span>&ndash;&gt;-->
  38. <!--&lt;!&ndash;</el-dropdown-item>&ndash;&gt;-->
  39. <!--<el-dropdown-item @click.native="logout">-->
  40. <!--<span>退出登录</span>-->
  41. <!--</el-dropdown-item>-->
  42. <!--</el-dropdown-menu>-->
  43. <!--</el-dropdown>-->
  44. <p style="height:30px;"></p>
  45. </div>
  46. </template>
  47. <script>
  48. import { mapGetters, mapState } from "vuex";
  49. import Logo from "./Logo";
  50. import SidebarItem from "./SidebarItem";
  51. import variables from "@/assets/styles/variables.scss";
  52. export default {
  53. components: { SidebarItem, Logo },
  54. computed: {
  55. ...mapState(["settings"]),
  56. ...mapGetters(["sidebarRouters", "sidebar","avatar","name"]),
  57. activeMenu() {
  58. const route = this.$route;
  59. // console.log("route",route)
  60. const { meta, path } = route;
  61. // if set path, the sidebar will highlight the path you set
  62. if (meta.activeMenu) {
  63. return meta.activeMenu;
  64. }
  65. this.$parent.demo(path);
  66. return path;
  67. },
  68. showLogo() {
  69. return this.$store.state.settings.sidebarLogo;
  70. },
  71. variables() {
  72. return variables;
  73. },
  74. isCollapse() {
  75. // return !this.sidebar.opened;
  76. },
  77. setting: {
  78. get() {
  79. return this.$store.state.settings.showSettings
  80. },
  81. set(val) {
  82. this.$store.dispatch('settings/changeSetting', {
  83. key: 'showSettings',
  84. value: val
  85. })
  86. }
  87. },
  88. },
  89. methods: {
  90. //退出登录
  91. async logout() {
  92. // console.log('visitedViews',this.$store.state.tagsView.visitedViews)
  93. // console.log('routes',this.$store.state.permission.routes)
  94. // console.log('theme',this.$store.state.settings.theme)
  95. this.$confirm('确定注销并退出系统吗?', '提示', {
  96. confirmButtonText: '确定',
  97. cancelButtonText: '取消',
  98. type: 'warning'
  99. }).then(() => {
  100. this.$store.dispatch('LogOut').then(() => {
  101. let list = [];
  102. list.push(this.$store.state.tagsView.visitedViews[0]);
  103. this.$store.state.tagsView.visitedViews = [];
  104. this.$store.state.tagsView.visitedViews.push(list[0]);
  105. console.log('visitedViews',this.$store.state.tagsView.visitedViews)
  106. // location.href = localStorage.getItem('windowHref');
  107. this.$router.push({ path:"/login" }).catch(()=>{});
  108. })
  109. }).catch(() => {});
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .max-box{
  116. /*height:100vh;*/
  117. display: flex;
  118. flex-direction: column;
  119. margin:5px 10px 0 0;
  120. border-bottom-right-radius: 10px;
  121. border-top-right-radius: 10px;
  122. .router-button-box{
  123. flex:1;
  124. }
  125. .user-box {
  126. width:230px;
  127. height:40px;
  128. margin:28px 0;
  129. margin-right: 30px;
  130. .avatar-wrapper {
  131. display: flex;
  132. position: relative;
  133. img{
  134. height:40px;
  135. width:40px;
  136. border-radius:50%;
  137. }
  138. p{
  139. flex:1;
  140. line-height:40px;
  141. margin:0 15px;
  142. font-size:14px;
  143. }
  144. i{
  145. -webkit-transform: rotateZ(-90deg);
  146. -ms-transform: rotate(-90deg);
  147. transform: rotateZ(-90deg);
  148. }
  149. }
  150. }
  151. }
  152. .el-dropdown-menu--medium{
  153. /*backAnimation: red!important;*/
  154. /*top:810px!important;*/
  155. }
  156. </style>