mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.3 KiB
71 lines
2.3 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using MyCompanyName.MyProjectName.Localization;
|
|
using Volo.Abp.UI.Navigation;
|
|
using Volo.Abp.Users;
|
|
using Volo.Abp.Account.Localization;
|
|
|
|
namespace MyCompanyName.MyProjectName.Blazor.Menus
|
|
{
|
|
public class MyProjectNameMenuContributor : IMenuContributor
|
|
{
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public MyProjectNameMenuContributor(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
|
|
{
|
|
if (context.Menu.Name == StandardMenus.Main)
|
|
{
|
|
await ConfigureMainMenuAsync(context);
|
|
}
|
|
else if (context.Menu.Name == StandardMenus.User)
|
|
{
|
|
await ConfigureUserMenuAsync(context);
|
|
}
|
|
}
|
|
|
|
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
|
|
{
|
|
var l = context.GetLocalizer<MyProjectNameResource>();
|
|
|
|
context.Menu.Items.Insert(
|
|
0,
|
|
new ApplicationMenuItem(
|
|
MyProjectNameMenus.Home,
|
|
l["Menu:Home"],
|
|
"/",
|
|
icon: "fas fa-home"
|
|
)
|
|
);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
|
|
{
|
|
var accountStringLocalizer = context.GetLocalizer<AccountResource>();
|
|
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
|
|
|
|
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
|
|
|
|
if ( currentUser.IsAuthenticated )
|
|
{
|
|
context.Menu.AddItem( new ApplicationMenuItem(
|
|
"Account.Manage",
|
|
accountStringLocalizer["ManageYourProfile"],
|
|
$"{identityServerUrl.EnsureEndsWith( '/' )}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}",
|
|
icon: "fa fa-cog",
|
|
order: 1000,
|
|
null ) );
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|
|
|