Navbar.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="navbar">
  3. <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
  5. <div class="right-menu">
  6. <template v-if="device!=='mobile'">
  7. <screenfull id="screenfull" class="right-menu-item hover-effect" />
  8. </template>
  9. <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
  10. <div class="avatar-wrapper">
  11. <img src="@/assets/avatar.gif" class="user-avatar">
  12. <i class="el-icon-caret-bottom" />
  13. </div>
  14. <el-dropdown-menu slot="dropdown">
  15. <router-link to="/profile/index">
  16. <el-dropdown-item>Profile</el-dropdown-item>
  17. </router-link>
  18. <router-link to="/">
  19. <el-dropdown-item>Dashboard</el-dropdown-item>
  20. </router-link>
  21. <a target="_blank" href="https://github.com/PanJiaChen/vue-element-admin/">
  22. <el-dropdown-item>Github</el-dropdown-item>
  23. </a>
  24. <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
  25. <el-dropdown-item>Docs</el-dropdown-item>
  26. </a>
  27. <el-dropdown-item divided @click.native="logout">
  28. <span style="display:block;">Log Out</span>
  29. </el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapGetters } from 'vuex'
  37. import Breadcrumb from '@/components/Breadcrumb'
  38. import Hamburger from '@/components/Hamburger'
  39. import ErrorLog from '@/components/ErrorLog'
  40. import Screenfull from '@/components/Screenfull'
  41. import SizeSelect from '@/components/SizeSelect'
  42. import Search from '@/components/HeaderSearch'
  43. export default {
  44. components: {
  45. Breadcrumb,
  46. Hamburger,
  47. ErrorLog,
  48. Screenfull,
  49. SizeSelect,
  50. Search
  51. },
  52. computed: {
  53. ...mapGetters([
  54. 'sidebar',
  55. 'avatar',
  56. 'device'
  57. ])
  58. },
  59. methods: {
  60. toggleSideBar() {
  61. this.$store.dispatch('app/toggleSideBar')
  62. },
  63. async logout() {
  64. await this.$store.dispatch('user/logout')
  65. this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .navbar {
  72. height: 50px;
  73. overflow: hidden;
  74. position: relative;
  75. background: #fff;
  76. box-shadow: 0 1px 4px rgba(0,21,41,.08);
  77. .hamburger-container {
  78. line-height: 46px;
  79. height: 100%;
  80. float: left;
  81. cursor: pointer;
  82. transition: background .3s;
  83. -webkit-tap-highlight-color:transparent;
  84. &:hover {
  85. background: rgba(0, 0, 0, .025)
  86. }
  87. }
  88. .breadcrumb-container {
  89. float: left;
  90. }
  91. .errLog-container {
  92. display: inline-block;
  93. vertical-align: top;
  94. }
  95. .right-menu {
  96. float: right;
  97. height: 100%;
  98. line-height: 50px;
  99. &:focus {
  100. outline: none;
  101. }
  102. .right-menu-item {
  103. display: inline-block;
  104. padding: 0 8px;
  105. height: 100%;
  106. font-size: 18px;
  107. color: #5a5e66;
  108. vertical-align: text-bottom;
  109. &.hover-effect {
  110. cursor: pointer;
  111. transition: background .3s;
  112. &:hover {
  113. background: rgba(0, 0, 0, .025)
  114. }
  115. }
  116. }
  117. .avatar-container {
  118. margin-right: 30px;
  119. .avatar-wrapper {
  120. margin-top: 5px;
  121. position: relative;
  122. .user-avatar {
  123. cursor: pointer;
  124. width: 40px;
  125. height: 40px;
  126. border-radius: 10px;
  127. }
  128. .el-icon-caret-bottom {
  129. cursor: pointer;
  130. position: absolute;
  131. right: -20px;
  132. top: 25px;
  133. font-size: 12px;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. </style>