ant-design-blazor/site/AntDesign.Docs/Shared/NavMenu.razor

54 lines
1.9 KiB
C#
Raw Normal View History

2020-07-26 19:20:16 +08:00
@using AntDesign.Docs.Services
<Menu Class="aside-container menu-site" Theme="MenuTheme.Light" Mode="MenuMode.Inline" >
@menuItemTemplate((MenuItems, LanguageService, 1))
</Menu>
@inject ILanguageService LanguageService
@inject NavigationManager NavigationManager
@inject HttpClient HttpClient
2020-07-26 19:20:16 +08:00
@inject DemoService DemoService;
@code {
[Parameter]
public DemoMenuItem[] MenuItems { get; set; } = {};
static readonly RenderFragment<(DemoMenuItem[] items, ILanguageService languageService, int level)> menuItemTemplate = context =>
2020-03-31 00:45:14 +08:00
@<Template>
@foreach (var menu in context.items)
{
2020-03-31 00:45:14 +08:00
if (menu.Type == "menuItem")
{
<MenuItem RouterLink="@($"{context.languageService.CurrentCulture.Name}/{menu.Url}")" RouterMatch="@NavLinkMatch.All">
2020-03-31 00:45:14 +08:00
<span>@menu.Title</span>
@if (menu.SubTitle != null)
{
<span class="chinese">@menu.SubTitle</span>
}
</MenuItem>
2020-03-31 00:45:14 +08:00
}
else if (menu.Type == "subMenu")
{
<SubMenu Title="@menu.Title" IsOpen="true">
2020-03-31 00:45:14 +08:00
@if (menu.Children.Any())
{
@menuItemTemplate((menu.Children, context.languageService, context.level + 1))
2020-03-31 00:45:14 +08:00
}
</SubMenu>
2020-03-31 00:45:14 +08:00
}
else if (menu.Type == "itemGroup")
{
<MenuItemGroup Title="@menu.Title">
2020-03-31 00:45:14 +08:00
@if (menu.Children.Any())
{
@menuItemTemplate((menu.Children, context.languageService, context.level + 1))
2020-03-31 00:45:14 +08:00
}
</MenuItemGroup>
2020-03-31 00:45:14 +08:00
}
}
2020-03-31 00:45:14 +08:00
</Template>;
}