感觉跟之前版本区别不是很大,先记录下。

1. 首先在sitemap.config 文件里添加菜单。

<siteMapNode SystemName="SystemManage" nopResource="系统管理" PermissionNames="per_sys_role,per_sys_permission,per_sys_user" IconClass="fa-line-chart">
<siteMapNode SystemName="sys_role" nopResource="角色管理" PermissionNames="per_sys_role" controller="SystemManage" action="Role" IconClass="fa-dot-circle-o"/>
<siteMapNode SystemName="sys_permission" nopResource="权限管理" PermissionNames="per_sys_permission" controller="SystemManage" action="Permission" IconClass="fa-dot-circle-o"/>
<siteMapNode SystemName="sys_user" nopResource="用户管理" PermissionNames="per_sys_user" controller="SystemManage" action="User" IconClass="fa-dot-circle-o"/>
</siteMapNode>

2. 然后在数据库PermissionRecord表里添加该菜单。

3. 还需要在 Nop.Services.Security.StandardPermissionProvider.cs  文件里添加权限记录

public static readonly PermissionRecord per_sys_role = new PermissionRecord { Name = "Admin area. Manage system", SystemName = "per_sys_role", Category = "SystemManage" };
public static readonly PermissionRecord per_sys_permission = new PermissionRecord { Name = "Admin area. Manage system", SystemName = "per_sys_permission", Category = "SystemManage" };
public static readonly PermissionRecord per_sys_user = new PermissionRecord { Name = "Admin area. Manage system", SystemName = "per_sys_user", Category = "SystemManage" };
public virtual IEnumerable<PermissionRecord> GetPermissions()
{
return new[]
{
AccessAdminPanel,
AllowCustomerImpersonation,
ManageProducts,
ManageCategories,
ManageManufacturers,
ManageProductReviews,
ManageProductTags,
ManageAttributes,
ManageCustomers,
ManageVendors,
ManageCurrentCarts,
ManageOrders,
ManageRecurringPayments,
ManageGiftCards,
ManageReturnRequests,
OrderCountryReport,
ManageAffiliates,
ManageCampaigns,
ManageDiscounts,
ManageNewsletterSubscribers,
ManagePolls,
ManageNews,
ManageBlog,
ManageWidgets,
ManageTopics,
ManageForums,
ManageMessageTemplates,
ManageCountries,
ManageLanguages,
ManageSettings,
ManagePaymentMethods,
ManageExternalAuthenticationMethods,
ManageTaxSettings,
ManageShippingSettings,
ManageCurrencies,
ManageActivityLog,
ManageAcl,
ManageEmailAccounts,
ManageStores,
ManagePlugins,
ManageSystemLog,
ManageMessageQueue,
ManageMaintenance,
HtmlEditorManagePictures,
ManageScheduleTasks,
DisplayPrices,
EnableShoppingCart,
EnableWishlist,
PublicStoreAllowNavigation,
AccessClosedStore,
per_sys_role,
per_sys_permission,
per_sys_user
};
}
/// <summary>
/// Get default permissions
/// </summary>
/// <returns>Permissions</returns>
public virtual HashSet<(string systemRoleName, PermissionRecord[] permissions)> GetDefaultPermissions()
{
return new HashSet<(string, PermissionRecord[])>
{
(
NopCustomerDefaults.AdministratorsRoleName,
new[]
{
AccessAdminPanel,
AllowCustomerImpersonation,
ManageProducts,
ManageCategories,
ManageManufacturers,
ManageProductReviews,
ManageProductTags,
ManageAttributes,
ManageCustomers,
ManageVendors,
ManageCurrentCarts,
ManageOrders,
ManageRecurringPayments,
ManageGiftCards,
ManageReturnRequests,
OrderCountryReport,
ManageAffiliates,
ManageCampaigns,
ManageDiscounts,
ManageNewsletterSubscribers,
ManagePolls,
ManageNews,
ManageBlog,
ManageWidgets,
ManageTopics,
ManageForums,
ManageMessageTemplates,
ManageCountries,
ManageLanguages,
ManageSettings,
ManagePaymentMethods,
ManageExternalAuthenticationMethods,
ManageTaxSettings,
ManageShippingSettings,
ManageCurrencies,
ManageActivityLog,
ManageAcl,
ManageEmailAccounts,
ManageStores,
ManagePlugins,
ManageSystemLog,
ManageMessageQueue,
ManageMaintenance,
HtmlEditorManagePictures,
ManageScheduleTasks,
DisplayPrices,
EnableShoppingCart,
EnableWishlist,
PublicStoreAllowNavigation,
AccessClosedStore,
per_sys_role,
per_sys_permission,
per_sys_user
}
),
(
NopCustomerDefaults.ForumModeratorsRoleName,
new[]
{
DisplayPrices,
EnableShoppingCart,
EnableWishlist,
PublicStoreAllowNavigation
}
),
(
NopCustomerDefaults.GuestsRoleName,
new[]
{
DisplayPrices,
EnableShoppingCart,
EnableWishlist,
PublicStoreAllowNavigation
}
),
(
NopCustomerDefaults.RegisteredRoleName,
new[]
{
DisplayPrices,
EnableShoppingCart,
EnableWishlist,
PublicStoreAllowNavigation
}
),
(
NopCustomerDefaults.VendorsRoleName,
new[]
{
AccessAdminPanel,
ManageProducts,
ManageProductReviews,
ManageOrders
}
)
};
}

4. 配置角色和权限记录表的关系,可在admin界面里操作。

最新文章

  1. AngularJS表单验证实现方法详解
  2. C# App.config文件配置数据的读写
  3. 在内部架设NuGet服务器(转载)
  4. 附录三 嵌入式C程序的编译与调试
  5. Linux php 中文乱码解决
  6. Copying Fields to a new Record
  7. One day
  8. 原生js方法document.getElementsByClassName在ie8及其以下的兼容性问题
  9. (转)iOS Wow体验 - 第五章 - 利用iOS技术特性打造最佳体验
  10. 第十三篇 一个安装、管理windows服务的桌面程序
  11. java 线程方法join的简单总结
  12. 【ThinkPHP框架学习 】(2) --- 后台管理系统如何用iframe点击左边右边局部刷新
  13. Unity3D_GUI (1)--按钮控件
  14. [SDOI2010] 魔法猪学院
  15. Sobel 边缘检测算子
  16. js入门关于js‘i++’‘++i’和‘i--’‘--i’计算的问题
  17. Python快速学习10: 循环的对象及设计 (生活的规律)
  18. element-ui组件中时间选择器设置时间禁用
  19. C# WebApi+Task+WebSocket实战项目演练(四)
  20. BZOJ4399魔法少女LJJ——线段树合并+并查集

热门文章

  1. MyBatisPlus(springBoot版)-尚硅谷
  2. javaSE学习四
  3. N63050 第三周运维作业
  4. nginx 与 k8s ingress 配置转发websocket
  5. SAP 交货单抬头客制化界面以及字段
  6. VS2022 17.1.6在windows10下打开winform设计器报timed out while connecting to named pipe错误
  7. dns服务之bind配置内网解析部分子域名,其它子域名转发
  8. 狂神--Docker
  9. WinForms 嵌入 Web服务
  10. 微信小程序中实现自定义省市区选择