Skip to content

Commit e3a9569

Browse files
committed
feat: 增加 ShowContextMenuFullScreen 参数
1 parent 4b9419a commit e3a9569

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/BootstrapBlazor/Components/Tab/Tab.razor

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ else if (ShowContextMenu)
2020
<ContextMenuItem Icon="@ContextMenuCloseIcon" Text="@Localizer["ContextClose"]" OnClick="OnClose"></ContextMenuItem>
2121
<ContextMenuItem Icon="@ContextMenuCloseOtherIcon" Text="@Localizer["ContextCloseOther"]" OnClick="OnCloseOther"></ContextMenuItem>
2222
<ContextMenuItem Icon="@ContextMenuCloseAllIcon" Text="@Localizer["ContextCloseAll"]" OnClick="OnCloseAll"></ContextMenuItem>
23+
@if (ShowContextMenuFullScreen)
24+
{
25+
<ContextMenuDivider></ContextMenuDivider>
26+
<ContextMenuItem Icon="@FullscreenToolbarButtonIcon" Text="@Localizer["ContextFullScreen"]" OnClick="OnFullScreen"></ContextMenuItem>
27+
}
2328
@if (ContextMenuTemplate != null)
2429
{
2530
@ContextMenuTemplate(this)

src/BootstrapBlazor/Components/Tab/Tab.razor.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public partial class Tab : IHandlerException
114114
[Parameter]
115115
public bool ShowFullScreen { get; set; }
116116

117+
/// <summary>
118+
/// Gets or sets whether show the full screen button on context menu. Default is true.
119+
/// </summary>
120+
[Parameter]
121+
public bool ShowContextMenuFullScreen { get; set; } = true;
122+
117123
/// <summary>
118124
/// 关闭标签页回调方法
119125
/// </summary>
@@ -433,6 +439,10 @@ public partial class Tab : IHandlerException
433439
[Inject, NotNull]
434440
private DialogService? DialogService { get; set; }
435441

442+
[Inject]
443+
[NotNull]
444+
private FullScreenService? FullScreenService { get; set; }
445+
436446
private ContextMenuZone? _contextMenuZone;
437447

438448
private ConcurrentDictionary<TabItem, bool> LazyTabCache { get; } = new();
@@ -1016,7 +1026,7 @@ public async Task DragItemCallback(int originIndex, int currentIndex)
10161026
}
10171027
}
10181028

1019-
private string? GetIdByTabItem(TabItem item) => ComponentIdGenerator.Generate(item);
1029+
private string GetIdByTabItem(TabItem item) => ComponentIdGenerator.Generate(item);
10201030

10211031
private async Task OnRefreshAsync()
10221032
{
@@ -1075,6 +1085,14 @@ private Task OnCloseAll(ContextMenuItem item, object? context)
10751085
return Task.CompletedTask;
10761086
}
10771087

1088+
private async Task OnFullScreen(ContextMenuItem item, object? context)
1089+
{
1090+
if (context is TabItem tabItem)
1091+
{
1092+
await FullScreenService.ToggleById(GetIdByTabItem(tabItem));
1093+
}
1094+
}
1095+
10781096
private async Task OnContextMenu(MouseEventArgs e, TabItem item)
10791097
{
10801098
if (_contextMenuZone != null)

0 commit comments

Comments
 (0)