mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 21:47:38 +08:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
|
|
namespace AntDesign.Docs.Shared
|
|
{
|
|
public partial class NavMenu : ComponentBase, IDisposable
|
|
{
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MenuItems = await DemoService.GetCurrentMenuItems();
|
|
|
|
LanguageService.LanguageChanged += OnLanguageChanged;
|
|
NavigationManager.LocationChanged += OnLocationChanged;
|
|
|
|
StateHasChanged();
|
|
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async void OnLanguageChanged(object sender, CultureInfo args)
|
|
{
|
|
MenuItems = await DemoService.GetCurrentMenuItems();
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async void OnLocationChanged(object sender, LocationChangedEventArgs args)
|
|
{
|
|
MenuItems = await DemoService.GetCurrentMenuItems();
|
|
StateHasChanged();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
LanguageService.LanguageChanged -= OnLanguageChanged;
|
|
NavigationManager.LocationChanged -= OnLocationChanged;
|
|
}
|
|
}
|
|
}
|