全局数据存储用户编号

This commit is contained in:
RuoYi 2023-09-27 15:21:37 +08:00
parent 1926840204
commit 9ced1e9766

View File

@ -4,6 +4,7 @@ import { getToken, setToken, removeToken } from '@/utils/auth'
const user = {
state: {
token: getToken(),
id: '',
name: '',
avatar: '',
roles: [],
@ -14,6 +15,9 @@ const user = {
SET_TOKEN: (state, token) => {
state.token = token
},
SET_ID: (state, id) => {
state.id = id
},
SET_NAME: (state, name) => {
state.name = name
},
@ -58,6 +62,7 @@ const user = {
} else {
commit('SET_ROLES', ['ROLE_DEFAULT'])
}
commit('SET_ID', user.userId)
commit('SET_NAME', user.userName)
commit('SET_AVATAR', avatar)
resolve(res)