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