Skip to content

Commit 9561196

Browse files
committed
!3224 test(#I5QFPC): add ShowClose parameter on toast service extensions method
* refactor: 更新参数名 * feat: Toast 扩展方法增加 ShowClose 参数
1 parent 59bf137 commit 9561196

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/BootstrapBlazor/Extensions/ToastServiceExtensions.cs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,60 +16,64 @@ public static class ToastServiceExtensions
1616
/// <param name="title">Title 属性</param>
1717
/// <param name="content">Content 属性</param>
1818
/// <param name="autoHide">自动隐藏属性默认为 true</param>
19-
/// <returns></returns>
20-
public static Task Success(this ToastService service, string? title = null, string? content = null, bool autoHide = true) => service.Show(new ToastOption()
19+
/// <param name="showClose">是否显示关闭按钮 默认 true</param>
20+
public static Task Success(this ToastService service, string? title = null, string? content = null, bool autoHide = true, bool showClose = true) => service.Show(new ToastOption()
2121
{
2222
Category = ToastCategory.Success,
2323
IsAutoHide = autoHide,
2424
Title = title ?? "",
25-
Content = content ?? ""
25+
Content = content ?? "",
26+
ShowClose = showClose
2627
});
2728

2829
/// <summary>
2930
/// Toast 调用错误快捷方法
3031
/// </summary>
3132
/// <param name="service"></param>
32-
/// <param name="title"></param>
33-
/// <param name="content"></param>
34-
/// <param name="autoHide"></param>
35-
/// <returns></returns>
36-
public static Task Error(this ToastService service, string? title = null, string? content = null, bool autoHide = true) => service.Show(new ToastOption()
33+
/// <param name="title">Title 属性</param>
34+
/// <param name="content">Content 属性</param>
35+
/// <param name="autoHide">自动隐藏属性默认为 true</param>
36+
/// <param name="showClose">是否显示关闭按钮 默认 true</param>
37+
public static Task Error(this ToastService service, string? title = null, string? content = null, bool autoHide = true, bool showClose = true) => service.Show(new ToastOption()
3738
{
3839
Category = ToastCategory.Error,
3940
IsAutoHide = autoHide,
4041
Title = title ?? "",
41-
Content = content ?? ""
42+
Content = content ?? "",
43+
ShowClose = showClose
4244
});
4345

4446
/// <summary>
4547
/// Toast 调用提示信息快捷方法
4648
/// </summary>
4749
/// <param name="service"></param>
48-
/// <param name="title"></param>
49-
/// <param name="content"></param>
50-
/// <param name="autoHide"></param>
51-
/// <returns></returns>
52-
public static Task Information(this ToastService service, string? title = null, string? content = null, bool autoHide = true) => service.Show(new ToastOption()
50+
/// <param name="title">Title 属性</param>
51+
/// <param name="content">Content 属性</param>
52+
/// <param name="autoHide">自动隐藏属性默认为 true</param>
53+
/// <param name="showClose">是否显示关闭按钮 默认 true</param>
54+
public static Task Information(this ToastService service, string? title = null, string? content = null, bool autoHide = true, bool showClose = true) => service.Show(new ToastOption()
5355
{
5456
Category = ToastCategory.Information,
5557
IsAutoHide = autoHide,
5658
Title = title ?? "",
57-
Content = content ?? ""
59+
Content = content ?? "",
60+
ShowClose = showClose
5861
});
5962

6063
/// <summary>
6164
/// Toast 调用警告信息快捷方法
6265
/// </summary>
6366
/// <param name="service"></param>
64-
/// <param name="title"></param>
65-
/// <param name="content"></param>
66-
/// <param name="autoHide"></param>
67-
/// <returns></returns>
68-
public static Task Warning(this ToastService service, string? title = null, string? content = null, bool autoHide = true) => service.Show(new ToastOption()
67+
/// <param name="title">Title 属性</param>
68+
/// <param name="content">Content 属性</param>
69+
/// <param name="autoHide">自动隐藏属性默认为 true</param>
70+
/// <param name="showClose">是否显示关闭按钮 默认 true</param>
71+
public static Task Warning(this ToastService service, string? title = null, string? content = null, bool autoHide = true, bool showClose = true) => service.Show(new ToastOption()
6972
{
7073
Category = ToastCategory.Warning,
7174
IsAutoHide = autoHide,
7275
Title = title ?? "",
73-
Content = content ?? ""
76+
Content = content ?? "",
77+
ShowClose = showClose
7478
});
7579
}

0 commit comments

Comments
 (0)