Skip to content

Commit bf03635

Browse files
committed
feat: 增加刷新按钮
1 parent 01c60f8 commit bf03635

File tree

9 files changed

+74
-3
lines changed

9 files changed

+74
-3
lines changed

src/BootstrapBlazor/Components/Tab/Tab.razor

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ else
7676
@if (ShowToolbar)
7777
{
7878
<div class="tabs-nav-toolbar">
79-
@if (ShowFullscreenButton)
79+
@if (ShowRefreshToolbarButton)
8080
{
81-
<div class="tabs-nav-toolbar-button">
81+
<div class="tabs-nav-toolbar-button tabs-nav-toolbar-refresh">
82+
<TabToolbarRefreshButton Icon="@RefreshToolbarButtonIcon" OnClickAsync="OnRefreshAsync"></TabToolbarRefreshButton>
83+
</div>
84+
}
85+
@if (ShowFullscreenToolbarButton)
86+
{
87+
<div class="tabs-nav-toolbar-button tabs-nav-toolbar-fs">
8288
<FullScreenButton TargetId="@Id"></FullScreenButton>
8389
</div>
8490
}

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,19 @@ public partial class Tab : IHandlerException
304304
/// Gets or sets whether show the full screen button. Default is true.
305305
/// </summary>
306306
[Parameter]
307-
public bool ShowFullscreenButton { get; set; } = true;
307+
public bool ShowFullscreenToolbarButton { get; set; } = true;
308+
309+
/// <summary>
310+
/// Gets or sets whether show the full screen button. Default is true.
311+
/// </summary>
312+
[Parameter]
313+
public bool ShowRefreshToolbarButton { get; set; } = true;
314+
315+
/// <summary>
316+
/// Gets or sets the refresh toolbar button icon string. Default is null.
317+
/// </summary>
318+
[Parameter]
319+
public string? RefreshToolbarButtonIcon { get; set; }
308320

309321
[CascadingParameter]
310322
private Layout? Layout { get; set; }
@@ -372,6 +384,7 @@ protected override void OnParametersSet()
372384
NextIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabNextIcon);
373385
DropdownIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabDropdownIcon);
374386
CloseIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabCloseIcon);
387+
RefreshToolbarButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.TabRefreshButtonIcon);
375388

376389
AdditionalAssemblies ??= new[] { Assembly.GetEntryAssembly()! };
377390

@@ -890,6 +903,11 @@ public async Task DragItemCallback(int originIndex, int currentIndex)
890903

891904
private string? GetIdByTabItem(TabItem item) => (ShowFullScreen && item.ShowFullScreen) ? ComponentIdGenerator.Generate(item) : null;
892905

906+
private Task OnRefreshAsync()
907+
{
908+
return Task.CompletedTask;
909+
}
910+
893911
/// <summary>
894912
/// <inheritdoc/>
895913
/// </summary>

src/BootstrapBlazor/Components/Tab/Tab.razor.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@
669669
display: none;
670670
align-items: center;
671671
height: 100%;
672+
673+
.tabs-nav-toolbar-button {
674+
cursor: pointer;
675+
}
672676
}
673677
}
674678
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@namespace BootstrapBlazor.Components
2+
3+
<i class="@Icon" @onclick="OnClick"></i>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Components;
7+
8+
/// <summary>
9+
/// TabToolbarRefreshButton component
10+
/// </summary>
11+
public partial class TabToolbarRefreshButton
12+
{
13+
/// <summary>
14+
/// Gets or sets the button icon string. Default is null.
15+
/// </summary>
16+
[Parameter]
17+
public string? Icon { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the button click event handler. Default is null.
21+
/// </summary>
22+
[Parameter]
23+
public Func<Task>? OnClickAsync { get; set; }
24+
25+
private async Task OnClick()
26+
{
27+
if (OnClickAsync != null)
28+
{
29+
await OnClickAsync();
30+
}
31+
}
32+
}

src/BootstrapBlazor/Enums/ComponentIcons.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,11 @@ public enum ComponentIcons
705705
/// </summary>
706706
TabCloseIcon,
707707

708+
/// <summary>
709+
/// Tab 组件 RefreshToolbarButtonIcon 属性图标
710+
/// </summary>
711+
TabRefreshButtonIcon,
712+
708713
/// <summary>
709714
/// Timer 组件 Icon 属性图标
710715
/// </summary>

src/BootstrapBlazor/Icons/BootstrapIcons.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ internal static class BootstrapIcons
136136
{ ComponentIcons.TabNextIcon, "bi bi-chevron-right" },
137137
{ ComponentIcons.TabDropdownIcon, "bi bi-chevron-down" },
138138
{ ComponentIcons.TabCloseIcon, "bi bi-x" },
139+
{ ComponentIcons.TabRefreshButtonIcon, "bi bi-arrow-clockwise" },
139140

140141
{ ComponentIcons.TableColumnToolboxIcon, "bi bi-gear" },
141142

src/BootstrapBlazor/Icons/FontAwesomeIcons.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ internal static class FontAwesomeIcons
134134
{ ComponentIcons.TabNextIcon, "fa-solid fa-chevron-right" },
135135
{ ComponentIcons.TabDropdownIcon, "fa-solid fa-chevron-down" },
136136
{ ComponentIcons.TabCloseIcon, "fa-solid fa-xmark" },
137+
{ ComponentIcons.TabRefreshButtonIcon, "fa-solid fa-arrows-rotate" },
137138

138139
{ ComponentIcons.TableColumnToolboxIcon, "fa-solid fa-gear" },
139140

src/BootstrapBlazor/Icons/MaterialDesignIcons.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ internal static class MaterialDesignIcons
136136
{ ComponentIcons.TabNextIcon, "mdi mdi-chevron-right" },
137137
{ ComponentIcons.TabDropdownIcon, "mdi mdi-chevron-down" },
138138
{ ComponentIcons.TabCloseIcon, "mdi mdi-close" },
139+
{ ComponentIcons.TabRefreshButtonIcon, "mdi mdi-refresh" },
139140

140141
{ ComponentIcons.TableColumnToolboxIcon, "mdi mdi-cog" },
141142

0 commit comments

Comments
 (0)