/
ThirdPartyPlatformsMenuContributor.cs
43 lines (36 loc) · 1.73 KB
/
ThirdPartyPlatformsMenuContributor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyAbp.WeChatManagement.Common.Web.Menus;
using EasyAbp.WeChatManagement.ThirdPartyPlatforms.Localization;
using EasyAbp.WeChatManagement.ThirdPartyPlatforms.Permissions;
using Volo.Abp.UI.Navigation;
namespace EasyAbp.WeChatManagement.ThirdPartyPlatforms.Web.Menus;
public class ThirdPartyPlatformsMenuContributor : IMenuContributor
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.Main)
{
await ConfigureMainMenuAsync(context);
}
}
private async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
var l = context.GetLocalizer<ThirdPartyPlatformsResource>();
var thirdPartyPlatformManagementMenuItem =
new ApplicationMenuItem(ThirdPartyPlatformsMenus.Prefix, l["Menu:ThirdPartyPlatformManagement"]);
if (await context.IsGrantedAsync(ThirdPartyPlatformsPermissions.Authorization.CreateRequest))
{
thirdPartyPlatformManagementMenuItem.AddItem(
new ApplicationMenuItem(ThirdPartyPlatformsMenus.Authorization,
l["Menu:Authorization"],
"/WeChatManagement/ThirdPartyPlatforms/Authorization"));
}
if (!thirdPartyPlatformManagementMenuItem.Items.IsNullOrEmpty())
{
var weChatManagementMenuItem = context.Menu.GetAdministration().Items.GetOrAdd(i => i.Name == CommonMenus.Prefix,
() => new ApplicationMenuItem("EasyAbpWeChatManagement", l["Menu:EasyAbpWeChatManagement"], icon: "fa fa-weixin"));
weChatManagementMenuItem.Items.Add(thirdPartyPlatformManagementMenuItem);
}
}
}