Improved plugin loading and handling #17

Merged
ChiaraBm merged 2 commits from feat/ImprovePluginLoading into v2.1 2026-02-19 07:36:06 +00:00
3 changed files with 30 additions and 2 deletions
Showing only changes of commit 0f26aaf803 - Show all commits

View File

@@ -0,0 +1,8 @@
using System.Reflection;
namespace Moonlight.Frontend.Configuration;
public class NavigationAssemblyOptions
{
public List<Assembly> Assemblies { get; private set; } = new();
}

View File

@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Moonlight.Frontend.Configuration;
using Moonlight.Frontend.Implementations;
using Moonlight.Frontend.Interfaces;
using Moonlight.Frontend.Services;
@@ -25,5 +26,10 @@ public partial class Startup
builder.Services.AddSingleton<ISidebarProvider, SidebarProvider>();
builder.Services.AddScoped<FrontendService>();
builder.Services.Configure<NavigationAssemblyOptions>(options =>
{
options.Assemblies.Add(typeof(Startup).Assembly);
});
}
}

View File

@@ -1,6 +1,9 @@
@using System.Net
@using System.Reflection
@using LucideBlazor
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.Extensions.Options
@using Moonlight.Frontend.Configuration
@using Moonlight.Frontend.UI.Shared
@using Moonlight.Frontend.UI.Shared.Components
@using ShadcnBlazor.Emptys
@@ -8,12 +11,13 @@
@using Moonlight.Frontend.UI.Shared.Partials
@inject NavigationManager Navigation
@inject IOptions<NavigationAssemblyOptions> NavigationOptions
<ErrorBoundary>
<ChildContent>
<AuthorizeView>
<ChildContent>
<Router AppAssembly="@typeof(App).Assembly" NotFoundPage="typeof(NotFound)">
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="Assemblies" NotFoundPage="typeof(NotFound)">
<Found Context="routeData">
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)">
<NotAuthorized Context="authRouteViewContext">
@@ -72,3 +76,13 @@
}
</ErrorContent>
</ErrorBoundary>
@code
{
private Assembly[] Assemblies;
protected override void OnInitialized()
{
Assemblies = NavigationOptions.Value.Assemblies.ToArray();
}
}