ABP開發手記13 - 更新菜單

来源:https://www.cnblogs.com/IT-Evan/archive/2019/10/03/ABP13.html
-Advertisement-
Play Games

點這裡進入ABP開發手記目錄 菜單更新 在展示層(即JD.CRS.Web.Mvc)的Startup下打開CRSNavigationProvider.cs //用以存放菜單相關信息 修改如下 1 using Abp.Application.Navigation; 2 using Abp.Localiz ...


點這裡進入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
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 第一步:初始化coda 命令:sudo gedit ~/.bashrc 第二部:複製其中這樣一段代碼 第三部:在結尾處添加 conda activate pyn_env ...
  • 背景 在沒有泛型前,一旦把一個對象丟進集合中,集合就會忘記對象的類型,把所有的對象都當成 Object 類型處理。當程式從集合中取出對象後,就需要進行強制類型轉換,這種轉換很容易引起 ClassCastException 異常。 定義 程式在創建集合時指定集合元素的類型。增加了泛型支持後的集合,可以 ...
  • 1、準備工作 PS:為了偷懶,每個pom文件都要依賴的公共依賴配置放在下麵: 1.1、由於需要動態修改配置,這裡需要創建config-server工程,pom依賴如下: 1.2、config-server工程啟動類如下: 1.3、添加項目配置文件,資源路徑:config-server\src\mai ...
  • virtualenv 1.安裝virtualenv包 2.創建虛擬環境,位置不固定,可以在項目的目錄下,也可以不在項目的目錄下。 3.激活虛擬環境,同時進入虛擬環境 4.安裝python的requests模塊 5.查看虛擬環境中安裝的模塊 6.創建項目並啟動項目 7.退出虛擬環境 虛擬環境的路徑與項 ...
  • `國慶有點懶散更新的內容不多,大家國慶快樂` 一.做的事情 "上次寫到點我查看" 設置中國時區 修改表單存儲位置 設計商品相關的表,主要是總庫存,退貨,進貨,銷售 優化登入驗證碼,去除 這些讓人難以區分的內容 重新設計文件目錄 二.配置相關 三.驗證碼相關 四.模型相關 ...
  • 點這裡進入ABP開發手記目錄 新增語言 在基礎設施層(即JD.CRS.EntityFrameworkCore)的\EntityFrameworkCore\Seed\Host\下打開DefaultLanguagesCreator.cs //用以存放多語言相關信息 新增語言 new Applicatio ...
  • 隨著微信小程式的火熱應用,市面上有關小程式開發的需求也多了起來。近來分析了一項生成有關生成微信小程式碼的需求——要求掃碼跳轉到小程式指定頁面(帶參數);看了下小程式官方文檔,以及網上的例子,未看到多少有價值的採用C#調用小程式介面生成小程式碼的例子,於是拾起多年前的代碼,略作分析嘗試,在此分享給有需 ...
  • .net core 中的局部視圖組件是ViewComponent,可以用於建制重覆使用公共功能組件 一、新建一個類DemoViewComponent(必須以ViewComponent結尾)且繼承ViewComponent 二、在View/Share目錄下建立Components目錄,併在此目錄下建立 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...