Browse Source
Add browser timezone retrieval and update timezone handling logic
pull/22236/head
maliming
2 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
11 additions and
5 deletions
-
framework/src/Volo.Abp.AspNetCore.Components.Web/wwwroot/libs/abp/js/abp.js
-
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/WebAssemblyCachedApplicationConfigurationClient.cs
|
|
@ -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.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 |
|
|
|
|
|
} |
|
|
})(); |
|
|
})(); |
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
using System.Threading.Tasks; |
|
|
using System; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.JSInterop; |
|
|
using Microsoft.JSInterop; |
|
|
using Volo.Abp.AspNetCore.Components.Web.Security; |
|
|
using Volo.Abp.AspNetCore.Components.Web.Security; |
|
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|
|
using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; |
|
|
@ -79,11 +80,13 @@ public class WebAssemblyCachedApplicationConfigurationClient : ICachedApplicatio |
|
|
configurationDto.CurrentTenant.Name |
|
|
configurationDto.CurrentTenant.Name |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
CurrentTimezoneProvider.TimeZone = configurationDto.Timing.TimeZone.Iana.TimeZoneName; |
|
|
if (Clock.SupportsMultipleTimezone) |
|
|
|
|
|
|
|
|
if (Clock.SupportsMultipleTimezone && !configurationDto.CurrentUser.IsAuthenticated) |
|
|
|
|
|
{ |
|
|
{ |
|
|
await JSRuntime.InvokeVoidAsync("abp.clock.setBrowserTimeZoneToCookie"); |
|
|
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"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|