From 509596429787f46dbf6dc8e54d2a62ec8a3db892 Mon Sep 17 00:00:00 2001
From: Nine <948825551@qq.com>
Date: Sat, 25 Sep 2021 13:52:30 +0000
Subject: [PATCH] =?UTF-8?q?!1897=20feat(#I4BS60):=20add=20a=20method=20tha?=
=?UTF-8?q?t=20get=20current=20item=20of=20tab=20*=20refactor:=20=E9=87=8D?=
=?UTF-8?q?=E5=91=BD=E5=90=8D=20GetActiveTab=20=E6=96=B9=E6=B3=95=20*=20re?=
=?UTF-8?q?factor:=20=E9=87=8D=E6=9E=84=20=E8=8E=B7=E5=8F=96=E5=BD=93?=
=?UTF-8?q?=E5=89=8D=20tab=20=E6=96=B9=E6=B3=95=20*=20doc:=20=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=20tab=20=E9=A1=B5=E9=9D=A2=E8=B5=84=E6=BA=90=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=20*=20feat:=20Tab=20=E7=BB=84=E4=BB=B6=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E8=8E=B7=E5=BE=97=E5=BD=93=E5=89=8D=20Tab=20=E7=9A=84?=
=?UTF-8?q?=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/BootstrapBlazor.Shared/Locales/en.json | 1 +
src/BootstrapBlazor.Shared/Locales/zh.json | 1 +
src/BootstrapBlazor.Shared/Pages/Samples/Tabs.razor.cs | 6 ++++++
src/BootstrapBlazor/Components/Tab/Tab.razor.cs | 6 ++++++
4 files changed, 14 insertions(+)
diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json
index 21a6aab74..28205cdee 100644
--- a/src/BootstrapBlazor.Shared/Locales/en.json
+++ b/src/BootstrapBlazor.Shared/Locales/en.json
@@ -701,6 +701,7 @@
"Method6": "Close the current tab method",
"Method7": "Close other tab methods",
"Method8": "Close all tab methods",
+ "Method9": "Get current tab methods",
"BackAddTabText": "I am a new Tab with the name {0}",
"BackText1": "Counter",
"BackText2": "Weather forecast",
diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json
index bdd16ff25..07ac982d3 100644
--- a/src/BootstrapBlazor.Shared/Locales/zh.json
+++ b/src/BootstrapBlazor.Shared/Locales/zh.json
@@ -701,6 +701,7 @@
"Method6": "关闭当前标签页方法",
"Method7": "关闭其他标签页方法",
"Method8": "关闭所有标签页方法",
+ "Method9": "获得当前标签页方法",
"BackAddTabText": "我是新建的 Tab, 名称是 {0}",
"BackText1": "计数器",
"BackText2": "天气预报",
diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/Tabs.razor.cs b/src/BootstrapBlazor.Shared/Pages/Samples/Tabs.razor.cs
index a2ba66dcb..adade1756 100644
--- a/src/BootstrapBlazor.Shared/Pages/Samples/Tabs.razor.cs
+++ b/src/BootstrapBlazor.Shared/Pages/Samples/Tabs.razor.cs
@@ -273,6 +273,12 @@ namespace BootstrapBlazor.Shared.Pages
Parameters = "",
ReturnValue = "Task"
},
+ new MethodItem() {
+ Name = nameof(Tab.GetActiveTab),
+ Description = Localizer["Method9"]!,
+ Parameters = "",
+ ReturnValue = "Tabitem"
+ },
};
}
}
diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs
index ecb362c7b..099967969 100644
--- a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs
+++ b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs
@@ -606,6 +606,12 @@ namespace BootstrapBlazor.Components
}
}
+ ///
+ /// 获得当前活动 Tab
+ ///
+ ///
+ public TabItem? GetActiveTab() => _items.FirstOrDefault(s => s.IsActive);
+
private void ActiveTabItem(TabItem item)
{
_items.ForEach(i => i.SetActive(false));