From f16875c9af2d51d6dba86234d63f86ac2d766bc4 Mon Sep 17 00:00:00 2001 From: 若依 <yzz_ivy@163.com> Date: 星期二, 28 十一月 2023 12:04:36 +0800 Subject: [PATCH] !799 update ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java. Merge pull request !799 from 张利/N/A --- ruoyi-ui/src/store/modules/user.js | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index 20f44bf..01c8683 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -4,6 +4,7 @@ const user = { state: { token: getToken(), + id: '', name: '', avatar: '', roles: [], @@ -13,6 +14,9 @@ mutations: { SET_TOKEN: (state, token) => { state.token = token + }, + SET_ID: (state, id) => { + state.id = id }, SET_NAME: (state, name) => { state.name = name @@ -49,16 +53,17 @@ // 获取用户信息 GetInfo({ commit, state }) { return new Promise((resolve, reject) => { - getInfo(state.token).then(res => { + getInfo().then(res => { const user = res.user - const avatar = user.avatar == "" ? require("@/assets/image/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; + const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 commit('SET_ROLES', res.roles) commit('SET_PERMISSIONS', res.permissions) } else { commit('SET_ROLES', ['ROLE_DEFAULT']) } - commit('SET_NAME', user.username) + commit('SET_ID', user.userId) + commit('SET_NAME', user.userName) commit('SET_AVATAR', avatar) resolve(res) }).catch(error => { @@ -66,7 +71,7 @@ }) }) }, - + // 退出系统 LogOut({ commit, state }) { return new Promise((resolve, reject) => { -- Gitblit v1.9.2