Repository navigation
Expand file tree
/
Copy pathheadTop.vue
More file actions
80 lines (76 loc) · 1.92 KB
/
Copy pathheadTop.vue
File metadata and controls
80 lines (76 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<template>
<div class="header_container">
<el-breadcrumb separator="/">
<el-breadcrumb-item :to="{ path: '/manage' }">首页</el-breadcrumb-item>
<el-breadcrumb-item v-for="(item, index) in $route.meta" :key="index">{{item}}</el-breadcrumb-item>
</el-breadcrumb>
<el-dropdown @command="handleCommand" menu-align='start'>
<img :src="baseImgPath + adminInfo.avatar" class="avator">
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="home">首页</el-dropdown-item>
<el-dropdown-item command="signout">退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
<script>
import {signout} from '@/api/getData'
import {baseImgPath} from '@/config/env'
import {mapActions, mapState} from 'vuex'
export default {
data(){
return {
baseImgPath,
}
},
created(){
if (!this.adminInfo.id) {
this.getAdminData()
}
},
computed: {
...mapState(['adminInfo']),
},
methods: {
...mapActions(['getAdminData']),
async handleCommand(command) {
if (command == 'home') {
this.$router.push('/manage');
}else if(command == 'signout'){
const res = await signout()
if (res.status == 1) {
this.$message({
type: 'success',
message: '退出成功'
});
this.$router.push('/');
}else{
this.$message({
type: 'error',
message: res.message
});
}
}
},
}
}
</script>
<style lang="less">
@import '../style/mixin';
.header_container{
background-color: #EFF2F7;
height: 60px;
display: flex;
justify-content: space-between;
align-items: center;
padding-left: 20px;
}
.avator{
.wh(36px, 36px);
border-radius: 50%;
margin-right: 37px;
}
.el-dropdown-menu__item{
text-align: center;
}
</style>