From 8a3bddb91782dd8229a7d9dbad21c2269fdd237b Mon Sep 17 00:00:00 2001 From: oldHome Date: Fri, 27 Jun 2025 17:22:08 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E7=94=A8=E6=88=B7=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E7=94=A8=E6=88=B7=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=92=8C=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/user.js | 4 ++++ src/views/layout/components/headbar.vue | 7 +++++++ 2 files changed, 11 insertions(+) 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) {