diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js b/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js index 52bec9bb7b..30f1915005 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js @@ -252,4 +252,7 @@ var abp = abp || {}; abp.utils.setCookieValue('__timezone', Intl.DateTimeFormat().resolvedOptions().timeZone, new Date(new Date().setFullYear(new Date().getFullYear() + 1)), '/'); } + abp.clock.getBrowserTimeZone = function () { + return Intl.DateTimeFormat().resolvedOptions().timeZone + } })(); diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs index e1256eb53e..aa80a5c3b0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Microsoft.JSInterop; using Volo.Abp.AspNetCore.Components.Web.Security; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; @@ -79,11 +80,13 @@ public class WebAssemblyCachedApplicationConfigurationClient : ICachedApplicatio configurationDto.CurrentTenant.Name ); - CurrentTimezoneProvider.TimeZone = configurationDto.Timing.TimeZone.Iana.TimeZoneName; - - if (Clock.SupportsMultipleTimezone && !configurationDto.CurrentUser.IsAuthenticated) + if (Clock.SupportsMultipleTimezone) { - await JSRuntime.InvokeVoidAsync("abp.clock.setBrowserTimeZoneToCookie"); + CurrentTimezoneProvider.TimeZone = !configurationDto.Timing.TimeZone.Iana.TimeZoneName.IsNullOrWhiteSpace() + ? configurationDto.Timing.TimeZone.Iana.TimeZoneName + : await JSRuntime.InvokeAsync("abp.clock.getBrowserTimeZone"); + + await JSRuntime.InvokeAsync("abp.clock.setBrowserTimeZoneToCookie"); } }