feat: 增加 LogoutLink 组件

This commit is contained in:
Argo-Tianyi 2022-01-04 01:58:42 +08:00
parent cbb75e58d8
commit 1ddef32a83
4 changed files with 5 additions and 11 deletions

View File

@ -11,7 +11,7 @@
<a href="/Admin/Profiles"><i class="fa fa-suitcase"></i>个人中心</a>
<a href="/Admin/Index"><i class="fa fa-cog"></i>设置</a>
<a href="/Admin/Notifications"><i class="fa fa-bell"></i>通知<span id="logoutNoti" class="badge badge-pill badge-success"></span></a>
<a href="#" @onclick="OnLogout"><i class="fa fa-key"></i>注销</a>
<LogoutLink />
</LinkTemplate>
</Logout>
<div class="layout-drawer"><i class="fa fa-gears"></i></div>

View File

@ -13,10 +13,6 @@ namespace BootstrapAdmin.Web.Shared
{
private IEnumerable<MenuItem>? MenuItems { get; set; }
[Inject]
[NotNull]
private NavigationManager? NavigationManager { get; set; }
[Inject]
[NotNull]
private INavigation? NavigationsService { get; set; }
@ -77,8 +73,6 @@ namespace BootstrapAdmin.Web.Shared
private Task<bool> OnAuthorizing(string url) => SecurityService.AuhorizingNavigation(Context.UserName, url);
private void OnLogout() => NavigationManager.NavigateTo("/Account/Logout", true);
private async Task OnErrorHandleAsync(ILogger logger, Exception ex)
{
await ToastService.Error(Title, ex.Message);

View File

@ -13,7 +13,7 @@
<a href="@ProfileUrl"><i class="fa fa-suitcase"></i>个人中心</a>
<a href="@SettingsUrl"><i class="fa fa-cog"></i>设置</a>
<a href="@NotificationUrl"><i class="fa fa-bell"></i>通知<span id="logoutNoti" class="badge badge-pill badge-success"></span></a>
<a href="#" @onclick="OnLogout"><i class="fa fa-key"></i>注销</a>
<LogoutLink Url="@LogoutUrl" />
</LinkTemplate>
</Logout>
<div class="layout-drawer" @onclick="@(e => IsOpen = !IsOpen)"><i class="fa fa-gears"></i></div>
@ -44,7 +44,7 @@
</div>
</Footer>
<NotAuthorized>
<Redirect Url="@GetAuthorUrl()" />
<Redirect Url="@AuthorUrl" />
</NotAuthorized>
</Layout>

View File

@ -128,8 +128,8 @@ namespace BootstrapClient.Web.Shared.Shared
private Task<bool> OnAuthorizing(string url) => SecurityService.AuhorizingNavigation(UserName, url);
private string GetAuthorUrl() => CombinePath($"/Account/Login?ReturnUrl={NavigationManager.Uri}");
private string LogoutUrl => CombinePath($"/Account/Logout");
private void OnLogout() => NavigationManager.NavigateTo(CombinePath("/Account/Logout"), true);
private string AuthorUrl => CombinePath($"/Account/Login?ReturnUrl={NavigationManager.Uri}");
}
}