Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<Version>9.12.2-beta02</Version>
<Version>9.12.2-beta03</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(VisualStudioVersion)' == '18.0'">
<Version>10.0.0-rc.2.2.4</Version>
<Version>10.0.0-rc.2.2.5</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Layout/Layout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions src/BootstrapBlazor/Components/Layout/Layout.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public partial class Layout : IHandlerException, ITabHeader
{
private bool IsSmallScreen { get; set; }

/// <summary>
/// 获得/设置 Tab 标签头文本本地化回调方法
/// </summary>
[Parameter]
public Func<string?, string?>? OnTabHeaderTextLocalizer { get; set; }

/// <summary>
/// Gets or sets the tab style. Default is <see cref="TabStyle.Default"/>.
/// </summary>
Expand Down
13 changes: 2 additions & 11 deletions src/BootstrapBlazor/Components/Tab/Tab.razor.cs
Original file line number Diff line number Diff line change
@@ -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([email protected]) Website: https://www.blazor.zone
Expand Down Expand Up @@ -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.
/// </summary>
[Parameter]
[NotNull]
public IEnumerable<Assembly>? AdditionalAssemblies { get; set; }

/// <summary>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, object?>
{
{ nameof(TabItem.Url), url }
Expand Down
16 changes: 16 additions & 0 deletions test/UnitTest/Components/LayoutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ public async Task TabStyle_Ok()
Assert.True(show);
}

[Fact]
public void OnTabHeaderTextLocalizer_Ok()
{
var cut = Context.RenderComponent<Layout>(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<FakeNavigationManager>();
nav.NavigateTo("/Cat");

cut.Contains("Localized-Cat");
}

[Fact]
public async Task ShowTabInHeader_Ok()
{
Expand Down
Loading