11<template >
2- <el-dropdown class =" userSelect" placement =" bottom" trigger =" click" @command = " onSelected " >
2+ <el-dropdown class =" userSelect" placement =" bottom" trigger =" click" >
33 <div class =" userSelect-container" >
44 <img src =" ~@/assets/img/logo.png" >
55 <span >{{user.nickname}}</span >
66 </div >
77 <el-dropdown-menu slot =" dropdown" >
88 <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 >
1312 </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" />
1416 </el-dropdown >
1517</template >
1618<script >
1719import { mapState } from ' vuex'
20+ import infoDialog from ' ./infoDialog'
21+ import passwordDialog from ' ./passwordDialog'
1822export default {
23+ components: { infoDialog, passwordDialog },
24+ data () {
25+ return {
26+ infoVisible: false ,
27+ passwordVisible: false
28+ }
29+ },
1930 computed: {
2031 ... mapState (' login' , {
2132 user : state => state .user
@@ -25,12 +36,20 @@ export default {
2536 }
2637 },
2738 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' )
3453 }
3554 }
3655}
@@ -40,6 +59,9 @@ $avatarSize = 30px;
4059.userSelect {
4160 font-size : 14px !important ;
4261 user-select : none ;
62+ a {
63+ color : inherit ;
64+ }
4365 .userSelect-container {
4466 flex-center ();
4567 height : 100% ;
0 commit comments