1.打开PageNames.cs文件,添加如下代码
public const string Departments = "Departments";
2.打开PermissionNames文件,添加如下代码
public const string Pages_Departments = "Pages.Departments";
3.打开MingAbpAuthorizationProvider.cs文件,在SetPermissions方法中添加如下代码
context.CreatePermission(PermissionNames.Pages_Departments, L("Departments"));
若不加上此代码,运行程序会抛出异常,如图所示
4.打开MingAbp-zh-Hans.xml,添加如下代码
<text name="Departments" value="部门" />
5.打开MingAbpNavigationProvider.cs文件,添加如下代码
.AddItem( new MenuItemDefinition( PageNames.Departments, L("Departments"), url: "Departments", icon: "fas fa-building", permissionDependency: new SimplePermissionDependency(PermissionNames.Pages_Departments) ) );
6.添加DepartmentsController控制器和对应的视图
using Abp.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc; using MingAbp.Controllers; namespace MingAbp.Web.Controllers { [AbpMvcAuthorize] public class DepartmentsController : MingAbpControllerBase { public ActionResult Index() { return View(); } } }
@* For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 *@ @{ } <h1>部门首页</h1>
7.运行项目
标签:实战,菜单,代码,Departments,public,Abp,添加,Pages From: https://www.cnblogs.com/mingcore/p/17001862.html