Skip to content

Commit c06050c

Browse files
authored
feat(BootstrapBlazorOptions): add ShowErrorLoggerToast parameter (#6117)
* feat: 增加 ShowErrorLoggerToast 参数 * test: 增加单元测试
1 parent 7065ff2 commit c06050c

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/BootstrapBlazor/Components/BaseComponents/BootstrapBlazorRoot.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@namespace BootstrapBlazor.Components
33

44
<CascadingValue Value="this" IsFixed="true">
5-
<ErrorLogger EnableErrorLogger="EnableErrorLoggerValue" ShowToast="ShowToast" ToastTitle="@ToastTitle" OnErrorHandleAsync="OnErrorHandleAsync!">
5+
<ErrorLogger EnableErrorLogger="_enableErrorLoggerValue" ShowToast="_showToast" ToastTitle="@ToastTitle" OnErrorHandleAsync="OnErrorHandleAsync!">
66
@ChildContent
77

88
<Dialog></Dialog>

src/BootstrapBlazor/Components/BaseComponents/BootstrapBlazorRoot.razor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public partial class BootstrapBlazorRoot
4848
public Func<ILogger, Exception, Task>? OnErrorHandleAsync { get; set; }
4949

5050
/// <summary>
51-
/// 获得/设置 是否显示 Error 提示弹窗 默认 true 显示
51+
/// 获得/设置 是否显示 Error 提示弹窗 默认 null 使用 <see cref="BootstrapBlazorOptions.ShowErrorLoggerToast"/> 设置值
5252
/// </summary>
5353
[Parameter]
54-
public bool ShowToast { get; set; } = true;
54+
public bool? ShowToast { get; set; }
5555

5656
/// <summary>
5757
/// 获得/设置 Error Toast 弹窗标题
@@ -65,7 +65,9 @@ public partial class BootstrapBlazorRoot
6565
[Parameter]
6666
public bool? EnableErrorLogger { get; set; }
6767

68-
private bool EnableErrorLoggerValue => EnableErrorLogger ?? Options.CurrentValue.EnableErrorLogger;
68+
private bool _enableErrorLoggerValue => EnableErrorLogger ?? Options.CurrentValue.EnableErrorLogger;
69+
70+
private bool _showToast => ShowToast ?? Options.CurrentValue.ShowErrorLoggerToast;
6971

7072
/// <summary>
7173
/// SetParametersAsync 方法

src/BootstrapBlazor/Options/BootstrapBlazorOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public class BootstrapBlazorOptions : IOptions<BootstrapBlazorOptions>
4848
/// </summary>
4949
public bool EnableErrorLogger { get; set; } = true;
5050

51+
/// <summary>
52+
/// Gets or sets whether to enable show toast popup when global exception capture, default is true
53+
/// </summary>
54+
public bool ShowErrorLoggerToast { get; set; } = true;
55+
5156
/// <summary>
5257
/// Gets or sets whether to fall back to the fallback culture, default is true
5358
/// </summary>

test/UnitTest/Options/BootstrapBlazorOptionsTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public void Options_Ok()
1313
var options = new BootstrapBlazorOptions()
1414
{
1515
EnableErrorLogger = true,
16+
ShowErrorLoggerToast = true,
1617
EnableFallbackCulture = true,
1718
JSModuleVersion = "1.0",
1819
TableSettings = new()

0 commit comments

Comments
 (0)