From 5c18554c5e1b181073c1076b426136479a6a201a Mon Sep 17 00:00:00 2001
From: lion <120344285@qq.com>
Date: Wed, 10 May 2023 10:14:35 +0800
Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/layout/components/Navbar.vue | 6 ++++++
src/store/modules/user.js | 13 +++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index 93c9cd3..7d2b5ca 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -77,6 +77,9 @@
+
+ {{userName}}
+
系统首页
@@ -123,6 +126,7 @@ export default {
//isLoading:false,
noticeData: [],
messageStatus: 2,
+ userName:'',
// columns:[
// {
// width: 160,
@@ -213,6 +217,8 @@ export default {
},
mounted() {
this.getNotice();
+ console.log("this.$store.state",this.$store.state)
+ this.userName = this.$store.state.user?.user_name
},
};
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index c288974..7160fdd 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -16,7 +16,8 @@ const getDefaultState = () => {
return {
token: getToken(),
name: '',
- avatar: '',
+ avatar: '',
+ user_name:'',
roles: []
}
}
@@ -32,6 +33,9 @@ const mutations = {
},
SET_NAME: (state, name) => {
state.name = name
+ },
+ SET_USER_NAME: (state, user_name) => {
+ state.user_name = user_name
},
SET_AVATAR: (state, avatar) => {
state.avatar = avatar
@@ -84,13 +88,14 @@ const actions = {
const {
roles,
name,
- avatar
+ avatar,
+ username
} = response
-
commit('SET_ROLES', roles)
- commit('SET_NAME', name)
+ commit('SET_NAME', name)
+ commit('SET_USER_NAME', username)
commit('SET_AVATAR', avatar)
resolve(response)
}).catch(error => {