mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Threading.Tasks;
|
|
using AntDesign.Docs.Localization;
|
|
using AntDesign.Docs.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign.Docs.Pages
|
|
{
|
|
public partial class Index : ComponentBase, IDisposable
|
|
{
|
|
private Recommend[] _recommends = { };
|
|
|
|
private Product[] _products = { };
|
|
|
|
private MoreProps[] _moreArticles = { };
|
|
|
|
[Inject] private DemoService DemoService { get; set; }
|
|
[Inject] private ILanguageService Language { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
await FetchData();
|
|
|
|
Language.LanguageChanged += HandleLanguageChanged;
|
|
}
|
|
|
|
private async void HandleLanguageChanged(object _, CultureInfo culture)
|
|
{
|
|
await FetchData();
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async Task FetchData()
|
|
{
|
|
_recommends = await DemoService.GetRecommend();
|
|
|
|
_products = await DemoService.GetProduct();
|
|
_moreArticles = await DemoService.GetMore();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Language.LanguageChanged -= HandleLanguageChanged;
|
|
}
|
|
}
|
|
}
|