refactor: 精简代码移动 NotAuthorized 到 razor 文件中

This commit is contained in:
Argo-Tianyi 2021-05-25 14:34:46 +08:00
parent 361037cdbd
commit b6f0e08257
2 changed files with 4 additions and 18 deletions

View File

@ -2,7 +2,7 @@
<Layout SideWidth="0" IsPage="true" ShowGotoTop="true" ShowCollapseBar="true"
IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter" ShowFooter="@ShowFooter"
Menus="@Menus" UseTabSet="@UseTabSet" NotAuthorized="@NotAuthorized" TabItemTextDictionary="@TabItemTextDictionary" AdditionalAssemblies="new[] { GetType().Assembly }" class="@Theme">
Menus="@Menus" UseTabSet="@UseTabSet" TabItemTextDictionary="@TabItemTextDictionary" AdditionalAssemblies="new[] { GetType().Assembly }" class="@Theme">
<Header>
<span class="ml-3 flex-sm-fill d-none d-sm-block">Bootstrap of Blazor</span>
<Widget></Widget>
@ -35,6 +35,9 @@
<a class="page-layout-demo-footer-link" href="https://gitee.com/LongbowEnterprise/BootstrapAdmin" target="_blank">Bootstrap Admin</a>
</div>
</Footer>
<NotAuthorized>
<RedirectToLogin />
</NotAuthorized>
</Layout>
<Drawer Placement="Placement.Right" @bind-IsOpen="@IsOpen" IsBackdrop="true">

View File

@ -49,27 +49,10 @@ namespace Bootstrap.Client.Blazor.Shared.Shared
[NotNull]
public string? UserName { get; private set; }
[NotNull]
private RenderFragment? NotAuthorized { get; set; }
[Inject]
[NotNull]
private AuthenticationStateProvider? AuthenticationStateProvider { get; set; }
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
NotAuthorized = builder =>
{
builder.OpenComponent<RedirectToLogin>(0);
builder.CloseComponent();
};
}
/// <summary>
/// OnInitialized 方法
/// </summary>