mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-05 21:47:38 +08:00
d2e9c4b247
* feat(module: config-provider): support RTL * add rtl for each component * fix rtl for pagination * add rtl for overlay
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using System.Threading.Tasks;
|
|
using AntDesign.Docs.Localization;
|
|
using AntDesign.Docs.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign.Docs.Shared
|
|
{
|
|
public partial class HeaderMenu : ComponentBase
|
|
{
|
|
[Parameter] public bool IsMobile { get; set; }
|
|
|
|
[Inject] private DemoService DemoService { get; set; }
|
|
|
|
[Inject] private ILanguageService LanguageService { get; set; }
|
|
|
|
[Inject] private NavigationManager NavigationManager { get; set; }
|
|
|
|
[CascadingParameter] public ConfigProvider ConfigProvider { get; set; }
|
|
|
|
string CurrentLanguage => LanguageService.CurrentCulture.Name;
|
|
|
|
string Direction => ConfigProvider?.Direction;
|
|
|
|
private DemoMenuItem[] _menuItems = { };
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
_menuItems = await DemoService.GetMenuAsync();
|
|
|
|
LanguageService.LanguageChanged += async (sender, args) =>
|
|
{
|
|
_menuItems = await DemoService.GetMenuAsync();
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
|
|
private void ChangeLanguage(string language)
|
|
{
|
|
var currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
|
|
var newUrl = currentUrl.IndexOf('/') > 0 ? currentUrl.Substring(currentUrl.IndexOf('/') + 1) : currentUrl;
|
|
NavigationManager.NavigateTo($"{language}/{newUrl}");
|
|
}
|
|
}
|
|
}
|