Navbar.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <style>
  2. .navbar {
  3. background: #F0F4F8;
  4. display: flex;
  5. }
  6. </style>
  7. <template>
  8. <el-menu class="navbar" mode="horizontal">
  9. <!--<hamburger :toggle-click="toggleSideBar" :is-active="sidebar.opened" class="hamburger-container"/>-->
  10. <breadcrumb />
  11. <div class="user">
  12. <a href="">客户端下载</a>
  13. <el-dropdown class="avatar-container" trigger="click">
  14. <div class="avatar-wrapper">
  15. <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
  16. <span class="name">{{ name }}</span>
  17. <img src="@/icons/image/vip.png" class="vip">
  18. <i class="el-icon-arrow-down"/>
  19. </div>
  20. <el-dropdown-menu slot="dropdown" class="user-dropdown">
  21. <router-link class="inlineBlock" to="/">
  22. <el-dropdown-item>
  23. Home
  24. </el-dropdown-item>
  25. </router-link>
  26. <el-dropdown-item divided>
  27. <span style="display:block;" @click="logout">LogOut</span>
  28. </el-dropdown-item>
  29. </el-dropdown-menu>
  30. </el-dropdown>
  31. </div>
  32. </el-menu>
  33. </template>
  34. <script>
  35. import { mapGetters } from 'vuex'
  36. import Breadcrumb from '@/components/Breadcrumb'
  37. // import Hamburger from '@/components/Hamburger'
  38. export default {
  39. components: {
  40. Breadcrumb
  41. // Hamburger
  42. },
  43. computed: {
  44. ...mapGetters([
  45. 'name',
  46. 'avatar'
  47. ])
  48. },
  49. methods: {
  50. // toggleSideBar() {
  51. // this.$store.dispatch('ToggleSideBar')
  52. // },
  53. logout() {
  54. this.$store.dispatch('FedLogOut').then(() => {
  55. location.reload() // 为了重新实例化vue-router对象 避免bug
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style rel="stylesheet/scss" lang="scss" scoped>
  62. .navbar {
  63. height: 90px;
  64. line-height: 90px;
  65. border-radius: 0px !important;
  66. .user {
  67. position: absolute;
  68. right: 35px;
  69. a {
  70. font-size: 16px;
  71. color: #4883FB;
  72. }
  73. }
  74. .user-avatar,
  75. .name,
  76. .vip,
  77. .el-icon-arrow-down {
  78. vertical-align: middle;
  79. }
  80. .screenfull {
  81. position: absolute;
  82. right: 90px;
  83. top: 16px;
  84. color: red;
  85. }
  86. .avatar-container {
  87. height: 90px;
  88. display: inline-block;
  89. .avatar-wrapper {
  90. cursor: pointer;
  91. margin-top: 5px;
  92. position: relative;
  93. line-height: initial;
  94. .user-avatar {
  95. width: 40px;
  96. height: 40px;
  97. border-radius: 10px;
  98. }
  99. .el-icon-caret-bottom {
  100. position: absolute;
  101. right: -20px;
  102. top: 25px;
  103. font-size: 12px;
  104. }
  105. }
  106. }
  107. }
  108. </style>