Skip to content

Commit db9568f

Browse files
committed
feat: 增加 Show 泛型扩展方法
1 parent 384fd9d commit db9568f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ namespace BootstrapBlazor.Components;
1212
/// </summary>
1313
public static class DialogServiceExtensions
1414
{
15+
/// <summary>
16+
/// 弹出带结果的对话框
17+
/// </summary>
18+
/// <param name="service">DialogService 服务实例</param>
19+
/// <param name="title">对话框标题,优先级高于 <see cref="DialogOption.Title"/></param>
20+
/// <param name="parameters">TCom 组件所需要的参数集合</param>
21+
/// <param name="dialog">指定弹窗组件 默认为 null 使用 <see cref="BootstrapBlazorRoot"/> 组件内置弹窗组件</param>
22+
public static Task Show<TComponent>(this DialogService service, string title, IDictionary<string, object?>? parameters = null, Dialog? dialog = null) where TComponent : IComponent
23+
{
24+
var option = new DialogOption();
25+
if (!string.IsNullOrEmpty(title))
26+
{
27+
option.Title = title;
28+
}
29+
option.ShowFooter = false;
30+
option.Component = BootstrapDynamicComponent.CreateComponent<TComponent>(parameters);
31+
return service.Show(option, dialog);
32+
}
33+
1534
/// <summary>
1635
/// 弹出搜索对话框
1736
/// </summary>

0 commit comments

Comments
 (0)