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 e4767cc031..58d4d5753e 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
@@ -26,9 +26,6 @@
@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 17718dbcfb..3238483cfb 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,50 +1,33 @@
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 : IDisposable
{
- [Inject]
- protected IMenuManager MenuManager { get; set; }
-
- [Inject]
- protected IStringLocalizer UiLocalizer { get; set; }
-
[Inject]
- protected IOptions RemoteServiceOptions { get; set; }
-
- protected ApplicationMenu Menu { get; set; }
+ protected IMenuManager MenuManager { get; set; }
- protected string ServerUrl { get; set; }
- protected string ServerAccountUrl { get; set; }
+ protected ApplicationMenu Menu { 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
+}
diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs
index 8097475d64..f93193670b 100644
--- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs
+++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs
@@ -55,7 +55,7 @@ namespace MyCompanyName.MyProjectName.Blazor
{
Configure(options =>
{
- options.MenuContributors.Add(new MyProjectNameMenuContributor());
+ options.MenuContributors.Add(new MyProjectNameMenuContributor(context.Services.GetConfiguration()));
});
}
diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameMenuContributor.cs
index 9dda814d93..003d882da6 100644
--- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameMenuContributor.cs
+++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameMenuContributor.cs
@@ -1,18 +1,37 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
using MyCompanyName.MyProjectName.Localization;
+using Volo.Abp.Account.Localization;
using Volo.Abp.UI.Navigation;
+using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Blazor
{
public class MyProjectNameMenuContributor : IMenuContributor
{
- public Task ConfigureMenuAsync(MenuConfigurationContext context)
+ private readonly IConfiguration _configuration;
+
+ public MyProjectNameMenuContributor(IConfiguration configuration)
{
- if(context.Menu.DisplayName != StandardMenus.Main)
+ _configuration = configuration;
+ }
+
+ public async Task ConfigureMenuAsync(MenuConfigurationContext context)
+ {
+ if (context.Menu.Name == StandardMenus.Main)
{
- return Task.CompletedTask;
+ await ConfigureMainMenuAsync(context);
}
+ else if (context.Menu.Name == StandardMenus.User)
+ {
+ await ConfigureUserMenuAsync(context);
+ }
+ }
+ private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
+ {
var l = context.GetLocalizer();
context.Menu.Items.Insert(
@@ -27,5 +46,27 @@ namespace MyCompanyName.MyProjectName.Blazor
return Task.CompletedTask;
}
+
+ private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
+ {
+ var accountStringLocalizer = context.GetLocalizer();
+ var currentUser = context.ServiceProvider.GetRequiredService();
+
+ var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
+
+ if (currentUser.IsAuthenticated)
+ {
+ context.Menu.AddItem(new ApplicationMenuItem(
+ "Account.Manage",
+ accountStringLocalizer["ManageYourProfile"],
+ $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage",
+ icon: "fa fa-cog",
+ order: 1000,
+ null,
+ "_blank"));
+ }
+
+ return Task.CompletedTask;
+ }
}
}