ABP入门教程13 - 更新菜单

点这里进入ABP入门教程目录 

菜单更新

在展示层(即JD.CRS.Web.Mvc)的Startup下打开CRSNavigationProvider.cs //用以存放菜单相关信息

修改如下

  1 using Abp.Application.Navigation;
  2 using Abp.Localization;
  3 using JD.CRS.Authorization;
  4 
  5 namespace JD.CRS.Web.Startup
  6 {
  7     /// <summary>
  8     /// This class defines menus for the application.
  9     /// </summary>
 10     public class CRSNavigationProvider : NavigationProvider
 11     {
 12         public override void SetNavigation(INavigationProviderContext context)
 13         {
 14             context.Manager.MainMenu
 15                 .AddItem( //一级菜单 - 首页
 16                     new MenuItemDefinition(
 17                         PageNames.Home,
 18                         L("HomePage"),
 19                         url: "",
 20                         icon: "home",
 21                         requiredPermissionName: PermissionNames.Pages_Home
 22                     )
 23                 )
 24                 .AddItem( //一级菜单 - 基础数据
 25                     new MenuItemDefinition(
 26                         "Data",
 27                         L("Data"),
 28                         icon: "storage"
 29                     ).AddItem( //二级菜单 - 办公室设置
 30                         new MenuItemDefinition(
 31                             PageNames.Office,
 32                             L("Office"),
 33                             url: "Office",
 34                             requiredPermissionName: PermissionNames.Pages_Office
 35                         )
 36                     ).AddItem( //二级菜单 - 院系设置
 37                         new MenuItemDefinition(
 38                             PageNames.Department,
 39                             L("Department"),
 40                             url: "Department",
 41                             requiredPermissionName: PermissionNames.Pages_Department
 42                         )
 43                     ).AddItem( //二级菜单 - 课程设置
 44                         new MenuItemDefinition(
 45                             PageNames.Course,
 46                             L("Course"),
 47                             url: "Course",
 48                             requiredPermissionName: PermissionNames.Pages_Course
 49                         )
 50                     ).AddItem( //二级菜单 - 教职员设置
 51                         new MenuItemDefinition(
 52                             PageNames.Instructor,
 53                             L("Instructor"),
 54                             url: "Instructor",
 55                             requiredPermissionName: PermissionNames.Pages_Instructor
 56                         )
 57                     ).AddItem( //二级菜单 - 学生设置
 58                         new MenuItemDefinition(
 59                             PageNames.Student,
 60                             L("Student"),
 61                             url: "Student",
 62                             requiredPermissionName: PermissionNames.Pages_Student
 63                         )
 64                     )
 65                 )
 66                 .AddItem( //一级菜单 - 综合服务
 67                     new MenuItemDefinition(
 68                         "Service",
 69                         L("Service"),
 70                         icon: "business"
 71                     ).AddItem( //二级菜单 - 教职员办公室设置
 72                         new MenuItemDefinition(
 73                             PageNames.OfficeInstructor,
 74                             L("OfficeInstructor"),
 75                             url: "OfficeInstructor"
 76                         )
 77                     ).AddItem( //二级菜单 - 院系主任设置
 78                         new MenuItemDefinition(
 79                             PageNames.DepartmentInstructor,
 80                             L("DepartmentInstructor"),
 81                             url: "DepartmentInstructor"
 82                         )
 83                     ).AddItem( //二级菜单 - 院系课程设置
 84                         new MenuItemDefinition(
 85                             PageNames.DepartmentCourse,
 86                             L("DepartmentCourse"),
 87                             url: "DepartmentCourse"
 88                         )
 89                     ).AddItem( //二级菜单 - 教职员课程设置
 90                         new MenuItemDefinition(
 91                             PageNames.InstructorCourse,
 92                             L("InstructorCourse"),
 93                             url: "InstructorCourse"
 94                         )
 95                     ).AddItem( //二级菜单 - 学生课程设置
 96                         new MenuItemDefinition(
 97                             PageNames.StudentCourse,
 98                             L("StudentCourse"),
 99                             url: "StudentCourse"
100                         )
101                     )
102                 )
103                 .AddItem( //一级菜单 - 管理报表
104                     new MenuItemDefinition(
105                         "Report",
106                         L("Report"),
107                         icon: "poll"
108                     ).AddItem( //二级菜单 - 办公室报表
109                         new MenuItemDefinition(
110                             PageNames.OfficeReport,
111                             L("OfficeReport"),
112                             url: "OfficeReport",
113                             requiredPermissionName: PermissionNames.Pages_OfficeReport
114                         )
115                     ).AddItem( //二级菜单 - 院系报表
116                         new MenuItemDefinition(
117                             PageNames.DepartmentReport,
118                             L("DepartmentReport"),
119                             url: "DepartmentReport",
120                             requiredPermissionName: PermissionNames.Pages_DepartmentReport
121                         )
122                     ).AddItem( //二级菜单 - 课程报表
123                         new MenuItemDefinition(
124                             PageNames.CourseReport,
125                             L("CourseReport"),
126                             url: "CourseReport",
127                             requiredPermissionName: PermissionNames.Pages_CourseReport
128                         )
129                     ).AddItem( //二级菜单 - 教职员报表
130                         new MenuItemDefinition(
131                             PageNames.InstructorReport,
132                             L("InstructorReport"),
133                             url: "InstructorReport",
134                             requiredPermissionName: PermissionNames.Pages_InstructorReport
135                         )
136                     ).AddItem( //二级菜单 - 学生报表
137                         new MenuItemDefinition(
138                             PageNames.StudentReport,
139                             L("StudentReport"),
140                             url: "StudentReport",
141                             requiredPermissionName: PermissionNames.Pages_StudentReport
142                         )
143                     )
144                 )
145                 .AddItem( //一级菜单 - 系统设置
146                     new MenuItemDefinition(
147                         "Setting",
148                         L("Setting"),
149                         icon: "settings"
150                     ).AddItem( //二级菜单 - 租户管理
151                         new MenuItemDefinition(
152                             PageNames.Tenants,
153                             L("Tenants"),
154                             url: "Tenants",
155                             requiredPermissionName: PermissionNames.Pages_Tenants
156                         )
157                     ).AddItem( //二级菜单 - 用户管理
158                         new MenuItemDefinition(
159                             PageNames.Users,
160                             L("Users"),
161                             url: "Users",
162                             requiredPermissionName: PermissionNames.Pages_Users
163                         )
164                     ).AddItem( //二级菜单 - 角色管理
165                         new MenuItemDefinition(
166                             PageNames.Roles,
167                             L("Roles"),
168                             url: "Roles",
169                             requiredPermissionName: PermissionNames.Pages_Roles
170                         )
171                     )
172                 )
173                 .AddItem( //一级菜单 - 关于
174                     new MenuItemDefinition(
175                         PageNames.About,
176                         L("About"),
177                         url: "About",
178                         icon: "info",
179                         requiresAuthentication: true
180                     )
181                 );
182         }
183 
184         private static ILocalizableString L(string name)
185         {
186             return new LocalizableString(name, CRSConsts.LocalizationSourceName);
187         }
188     }
189 }
View Code

