我的项目源码地址
页面级的权限管理
新建views/NoAuth.js,并配置view/index.js
新增routes
actions里return的要新增一个role
修改App.js
1
2const hasPermission =route.roles.includes(this.props.role)
return hasPermission?<route.component {...routerProps} />:<Redirect to="/admin/noauth" />
此时发现如果在ajax尚未返回数据时就点击别的会报错,可以加如下代码进行优化(多console)
1 | if(!this.updater.isMounted(this)) return |
个人设置界面
view->routes->frame
tips: hashRouter有#,BrowserRouter没有#但是要加try_files
上传图片
实际上保存的是url
贴图库(新用户注册可以免费上传7张)
antd官网关于Upload组件的介绍根据里面的示例写views/Profile.js
上传完后自动同步到状态栏
- actionTypes添加修改头像操作
- actions/user里写change函数
- reducers/user里添加case情况
- views/profile界面connect函数联结
- 本文作者: Raphael_Li
- 本文链接: https://lifei-2019.github.io/react15/
- 版权声明: 本博客所有文章除特别声明外,均采用 Apache License 2.0 许可协议。转载请注明出处!