|
@@ -18,6 +18,7 @@ const state = () => ({
|
|
|
phone: '',
|
|
phone: '',
|
|
|
avatar: require('@/assets/login_images/user_avatar.png'),
|
|
avatar: require('@/assets/login_images/user_avatar.png'),
|
|
|
isFirstLogin: false,
|
|
isFirstLogin: false,
|
|
|
|
|
+ roleKeys: [],
|
|
|
})
|
|
})
|
|
|
const getters = {
|
|
const getters = {
|
|
|
id: (state) => state.id,
|
|
id: (state) => state.id,
|
|
@@ -27,6 +28,7 @@ const getters = {
|
|
|
phone: (state) => state.phone,
|
|
phone: (state) => state.phone,
|
|
|
avatar: (state) => state.avatar,
|
|
avatar: (state) => state.avatar,
|
|
|
isFirstLogin: (state) => state.isFirstLogin,
|
|
isFirstLogin: (state) => state.isFirstLogin,
|
|
|
|
|
+ roleKeys: (state) => state.roleKeys,
|
|
|
}
|
|
}
|
|
|
const mutations = {
|
|
const mutations = {
|
|
|
/**
|
|
/**
|
|
@@ -67,6 +69,9 @@ const mutations = {
|
|
|
setAvatar(state, avatar) {
|
|
setAvatar(state, avatar) {
|
|
|
state.avatar = avatar
|
|
state.avatar = avatar
|
|
|
},
|
|
},
|
|
|
|
|
+ setRoleKeys(state, roleKeys) {
|
|
|
|
|
+ state.roleKeys = roleKeys
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
const actions = {
|
|
const actions = {
|
|
|
/**
|
|
/**
|
|
@@ -113,7 +118,7 @@ const actions = {
|
|
|
|
|
|
|
|
const res = await userApi.getUserInfo()
|
|
const res = await userApi.getUserInfo()
|
|
|
const { id, userName, nickName, phone, avatar } = res.data.entity
|
|
const { id, userName, nickName, phone, avatar } = res.data.entity
|
|
|
- const { roleIds, permissions } = res.data
|
|
|
|
|
|
|
+ const { roleIds, roleKeys, permissions } = res.data
|
|
|
/**
|
|
/**
|
|
|
* 检验返回数据是否正常,无对应参数,将使用默认用户名,头像,Roles和Permissions
|
|
* 检验返回数据是否正常,无对应参数,将使用默认用户名,头像,Roles和Permissions
|
|
|
* username {String}
|
|
* username {String}
|
|
@@ -126,6 +131,7 @@ const actions = {
|
|
|
(avatar && !isString(avatar)) ||
|
|
(avatar && !isString(avatar)) ||
|
|
|
(nickName && !isString(nickName)) ||
|
|
(nickName && !isString(nickName)) ||
|
|
|
(phone && !isString(phone)) ||
|
|
(phone && !isString(phone)) ||
|
|
|
|
|
+ (roleKeys && !isArray(roleKeys)) ||
|
|
|
(roleIds && !isArray(roleIds)) ||
|
|
(roleIds && !isArray(roleIds)) ||
|
|
|
(permissions && !isArray(permissions))
|
|
(permissions && !isArray(permissions))
|
|
|
) {
|
|
) {
|
|
@@ -143,6 +149,7 @@ const actions = {
|
|
|
if (avatar) commit('setAvatar', avatar)
|
|
if (avatar) commit('setAvatar', avatar)
|
|
|
// 如不使用roles权限控制,可删除以下代码
|
|
// 如不使用roles权限控制,可删除以下代码
|
|
|
if (roleIds) dispatch('acl/setRole', roleIds, { root: true })
|
|
if (roleIds) dispatch('acl/setRole', roleIds, { root: true })
|
|
|
|
|
+ if (roleKeys) commit('setRoleKeys', roleKeys)
|
|
|
// 如不使用permissions权限控制,可删除以下代码
|
|
// 如不使用permissions权限控制,可删除以下代码
|
|
|
if (permissions) dispatch('acl/setPermission', permissions, { root: true })
|
|
if (permissions) dispatch('acl/setPermission', permissions, { root: true })
|
|
|
|
|
|