diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 769e8b7..f7363b1 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -6,6 +6,7 @@ export default { namespaced: true, state: { token: null, + id: null, name: null, uname: null, photo: null, @@ -19,6 +20,7 @@ export default { if (state.token == null) { if (localStorage.getItem('token') != null) { state.token = localStorage.getItem('token') + state.id = localStorage.getItem('id') state.name = localStorage.getItem('name') state.uname = localStorage.getItem('uname') state.photo = localStorage.getItem('photo') @@ -31,6 +33,7 @@ export default { // 清除用户信息 destroyUser (state) { state.token = null + state.id = null state.name = null state.uname = null state.photo = null @@ -57,6 +60,7 @@ export default { res => { if (res.data.status === 1) { localStorage.setItem('token', res.data.token) + localStorage.setItem('id', res.data.adminInfo.id) localStorage.setItem('name', res.data.adminInfo.name) localStorage.setItem('uname', res.data.adminInfo.uname) localStorage.setItem('photo', res.data.adminInfo.photo) diff --git a/src/views/layout/components/headbar.vue b/src/views/layout/components/headbar.vue index ef8a760..8c9f5fc 100644 --- a/src/views/layout/components/headbar.vue +++ b/src/views/layout/components/headbar.vue @@ -20,6 +20,11 @@ + + + + {{ this.$store.state.user.name }} + @@ -290,6 +295,8 @@ export default { this.$router.push('/home/set') } else if (command === 'logout') { this.logout() + } else if (command === 'go-adminEdit') { + this.$router.push(`/admin/edit/${this.$store.state.user.id}`) } }, changeLang (lang) {