diff --git a/build/build-all.ps1 b/build/build-all.ps1 index f0b2f398db8..c8b37ec33c0 100644 --- a/build/build-all.ps1 +++ b/build/build-all.ps1 @@ -7,6 +7,7 @@ $full = $args[0] Write-Host $solutionPaths dotnet workload install wasm-tools +dotnet workload install maui-tizen foreach ($solutionPath in $solutionPaths) { $solutionAbsPath = (Join-Path $rootFolder $solutionPath) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj index b1b9dcde815..5340bdfb1cb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo.Abp.AspNetCore.Components.MauiBlazor.csproj @@ -11,6 +11,7 @@ false false false + true diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs index e7d116b5cc5..9772db6a92b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpAspNetCoreComponentsMauiBlazorModule.cs @@ -9,9 +9,15 @@ using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.Threading; +using Volo.Abp.UI; namespace Volo.Abp.AspNetCore.Components.MauiBlazor; +[DependsOn( + typeof(AbpAspNetCoreMvcClientCommonModule), + typeof(AbpUiModule), + typeof(AbpAspNetCoreComponentsWebModule) +)] public class AbpAspNetCoreComponentsMauiBlazorModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) @@ -20,7 +26,7 @@ public override void PreConfigureServices(ServiceConfigurationContext context) { options.ProxyClientBuildActions.Add((_, builder) => { - builder.AddHttpMessageHandler(); + builder.AddHttpMessageHandler(); }); }); } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs new file mode 100644 index 00000000000..5520eed966d --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/AbpMauiBlazorClientHttpMessageHandler.cs @@ -0,0 +1,55 @@ +using System; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Maui.Storage; +using Volo.Abp.AspNetCore.Components.Progression; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.AspNetCore.Components.MauiBlazor; + +public class AbpMauiBlazorClientHttpMessageHandler : DelegatingHandler, ITransientDependency +{ + private readonly IUiPageProgressService _uiPageProgressService; + + private const string SelectedLanguageName = "Abp.SelectedLanguage"; + + public AbpMauiBlazorClientHttpMessageHandler(IClientScopeServiceProviderAccessor clientScopeServiceProviderAccessor) + { + _uiPageProgressService = clientScopeServiceProviderAccessor.ServiceProvider.GetRequiredService(); + } + + protected async override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + try + { + await _uiPageProgressService.Go(null, options => + { + options.Type = UiPageProgressType.Info; + }); + + await SetLanguageAsync(request); + + return await base.SendAsync(request, cancellationToken); + } + finally + { + await _uiPageProgressService.Go(-1); + } + } + + private Task SetLanguageAsync(HttpRequestMessage request) + { + var selectedLanguage = Preferences.Get(SelectedLanguageName, string.Empty); + + if (!selectedLanguage.IsNullOrWhiteSpace()) + { + request.Headers.AcceptLanguage.Clear(); + request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(selectedLanguage)); + } + + return Task.CompletedTask; + } +} \ No newline at end of file