权限更新

在领域层(即JD.CRS.Core)的Authorization下打开CRSAuthorizationProvider.cs //用以存放权限相关信息

修改如下

 1 using Abp.Authorization;
 2 using Abp.Localization;
 3 using Abp.MultiTenancy;
 4 
 5 namespace JD.CRS.Authorization
 6 {
 7     public class CRSAuthorizationProvider : AuthorizationProvider
 8     {
 9         private static ILocalizableString L(string name)
10         {
11             return new LocalizableString(name, CRSConsts.LocalizationSourceName);
12         }
13         public override void SetPermissions(IPermissionDefinitionContext context)
14         {
15             context.CreatePermission(PermissionNames.Pages_Home, L("Home"));
16             context.CreatePermission(PermissionNames.Pages_Office, L("Office"));
17             context.CreatePermission(PermissionNames.Pages_Department, L("Department"));
18             context.CreatePermission(PermissionNames.Pages_Course, L("Course"));
19             context.CreatePermission(PermissionNames.Pages_Instructor, L("Instructor"));
20             context.CreatePermission(PermissionNames.Pages_Student, L("Student"));
21             context.CreatePermission(PermissionNames.Pages_OfficeInstructor, L("OfficeInstructor"));
22             context.CreatePermission(PermissionNames.Pages_DepartmentInstructor, L("DepartmentInstructor"));
23             context.CreatePermission(PermissionNames.Pages_DepartmentCourse, L("DepartmentCourse"));
24             context.CreatePermission(PermissionNames.Pages_InstructorCourse, L("InstructorCourse"));
25             context.CreatePermission(PermissionNames.Pages_StudentCourse, L("StudentCourse"));
26             context.CreatePermission(PermissionNames.Pages_OfficeReport, L("OfficeReport"));
27             context.CreatePermission(PermissionNames.Pages_DepartmentReport, L("DepartmentReport"));
28             context.CreatePermission(PermissionNames.Pages_CourseReport, L("CourseReport"));
29             context.CreatePermission(PermissionNames.Pages_InstructorReport, L("InstructorReport"));
30             context.CreatePermission(PermissionNames.Pages_StudentReport, L("StudentReport"));
31             context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
32             context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
33             context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
34         }
35     }
36 }
View Code

