@using MoonCore.PluginFramework.Services
@using Moonlight.Client.Interfaces
@using Moonlight.Client.Models
@using Moonlight.Client.Services
@using Moonlight.Client.UI.Layouts
@inject NavigationManager Navigation
@inject IdentityService IdentityService
@inject ImplementationService ImplementationService
@{
var url = new Uri(Navigation.Uri);
}
a
@code
{
[Parameter] public MainLayout Layout { get; set; }
private Dictionary Items = new();
protected override void OnInitialized()
{
Items = ImplementationService.Get()
.SelectMany(x => x.Get())
.Where(x => x.Permission == null || (x.Permission != null && IdentityService.HasPermission(x.Permission)))
.GroupBy(x => x.Group ?? "")
.OrderByDescending(x => string.IsNullOrEmpty(x.Key))
.ToDictionary(x => x.Key, x => x.OrderBy(y => y.Priority).ToArray());
}
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return Task.CompletedTask;
Layout.OnStateChanged += () => InvokeAsync(StateHasChanged);
Navigation.LocationChanged += async (_, _) =>
{
if (!Layout.ShowMobileNavigation)
return;
await Layout.ToggleMobileNavigation();
};
return Task.CompletedTask;
}
}