首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSON结构-授权用户菜单

JSON结构-授权用户菜单
EN

Stack Overflow用户
提问于 2017-04-07 12:22:57
回答 1查看 30关注 0票数 0

我想通过用户登录来显示菜单。如果我用user1登录,只需显示menu1、menu2、menu3。如果我用user2登录,只需显示menu2和menu3。

我已经为每个模块创建了JSON结构。

代码语言:javascript
复制
tiles :
        {
                module1 : [
                    {
                        "header":"Data Peserta",
                        "subheader":"Kepesertaan",
                        "icon":"sap-icon://log",
                        "route":"datapeserta"
                    },
                    {
                        "header":"Header1",
                        "subheader":"Kepesertaan",
                        "icon":"sap-icon://delete",
                        "route":"first"
                    },
                    {
                        "header":"Header1",
                        "subheader":"Kepesertaan",
                        "icon":"sap-icon://line-charts",
                        "route":"first"
                    }                       
                ],

                module2 : [
                    {
                        "header":"Header2",
                        "subheader":"Layanan dan Manfaat",
                        "icon":"sap-icon://add-filter",
                        "route":"first"
                    },
                    {
                        "header":"Header2",
                        "subheader":"Layanan dan Manfaat",
                        "icon":"sap-icon://add-filter",
                        "route":"first"
                    },
                    {
                        "header":"Header2",
                        "subheader":"Layanan dan Manfaat",
                        "icon":"sap-icon://action",
                        "route":"first"
                    }                       
                ],                      

                module3 : [
                    {
                        "header":"Header3",
                        "subheader":"Investasi",
                        "icon":"sap-icon://activate",
                        "route":"first"
                    },
                    {
                        "header":"Header3",
                        "subheader":"Investasi",
                        "icon":"sap-icon://display-more",
                        "route":"first"
                    },
                    {
                        "header":"Header3",
                        "subheader":"Investasi",
                        "icon":"sap-icon://customize",
                        "route":"first"
                    }                       
                ]
        }

因此,每个模块都有一个菜单,并且都有3个模块。如何编辑此json结构以供用户授权?我把对象放到了这个JSON模型中吗?

谢谢大家。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-07 13:09:07

我不太清楚这个问题,但是如果您想将它合并到同一个JSON中,那么可以将"userlist“作为一个数组属性。有些事情是这样的(我是以module1为例):

{ "header":"Data Peserta", "subheader":"Kepesertaan", "icon":"sap-icon://log", "route":"datapeserta", "userlist":["user1","user2","user3"] }, { "header":"Header1", "subheader":"Kepesertaan", "icon":"sap-icon://delete", "route":"first", "userlist":["user2","user3"] }

这将为您提供更多粒度的访问控制。在这种情况下,模块内哪个用户要显示哪个标头/子头等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43278057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档