mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 21:47:38 +08:00
54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
@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
|
|
@inject DemoService DemoService;
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
public DemoMenuItem[] MenuItems { get; set; } = {};
|
|
|
|
static readonly RenderFragment<(DemoMenuItem[] items, ILanguageService languageService, int level)> menuItemTemplate = context =>
|
|
@<Template>
|
|
@foreach (var menu in context.items)
|
|
{
|
|
if (menu.Type == "menuItem")
|
|
{
|
|
<MenuItem RouterLink="@($"{context.languageService.CurrentCulture.Name}/{menu.Url}")" RouterMatch="@NavLinkMatch.All">
|
|
<span>@menu.Title</span>
|
|
@if (menu.SubTitle != null)
|
|
{
|
|
<span class="chinese">@menu.SubTitle</span>
|
|
}
|
|
</MenuItem>
|
|
}
|
|
else if (menu.Type == "subMenu")
|
|
{
|
|
<SubMenu Title="@menu.Title" IsOpen="true">
|
|
@if (menu.Children.Any())
|
|
{
|
|
@menuItemTemplate((menu.Children, context.languageService, context.level + 1))
|
|
}
|
|
</SubMenu>
|
|
}
|
|
else if (menu.Type == "itemGroup")
|
|
{
|
|
<MenuItemGroup Title="@menu.Title">
|
|
@if (menu.Children.Any())
|
|
{
|
|
@menuItemTemplate((menu.Children, context.languageService, context.level + 1))
|
|
}
|
|
</MenuItemGroup>
|
|
}
|
|
}
|
|
</Template>;
|
|
|
|
|
|
}
|