关联更新

与菜单/权限关联的两个静态类也需要更新

JD.CRS.Web.Mvc\Startup\PageNames.cs //用以存放菜单相关静态信息

 1 namespace JD.CRS.Web.Startup
 2 {
 3     public class PageNames
 4     {
 5         public const string Home = "Home";
 6         public const string Office = "Office";
 7         public const string Department = "Department";
 8         public const string Course = "Course";
 9         public const string Instructor = "Instructor";
10         public const string Student = "Student";
11         public const string OfficeInstructor = "OfficeInstructor";
12         public const string DepartmentInstructor = "DepartmentInstructor";
13         public const string DepartmentCourse = "DepartmentCourse";
14         public const string InstructorCourse = "InstructorCourse";
15         public const string StudentCourse = "StudentCourse";
16         public const string OfficeReport = "OfficeReport";
17         public const string DepartmentReport = "DepartmentReport";
18         public const string CourseReport = "CourseReport";
19         public const string InstructorReport = "InstructorReport";
20         public const string StudentReport = "StudentReport";
21         public const string Tenants = "Tenants";
22         public const string Users = "Users";
23         public const string Roles = "Roles";
24         public const string About = "About";
25     }
26 }
View Code

 JD.CRS.Core\Authorization\PermissionNames.cs //用以存放权限相关静态信息

 1 namespace JD.CRS.Authorization
 2 {
 3     public static class PermissionNames
 4     {        
 5         public const string Pages_Home = "Pages.Home";
 6         public const string Pages_Data = "Menu.Data";
 7         public const string Pages_Operation = "Menu.Operation";
 8         public const string Pages_Report = "Menu.Report";
 9         public const string Pages_Setting = "Menu.Setting";
10         public const string Pages_About = "Pages.About";
11         public const string Pages_Office = "Pages.Office";
12         public const string Pages_Department = "Pages.Department";
13         public const string Pages_Course = "Pages.Course";
14         public const string Pages_Instructor = "Pages.Instructor";
15         public const string Pages_Student = "Pages.Student";
16         public const string Pages_OfficeInstructor = "Pages.OfficeInstructor";
17         public const string Pages_DepartmentInstructor = "Pages.DepartmentInstructor";
18         public const string Pages_DepartmentCourse = "Pages.DepartmentCourse";
19         public const string Pages_InstructorCourse = "Pages.InstructorCourse";
20         public const string Pages_StudentCourse = "Pages.StudentCourse";
21         public const string Pages_OfficeReport = "Pages.OfficeReport";
22         public const string Pages_DepartmentReport = "Pages.DepartmentReport";
23         public const string Pages_CourseReport = "Pages.CourseReport";
24         public const string Pages_InstructorReport = "Pages.InstructorReport";
25         public const string Pages_StudentReport = "Pages.StudentReport";
26         public const string Pages_Tenants = "Pages.Tenants";
27         public const string Pages_Users = "Pages.Users";
28         public const string Pages_Roles = "Pages.Roles";
29     }
30 }
View Code
posted @ 2019-10-03 12:48  智慧园区-老朱  阅读(3512)  评论(2编辑  收藏  举报