的后端权限控制模型
一、大体的前端路由流程图,
非登录页的外层布局userLayout代码:
@connect(({ nav }) => ({
navList:nav.navList
}))
class Layout0 extends React.PureComponent {
render() {
const { childrenComponent } = this.props;
return (
<div>
<div>Layout0</div>
<div>链接:
<Link to="/"> 首页</Link>
<br/>
<Link to="/example">例页</Link>
<br/>
<Link to="/example2">例页2</Link>
</div>
<div>
<div>子区域</div>
<Switch>
{
Object.keys(childrenComponent).map(key=>
<Route path={key} component={childrenComponent[key]} key={key}/>
)
}
<Route render={()=><Redirect to={Object.keys(childrenComponent)[0]}/>} />
</Switch>
</div>
</div>
);
}
}
export default Layout0;
加载models/nav时自动加载当前用户的信息,
subscriptions:{
initNavList({dispatch}){
dispatch({type:"fetchNavList"})
}
}