zoukankan      html  css  js  c++  java
  • 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界面里操作。

     

  • 相关阅读:
    腾讯ios内部视频,什么垃圾视频
    项目中学习ReactiveCocoa的使用方法
    Mac 裁剪mp3
    AFN使用etag进行网络缓存
    Mac 高效 软件
    presentedViewController 和 presentingViewController 以及 dismissViewControllerAnimated 的使用
    Objective-C: NSFileManager 的使用
    UIButton的imageEdgeInsets 和 titleEdgeInsets
    Objective-C :Category
    Objective-C中的@property
  • 原文地址:https://www.cnblogs.com/hpbkin/p/12956049.html
Copyright © 2011-2022 走看看