1
1
<template >
2
- <el-dropdown class =" userSelect" placement =" bottom" trigger =" click" @command = " onSelected " >
2
+ <el-dropdown class =" userSelect" placement =" bottom" trigger =" click" >
3
3
<div class =" userSelect-container" >
4
4
<img src =" ~@/assets/img/logo.png" >
5
5
<span >{{user.nickname}}</span >
6
6
</div >
7
7
<el-dropdown-menu slot =" dropdown" >
8
8
<el-dropdown-item :disabled =" true" >{{version}}</el-dropdown-item >
9
- <el-dropdown-item >
10
- <a style =" color :inherit ;" href =" https://github.com/uncleLian/vue-blog" target =" _blank" >{{$t('header.github')}}</a >
11
- </el-dropdown-item >
12
- <el-dropdown-item divided command =" exit" >{{$t('header.logout')}}</el-dropdown-item >
9
+ <el-dropdown-item divided @click.native =" infoVisible = true" >{{$t('header.userInfo')}}</el-dropdown-item >
10
+ <el-dropdown-item @click.native =" passwordVisible = true" >{{$t('header.password')}}</el-dropdown-item >
11
+ <el-dropdown-item @click.native =" handleLogout" >{{$t('header.logout')}}</el-dropdown-item >
13
12
</el-dropdown-menu >
13
+ <!-- dialog -->
14
+ <info-dialog :title =" $t('header.userInfo')" v-if =" infoVisible" :visible.sync =" infoVisible" @onSubmit =" handleChangeUserInfo" disabled :json =" user" />
15
+ <password-dialog :title =" $t('header.password')" v-if =" passwordVisible" :visible.sync =" passwordVisible" @onSubmit =" handleChangeUserPassword" />
14
16
</el-dropdown >
15
17
</template >
16
18
<script >
17
19
import { mapState } from ' vuex'
20
+ import infoDialog from ' ./infoDialog'
21
+ import passwordDialog from ' ./passwordDialog'
18
22
export default {
23
+ components: { infoDialog, passwordDialog },
24
+ data () {
25
+ return {
26
+ infoVisible: false ,
27
+ passwordVisible: false
28
+ }
29
+ },
19
30
computed: {
20
31
... mapState (' login' , {
21
32
user : state => state .user
@@ -25,12 +36,20 @@ export default {
25
36
}
26
37
},
27
38
methods: {
28
- onSelected (val ) {
29
- if (val === ' exit' ) {
30
- this .$store .dispatch (' login/logout' ).then (() => {
31
- this .$router .push (' /login' )
32
- })
33
- }
39
+ handleLogout (val ) {
40
+ this .$store .dispatch (' login/logout' )
41
+ },
42
+ handleChangeUserInfo (form ) {
43
+ // 假修改
44
+ const user = { ... this .user , ... form }
45
+ this .$store .commit (' login/SET_USER' , user)
46
+ this .infoVisible = false
47
+ this .$message .success (' success' )
48
+ },
49
+ handleChangeUserPassword (form ) {
50
+ // 假修改
51
+ this .passwordVisible = false
52
+ this .$message .success (' success' )
34
53
}
35
54
}
36
55
}
@@ -40,6 +59,9 @@ $avatarSize = 30px;
40
59
.userSelect {
41
60
font-size : 14px !important ;
42
61
user-select : none ;
62
+ a {
63
+ color : inherit ;
64
+ }
43
65
.userSelect-container {
44
66
flex-center ();
45
67
height : 100% ;
0 commit comments