Added options for navigation assemblies for the router
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Moonlight.Frontend.Configuration;
|
||||||
|
|
||||||
|
public class NavigationAssemblyOptions
|
||||||
|
{
|
||||||
|
public List<Assembly> Assemblies { get; private set; } = new();
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Moonlight.Frontend.Configuration;
|
||||||
using Moonlight.Frontend.Implementations;
|
using Moonlight.Frontend.Implementations;
|
||||||
using Moonlight.Frontend.Interfaces;
|
using Moonlight.Frontend.Interfaces;
|
||||||
using Moonlight.Frontend.Services;
|
using Moonlight.Frontend.Services;
|
||||||
@@ -25,5 +26,10 @@ public partial class Startup
|
|||||||
builder.Services.AddSingleton<ISidebarProvider, SidebarProvider>();
|
builder.Services.AddSingleton<ISidebarProvider, SidebarProvider>();
|
||||||
|
|
||||||
builder.Services.AddScoped<FrontendService>();
|
builder.Services.AddScoped<FrontendService>();
|
||||||
|
|
||||||
|
builder.Services.Configure<NavigationAssemblyOptions>(options =>
|
||||||
|
{
|
||||||
|
options.Assemblies.Add(typeof(Startup).Assembly);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
@using System.Net
|
@using System.Net
|
||||||
|
@using System.Reflection
|
||||||
@using LucideBlazor
|
@using LucideBlazor
|
||||||
@using Microsoft.AspNetCore.Components.Authorization
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
|
@using Microsoft.Extensions.Options
|
||||||
|
@using Moonlight.Frontend.Configuration
|
||||||
@using Moonlight.Frontend.UI.Shared
|
@using Moonlight.Frontend.UI.Shared
|
||||||
@using Moonlight.Frontend.UI.Shared.Components
|
@using Moonlight.Frontend.UI.Shared.Components
|
||||||
@using ShadcnBlazor.Emptys
|
@using ShadcnBlazor.Emptys
|
||||||
@@ -8,12 +11,13 @@
|
|||||||
@using Moonlight.Frontend.UI.Shared.Partials
|
@using Moonlight.Frontend.UI.Shared.Partials
|
||||||
|
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
|
@inject IOptions<NavigationAssemblyOptions> NavigationOptions
|
||||||
|
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<AuthorizeView>
|
<AuthorizeView>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<Router AppAssembly="@typeof(App).Assembly" NotFoundPage="typeof(NotFound)">
|
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="Assemblies" NotFoundPage="typeof(NotFound)">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)">
|
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)">
|
||||||
<NotAuthorized Context="authRouteViewContext">
|
<NotAuthorized Context="authRouteViewContext">
|
||||||
@@ -71,4 +75,14 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</ErrorContent>
|
</ErrorContent>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private Assembly[] Assemblies;
|
||||||
|
|
||||||
|
protected override void OnInitialized()
|
||||||
|
{
|
||||||
|
Assemblies = NavigationOptions.Value.Assemblies.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user