Browse Source

Merge pull request #23990 from abpframework/auto-merge/rel-10-0/4055

Merge branch dev with rel-10.0
pull/24010/head
Ma Liming 1 year ago
committed by GitHub
parent
commit
cfc222496e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 28
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCachedApplicationConfigurationClient.cs
  2. 41
      framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCurrentTimezoneService.cs

28
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCachedApplicationConfigurationClient.cs

@ -1,14 +1,11 @@
using System;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.JSInterop;
using Volo.Abp.AspNetCore.Components.Web.Security;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ClientProxies;
using Volo.Abp.AspNetCore.Mvc.Client;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing;
namespace Volo.Abp.AspNetCore.Components.MauiBlazor
{
@ -22,33 +19,21 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor
protected ICurrentTenantAccessor CurrentTenantAccessor { get; }
protected ICurrentTimezoneProvider CurrentTimezoneProvider { get; }
protected ApplicationConfigurationChangedService ApplicationConfigurationChangedService { get; }
protected IJSRuntime JSRuntime { get; }
protected IClock Clock { get; }
public MauiBlazorCachedApplicationConfigurationClient(
AbpApplicationConfigurationClientProxy applicationConfigurationClientProxy,
ApplicationConfigurationCache cache,
ICurrentTenantAccessor currentTenantAccessor,
ICurrentTimezoneProvider currentTimezoneProvider,
AuthenticationStateProvider authenticationStateProvider,
AbpApplicationLocalizationClientProxy applicationLocalizationClientProxy,
ApplicationConfigurationChangedService applicationConfigurationChangedService,
IJSRuntime jsRuntime,
IClock clock)
ApplicationConfigurationChangedService applicationConfigurationChangedService)
{
ApplicationConfigurationClientProxy = applicationConfigurationClientProxy;
Cache = cache;
CurrentTenantAccessor = currentTenantAccessor;
CurrentTimezoneProvider = currentTimezoneProvider;
ApplicationLocalizationClientProxy = applicationLocalizationClientProxy;
ApplicationConfigurationChangedService = applicationConfigurationChangedService;
JSRuntime = jsRuntime;
Clock = clock;
authenticationStateProvider.AuthenticationStateChanged += async _ => { await InitializeAsync(); };
}
@ -78,15 +63,6 @@ namespace Volo.Abp.AspNetCore.Components.MauiBlazor
configurationDto.CurrentTenant.Id,
configurationDto.CurrentTenant.Name);
if (Clock.SupportsMultipleTimezone)
{
CurrentTimezoneProvider.TimeZone = !configurationDto.Timing.TimeZone.Iana.TimeZoneName.IsNullOrWhiteSpace()
? configurationDto.Timing.TimeZone.Iana.TimeZoneName
: await JSRuntime.InvokeAsync<string>("abp.clock.getBrowserTimeZone");
await JSRuntime.InvokeAsync<string>("abp.clock.setBrowserTimeZoneToCookie");
}
ApplicationConfigurationChangedService.NotifyChanged();
}

41
framework/src/Volo.Abp.AspNetCore.Components.MauiBlazor/Volo/Abp/AspNetCore/Components/MauiBlazor/MauiBlazorCurrentTimezoneService.cs

@ -0,0 +1,41 @@
using System;
using System.Threading.Tasks;
using Microsoft.JSInterop;
using Volo.Abp.AspNetCore.Mvc.Client;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Timing;
namespace Volo.Abp.AspNetCore.Components.MauiBlazor;
public class MauiBlazorCurrentTimezoneService : ITransientDependency
{
protected IClock Clock { get; }
protected ICachedApplicationConfigurationClient ApplicationConfigurationClient { get; }
protected IJSRuntime JsRuntime { get; }
protected ICurrentTimezoneProvider CurrentTimezoneProvider { get; }
public MauiBlazorCurrentTimezoneService(
IClock clock,
ICachedApplicationConfigurationClient applicationConfigurationClient,
IJSRuntime jsRuntime,
ICurrentTimezoneProvider currentTimezoneProvider)
{
Clock = clock;
ApplicationConfigurationClient = applicationConfigurationClient;
JsRuntime = jsRuntime;
CurrentTimezoneProvider = currentTimezoneProvider;
}
public virtual async Task InitializeAsync()
{
if (Clock.SupportsMultipleTimezone)
{
var configurationDto = await ApplicationConfigurationClient.GetAsync();
CurrentTimezoneProvider.TimeZone = !configurationDto.Timing.TimeZone.Iana.TimeZoneName.IsNullOrEmpty()
? configurationDto.Timing.TimeZone.Iana.TimeZoneName
: await JsRuntime.InvokeAsync<string>("abp.clock.getBrowserTimeZone");
await JsRuntime.InvokeAsync<string>("abp.clock.setBrowserTimeZoneToCookie");
}
}
}
Loading…
Cancel
Save