• nop4.3 admin中添加新菜单


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

    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>
    View Code

    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" };
    View Code
    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
                };
            }
    View Code
    /// <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
                        }
                    )
                };
            }
    View Code

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

     

  • 相关阅读:
    javascrpt each map
    实现strcmp非常easy的思维
    POJ1300(欧拉回路)
    採用Android中的httpclient框架发送post请求
    蓝桥杯 带分数
    C++第11周(春)项目1
    每天一点儿JAVA-向量的操作
    js回车事件
    WebService(2)-XML系列之Java和Xml之间相互转换
    Android下的单元測试
  • 原文地址:https://www.cnblogs.com/hpbkin/p/12956049.html
Copyright © 2020-2023  润新知