Header.vue
2.42 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template lang="pug">
div(class="header")
.logo
span(@click="expanMenu")
<svg-icon className="toggle-icon" icon-class='togglemenu' />
.right-menu
el-dropdown(trigger="click" @command="handleCommand")
span(class="el-dropdown-link")
<svg-icon className="icon" icon-class='user' />
span(class="userInfo-name userInfo-discription") {{name}}
i(class="el-icon-arrow-down el-icon-caret-bottom")
el-dropdown-menu(slot="dropdown")
el-dropdown-item(command="logout")
span(class="userInfo-operation userInfo-discription") 退出
</template>
<script>
import { mapState, mapActions, mapMutations } from 'vuex'
export default {
name: 'CommHeader',
computed: {
...mapState('app', ['sidebar']),
...mapState(['name', 'userId']),
isCollapse() {
return this.sidebar.opened
}
},
data() {
return {
visible: true,
resetObj: null
}
},
mounted() {},
methods: {
...mapMutations(['TOGGLE_UPDATEPASS_DIALOG']),
...mapActions(['logout']),
...mapActions('app', ['toggleSideBar']),
handleLogout() {
try {
this.logout()
this.$router.push('/login')
} catch (error) {
console.log(error)
}
},
handleUpdatepass() {
this.TOGGLE_UPDATEPASS_DIALOG({
name: this.name,
username: this.userId
})
},
expanMenu() {
this.toggleSideBar()
},
handleCommand(data) {
if (data === 'pass') {
this.handleUpdatepass()
} else if (data === 'logout') {
this.handleLogout()
}
}
}
}
</script>
<style lang="scss" scoped>
.header {
display: flex;
justify-content: space-between;
align-items: center;
height: 64px;
box-shadow: 0px 1px 4px 0px rgba(0, 21, 41, 0.12);
padding: 0 20px 0 24px;
}
.logo {
display: flex;
justify-content: flex-start;
align-items: center;
.toggle-icon {
width: 20px;
height: 20px;
}
span {
font-size: 14px;
cursor: pointer;
.rotate {
transform: rotate(90deg);
}
}
}
.right-menu {
.el-dropdown-link {
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
height: 100%;
.icon {
height: 28px;
width: 28px;
margin-right: 6px;
}
}
.user-icon {
font-size: 20px;
margin-right: 10px;
}
.userInfo-name {
margin-right: 10px;
color: #666666;
}
}
</style>