Navbar.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <el-menu class="navbar" mode="horizontal">
  3. <hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger>
  4. <levelbar></levelbar>
  5. <el-dropdown class="avatar-container" trigger="click">
  6. <div class="avatar-wrapper">
  7. <img class="user-avatar" :src="avatar+'?imageView2/1/w/80/h/80'">
  8. <i class="el-icon-caret-bottom"></i>
  9. </div>
  10. <el-dropdown-menu class="user-dropdown" slot="dropdown">
  11. <router-link class='inlineBlock' to="/">
  12. <el-dropdown-item>
  13. Home
  14. </el-dropdown-item>
  15. </router-link>
  16. <el-dropdown-item divided><span @click="logout" style="display:block;">LogOut</span></el-dropdown-item>
  17. </el-dropdown-menu>
  18. </el-dropdown>
  19. </el-menu>
  20. </template>
  21. <script>
  22. import { mapGetters } from 'vuex'
  23. import Levelbar from './Levelbar'
  24. import Hamburger from '@/components/Hamburger'
  25. export default {
  26. components: {
  27. Levelbar,
  28. Hamburger
  29. },
  30. computed: {
  31. ...mapGetters([
  32. 'sidebar',
  33. 'avatar'
  34. ])
  35. },
  36. methods: {
  37. toggleSideBar() {
  38. this.$store.dispatch('ToggleSideBar')
  39. },
  40. logout() {
  41. this.$store.dispatch('LogOut').then(() => {
  42. location.reload() // 为了重新实例化vue-router对象 避免bug
  43. })
  44. }
  45. }
  46. }
  47. </script>
  48. <style rel="stylesheet/scss" lang="scss" scoped>
  49. .navbar {
  50. height: 50px;
  51. line-height: 50px;
  52. border-radius: 0px !important;
  53. .hamburger-container {
  54. line-height: 58px;
  55. height: 50px;
  56. float: left;
  57. padding: 0 10px;
  58. }
  59. .errLog-container {
  60. display: inline-block;
  61. position: absolute;
  62. right: 150px;
  63. }
  64. .screenfull {
  65. position: absolute;
  66. right: 90px;
  67. top: 16px;
  68. color: red;
  69. }
  70. .avatar-container {
  71. height: 50px;
  72. display: inline-block;
  73. position: absolute;
  74. right: 35px;
  75. .avatar-wrapper {
  76. cursor: pointer;
  77. margin-top: 5px;
  78. position: relative;
  79. .user-avatar {
  80. width: 40px;
  81. height: 40px;
  82. border-radius: 10px;
  83. }
  84. .el-icon-caret-bottom {
  85. position: absolute;
  86. right: -20px;
  87. top: 25px;
  88. font-size: 12px;
  89. }
  90. }
  91. }
  92. }
  93. </style>