index.vue
1.86 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
<template>
<div>
<!-- <el-dropdown size="small" class="d2-mr">
<span class="btn-text">{{info.name ? `你好 ${info.name}` : '未登录'}}</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="logOff">
<d2-icon name="power-off" class="d2-mr-5"/>
注销
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>-->
<div v-popover:popover-personal class="d2-mr personal-wrap">
<span v-if="show" class="btn-text">{{info && info.userType ? (info.userType == 1 ? `${info.detail.name}` : '管理员') : '未登录'}}</span>
<span class="btn-text out-txt" @click="logOut">退出</span>
<!-- <el-popover ref="popover-personal" placement="bottom-end" trigger="hover">
<personal-panel :user="info"></personal-panel>
</el-popover> -->
</div>
</div>
</template>
<script>
import { mapActions } from 'vuex'
// import PersonalPanel from '../personal-panel'
export default {
data() {
return {
show: true
}
},
// components: {
// PersonalPanel
// },
mounted() {
this.show = false
this.$event.$on('e-password-dialog', res => (this.passVisible = res))
this.getInfo()
},
methods: {
...mapActions('d2admin/user', ['load']),
...mapActions('d2admin/account', ['logout']),
/**
* @description 登出
*/
async logOut() {
this.$confirm('确认退出?', '退出', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async() => {
await this.logout()
await this.$StoreReset.call(this.$store) // 重置 store
this.$router.push('/login')
})
},
async getInfo() {
this.info = await this.load()
this.$nextTick(() => {
this.show = true
})
}
}
}
</script>
<style lang="scss" scoped>
.personal-wrap{
transform: translateY(-3px);
}
</style>