Navbar.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div class="navbar">
  3. <!-- <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> -->
  4. <!-- <breadcrumb class="breadcrumb-container" /> -->
  5. <div class="left-menu">
  6. <i class='el-icon-location-information topIcon'></i>
  7. 武汉分部
  8. </div>
  9. <div class="right-menu">
  10. <div class="msginfo">
  11. <img src="@/assets/images/base/base-bell.png"
  12. alt="">
  13. <div class="active"></div>
  14. </div>
  15. <el-dropdown class="avatar-container"
  16. trigger="click">
  17. <div class="avatar-wrapper">
  18. <img src="@/assets/images/base/placehorder-icon.png"
  19. class="user-avatar" />
  20. <!-- <i class="el-icon-caret-bottom" /> -->
  21. <span>{{ username }}</span>
  22. </div>
  23. <el-dropdown-menu slot="dropdown"
  24. class="user-dropdown">
  25. <router-link to="/">
  26. <el-dropdown-item>Home</el-dropdown-item>
  27. </router-link>
  28. <a target="_blank"
  29. href="https://github.com/PanJiaChen/vue-admin-template/">
  30. <el-dropdown-item>Github</el-dropdown-item>
  31. </a>
  32. <a target="_blank"
  33. href="https://panjiachen.github.io/vue-element-admin-site/#/">
  34. <el-dropdown-item>Docs</el-dropdown-item>
  35. </a>
  36. <el-dropdown-item divided>
  37. <span style="display:block;"
  38. @click="logout">登出</span>
  39. </el-dropdown-item>
  40. </el-dropdown-menu>
  41. </el-dropdown>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import { mapGetters } from "vuex";
  47. // import Breadcrumb from '@/components/Breadcrumb'
  48. // import Hamburger from '@/components/Hamburger'
  49. export default {
  50. data () {
  51. return {
  52. username: ''
  53. }
  54. },
  55. components: {
  56. // Breadcrumb,
  57. // Hamburger
  58. },
  59. computed: {
  60. ...mapGetters(["sidebar", "avatar"])
  61. },
  62. mounted () {
  63. // 手动加入
  64. this.toggleSideBar();
  65. this.username = this.$store.getters.name;
  66. // console.log(this.$store.getters.name)
  67. },
  68. methods: {
  69. toggleSideBar () {
  70. this.$store.dispatch("app/toggleSideBar");
  71. },
  72. async logout () {
  73. await this.$store.dispatch("user/logout");
  74. this.$router.push(`/login?redirect=${this.$route.fullPath}`);
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .navbar {
  81. display: flex;
  82. flex-direction: row;
  83. justify-content: space-between;
  84. height: 60px;
  85. overflow: hidden;
  86. position: relative;
  87. background: #fff;
  88. box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.1);
  89. h2 {
  90. font-size: 18px;
  91. line-height: 60px;
  92. margin: 0 0 0 30px;
  93. display: inline-block;
  94. }
  95. .hamburger-container {
  96. line-height: 60px;
  97. height: 100%;
  98. float: left;
  99. cursor: pointer;
  100. transition: background 0.3s;
  101. -webkit-tap-highlight-color: transparent;
  102. &:hover {
  103. background: rgba(0, 0, 0, 0.025);
  104. }
  105. }
  106. .breadcrumb-container {
  107. float: left;
  108. }
  109. .left-menu {
  110. line-height: 60px;
  111. padding-left: 22px;
  112. font-size: 16px;
  113. color: #444;
  114. .topIcon {
  115. width: 20px;
  116. height: 25px;
  117. }
  118. }
  119. .right-menu {
  120. min-width: 204px;
  121. float: right;
  122. height: 100%;
  123. line-height: 60px;
  124. display: flex;
  125. flex-direction: row;
  126. justify-content: flex-start;
  127. &:focus {
  128. outline: none;
  129. }
  130. .msginfo {
  131. display: flex;
  132. flex-direction: row;
  133. justify-content: flex-start;
  134. align-items: center;
  135. margin-right: 34px;
  136. position: relative;
  137. cursor: pointer;
  138. img {
  139. width: 23px;
  140. height: 30px;
  141. }
  142. .active {
  143. position: absolute;
  144. width: 7px;
  145. height: 7px;
  146. background-color: #f97215;
  147. border-radius: 50%;
  148. top: 20px;
  149. right: -4px;
  150. }
  151. }
  152. .right-menu-item {
  153. display: inline-block;
  154. padding: 0 8px;
  155. height: 100%;
  156. font-size: 14px;
  157. color: #5a5e66;
  158. vertical-align: text-bottom;
  159. &.hover-effect {
  160. cursor: pointer;
  161. transition: background 0.3s;
  162. &:hover {
  163. background: rgba(0, 0, 0, 0.025);
  164. }
  165. }
  166. }
  167. .avatar-container {
  168. height: 60px;
  169. margin-right: 42px;
  170. cursor: pointer;
  171. .avatar-wrapper {
  172. position: relative;
  173. display: flex;
  174. flex-direction: row;
  175. justify-content: flex-start;
  176. align-items: center;
  177. span {
  178. margin-left: 15px;
  179. font-size: 14px;
  180. font-weight: 500;
  181. color: rgba(68, 68, 68, 1);
  182. }
  183. .user-avatar {
  184. cursor: pointer;
  185. width: 32px;
  186. height: 32px;
  187. border: 2px solid #f0f2f5;
  188. border-radius: 50%;
  189. }
  190. .el-icon-caret-bottom {
  191. cursor: pointer;
  192. position: absolute;
  193. right: -20px;
  194. top: 25px;
  195. font-size: 14px;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. </style>