|
@@ -39,34 +39,70 @@ export default {
|
|
|
/**
|
|
/**
|
|
|
* 请求用户信息、权限、角色、菜单
|
|
* 请求用户信息、权限、角色、菜单
|
|
|
*/
|
|
*/
|
|
|
|
|
+ // async fetchUserInfo({ commit }) {
|
|
|
|
|
+ // const result = await getUserInfo().catch(() => {});
|
|
|
|
|
+ // if (!result) {
|
|
|
|
|
+ // return {};
|
|
|
|
|
+ // }
|
|
|
|
|
+ // // 用户信息
|
|
|
|
|
+ // commit('setUserInfo', result);
|
|
|
|
|
+ // // 用户权限
|
|
|
|
|
+ // const authorities =
|
|
|
|
|
+ // result.authorities
|
|
|
|
|
+ // ?.filter((d) => !!d.authority)
|
|
|
|
|
+ // ?.map((d) => d.authority) ?? [];
|
|
|
|
|
+ // commit('setAuthorities', authorities);
|
|
|
|
|
+ // // 用户角色
|
|
|
|
|
+ // const roles = result.roles?.map((d) => d.roleCode) ?? [];
|
|
|
|
|
+ // commit('setRoles', roles);
|
|
|
|
|
+ // // 用户菜单, 过滤掉按钮类型并转为 children 形式
|
|
|
|
|
+ // const { menus, homePath } = formatMenus(
|
|
|
|
|
+ // USER_MENUS ??
|
|
|
|
|
+ // toTreeData({
|
|
|
|
|
+ // data: result.authorities?.filter((d) => d.menuType !== 1),
|
|
|
|
|
+ // idField: 'menuId',
|
|
|
|
|
+ // parentIdField: 'parentId'
|
|
|
|
|
+ // })
|
|
|
|
|
+ // );
|
|
|
|
|
+ // commit('setMenus', menus);
|
|
|
|
|
+ // console.log('menus',menus, 'homePath',homePath)
|
|
|
|
|
+ // return { menus, homePath };
|
|
|
|
|
+ // },
|
|
|
|
|
+ //动态路由
|
|
|
async fetchUserInfo({ commit }) {
|
|
async fetchUserInfo({ commit }) {
|
|
|
const result = await getUserInfo().catch(() => {});
|
|
const result = await getUserInfo().catch(() => {});
|
|
|
|
|
+ console.log('result--',result)
|
|
|
if (!result) {
|
|
if (!result) {
|
|
|
return {};
|
|
return {};
|
|
|
}
|
|
}
|
|
|
// 用户信息
|
|
// 用户信息
|
|
|
- commit('setUserInfo', result);
|
|
|
|
|
|
|
+ // commit('setUserInfo', result);
|
|
|
// 用户权限
|
|
// 用户权限
|
|
|
- const authorities =
|
|
|
|
|
- result.authorities
|
|
|
|
|
- ?.filter((d) => !!d.authority)
|
|
|
|
|
- ?.map((d) => d.authority) ?? [];
|
|
|
|
|
- commit('setAuthorities', authorities);
|
|
|
|
|
|
|
+ // const authorities =
|
|
|
|
|
+ // result.authorities
|
|
|
|
|
+ // ?.filter((d) => !!d.authority)
|
|
|
|
|
+ // ?.map((d) => d.authority) ?? [];
|
|
|
|
|
+ // commit('setAuthorities', authorities);
|
|
|
// 用户角色
|
|
// 用户角色
|
|
|
- const roles = result.roles?.map((d) => d.roleCode) ?? [];
|
|
|
|
|
- commit('setRoles', roles);
|
|
|
|
|
|
|
+ // const roles = result.roles?.map((d) => d.roleCode) ?? [];
|
|
|
|
|
+ // commit('setRoles', roles);
|
|
|
// 用户菜单, 过滤掉按钮类型并转为 children 形式
|
|
// 用户菜单, 过滤掉按钮类型并转为 children 形式
|
|
|
const { menus, homePath } = formatMenus(
|
|
const { menus, homePath } = formatMenus(
|
|
|
USER_MENUS ??
|
|
USER_MENUS ??
|
|
|
toTreeData({
|
|
toTreeData({
|
|
|
- data: result.authorities?.filter((d) => d.menuType !== 1),
|
|
|
|
|
- idField: 'menuId',
|
|
|
|
|
|
|
+ data: result?.filter((d) => d.menuType !== 1),
|
|
|
|
|
+ idField: 'id',
|
|
|
parentIdField: 'parentId'
|
|
parentIdField: 'parentId'
|
|
|
})
|
|
})
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
|
|
+ // console.log('menus--',menus)
|
|
|
commit('setMenus', menus);
|
|
commit('setMenus', menus);
|
|
|
|
|
+ // const menus = result;
|
|
|
|
|
+ // const homePath = '/dashboard/workplace';
|
|
|
return { menus, homePath };
|
|
return { menus, homePath };
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 更新用户信息
|
|
* 更新用户信息
|
|
|
*/
|
|
*/
|