diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 88b8c9ef786..c64dd357097 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,11 +1,11 @@ - 9.12.2-beta02 + 9.12.2-beta03 - 10.0.0-rc.2.2.4 + 10.0.0-rc.2.2.5 diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor b/src/BootstrapBlazor/Components/Layout/Layout.razor index 69f78c4a964..80df44fc010 100644 --- a/src/BootstrapBlazor/Components/Layout/Layout.razor +++ b/src/BootstrapBlazor/Components/Layout/Layout.razor @@ -138,7 +138,7 @@ ShowExtendButtons="ShowTabExtendButtons" ShowClose="ShowTabItemClose" AllowDrag="AllowDragTab" DefaultUrl="@TabDefaultUrl" ExcludeUrls="@ExcludeUrls" IsOnlyRenderActiveTab="IsOnlyRenderActiveTab" TabStyle="TabStyle" ShowToolbar="@ShowToolbar" ToolbarTemplate="@ToolbarTemplate" - ShowContextMenu="ShowTabContextMenu" + ShowContextMenu="ShowTabContextMenu" OnTabHeaderTextLocalizer="OnTabHeaderTextLocalizer" BeforeContextMenuTemplate="@BeforeTabContextMenuTemplate" ContextMenuTemplate="@TabContextMenuTemplate" ContextMenuRefreshIcon="@TabContextMenuRefreshIcon" ContextMenuCloseIcon="@TabContextMenuCloseIcon" ContextMenuCloseOtherIcon="@TabContextMenuCloseOtherIcon" ContextMenuCloseAllIcon="@TabContextMenuCloseAllIcon" diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor.cs b/src/BootstrapBlazor/Components/Layout/Layout.razor.cs index b4848267606..81ae8864981 100644 --- a/src/BootstrapBlazor/Components/Layout/Layout.razor.cs +++ b/src/BootstrapBlazor/Components/Layout/Layout.razor.cs @@ -18,6 +18,12 @@ public partial class Layout : IHandlerException, ITabHeader { private bool IsSmallScreen { get; set; } + /// + /// 获得/设置 Tab 标签头文本本地化回调方法 + /// + [Parameter] + public Func? OnTabHeaderTextLocalizer { get; set; } + /// /// Gets or sets the tab style. Default is . /// diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs index 5455b4f6243..a5e60687230 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -197,7 +197,6 @@ public partial class Tab /// 获得/设置 Gets or sets a collection of additional assemblies that should be searched for components that can match URIs. /// [Parameter] - [NotNull] public IEnumerable? AdditionalAssemblies { get; set; } /// @@ -529,15 +528,6 @@ protected override void OnParametersSet() ContextMenuCloseAllIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabContextMenuCloseAllIcon); ContextMenuFullScreenIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabContextMenuFullScreenIcon); - if (AdditionalAssemblies is null) - { - var entryAssembly = Assembly.GetEntryAssembly(); - if (entryAssembly is not null) - { - AdditionalAssemblies = [entryAssembly]; - } - } - if (Placement != Placement.Top && TabStyle == TabStyle.Chrome) { TabStyle = TabStyle.Default; @@ -816,6 +806,7 @@ public void AddTab(string url, string text, string? icon = null, bool active = t private void AddTabItem(string url) { + AdditionalAssemblies ??= [Assembly.GetEntryAssembly()!]; var parameters = new Dictionary { { nameof(TabItem.Url), url } diff --git a/test/UnitTest/Components/LayoutTest.cs b/test/UnitTest/Components/LayoutTest.cs index 37dc4365049..e49dc42c9ac 100644 --- a/test/UnitTest/Components/LayoutTest.cs +++ b/test/UnitTest/Components/LayoutTest.cs @@ -93,6 +93,22 @@ public async Task TabStyle_Ok() Assert.True(show); } + [Fact] + public void OnTabHeaderTextLocalizer_Ok() + { + var cut = Context.RenderComponent(pb => + { + pb.Add(a => a.UseTabSet, true); + pb.Add(a => a.AdditionalAssemblies, new Assembly[] { GetType().Assembly }); + pb.Add(a => a.OnTabHeaderTextLocalizer, text => $"Localized-{text}"); + }); + + var nav = cut.Services.GetRequiredService(); + nav.NavigateTo("/Cat"); + + cut.Contains("Localized-Cat"); + } + [Fact] public async Task ShowTabInHeader_Ok() {