From c641dcf2ab207a1b8925b4de0a8c42b43335dfb2 Mon Sep 17 00:00:00 2001 From: "hualin.zhu" Date: Thu, 15 Feb 2024 21:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20INotificationService=20Pre?= =?UTF-8?q?load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Server.UI/DependencyInjection.cs | 13 +++++++------ src/Server.UI/Program.cs | 6 ++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Server.UI/DependencyInjection.cs b/src/Server.UI/DependencyInjection.cs index fe0556a30..9b32c8be8 100644 --- a/src/Server.UI/DependencyInjection.cs +++ b/src/Server.UI/DependencyInjection.cs @@ -59,7 +59,13 @@ public static IServiceCollection AddServerUI(this IServiceCollection services, I .AddBlazorDownloadFile() .AddScoped() .AddScoped() - .AddScoped(); + .AddScoped() + .AddScoped(sp => + { + var service = sp.GetRequiredService(); + service.Preload(); + return service; + }); return services; } @@ -96,9 +102,7 @@ public static WebApplication ConfigureServer(this WebApplication app, IConfigura .SetDefaultCulture(LocalizationConstants.SupportedLanguages.Select(x => x.Code).First()) .AddSupportedCultures(LocalizationConstants.SupportedLanguages.Select(x => x.Code).ToArray()) .AddSupportedUICultures(LocalizationConstants.SupportedLanguages.Select(x => x.Code).ToArray()); - app.UseRequestLocalization(localizationOptions); - app.UseMiddleware(); app.UseExceptionHandler(); app.UseHangfireDashboard("/jobs", new DashboardOptions @@ -106,11 +110,8 @@ public static WebApplication ConfigureServer(this WebApplication app, IConfigura Authorization = new[] { new HangfireDashboardAuthorizationFilter() }, AsyncAuthorization = new[] { new HangfireDashboardAsyncAuthorizationFilter() } }); - - app.MapRazorComponents().AddInteractiveServerRenderMode(); app.MapHub(ISignalRHub.Url); - return app; } } \ No newline at end of file diff --git a/src/Server.UI/Program.cs b/src/Server.UI/Program.cs index 0f64be110..25916ddbf 100644 --- a/src/Server.UI/Program.cs +++ b/src/Server.UI/Program.cs @@ -1,4 +1,4 @@ -using CleanArchitecture.Blazor.Application; +using CleanArchitecture.Blazor.Application; using CleanArchitecture.Blazor.Infrastructure; using CleanArchitecture.Blazor.Infrastructure.Persistence; using CleanArchitecture.Blazor.Server; @@ -27,9 +27,7 @@ var initializer = scope.ServiceProvider.GetRequiredService(); await initializer.InitialiseAsync(); await initializer.SeedAsync(); - var notificationService = scope.ServiceProvider.GetService(); - if (notificationService is InMemoryNotificationService inMemoryNotificationService) - inMemoryNotificationService.Preload(); + } await app.RunAsync(); \ No newline at end of file