diff --git a/src/BootstrapBlazor.Server/Components/Samples/Tabs.razor b/src/BootstrapBlazor.Server/Components/Samples/Tabs.razor index 4e4720d6cfc..1be6b06f553 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Tabs.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/Tabs.razor @@ -500,9 +500,8 @@ private void Navigation() @((MarkupString)Localizer["TabsContextMenuDesc"].Value) - - + + @Localizer["TabItem1Content"] diff --git a/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.scss b/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.scss index 3d8e6cc4eef..cdcf0917236 100644 --- a/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.scss +++ b/src/BootstrapBlazor/Components/ContextMenu/ContextMenu.razor.scss @@ -1,4 +1,4 @@ -.bb-cm { +.bb-cm { --bb-cm-icon-min-width: #{$bb-cm-icon-min-width}; --bb-cm-icon-min-height: #{$bb-cm-icon-min-height}; z-index: 1200; @@ -10,6 +10,6 @@ } .divider { - margin: 0.5rem 0; + margin: 0.25rem 0; } } diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor b/src/BootstrapBlazor/Components/Tab/Tab.razor index a9de8d62912..bc398dd2b8a 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor @@ -20,6 +20,11 @@ else if (ShowContextMenu) + @if (ShowContextMenuFullScreen) + { + + + } @if (ContextMenuTemplate != null) { @ContextMenuTemplate(this) diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs index 21610165ab0..13f511925f1 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs @@ -114,6 +114,12 @@ public partial class Tab : IHandlerException [Parameter] public bool ShowFullScreen { get; set; } + /// + /// Gets or sets whether show the full screen button on context menu. Default is true. + /// + [Parameter] + public bool ShowContextMenuFullScreen { get; set; } = true; + /// /// 关闭标签页回调方法 /// @@ -401,6 +407,12 @@ public partial class Tab : IHandlerException [Parameter] public string? ContextMenuCloseAllIcon { get; set; } + /// + /// Gets or sets the icon of tab item context menu full screen button. Default is null. + /// + [Parameter] + public string? ContextMenuFullScreenIcon { get; set; } + /// /// Gets or sets before popup context menu callback. Default is null. /// @@ -433,6 +445,10 @@ public partial class Tab : IHandlerException [Inject, NotNull] private DialogService? DialogService { get; set; } + [Inject] + [NotNull] + private FullScreenService? FullScreenService { get; set; } + private ContextMenuZone? _contextMenuZone; private ConcurrentDictionary LazyTabCache { get; } = new(); @@ -490,6 +506,7 @@ protected override void OnParametersSet() ContextMenuCloseIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabContextMenuCloseIcon); ContextMenuCloseOtherIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabContextMenuCloseOtherIcon); ContextMenuCloseAllIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabContextMenuCloseAllIcon); + ContextMenuFullScreenIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabContextMenuFullScreenIcon); if (AdditionalAssemblies is null) { @@ -1016,7 +1033,7 @@ public async Task DragItemCallback(int originIndex, int currentIndex) } } - private string? GetIdByTabItem(TabItem item) => ComponentIdGenerator.Generate(item); + private string GetIdByTabItem(TabItem item) => ComponentIdGenerator.Generate(item); private async Task OnRefreshAsync() { @@ -1075,6 +1092,14 @@ private Task OnCloseAll(ContextMenuItem item, object? context) return Task.CompletedTask; } + private async Task OnFullScreen(ContextMenuItem item, object? context) + { + if (context is TabItem tabItem) + { + await FullScreenService.ToggleById(GetIdByTabItem(tabItem)); + } + } + private async Task OnContextMenu(MouseEventArgs e, TabItem item) { if (_contextMenuZone != null) diff --git a/src/BootstrapBlazor/Enums/ComponentIcons.cs b/src/BootstrapBlazor/Enums/ComponentIcons.cs index 3b417961e69..a401bf07393 100644 --- a/src/BootstrapBlazor/Enums/ComponentIcons.cs +++ b/src/BootstrapBlazor/Enums/ComponentIcons.cs @@ -730,6 +730,11 @@ public enum ComponentIcons /// TabContextMenuCloseAllIcon, + /// + /// Tab 组件 TabContextMenuFullScreenIcon 属性图标 + /// + TabContextMenuFullScreenIcon, + /// /// Timer 组件 Icon 属性图标 /// diff --git a/src/BootstrapBlazor/Icons/BootstrapIcons.cs b/src/BootstrapBlazor/Icons/BootstrapIcons.cs index 1b420a62a6c..641d0182b37 100644 --- a/src/BootstrapBlazor/Icons/BootstrapIcons.cs +++ b/src/BootstrapBlazor/Icons/BootstrapIcons.cs @@ -90,6 +90,7 @@ internal static class BootstrapIcons { ComponentIcons.TabContextMenuCloseIcon, "bi bi-x" }, { ComponentIcons.TabContextMenuCloseOtherIcon, "bi bi-arrow" }, { ComponentIcons.TabContextMenuCloseAllIcon, "bi bi-arrow-left-right" }, + { ComponentIcons.TabContextMenuFullScreenIcon, "bi bi-arrows-fullscreen" }, { ComponentIcons.LogoutLinkIcon, "bi bi-box-arrow-right" }, diff --git a/src/BootstrapBlazor/Icons/FontAwesomeIcons.cs b/src/BootstrapBlazor/Icons/FontAwesomeIcons.cs index 4788bb160bd..893d038e89a 100644 --- a/src/BootstrapBlazor/Icons/FontAwesomeIcons.cs +++ b/src/BootstrapBlazor/Icons/FontAwesomeIcons.cs @@ -90,6 +90,7 @@ internal static class FontAwesomeIcons { ComponentIcons.TabContextMenuCloseIcon, "fa-fw fa-solid fa-xmark" }, { ComponentIcons.TabContextMenuCloseOtherIcon, "fa-fw fa-solid fa-left-right" }, { ComponentIcons.TabContextMenuCloseAllIcon, "fa-fw fa-solid fa-arrows-left-right-to-line" }, + { ComponentIcons.TabContextMenuFullScreenIcon, "fa-fw fa-solid fa-maximize" }, { ComponentIcons.LogoutLinkIcon, "fa-solid fa-key" }, diff --git a/src/BootstrapBlazor/Icons/MaterialDesignIcons.cs b/src/BootstrapBlazor/Icons/MaterialDesignIcons.cs index 42ebb0881d9..a75eb1597ea 100644 --- a/src/BootstrapBlazor/Icons/MaterialDesignIcons.cs +++ b/src/BootstrapBlazor/Icons/MaterialDesignIcons.cs @@ -90,6 +90,7 @@ internal static class MaterialDesignIcons { ComponentIcons.TabContextMenuCloseIcon, "mdi mdi-close" }, { ComponentIcons.TabContextMenuCloseOtherIcon, "mdi mdi-menu" }, { ComponentIcons.TabContextMenuCloseAllIcon, "mdi mdi-arrow-left-right-bold" }, + { ComponentIcons.TabContextMenuFullScreenIcon, "mdi mdi-arrow-expand-all" }, { ComponentIcons.LogoutLinkIcon, "mdi mdi-logout" }, diff --git a/src/BootstrapBlazor/Locales/en.json b/src/BootstrapBlazor/Locales/en.json index 847e2e1a738..c2d030ddbe0 100644 --- a/src/BootstrapBlazor/Locales/en.json +++ b/src/BootstrapBlazor/Locales/en.json @@ -182,7 +182,8 @@ "ContextRefresh": "Refresh", "ContextClose": "Close", "ContextCloseOther": "Close Other Tabs", - "ContextCloseAll": "Close All Tabs" + "ContextCloseAll": "Close All Tabs", + "ContextFullScreen": "Full screen" }, "BootstrapBlazor.Components.MultiFilter": { "MultiFilterSearchPlaceHolderText": "Please enter ...", diff --git a/src/BootstrapBlazor/Locales/zh.json b/src/BootstrapBlazor/Locales/zh.json index 22af6c45ff4..219dd19ade3 100644 --- a/src/BootstrapBlazor/Locales/zh.json +++ b/src/BootstrapBlazor/Locales/zh.json @@ -182,7 +182,8 @@ "ContextRefresh": "刷新", "ContextClose": "关闭", "ContextCloseOther": "关闭其他", - "ContextCloseAll": "关闭全部" + "ContextCloseAll": "关闭全部", + "ContextFullScreen": "全屏" }, "BootstrapBlazor.Components.MultiFilter": { "MultiFilterSearchPlaceHolderText": "请输入 ...", diff --git a/test/UnitTest/Components/TabTest.cs b/test/UnitTest/Components/TabTest.cs index 99df42b4fc2..3602fd93a3b 100644 --- a/test/UnitTest/Components/TabTest.cs +++ b/test/UnitTest/Components/TabTest.cs @@ -33,6 +33,7 @@ public async Task ContextMenu_Ok() pb.AddChildContent(pb => { pb.Add(a => a.ShowContextMenu, true); + pb.Add(a => a.ShowContextMenuFullScreen, true); pb.AddChildContent(pb => { pb.Add(a => a.IsDisabled, true);
@((MarkupString)Localizer["TabsContextMenuDesc"].Value)