From 48d73aa60753d192236ce5b4a3a167f85fb5b53b Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 1 Oct 2020 14:52:57 +0300 Subject: [PATCH] Added ManageYourAccount navigation to Blazor LoginDisplay --- .../Themes/Basic/LoginDisplay.razor | 3 ++ .../Themes/Basic/LoginDisplay.razor.cs | 40 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor index f55685e665..3d3dd26fae 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor @@ -17,6 +17,9 @@ @menuItem.DisplayName } } + + @UiLocalizer["ManageYourAccount"] + Logout diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs index e0ad688513..17718dbcfb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs @@ -1,18 +1,50 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; +using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.Extensions.Localization; +using Microsoft.Extensions.Options; +using Volo.Abp.Http.Client; using Volo.Abp.UI.Navigation; namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic { - public partial class LoginDisplay + public partial class LoginDisplay : IDisposable { - [Inject] protected IMenuManager MenuManager { get; set; } - + [Inject] + protected IMenuManager MenuManager { get; set; } + + [Inject] + protected IStringLocalizer UiLocalizer { get; set; } + + [Inject] + protected IOptions RemoteServiceOptions { get; set; } + protected ApplicationMenu Menu { get; set; } + protected string ServerUrl { get; set; } + protected string ServerAccountUrl { get; set; } + protected override async Task OnInitializedAsync() { Menu = await MenuManager.GetAsync(StandardMenus.User); + + ServerUrl = RemoteServiceOptions.Value.RemoteServices.Default?.BaseUrl?.TrimEnd('/'); + ServerAccountUrl = ServerUrl + "/Account/Manage?returnUrl=" + Navigation.Uri; + + Navigation.LocationChanged += OnLocationChanged; + } + + protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e) + { + ServerAccountUrl = ServerUrl + "/Account/Manage?returnUrl=" + Navigation.Uri; + StateHasChanged(); + } + + public void Dispose() + { + Navigation.LocationChanged -= OnLocationChanged; } } } \ No newline at end of file