Refactored / removed JavaScript. Replaced BlazoredLocalStorage.
This commit is contained in:
Родитель
b18a71d89e
Коммит
af781cdd4e
|
@ -1,12 +1,12 @@
|
|||
@using System.Globalization
|
||||
|
||||
@inject IJSRuntime js
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ILocalStorageService LocalStorage
|
||||
|
||||
<div style="margin-bottom: 20px;">
|
||||
<TelerikDropDownList Data="@Cultures"
|
||||
Value="@SelectedCulture"
|
||||
ValueChanged="@((string value) => { OnValueChanged(value); })"
|
||||
ValueChanged="@((string value) => OnValueChanged(value) )"
|
||||
TextField="@nameof(CultureData.Text)"
|
||||
ValueField="@nameof(CultureData.Value)">
|
||||
</TelerikDropDownList>
|
||||
|
@ -29,18 +29,18 @@
|
|||
|
||||
public string SelectedCulture { get; set; }
|
||||
|
||||
public void OnValueChanged(string eventArgs)
|
||||
public async Task OnValueChanged(string eventArgs)
|
||||
{
|
||||
SelectedCulture = eventArgs;
|
||||
|
||||
SetCulture(eventArgs);
|
||||
await SetCulture(eventArgs);
|
||||
}
|
||||
|
||||
public void SetCulture(string culture)
|
||||
public async Task SetCulture(string culture)
|
||||
{
|
||||
if (CultureInfo.CurrentCulture.Name != culture)
|
||||
{
|
||||
js.InvokeVoidAsync("blazorCulture.set", culture);
|
||||
await LocalStorage.SetItemAsync("BlazorCulture", culture);
|
||||
|
||||
NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@
|
|||
|
||||
public async Task GetCulture()
|
||||
{
|
||||
var value = await js.InvokeAsync<string>("blazorCulture.get");
|
||||
var value = await LocalStorage.GetItemAsStringAsync("BlazorCulture");
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
value = "en-US";
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
{
|
||||
Expanded = value;
|
||||
|
||||
await LocalStorage.SetItemAsync<bool>("drawerState", value);
|
||||
await LocalStorage.SetItemAsync("drawerState", value);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
</div>
|
||||
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
<script src="js/blazorCulture.js"></script>
|
||||
<script src="js/themeChooser.js"></script>
|
||||
<script>
|
||||
window.themeChooser.init();
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
window.blazorCulture = {
|
||||
get: () => {
|
||||
return window.localStorage['BlazorCulture'];
|
||||
},
|
||||
|
||||
set: (value) => {
|
||||
window.localStorage['BlazorCulture'] = value;
|
||||
}
|
||||
};
|
Загрузка…
Ссылка в новой задаче