Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

根据后端接口返回的数据,动态追加权限 #2916 #2928

Merged
merged 2 commits into from
Jan 10, 2019

Conversation

xiaohuoni
Copy link
Member

@xiaohuoni xiaohuoni commented Nov 20, 2018

Close: #2916
根据mock返回的数据,为user追加了访问高级表单(/form/advanced-form)页面的权限
可以用于多角色管理菜单,把菜单访问权限交给服务端。

@netlify
Copy link

netlify bot commented Nov 20, 2018

Deploy preview for ant-design-pro ready!

Built with commit f864505

https://deploy-preview-2928--ant-design-pro.netlify.com

@chenshuai2144
Copy link
Collaborator

年轻人 你忘记写文档了

@xiaohuoni
Copy link
Member Author

@chenshuai2144 写啥文档?

@afc163
Copy link
Member

afc163 commented Nov 22, 2018

类似《如何根据后端接口返回的数据,动态加载路由》

@xiaohuoni
Copy link
Member Author

xiaohuoni commented Nov 22, 2018

考虑一下再写

@xiaohuoni
Copy link
Member Author

xiaohuoni commented Nov 22, 2018

文档说明:umijs/umi#1051

@xiaohuoni
Copy link
Member Author

xiaohuoni commented Nov 22, 2018

用例出处:umijs/umi#1377 (comment)

@xiaohuoni
Copy link
Member Author

现在的方案,修改的是编译后的路由数组,可能需要考虑一些能不能直接修改编译前的数组,相当于api.modifyRoutes,不然现在的方案,需要修改的内容很多的时候,有点困难。

@dongliang1993
Copy link

楼上 m430 说的那个,我想到一个不怎么样的解决方案:BasicLayout.js 会在 componentDidMount 时 dispatch 一个 getMenuData 的 effect,在这个方发里面根据 router.config.js 的数据(routes)生成 menuData 和 breadcrumbNameMap,然后通过这两个数据生成 SiderMenu 和 面包屑。所以我想的是,可以在登录时请求所有菜单数据,然后在 getMenuData 里面根据之前的请求回来的菜单数据来对比 routes,比如后端菜单数据里面没有 A、A-1 权限,那就删除 routes 对应的数据。最后渲染出的 SiderMenu 没有删除的那些菜单,但路由还是注册了

@denghp
Copy link

denghp commented Dec 26, 2018

最新代码如何实现动态菜单,有具体实现方式吗? 看了好多issues 没有找到具体方案?
官方文档就一句话,个人能力有限,真心不知道咋实现。
image
@chenshuai2144 @xiaohuoni 各位大牛,能更新下官网文档,给个具体解决方案吗?

@xiaohuoni xiaohuoni closed this Jan 9, 2019
@afc163 afc163 deleted the runtime-routes-appjs branch January 9, 2019 13:36
@afc163 afc163 restored the runtime-routes-appjs branch January 9, 2019 13:36
@xiaohuoni xiaohuoni reopened this Jan 9, 2019
@xiaohuoni xiaohuoni changed the title 根据后端接口返回的数据,动态加载路由 #2916 根据后端接口返回的数据,动态追加权限 #2916 Jan 9, 2019
@xiaohuoni
Copy link
Member Author

@chenshuai2144 这个看看可不可以合并了?

@xiaohuoni xiaohuoni merged commit 1682159 into master Jan 10, 2019
@xiaohuoni xiaohuoni deleted the runtime-routes-appjs branch January 10, 2019 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants