Navbar.vue 4.0 KB

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