ABP框架系列之三十七:(Navigation-导航)
Every web application has some menu to navigate between pages/screens. ASP.NET Boilerplate provides a common ifrastructure to create and show menu to users.
每个Web应用程序都有一些菜单在页面/屏幕之间导航。ASP.NET提供了一个通用的ifrastructure样板文件创建和显示菜单的用户。
Creating Menus
An application may be consists of different modules and each module can have it's own menu items. To define menu items, we need to create a class derived from NavigationProvider.
Assume that we have a main menu as shown below:
应用程序可以由不同的模块组成,每个模块都可以有自己的菜单项。定义菜单项,我们需要创建一个类派生navigationprovider。
假设我们有一个主菜单,如下所示:
- Tasks
- Reports
- Administration
- User management
- Role management
Here, Administration menu item has two sub menu items. Example navigation provider class to create such a menu can be as below:
public class SimpleTaskSystemNavigationProvider : NavigationProvider
{
public override void SetNavigation(INavigationProviderContext context)
{
context.Manager.MainMenu
.AddItem(
new MenuItemDefinition(
"Tasks",
new LocalizableString("Tasks", "SimpleTaskSystem"),
url: "/Tasks",
icon: "fa fa-tasks"
)
).AddItem(
new MenuItemDefinition(
"Reports",
new LocalizableString("Reports", "SimpleTaskSystem"),
url: "/Reports",
icon: "fa fa-bar-chart"
)
).AddItem(
new MenuItemDefinition(
"Administration",
new LocalizableString("Administration", "SimpleTaskSystem"),
icon: "fa fa-cogs"
).AddItem(
new MenuItemDefinition(
"UserManagement",
new LocalizableString("UserManagement", "SimpleTaskSystem"),
url: "/Administration/Users",
icon: "fa fa-users",
requiredPermissionName: "SimpleTaskSystem.Permissions.UserManagement"
)
).AddItem(
new MenuItemDefinition(
"RoleManagement",
new LocalizableString("RoleManagement", "SimpleTaskSystem"),
url: "/Administration/Roles",
icon: "fa fa-star",
requiredPermissionName: "SimpleTaskSystem.Permissions.RoleManagement"
)
)
);
}
}
A MenuItemDefinition can basically have a unique name, a localizable display name, a url and an icon. Also,
一个menuitemdefinition基本上能有一个独特的名字,一个本地化的显示名称,URL和图标
- A menu item may require a permission to show this menu to a particular user (See authorization document). requiredPermissionName property can be used in this case.
- A menu item can be depend on a feature. featureDependency property can be used in this case.
- A menu item can define a customData and order.
菜单项可能需要允许将菜单显示给特定用户(请参阅授权文档)。requiredpermissionname属性可以在这种情况下使用。
菜单项可以依赖于一个特性。FeatureDependency属性可以在这种情况下使用。
菜单项可以定义一个customdata和order。
INavigationProviderContext has methods to get existing menu items, add menus and menu items. Thus, different modules can add it's own items to the menu.
There may be one or more menus in an application. context.Manager.MainMenu references the default, main menu. We can create and add more menus using context.Manager.Menus property.
inavigationprovidercontext有方法让现有的菜单项,添加菜单和菜单项。因此,不同的模块可以将自己的项目添加到菜单中。
应用程序中可能有一个或多个菜单。context.manager.mainmenu引用默认的主菜单。我们可以创建和使用context.manager.menus属性添加更多的菜单。
Registering Navigation Provider
After creating the navigation provider, we should register it to ASP.NET Boilerplate configuration on PreInitialize event of our module:
Configuration.Navigation.Providers.Add<SimpleTaskSystemNavigationProvider>();
Showing Menu
IUserNavigationManager can be injected and used to get menu items and show to the user. Thus, we can create menu in server side.
ASP.NET Boilerplate automatically generates a javascript API to get menu and items in client side. Methods and objects under abp.nav namespace can be used for this purpose. For instance, abp.nav.menus.MainMenucan be used to get main menu of the application. Thus, we can create menu in client side.
ASP.NET Boilerplate templates uses this system to create and show menu to the user. Try to create a template and see source codes for more.
iusernavigationmanager可以注入,用得到的菜单项和显示给用户。因此,我们可以在服务器端创建菜单。
ASP.NET样板自动生成JavaScript API来获取客户端菜单项。在abp.nav命名空间对象和方法可用于这一目的。例如,abp.nav.menus.mainmenucan被用于获得应用程序主菜单。因此,我们可以在客户端创建菜单。
ASP.NET的模板模板使用本系统创建和显示菜单的用户。尝试创建一个模板并查看更多的源代码。
ABP框架系列之三十七:(Navigation-导航)的更多相关文章
- ABP框架系列之三十四:(Multi-Tenancy-多租户)
What Is Multi Tenancy? "Software Multitenancy refers to a software architecture in which a sing ...
- ABP框架系列之三十九:(NLayer-Architecture-多层架构)
Introduction Layering of an application's codebase is a widely accepted technique to help reduce com ...
- ABP框架系列之十七:(Data-Filters-数据过滤)
Introduction It's common to use the soft-deletepattern which is used to not delete an entity from da ...
- ABP框架系列之三十三:(Module-System-模块系统)
Introduction ASP.NET Boilerplate provides an infrastructure to build modules and compose them to cre ...
- ABP框架系列之三:(Entity Framework Integration-实体框架集成)
ASP.NET Boilerplate can work with any O/RM framework. It has built-in integration with EntityFramewo ...
- ABP框架系列之三十八:(NHibernate-Integration-NHibernate-集成)
ASP.NET Boilerplate can work with any O/RM framework. It has built-in integration with NHibernate. T ...
- ABP框架系列之三十二:(Logging-登录)
Server Side(服务端) ASP.NET Boilerplate uses Castle Windsor's logging facility. It can work with differ ...
- ABP框架系列之三十五:(MVC-Controllers-MVC控制器)
Introduction ASP.NET Boilerplate is integrated to ASP.NET MVC Controllers via Abp.Web.Mvc nuget pack ...
- ABP框架系列之三十六:(MVC-Views-MVC视图)
Introduction ASP.NET Boilerplate is integrated to MVC Views via Abp.Web.Mvc nuget package. You can c ...
随机推荐
- 从Tomcat的处理web请求分析Java的内存模型
Tomcat作为一个java应用,同样是有主线程和子线程的.主线使用while(true)的方式一直循环,等待客户端来连接.一个客户端来了之后,就从线程池中拿一个线程来处理请求,如果没有配置线程池,就 ...
- 03-封装BeanUtil工具类(javabean转map和map转javabean对象)
package com.oa.test; import java.beans.BeanInfo; import java.beans.IntrospectionException; import ja ...
- 关于CPU CACHE工作机制的学习
转自:http://blog.csdn.net/notbaron/article/details/48143409 1. 存储层次结构 由于两个不谋而合的因素如下: l 硬件:由于不同存储技术的访 ...
- Android Studio 制作一个循环播报的效果
这个就是用到了一个TextView 控件,直接上代码. <TextView android:id="@+id/tv_7" android:layout_width=" ...
- RedHat 7.0更新升级openSSH7.4p1
由于目前服务器上ssh版本较低,存在安全漏洞,需要升级到最新版本. 系统版本:RedHat 7.0 旧openSSH版本:6.4p1 新openSSH版本:7.4p1 升级方式:源码安装 安装操作步骤 ...
- 源码阅读经验谈-slim,darknet,labelimg,caffe(1)
本文首先谈自己的源码阅读体验,然后给几个案例解读,选的例子都是比较简单.重在说明我琢磨的点线面源码阅读方法.我不是专业架构师,是从一个深度学习算法工程师的角度来谈的,不专业的地方请大家轻拍. 经常看别 ...
- JavaScript学习-3——数组、函数、递归
本章目录 -----------①数组 -----------②函数 -----------③递归 一.数组 弱类型:任何类型数据,且没有强度限制: 强类型:同一类型的数据存储的集合(内存中连续存储) ...
- 网络抓包工具 wireshark 入门教程
Wireshark Wireshark(前称Ethereal)是一个网络数据包分析软件.网络数据包分析软件的功能是截取网络数据包,并尽可能显示出最为详细的网络数据包数据.Wireshark使用WinP ...
- 《CSAPP》符号解析
符号解析 链接器解析符号引用的方法是将每个引用与它输入的可重定位目标文件的符号表中的一个确定的符号定义联系起来.编译器只允许每个模块中每个本地符号只有一个定义. 对于全局符号,当编译器遇到一个不是在当 ...
- springboot整合dubbox与zookeeper
springboot中dubbo依赖的引入和配置(application.properties)参见:https://blog.csdn.net/wohaqiyi/article/details/72 ...