From 02950a964bb0dcc202bd1f4ddd6c6fc4a92c8048 Mon Sep 17 00:00:00 2001 From: feige <791364011@qq.com> Date: 星期二, 15 四月 2025 17:14:50 +0800 Subject: [PATCH] 修改了bug --- ruoyi-ui/src/store/modules/user.js | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ruoyi-ui/src/store/modules/user.js b/ruoyi-ui/src/store/modules/user.js index 2816332..ad92ec3 100644 --- a/ruoyi-ui/src/store/modules/user.js +++ b/ruoyi-ui/src/store/modules/user.js @@ -6,6 +6,8 @@ token: getToken(), name: '', avatar: '', + clanId: '', + userId: '', roles: [], permissions: [] }, @@ -17,6 +19,9 @@ SET_NAME: (state, name) => { state.name = name }, + SET_USERNAME: (state, uname) => { + state.userName = uname + }, SET_AVATAR: (state, avatar) => { state.avatar = avatar }, @@ -25,14 +30,20 @@ }, SET_PERMISSIONS: (state, permissions) => { state.permissions = permissions - } + }, + SET_CLANID: (state, clanId) => { + state.clanId = clanId + }, + SET_USERID: (state, userId) => { + state.userId = userId + }, }, actions: { // 鐧诲綍 Login({ commit }, userInfo) { - const username = userInfo.username.trim() + const nickname = userInfo.nickName.trim() const password = userInfo.password const code = userInfo.code @@ -40,7 +51,7 @@ const uuid = userInfo.uuid return new Promise((resolve, reject) => { - login(username, password, code, uuid).then(res => { + login(nickname, password, code, uuid).then(res => { setToken(res.data.token) @@ -58,14 +69,22 @@ return new Promise((resolve, reject) => { getInfo().then(res => { const user = res.user - const avatar = (user.avatar == "" || user.avatar == null) ? require("@/assets/images/profile.jpg") : process.env.VUE_APP_BASE_API + user.avatar; + // (user.avatar == "" || user.avatar == null) ?: process.env.VUE_APP_BASE_API + user.avatar + const avatar =require("@/assets/images/zhang.png") ; if (res.roles && res.roles.length > 0) { // 楠岃瘉杩斿洖鐨剅oles鏄惁鏄竴涓潪绌烘暟缁� commit('SET_ROLES', res.roles) commit('SET_PERMISSIONS', res.permissions) + + } else { commit('SET_ROLES', ['ROLE_DEFAULT']) } + // console.log(res) + // alert(res.user.clanId) + commit('SET_USERID', res.user.userId) + commit('SET_CLANID', res.user.clanId) commit('SET_NAME', user.userName) + commit('SET_USERNAME', user.nickName) commit('SET_AVATAR', avatar) resolve(res) }).catch(error => { -- Gitblit v1.9.1