From ce25d2ebab22f69bab258fd4b3c88f0cbdf69791 Mon Sep 17 00:00:00 2001 From: gdlcf88 Date: Sun, 12 Jun 2022 18:55:05 +0800 Subject: [PATCH 1/2] Use the LeptonX Lite theme in the sample app. --- .../Menus/OrdersMenuContributor.cs | 2 +- .../Menus/PaymentsMenuContributor.cs | 2 +- .../Menus/ProductsMenuContributor.cs | 2 +- .../Menus/StoresMenuContributor.cs | 2 +- .../Menus/BasketsMenuContributor.cs | 2 +- .../Menus/CouponsMenuContributor.cs | 2 +- .../EShopSample.Web/EShopSample.Web.csproj | 2 +- .../EShopSample.Web/EShopSampleWebModule.cs | 33 +++++++------------ .../EShopSample.Web/wwwroot/global-styles.css | 1 + .../wwwroot/libs/abp/jquery/abp.jquery.js | 10 +++--- .../bootstrap.enable.popovers.everywhere.js | 5 +++ 11 files changed, 31 insertions(+), 32 deletions(-) create mode 100644 samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/global-styles.css create mode 100644 samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/bootstrap/js/bootstrap.enable.popovers.everywhere.js diff --git a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Menus/OrdersMenuContributor.cs b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Menus/OrdersMenuContributor.cs index f1660326..a31277c7 100644 --- a/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Menus/OrdersMenuContributor.cs +++ b/modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Web/Menus/OrdersMenuContributor.cs @@ -38,7 +38,7 @@ namespace EasyAbp.EShop.Orders.Web.Menus if (!orderManagementMenuItem.Items.IsNullOrEmpty()) { var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == OrdersMenus.ModuleGroupPrefix, - () => new ApplicationMenuItem(OrdersMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"])); + () => new ApplicationMenuItem(OrdersMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"], icon: "fa fa-shopping-bag")); eShopMenuItem.Items.Add(orderManagementMenuItem); } diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/Menus/PaymentsMenuContributor.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/Menus/PaymentsMenuContributor.cs index 604c97e0..0896b069 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/Menus/PaymentsMenuContributor.cs +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Web/Menus/PaymentsMenuContributor.cs @@ -44,7 +44,7 @@ namespace EasyAbp.EShop.Payments.Web.Menus if (!paymentManagementMenuItem.Items.IsNullOrEmpty()) { var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == PaymentsMenus.ModuleGroupPrefix, - () => new ApplicationMenuItem(PaymentsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"])); + () => new ApplicationMenuItem(PaymentsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"], icon: "fa fa-shopping-bag")); eShopMenuItem.Items.Add(paymentManagementMenuItem); } diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Menus/ProductsMenuContributor.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Menus/ProductsMenuContributor.cs index a202f774..591364de 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Menus/ProductsMenuContributor.cs +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Web/Menus/ProductsMenuContributor.cs @@ -41,7 +41,7 @@ namespace EasyAbp.EShop.Products.Web.Menus if (!productManagementMenuItem.Items.IsNullOrEmpty()) { var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == ProductsMenus.ModuleGroupPrefix, - () => new ApplicationMenuItem(ProductsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"])); + () => new ApplicationMenuItem(ProductsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"], icon: "fa fa-shopping-bag")); eShopMenuItem.Items.Add(productManagementMenuItem); } diff --git a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs index d320bae3..4d4b4b92 100644 --- a/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs +++ b/modules/EasyAbp.EShop.Stores/src/EasyAbp.EShop.Stores.Web/Menus/StoresMenuContributor.cs @@ -51,7 +51,7 @@ namespace EasyAbp.EShop.Stores.Web.Menus if (!storeManagementMenuItem.Items.IsNullOrEmpty()) { var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == StoresMenus.ModuleGroupPrefix, - () => new ApplicationMenuItem(StoresMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"])); + () => new ApplicationMenuItem(StoresMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"], icon: "fa fa-shopping-bag")); eShopMenuItem.Items.Add(storeManagementMenuItem); } diff --git a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/Menus/BasketsMenuContributor.cs b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/Menus/BasketsMenuContributor.cs index 9badbcb4..ad964b3e 100644 --- a/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/Menus/BasketsMenuContributor.cs +++ b/plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Web/Menus/BasketsMenuContributor.cs @@ -28,7 +28,7 @@ namespace EasyAbp.EShop.Plugins.Baskets.Web.Menus if (!basketManagementMenuItem.Items.IsNullOrEmpty()) { var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == BasketsMenus.ModuleGroupPrefix, - () => new ApplicationMenuItem(BasketsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"])); + () => new ApplicationMenuItem(BasketsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"], icon: "fa fa-shopping-bag")); eShopMenuItem.Items.Add(basketManagementMenuItem); } diff --git a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Menus/CouponsMenuContributor.cs b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Menus/CouponsMenuContributor.cs index bd324755..b80d3aea 100644 --- a/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Menus/CouponsMenuContributor.cs +++ b/plugins/Coupons/src/EasyAbp.EShop.Plugins.Coupons.Web/Menus/CouponsMenuContributor.cs @@ -39,7 +39,7 @@ namespace EasyAbp.EShop.Plugins.Coupons.Web.Menus if (!couponManagementMenuItem.Items.IsNullOrEmpty()) { var eShopMenuItem = context.Menu.Items.GetOrAdd(i => i.Name == CouponsMenus.ModuleGroupPrefix, - () => new ApplicationMenuItem(CouponsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"])); + () => new ApplicationMenuItem(CouponsMenus.ModuleGroupPrefix, l["Menu:EasyAbpEShop"], icon: "fa fa-shopping-bag")); eShopMenuItem.Items.Add(couponManagementMenuItem); } diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj index 2d95a425..c602502d 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSample.Web.csproj @@ -47,7 +47,7 @@ - + diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs index bca6f97e..650ebf3f 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using EasyAbp.EShop; using EasyAbp.EShop.Plugins; using EasyAbp.EShop.Plugins.Web; @@ -30,13 +29,14 @@ using EShopSample.Localization; using EShopSample.MultiTenancy; using EShopSample.Web.Menus; using Microsoft.OpenApi.Models; -using NUglify.JavaScript.Syntax; using Volo.Abp; using Volo.Abp.Account.Web; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.Localization; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; @@ -61,7 +61,7 @@ namespace EShopSample.Web typeof(AbpAutofacModule), typeof(AbpIdentityWebModule), typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpTenantManagementWebModule), typeof(AbpFeatureManagementWebModule), @@ -98,21 +98,23 @@ namespace EShopSample.Web var configuration = context.Services.GetConfiguration(); ConfigureUrls(configuration); - ConfigureAuthentication(context, configuration); + ConfigureBundles(); ConfigureAutoMapper(); ConfigureVirtualFileSystem(hostingEnvironment); ConfigureLocalizationServices(); ConfigureNavigationServices(); ConfigureAutoApiControllers(); ConfigureSwaggerServices(context.Services); - ConfigureConventionalControllers(); } - private void ConfigureConventionalControllers() + private void ConfigureBundles() { - Configure(options => + Configure(options => { - options.ConventionalControllers.Create(typeof(EShopSampleApplicationModule).Assembly); + options.StyleBundles.Configure( + LeptonXLiteThemeBundles.Styles.Global, + bundle => { bundle.AddFiles("/global-styles.css"); } + ); }); } @@ -124,17 +126,6 @@ namespace EShopSample.Web }); } - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) - { - context.Services.AddAuthentication() - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = false; - options.Audience = "EShopSample"; - }); - } - private void ConfigureAutoMapper() { Configure(options => diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/global-styles.css b/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/global-styles.css new file mode 100644 index 00000000..056b01e3 --- /dev/null +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/global-styles.css @@ -0,0 +1 @@ +/* Your Global Styles */ \ No newline at end of file diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/abp/jquery/abp.jquery.js b/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/abp/jquery/abp.jquery.js index 81ebf1e2..76dfd389 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/abp/jquery/abp.jquery.js +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/abp/jquery/abp.jquery.js @@ -205,14 +205,16 @@ var abp = abp || {}; handleAbpErrorResponse: function (jqXHR, userOptions, $dfd) { var messagePromise = null; + var responseJSON = jqXHR.responseJSON ? jqXHR.responseJSON : JSON.parse(jqXHR.responseText); + if (userOptions.abpHandleError !== false) { - messagePromise = abp.ajax.showError(jqXHR.responseJSON.error); + messagePromise = abp.ajax.showError(responseJSON.error); } - abp.ajax.logError(jqXHR.responseJSON.error); + abp.ajax.logError(responseJSON.error); - $dfd && $dfd.reject(jqXHR.responseJSON.error, jqXHR); - userOptions.error && userOptions.error(jqXHR.responseJSON.error, jqXHR); + $dfd && $dfd.reject(responseJSON.error, jqXHR); + userOptions.error && userOptions.error(responseJSON.error, jqXHR); if (jqXHR.status === 401 && userOptions.abpHandleError !== false) { abp.ajax.handleUnAuthorizedRequest(messagePromise); diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/bootstrap/js/bootstrap.enable.popovers.everywhere.js b/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/bootstrap/js/bootstrap.enable.popovers.everywhere.js new file mode 100644 index 00000000..a02a2a7a --- /dev/null +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/wwwroot/libs/bootstrap/js/bootstrap.enable.popovers.everywhere.js @@ -0,0 +1,5 @@ +(function () { + [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]')).map(function (popoverTriggerEl) { + return new bootstrap.Popover(popoverTriggerEl) + }) +})(); From faff1273b83bb88bddf055a01d637d95381fddfd Mon Sep 17 00:00:00 2001 From: gdlcf88 Date: Sun, 12 Jun 2022 20:58:51 +0800 Subject: [PATCH 2/2] Add `ConfigureAuthentication` --- .../src/EShopSample.Web/EShopSampleWebModule.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs index 650ebf3f..723563d9 100644 --- a/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs +++ b/samples/EShopSample/aspnet-core/src/EShopSample.Web/EShopSampleWebModule.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using EasyAbp.EShop; using EasyAbp.EShop.Plugins; using EasyAbp.EShop.Plugins.Web; @@ -99,6 +100,7 @@ namespace EShopSample.Web ConfigureUrls(configuration); ConfigureBundles(); + ConfigureAuthentication(context, configuration); ConfigureAutoMapper(); ConfigureVirtualFileSystem(hostingEnvironment); ConfigureLocalizationServices(); @@ -118,6 +120,17 @@ namespace EShopSample.Web }); } + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication() + .AddJwtBearer(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "EShopSample"; + }); + } + private void ConfigureUrls(IConfiguration configuration) { Configure(options => @@ -266,7 +279,6 @@ namespace EShopSample.Web app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); - app.UseJwtTokenMiddleware(); if (MultiTenancyConsts.IsEnabled) {