mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-04 21:20:16 +08:00
!1614 fix(#I4175P): tab support not found render template
* feat: Layout 增加 NotFound 模板 * feat: Tab 组件增加 NotFound 模板 * feat: 增加资源文件
This commit is contained in:
parent
d2a0bdf863
commit
1fb750a295
@ -97,10 +97,13 @@ RenderFragment RenderMain =>
|
||||
{
|
||||
<RenderTemplate>
|
||||
<Tab ClickTabToNavigation="true" ShowExtendButtons="true" ShowClose="true" TabItemTextDictionary="@TabItemTextDictionary"
|
||||
AdditionalAssemblies="@AdditionalAssemblies" ExcludeUrls="@ExcludeUrls" Body="@Main">
|
||||
AdditionalAssemblies="@AdditionalAssemblies" ExcludeUrls="@ExcludeUrls" NotFoundTabText="@NotFoundTabText" Body="@Main">
|
||||
<NotAuthorized>
|
||||
@NotAuthorized
|
||||
</NotAuthorized>
|
||||
<NotFound>
|
||||
@NotFound
|
||||
</NotFound>
|
||||
</Tab>
|
||||
</RenderTemplate>
|
||||
}
|
||||
|
@ -50,6 +50,19 @@ namespace BootstrapBlazor.Components
|
||||
[Parameter]
|
||||
public RenderFragment? NotAuthorized { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 NotFound 模板
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment? NotFound { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 NotFound 标签文本
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
[NotNull]
|
||||
public string? NotFoundTabText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 Footer 高度 支持百分比 默认宽度为 300px
|
||||
/// </summary>
|
||||
|
@ -122,6 +122,12 @@ namespace BootstrapBlazor.Components
|
||||
[Parameter]
|
||||
public RenderFragment? NotAuthorized { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 NotFound 模板
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment? NotFound { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 TabItems 模板
|
||||
/// </summary>
|
||||
@ -147,6 +153,13 @@ namespace BootstrapBlazor.Components
|
||||
[Parameter]
|
||||
public Func<TabItem, Task>? OnClickTab { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 NotFound 标签文本
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
[NotNull]
|
||||
public string? NotFoundTabText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 关闭当前 TabItem 菜单文本
|
||||
/// </summary>
|
||||
@ -208,6 +221,7 @@ namespace BootstrapBlazor.Components
|
||||
CloseOtherTabsText ??= Localizer[nameof(CloseOtherTabsText)];
|
||||
CloseAllTabsText ??= Localizer[nameof(CloseAllTabsText)];
|
||||
CloseCurrentTabText ??= Localizer[nameof(CloseCurrentTabText)];
|
||||
NotFoundTabText ??= Localizer[nameof(NotFoundTabText)];
|
||||
|
||||
if (!OperatingSystem.IsBrowser() && AdditionalAssemblies == null)
|
||||
{
|
||||
@ -451,35 +465,45 @@ namespace BootstrapBlazor.Components
|
||||
|
||||
private void AddTabItem(string url, string? text = null, string? icon = null, bool? active = null, bool? closable = null)
|
||||
{
|
||||
if (TryGetTabItemText(url, out var tabText))
|
||||
{
|
||||
text = tabText;
|
||||
}
|
||||
text ??= Options.Text;
|
||||
icon ??= Options.Icon ?? string.Empty;
|
||||
active ??= Options.IsActive ?? true;
|
||||
closable ??= Options.Closable ?? true;
|
||||
Options.Reset();
|
||||
|
||||
var parameters = new Dictionary<string, object?>()
|
||||
{
|
||||
[nameof(TabItem.Url)] = url,
|
||||
[nameof(TabItem.Icon)] = icon,
|
||||
[nameof(TabItem.Closable)] = closable,
|
||||
[nameof(TabItem.IsActive)] = active
|
||||
};
|
||||
var context = RouteTableFactory.Create(AdditionalAssemblies, url);
|
||||
if (context.Handler != null)
|
||||
{
|
||||
if (TryGetTabItemText(url, out var tabText))
|
||||
parameters.Add(nameof(TabItem.Text), GetTabText(text, context.Segments));
|
||||
parameters.Add(nameof(TabItem.ChildContent), new RenderFragment(builder =>
|
||||
{
|
||||
text = tabText;
|
||||
}
|
||||
text ??= Options.Text;
|
||||
icon ??= Options.Icon ?? string.Empty;
|
||||
active ??= Options.IsActive ?? true;
|
||||
closable ??= Options.Closable ?? true;
|
||||
Options.Reset();
|
||||
|
||||
AddTabItem(new Dictionary<string, object?>
|
||||
{
|
||||
[nameof(TabItem.Text)] = GetTabText(text, context.Segments),
|
||||
[nameof(TabItem.Url)] = url,
|
||||
[nameof(TabItem.Icon)] = icon,
|
||||
[nameof(TabItem.Closable)] = closable,
|
||||
[nameof(TabItem.IsActive)] = active,
|
||||
[nameof(TabItem.ChildContent)] = new RenderFragment(builder =>
|
||||
{
|
||||
builder.OpenComponent<BootstrapBlazorAuthorizeView>(0);
|
||||
builder.AddAttribute(1, nameof(BootstrapBlazorAuthorizeView.RouteContext), context);
|
||||
builder.AddAttribute(2, nameof(BootstrapBlazorAuthorizeView.NotAuthorized), NotAuthorized);
|
||||
builder.CloseComponent();
|
||||
})
|
||||
});
|
||||
builder.OpenComponent<BootstrapBlazorAuthorizeView>(0);
|
||||
builder.AddAttribute(1, nameof(BootstrapBlazorAuthorizeView.RouteContext), context);
|
||||
builder.AddAttribute(2, nameof(BootstrapBlazorAuthorizeView.NotAuthorized), NotAuthorized);
|
||||
builder.CloseComponent();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters.Add(nameof(TabItem.Text), text ?? NotFoundTabText);
|
||||
parameters.Add(nameof(TabItem.ChildContent), new RenderFragment(builder =>
|
||||
{
|
||||
builder.AddContent(0, NotFound);
|
||||
}));
|
||||
}
|
||||
|
||||
AddTabItem(parameters);
|
||||
}
|
||||
|
||||
private string GetTabText(string? text, string[]? segments)
|
||||
|
@ -179,7 +179,8 @@
|
||||
"BootstrapBlazor.Components.Tab": {
|
||||
"CloseCurrentTabText": "Close",
|
||||
"CloseOtherTabsText": "Close Other",
|
||||
"CloseAllTabsText": "Close All"
|
||||
"CloseAllTabsText": "Close All",
|
||||
"NotFoundTabText": "NotFound"
|
||||
},
|
||||
"BootstrapBlazor.Components.Table": {
|
||||
"AddButtonText": "Add",
|
||||
|
@ -179,7 +179,8 @@
|
||||
"BootstrapBlazor.Components.Tab": {
|
||||
"CloseCurrentTabText": "关闭当前标签",
|
||||
"CloseOtherTabsText": "关闭其他标签",
|
||||
"CloseAllTabsText": "关闭所有标签"
|
||||
"CloseAllTabsText": "关闭所有标签",
|
||||
"NotFoundTabText": "未找到"
|
||||
},
|
||||
"BootstrapBlazor.Components.Table": {
|
||||
"AddButtonText": "新建",
|
||||
|
Loading…
Reference in New Issue
Block a user