account.vue
1.21 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
<template>
<div class="sign_out">
<el-dropdown>
<div class="el-dropdown-link">
<Icon name="avatar" class="avatar"></Icon>
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>{{ userName }}</el-dropdown-item>
<el-dropdown-item @click.native="removeCookie">退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
<script>
import { removeToken } from "../../utils/auth";
import { mapGetters } from "vuex";
export default {
methods: {
removeCookie() {
removeToken();
this.$store.dispatch("clearInfo");
this.$router.push("/login");
},
},
computed: {
...mapGetters(["userName"]),
},
};
</script>
<style lang="less" scoped>
.sign_out {
float: right;
margin-right: 20px;
> * {
display: inline-block;
vertical-align: middle;
}
.avatar {
font-size: 40px;
margin-top: 5px;
color: @highlightColor;
}
img {
width: 40px;
height: 40px;
border-radius: 10px;
margin-top: 5px;
}
.sign_out_icon {
color: #5a5e66;
font-size: 20px;
cursor: pointer;
&:hover {
color: #aaa;
}
}
}
</style>