antd pro v5 of js安装了此插件, access中使用hasRoutes.includes(route.name),菜单中出现页面,但访问页面之后访问出现403[Bug]
ajunc opened this issue · comments
// access.js
export default function access(initialState) {
const { currentUser, hasRoutes = [] } = initialState || {};
debugger
return {
// canAdmin: currentUser && currentUser.access === 'admin',
// normalRouteFilter: (route) => hasRoutes.includes(route && route.name),
normalRouteFilter: (route) => hasRoutes.includes(route.name),
touristRole: true
};
}
//路由配置
{
path: '/dashboard',
name: 'dashboard',
icon: 'dashboard',
access: 'normalRouteFilter',
routes: [
{
path: '/dashboard',
redirect: '/dashboard/analysis',
},
{
name: 'monitor',
access: 'normalRouteFilter',
icon: 'smile',
path: '/dashboard/monitor',
component: './dashboard/monitor',
},
],
},
// app.jsx 中的 getInitialState
const hasRoutes = ['dashboard','monitor']
// if (history.location.pathname !== loginPath) {
const currentUser = await fetchUserInfo();
return {
fetchUserInfo,
currentUser,
hasRoutes,
settings: {},
};
是不是此插件跟antd pro v5有冲突导致呢?应该如何解决此问题呢?谢谢
@fangzhengjin
antd design pro 不支持你这种写法吧?
access文件返回的对象只能有一层, 并且是 key: string => value: boolean 的形式
{
touristRole1: true,
touristRole2: true
}
你可以将hasRoutes合并入返回的json中, 在路由文件route.ts配置access标签为每个路由设置对应的权限代码