Files
Nexus.Reader/src/NexusReader.Maui/Main.razor
T

40 lines
1.3 KiB
Plaintext

@using Microsoft.AspNetCore.Components.Routing
@using NexusReader.UI.Shared
@using NexusReader.Maui.Infrastructure.Logging
@inject IJSRuntime JSRuntime
@inject BlazorLoggingBridge LoggingBridge
<Router AppAssembly="@typeof(NexusReader.UI.Shared._Imports).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(NexusReader.UI.Shared.Layout.MainHubLayout)">
<NotAuthorized>
<RedirectToLogin />
</NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(NexusReader.UI.Shared.Layout.MainHubLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
try
{
var dotNetRef = DotNetObjectReference.Create(LoggingBridge);
await JSRuntime.InvokeVoidAsync("NexusLogging.initializeBridge", dotNetRef);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[SerilogBridge] Failed to initialize Blazor/JS Bridge: {ex}");
}
}
}
}