An Abp Blazor Theme based Ant-Design-Blazor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.3 KiB

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Options;
using Volo.Abp.UI.Navigation;
namespace Lsw.Abp.AspnetCore.Components.Web.AntDesignTheme.Themes.AntDesign;
public partial class MainMenu : IDisposable
{
[Inject]
protected IMenuManager MenuManager { get; set; }
[Inject]
protected IOptions<AbpAntDesignThemeOptions> Options { get; set; }
[Inject]
protected AuthenticationStateProvider AuthenticationStateProvider { get; set; }
protected ApplicationMenu Menu { get; set; }
protected override async Task OnInitializedAsync()
{
await GetMenuAsync();
AuthenticationStateProvider.AuthenticationStateChanged += AuthenticationStateProviderOnAuthenticationStateChanged;
}
private async Task GetMenuAsync()
{
Menu = await MenuManager.GetMainMenuAsync();
}
private async void AuthenticationStateProviderOnAuthenticationStateChanged(Task<AuthenticationState> task)
{
await GetMenuAsync();
await InvokeAsync(StateHasChanged);
}
public void Dispose()
{
AuthenticationStateProvider.AuthenticationStateChanged -= AuthenticationStateProviderOnAuthenticationStateChanged;
}
}