2024-08-28 00:54:33 +08:00
|
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-09-19 09:33:50 +08:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-07-26 19:20:16 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2020-09-19 09:33:50 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components.Routing;
|
2020-07-26 19:20:16 +08:00
|
|
|
|
|
|
|
|
|
namespace AntDesign.Docs.Shared
|
|
|
|
|
{
|
2020-09-19 09:33:50 +08:00
|
|
|
|
public partial class NavMenu : ComponentBase, IDisposable
|
2020-07-26 19:20:16 +08:00
|
|
|
|
{
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
MenuItems = await DemoService.GetCurrentMenuItems();
|
|
|
|
|
|
2024-04-19 20:28:55 +08:00
|
|
|
|
LocalizationService.LanguageChanged += OnLanguageChanged;
|
2020-09-19 09:33:50 +08:00
|
|
|
|
NavigationManager.LocationChanged += OnLocationChanged;
|
2020-07-26 19:20:16 +08:00
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
}
|
2020-09-19 09:33:50 +08:00
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
2024-04-19 20:28:55 +08:00
|
|
|
|
LocalizationService.LanguageChanged -= OnLanguageChanged;
|
2020-09-19 09:33:50 +08:00
|
|
|
|
NavigationManager.LocationChanged -= OnLocationChanged;
|
|
|
|
|
}
|
2020-07-26 19:20:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|