提交 31110e5f 作者: 龚洪江

功能,路由权限

上级 de896770
...@@ -8,7 +8,7 @@ import { InterReqType } from '~/api/interface'; ...@@ -8,7 +8,7 @@ import { InterReqType } from '~/api/interface';
import { BackEndLoginType } from '~/api/interface/commonType'; import { BackEndLoginType } from '~/api/interface/commonType';
import { CommonAPI, SystemManageAPI } from '~/api'; import { CommonAPI, SystemManageAPI } from '~/api';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { SET_USERINFO, SET_ROLE_LIST } from '~/store/module/userInfo'; import { SET_USERINFO } from '~/store/module/userInfo';
import { authRouterList } from '~/router'; import { authRouterList } from '~/router';
// 请求的类型 // 请求的类型
...@@ -38,8 +38,8 @@ function LoginView() { ...@@ -38,8 +38,8 @@ function LoginView() {
// 存用户信息 // 存用户信息
dispatch(SET_USERINFO(res.result)); dispatch(SET_USERINFO(res.result));
SystemManageAPI.getListRoleMenuInfo({ roleId: res.result.roleInfo.id }).then(({ result }) => { SystemManageAPI.getListRoleMenuInfo({ roleId: res.result.roleInfo.id }).then(({ result }) => {
dispatch(SET_ROLE_LIST(result)); localStorage.setItem('roleObj', JSON.stringify(result));
const routeList = authRouterList(result); const routeList = authRouterList();
// 获取第一个路由 // 获取第一个路由
navigate({ pathname: routeList[0]?.children?.[0]?.path }); navigate({ pathname: routeList[0]?.children?.[0]?.path });
}); });
......
...@@ -6,8 +6,8 @@ import { listMenuInfoType } from '~/api/interface/systemManageType'; ...@@ -6,8 +6,8 @@ import { listMenuInfoType } from '~/api/interface/systemManageType';
type menuType = InterDataType<listMenuInfoType>; type menuType = InterDataType<listMenuInfoType>;
// 获取用户权限路由列表 // 获取用户权限路由列表
export const authRouterList = (data?: menuType) => { export const authRouterList = () => {
const roleObj: menuType = data || JSON.parse(localStorage.getItem('roleObj') as string); const roleObj: menuType = JSON.parse(localStorage.getItem('roleObj') as string);
if (roleObj) { if (roleObj) {
const ids: number[] = getAllKeys([roleObj]); const ids: number[] = getAllKeys([roleObj]);
const getRouteList = (data: RouteObjectType[]) => { const getRouteList = (data: RouteObjectType[]) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论