Neighbourhood.omg.lol/Components/Routes.razor

31 lines
1 KiB
Text
Raw Normal View History

@using Microsoft.AspNetCore.Components.Authorization
@inject NavigationManager navigationManager
<Router AppAssembly="@typeof(MauiProgram).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
<Authorizing>Logging in...</Authorizing>
<NotAuthorized><RedirectToLogin /></NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<CascadingAuthenticationState>
<LayoutView Layout="@typeof(Layout.MainLayout)">
<img data-emoji="🦒" />
<p>Sorry, there's nothing here.</p>
</LayoutView>
</CascadingAuthenticationState>
</NotFound>
2024-05-30 01:06:08 +00:00
</Router>
@code
{
protected override void OnAfterRender(bool firstRender) {
string? shareString = Preferences.Get("shareString", null);
if (!string.IsNullOrWhiteSpace(shareString)) {
Preferences.Remove("shareString");
navigationManager.NavigateTo($"/sharetext/{shareString}");
}
}
}