| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- @using EasyTemplate.Page.Common
- @using Microsoft.AspNetCore.Components.Authorization
- <CascadingAuthenticationState>
- <Router AppAssembly="typeof(Program).Assembly" AdditionalAssemblies="@TheAssembly.Assemblies" OnNavigateAsync="CallbackAsync">
- <Found Context="routeData">
- <CascadingValue Value="routeData">
- <Microsoft.AspNetCore.Components.Authorization.AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.BasicLayout)">
- <NotAuthorized>
- <RedirectToLogin />
- </NotAuthorized>
- </Microsoft.AspNetCore.Components.Authorization.AuthorizeRouteView>
- </CascadingValue>
- <FocusOnNavigate RouteData="routeData" Selector="h1" />
- </Found>
- <NotFound>
- <LayoutView Layout="@typeof(Layout.ErrorLayout)" />
- </NotFound>
- </Router>
- <AntContainer />
- </CascadingAuthenticationState>
- @inject NavigationManager NavigationManager
- @inject IJSRuntime IJSRuntime
- @code {
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- if (firstRender)
- {
- await NavigationManager.RedirectLogin(IJSRuntime);
- }
- }
- private async Task CallbackAsync(NavigationContext obj)
- {
- Global.CurrentPath = obj.Path;
- await Task.CompletedTask;
- }
- }
|