ASP.NET Core Zero Rad Tool生成新Area模块需要的必要配置
使用Asp.Net Core Zero Tool时应该注意的事项:
- 如果项目需要新建Area时,可以选使用Visual Studio先创建相应的“Area名”及相应的架构。
- 新的Area架构创建完成后,在现有架构中创建“Startup”目录,并创建”NavigationProvider”,“PageNames”文件。用于定义“新Area”模块的菜单项。
- 将“Admin Area -> Models -> Common”目录中的所有文件复制到“新建Area -> Models ->Common”目录中,同时目录文件的命名空间修改为”新Area“名。
- 将“Admin Area -> Views -> Common”目录中的所有文件复制到“新建Area -> Views -> Common”目录中,同时目录文件的命名空间修改为”新Area“名。。
- 将“Admin Area -> Views”目录中的“_ViewImports.cshtml” 与 "_ViewStar.cshtml"文件复制到"新建Area -> Views"目录中。(不要修改_ViewStart.cshtml文件中Layout指定的目录位置,依然保持原来指定的”Admin“目录中的Layout位置。)
- 修改工具模板
- 修改“AspNetZeroRadTool -> FileTemplates -> Client -> Mvc -> IndexHtmlTemplate”目录中“MainTemplate”文件中“Table”式样定义。
1 <table id="{{Entity_Name_Plural_Here}}Table" class="display table table-separate table-head-custom no-footer dtr-inline dt-responsive nowrap"> 2 <thead> 3 <tr> 4 <th></th> 5 {{NP_OneToMany_Looped_Table_Header_Here}} 6 <th>@L("Actions")</th>{{Property_Looped_Template_Here}}{{NP_Looped_Template_Here}} 7 8 </tr> 9 </thead> 10 </table>
- AspNetZeroRadTool v2.7.8工具中生成的ExportToFile功能中原模板存在兼容性问题,需要按如下修正。
1 public FileDto ExportToFile(List<Get{{Entity_Name_Here}}ForViewDto> {{entity_Name_Plural_Here}}) 2 { 3 return CreateExcelPackage( 4 "{{Entity_Name_Plural_Here}}.xlsx", 5 excelPackage => 6 { 7 8 {{Sheet_Initialization_Here}} 9 10 AddHeader( 11 sheet{{Property_Header_Here}}{{NP_Header_Here}} 12 ); 13 14 AddObjects( 15 sheet, {{entity_Name_Plural_Here}}{{Property_Params_Here}}{{NP_Params_Here}} 16 ); 17 18 {{Property_DateTime_Formatter_Here_Before_080400}} 19 {{Property_DateTime_Formatter_Here_After_080400}} 20 }); 21 }
- 修改“AspNetZeroRadTool -> FileTemplates -> Client -> Mvc -> IndexHtmlTemplate”目录中“MainTemplate”文件中“Table”式样定义。
- AspNetZeroRadTool 工具生成代码修改。
- 在项目Core中的Authorization命名空间下的AppAuthorizationProvider.cs文件中生成的权限只有Root与Administrator两种,需要手动修改为以配合自已的需要。
-
修改Core项目Authorization命名空间下的AppPermissions.cs文件中生成权限定义 。
- 同时修改生成的视图文件中的命名空间引用,由Admin修改为“新Area”名称。
- 在项目Core中的Authorization命名空间下的AppAuthorizationProvider.cs文件中生成的权限只有Root与Administrator两种,需要手动修改为以配合自已的需要。