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..b76f11ec5f 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
@@ -1,6 +1,8 @@
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Volo.Abp.Users
@using Volo.Abp.MultiTenancy
+@using Volo.Abp.UI.Navigation
+@inject IJSRuntime JsRuntime
@inject ICurrentUser CurrentUser
@inject ICurrentTenant CurrentTenant
@inject NavigationManager Navigation
@@ -23,12 +25,9 @@
{
@foreach (var menuItem in Menu.Items)
{
- @menuItem.DisplayName
+ @menuItem.DisplayName
}
}
-
- @UiLocalizer["ManageYourAccount"]
-
Logout
@@ -40,14 +39,21 @@
@code{
- private void NavigateTo(string uri)
+ private async Task NavigateToAsync(string uri, string target = "_self")
{
- Navigation.NavigateTo(uri);
+ if (target == "_blank")
+ {
+ await JsRuntime.InvokeVoidAsync("open", uri, "_blank");
+ }
+ else
+ {
+ Navigation.NavigateTo(uri);
+ }
}
private async Task BeginSignOut()
{
await SignOutManager.SetSignOutState();
- NavigateTo("authentication/logout");
+ await NavigateToAsync("authentication/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..c3737bafdb 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
@@ -12,39 +12,32 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
{
public partial class LoginDisplay : IDisposable
{
- [Inject]
+ [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 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;
+ }
}
}