Skip to content

Commit 1d0381e

Browse files
committed
doc: 更新示例
1 parent 382aa34 commit 1d0381e

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

src/BootstrapBlazor.Server/Components/Samples/Tabs.razor

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ private void Navigation()
498498

499499
<DemoBlock Title="@Localizer["TabsContextMenuTitle"]" Introduction="@Localizer["TabsContextMenuIntro"]" Name="ContextMenu">
500500
<ContextMenuZone>
501-
<Tab IsCard="true" ShowClose="true" TabStyle="TabStyle.Chrome" ShowToolbar="true">
501+
<Tab IsCard="true" ShowClose="true" TabStyle="TabStyle.Chrome" ShowToolbar="true" @ref="_tab">
502502
<TabItem Text="@Localizer["TabItem1Text"]" Icon="fa-solid fa-user">
503503
<div>@Localizer["TabItem1Content"]</div>
504504
</TabItem>
@@ -513,11 +513,9 @@ private void Navigation()
513513
</TabItem>
514514
</Tab>
515515
<ContextMenu>
516-
<ContextMenuItem Icon="fa-solid fa-xmark" Text="关闭"></ContextMenuItem>
517-
<ContextMenuItem Icon="fa-solid fa-left-right" Text="关闭其他"></ContextMenuItem>
518-
<ContextMenuItem Icon="fa-solid fa-angle-left" Text="关闭左侧"></ContextMenuItem>
519-
<ContextMenuItem Icon="fa-solid fa-angle-right" Text="关闭右侧"></ContextMenuItem>
520-
<ContextMenuItem Icon="fa-solid fa-arrows-left-right-to-line" Text="关闭全部"></ContextMenuItem>
516+
<ContextMenuItem Icon="fa-solid fa-xmark" Text="@Localizer["ContextClose"]" OnClick="OnClose"></ContextMenuItem>
517+
<ContextMenuItem Icon="fa-solid fa-left-right" Text="@Localizer["ContextCloseOther"]" OnClick="OnCloseOther"></ContextMenuItem>
518+
<ContextMenuItem Icon="fa-solid fa-arrows-left-right-to-line" Text="@Localizer["ContextCloseAll"]" OnClick="OnCloseAll"></ContextMenuItem>
521519
</ContextMenu>
522520
</ContextMenuZone>
523521
</DemoBlock>

src/BootstrapBlazor.Server/Components/Samples/Tabs.razor.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,33 @@ private Task OnSetTitle(string text)
171171
return Task.CompletedTask;
172172
}
173173

174+
[NotNull]
175+
private Tab? _tab = null;
176+
177+
private async Task OnClose(ContextMenuItem item, object? context)
178+
{
179+
if (context is TabItem tabItem)
180+
{
181+
await _tab.RemoveTab(tabItem);
182+
}
183+
}
184+
185+
private Task OnCloseOther(ContextMenuItem item, object? context)
186+
{
187+
if (context is TabItem tabItem)
188+
{
189+
_tab.ActiveTab(tabItem);
190+
}
191+
_tab.CloseOtherTabs();
192+
return Task.CompletedTask;
193+
}
194+
195+
private Task OnCloseAll(ContextMenuItem item, object? context)
196+
{
197+
_tab.CloseAllTabs();
198+
return Task.CompletedTask;
199+
}
200+
174201
/// <summary>
175202
/// 获得属性方法
176203
/// </summary>

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,12 @@
21322132
"AttributeRefreshToolbarButtonIcon": "Toolbar refresh button icon",
21332133
"AttributeFullscreenToolbarButtonIcon": "Toolbar full screen button icon",
21342134
"TabsToolbarDesc": "After clicking the button, the counter value increases, and clicking the <b>Refresh</b> button on the toolbar will reset the counter.",
2135-
"AttributeOnToolbarRefreshCallback": "Click the toolbar refresh button callback method"
2135+
"AttributeOnToolbarRefreshCallback": "Click the toolbar refresh button callback method",
2136+
"ContextClose": "Close",
2137+
"ContextCloseOther": "Close Other Tabs",
2138+
"ContextCloseAll": "Close All Tabs",
2139+
"TabsContextMenuTitle": "TabItem Context Menu",
2140+
"TabsContextMenuIntro": "Use the built-in <code>ContextMenuZone</code> component to pop up a custom context menu when you right-click a tab item"
21362141
},
21372142
"BootstrapBlazor.Server.Components.Components.DemoTabItem": {
21382143
"Info": "Reset the title of this <code>TabItem</code> by click the button",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,12 @@
21322132
"AttributeRefreshToolbarButtonIcon": "工具栏刷新按钮图标",
21332133
"AttributeFullscreenToolbarButtonIcon": "工具栏全屏按钮图标",
21342134
"TabsToolbarDesc": "点击按钮计数器数值增加后,点击工具栏的 <b>刷新</b> 按钮计数器清零",
2135-
"AttributeOnToolbarRefreshCallback": "点击工具栏刷新按钮回调方法"
2135+
"AttributeOnToolbarRefreshCallback": "点击工具栏刷新按钮回调方法",
2136+
"ContextClose": "关闭",
2137+
"ContextCloseOther": "关闭其他",
2138+
"ContextCloseAll": "关闭全部",
2139+
"TabsContextMenuTitle": "右键菜单",
2140+
"TabsContextMenuIntro": "通过内置 <code>ContextMenuZone</code> 组件,点击标签页右键时弹窗自定义右键菜单"
21362141
},
21372142
"BootstrapBlazor.Server.Components.Components.DemoTabItem": {
21382143
"Info": "点击下方按钮,本 <code>TabItem</code> 标题更改为当前分钟与秒",

0 commit comments

Comments
 (0)