@@ -297,6 +297,48 @@ public partial class Layout : IHandlerException
297297 [ Parameter ]
298298 public string NotAuthorizeUrl { get ; set ; } = "/Account/Login" ;
299299
300+ /// <summary>
301+ /// Gets or sets whether enable tab context menu. Default is false.
302+ /// </summary>
303+ [ Parameter ]
304+ public bool ShowTabContextMenu { get ; set ; }
305+
306+ /// <summary>
307+ /// Gets or sets the template of before tab context menu. Default is null.
308+ /// </summary>
309+ [ Parameter ]
310+ public RenderFragment < Tab > ? BeforeTabContextMenuTemplate { get ; set ; }
311+
312+ /// <summary>
313+ /// Gets or sets the template of tab context menu. Default is null.
314+ /// </summary>
315+ [ Parameter ]
316+ public RenderFragment < Tab > ? TabContextMenuTemplate { get ; set ; }
317+
318+ /// <summary>
319+ /// Gets or sets the icon of tab item context menu refresh button. Default is null.
320+ /// </summary>
321+ [ Parameter ]
322+ public string ? TabContextMenuRefreshIcon { get ; set ; }
323+
324+ /// <summary>
325+ /// Gets or sets the icon of tab item context menu close button. Default is null.
326+ /// </summary>
327+ [ Parameter ]
328+ public string ? TabContextMenuCloseIcon { get ; set ; }
329+
330+ /// <summary>
331+ /// Gets or sets the icon of tab item context menu close other button. Default is null.
332+ /// </summary>
333+ [ Parameter ]
334+ public string ? TabContextMenuCloseOtherIcon { get ; set ; }
335+
336+ /// <summary>
337+ /// Gets or sets the icon of tab item context menu close all button. Default is null.
338+ /// </summary>
339+ [ Parameter ]
340+ public string ? TabContextMenuCloseAllIcon { get ; set ; }
341+
300342 [ Inject ]
301343 [ NotNull ]
302344 private NavigationManager ? Navigation { get ; set ; }
@@ -404,7 +446,8 @@ public partial class Layout : IHandlerException
404446 [ NotNull ]
405447 private IStringLocalizer < Layout > ? Localizer { get ; set ; }
406448
407- private bool _init { get ; set ; }
449+ private bool _init ;
450+ private Tab _tab = default ! ;
408451
409452 /// <summary>
410453 /// <inheritdoc/>
@@ -466,6 +509,10 @@ protected override void OnParametersSet()
466509
467510 TooltipText ??= Localizer [ nameof ( TooltipText ) ] ;
468511 MenuBarIcon ??= IconTheme . GetIconByKey ( ComponentIcons . LayoutMenuBarIcon ) ;
512+ TabContextMenuRefreshIcon ??= IconTheme . GetIconByKey ( ComponentIcons . TabContextMenuRefreshIcon ) ;
513+ TabContextMenuCloseIcon ??= IconTheme . GetIconByKey ( ComponentIcons . TabContextMenuCloseIcon ) ;
514+ TabContextMenuCloseOtherIcon ??= IconTheme . GetIconByKey ( ComponentIcons . TabContextMenuCloseOtherIcon ) ;
515+ TabContextMenuCloseAllIcon ??= IconTheme . GetIconByKey ( ComponentIcons . TabContextMenuCloseAllIcon ) ;
469516 }
470517
471518 /// <summary>
@@ -580,6 +627,38 @@ public virtual Task HandlerException(Exception ex, RenderFragment<Exception> err
580627
581628 private string ? GetTargetString ( ) => IsFixedTabHeader ? ".tabs-body" : null ;
582629
630+ private async Task OnRefrsh ( ContextMenuItem item , object ? context )
631+ {
632+ if ( context is TabItem tabItem )
633+ {
634+ await _tab . Refresh ( tabItem ) ;
635+ }
636+ }
637+
638+ private async Task OnClose ( ContextMenuItem item , object ? context )
639+ {
640+ if ( context is TabItem tabItem )
641+ {
642+ await _tab . RemoveTab ( tabItem ) ;
643+ }
644+ }
645+
646+ private Task OnCloseOther ( ContextMenuItem item , object ? context )
647+ {
648+ if ( context is TabItem tabItem )
649+ {
650+ _tab . ActiveTab ( tabItem ) ;
651+ }
652+ _tab . CloseOtherTabs ( ) ;
653+ return Task . CompletedTask ;
654+ }
655+
656+ private Task OnCloseAll ( ContextMenuItem item , object ? context )
657+ {
658+ _tab . CloseAllTabs ( ) ;
659+ return Task . CompletedTask ;
660+ }
661+
583662 /// <summary>
584663 /// <inheritdoc/>
585664 /// </summary>
0 commit comments