feat: Home 页面下增加授权
This commit is contained in:
parent
05cfdeefb3
commit
5037b16123
|
@ -1,4 +1,6 @@
|
|||
namespace BootstrapAdmin.Web.Pages.Home
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace BootstrapAdmin.Web.Pages.Home
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -6,6 +8,7 @@
|
|||
[Route("/")]
|
||||
[Route("/Home")]
|
||||
[Route("/Home/Index")]
|
||||
[Authorize]
|
||||
public class Index : ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
|
|
|
@ -1,40 +1,37 @@
|
|||
@inherits LayoutComponentBase
|
||||
|
||||
@if (Login)
|
||||
{
|
||||
<Layout SideWidth="0" IsPage="true" IsFullSide="true" IsFixedHeader="true" IsFixedFooter="false"
|
||||
<Layout SideWidth="0" IsPage="true" IsFullSide="true" IsFixedHeader="true" IsFixedFooter="false"
|
||||
ShowFooter="true" ShowGotoTop="true" ShowCollapseBar="true" Menus="@MenuItems"
|
||||
OnAuthorizing="@OnAuthorizing"
|
||||
UseTabSet="true" TabDefaultUrl="/Admin/Index">
|
||||
<Header>
|
||||
<span class="ms-3 flex-fill">Bootstrap of Blazor</span>
|
||||
<img src="/images/Argo.png" class="layout-avatar-right" />
|
||||
<span class="mx-3 d-none d-sm-block">@DisplayName</span>
|
||||
<div class="layout-drawer"><i class="fa fa-gears"></i></div>
|
||||
</Header>
|
||||
<Side>
|
||||
<div class="layout-banner">
|
||||
<img class="layout-logo" src="/images/brand.png" />
|
||||
<div class="layout-title">
|
||||
<span>@Title</span>
|
||||
</div>
|
||||
<Header>
|
||||
<span class="ms-3 flex-fill">Bootstrap of Blazor</span>
|
||||
<img src="/images/Argo.png" class="layout-avatar-right" />
|
||||
<span class="mx-3 d-none d-sm-block">@DisplayName</span>
|
||||
<div class="layout-drawer"><i class="fa fa-gears"></i></div>
|
||||
</Header>
|
||||
<Side>
|
||||
<div class="layout-banner">
|
||||
<img class="layout-logo" src="/images/brand.png" />
|
||||
<div class="layout-title">
|
||||
<span>@Title</span>
|
||||
</div>
|
||||
<div class="layout-user">
|
||||
<img class="layout-avatar" src="/images/Argo-C.png">
|
||||
<div class="layout-title">
|
||||
<span>@DisplayName</span>
|
||||
</div>
|
||||
<div class="layout-user-state"></div>
|
||||
</div>
|
||||
<div class="layout-user">
|
||||
<img class="layout-avatar" src="/images/Argo-C.png">
|
||||
<div class="layout-title">
|
||||
<span>@DisplayName</span>
|
||||
</div>
|
||||
</Side>
|
||||
<Main>
|
||||
@Body
|
||||
</Main>
|
||||
<Footer>
|
||||
<div class="flex-fill text-center text-dark">@Footer</div>
|
||||
</Footer>
|
||||
<NotAuthorized>
|
||||
<Redirect />
|
||||
</NotAuthorized>
|
||||
</Layout>
|
||||
}
|
||||
<div class="layout-user-state"></div>
|
||||
</div>
|
||||
</Side>
|
||||
<Main>
|
||||
@Body
|
||||
</Main>
|
||||
<Footer>
|
||||
<div class="flex-fill text-center text-dark">@Footer</div>
|
||||
</Footer>
|
||||
<NotAuthorized>
|
||||
<Redirect />
|
||||
</NotAuthorized>
|
||||
</Layout>
|
||||
|
|
|
@ -60,13 +60,13 @@ namespace BootstrapAdmin.Web.Shared
|
|||
Context.UserName = userName;
|
||||
Context.DisplayName = DisplayName;
|
||||
|
||||
MenuItems = NavigationsService.GetAllMenus("Admin").ToAdminMenus();
|
||||
MenuItems = NavigationsService.GetAllMenus(userName).ToAdminMenus();
|
||||
|
||||
Login = true;
|
||||
}
|
||||
|
||||
Title = DictsService.GetWebTitle();
|
||||
Footer = DictsService.GetWebFooter();
|
||||
|
||||
Login = true;
|
||||
}
|
||||
|
||||
private Task<bool> OnAuthorizing(string url) => SecurityService.AuhorizingNavigation(Context.UserName, url);
|
||||
|
|
Loading…
Reference in New Issue