概念/述语
从这里开始
数据库
开发入门
程序扩展
使用介绍
其它

纸壳CMS的所有插件都可以定义自己的菜单,也可以将菜单添加到已有分组中。给后端添加菜单的方式很简单,只要在插件类中返回菜单即可。

系统菜单

CMS系统的核心功能菜单在初始化在AdminMenus类的Menus对象中:

namespace ZKEACMS
{
    public static class AdminMenus
    {
        public static List<AdminMenu> Menus { get; } = new List<AdminMenu>
        {
            new AdminMenu
            {
                Title = "仪表盘",
                Icon = "glyphicon-dashboard",
                Url = "~/admin",
                Order = 0
            },
            new AdminMenu
            {
                Title = "布局",
                Icon = "glyphicon-th-list",
                Order = 1,
                Children = new List<AdminMenu>
                {
                    new AdminMenu
                    {
                        Title = "布局列表",
                        Url = "~/admin/Layout",
                        Icon = "glyphicon-align-justify",
                        PermissionKey = PermissionKeys.ViewLayout
                    },
                    new AdminMenu
                    {
                        Title = "布局内容",
                        Url = "~/admin/Layout/LayoutWidget",
                        Icon = "glyphicon-th-list",
                        PermissionKey = PermissionKeys.ViewLayout
                    }
                }
            },
            new AdminMenu
            {
                Title = "页面",
                Icon = "glyphicon-eye-open",
                Url = "~/admin/Page",
                Order = 2,
                PermissionKey = PermissionKeys.ViewPage
            }
            ......
        };
    }
}

插件菜单

每一个插件都可以添加各自的菜单,只需要在插件类(XXXPlug.cs)中定义即可,如URL重定向插件RedirectionPlug

namespace ZKEACMS.Redirection
{
    public class RedirectionPlug : PluginBase
    {

        public override IEnumerable<AdminMenu> AdminMenu()
        {
            yield return new AdminMenu
            {
                Group = "系统",
                Title = "URL重定向",
                Url = "~/Admin/UrlRedirection",
                Icon = "glyphicon-random",
                Order = 12,
                PermissionKey = PermissionKeys.ViewUrlRedirect
            };
        }

    }
}

注意:Group即可将该菜单放到指定的菜单目录下。PermissionKey用来指定该菜单的出现至少需要什么权限。

常见问题

添加了菜单为什么在后端还是看不到?

首先先确定已经生成了项目。如果菜单中还是没有出现,请确认角色(/admin/role)是否有这项权限。新加的权限,也要主动赋给角色才会有权限。

微信公众号