Skip to content

Commit 7327b8b

Browse files
committed
refactor: 增加 IsFade 参数支持
1 parent 038c79d commit 7327b8b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/BootstrapBlazor/Components/Dialog/Dialog.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@namespace BootstrapBlazor.Components
22
@inherits BootstrapComponentBase
33

4-
<Modal @ref="ModalContainer" IsBackdrop="IsBackdrop" IsKeyboard="@IsKeyboard" OnShownAsync="@OnShownAsync" OnCloseAsync="OnCloseAsync">
4+
<Modal @ref="ModalContainer" IsBackdrop="_isBackdrop" IsKeyboard="@_isKeyboard" IsFade="@_isFade"
5+
OnShownAsync="@OnShownAsync" OnCloseAsync="OnCloseAsync">
56
@for (var index = 0; index < DialogParameters.Keys.Count; index++)
67
{
78
@RenderDialog(index, DialogParameters.Keys.ElementAt(index))

src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ public partial class Dialog : IDisposable
2121
/// </summary>
2222
private Dictionary<Dictionary<string, object>, (bool IsKeyboard, bool IsBackdrop)> DialogParameters { get; } = [];
2323

24-
private bool IsKeyboard { get; set; }
24+
private bool _isKeyboard = false;
2525

26-
private bool IsBackdrop { get; set; }
26+
private bool _isBackdrop = false;
27+
28+
private bool _isFade = true;
2729

2830
/// <summary>
2931
/// DialogServices 服务实例
@@ -92,15 +94,16 @@ private async Task Show(DialogOption option)
9294
// 多弹窗支持
9395
var p = DialogParameters.LastOrDefault();
9496
CurrentParameter = p.Key;
95-
IsKeyboard = p.Value.IsKeyboard;
96-
IsBackdrop = p.Value.IsBackdrop;
97+
_isKeyboard = p.Value.IsKeyboard;
98+
_isBackdrop = p.Value.IsBackdrop;
9799

98100
StateHasChanged();
99101
}
100102
};
101103

102-
IsKeyboard = option.IsKeyboard;
103-
IsBackdrop = option.IsBackdrop;
104+
_isKeyboard = option.IsKeyboard;
105+
_isBackdrop = option.IsBackdrop;
106+
_isFade = option.IsFade;
104107

105108
option.Modal = ModalContainer;
106109

@@ -167,7 +170,7 @@ private async Task Show(DialogOption option)
167170
CurrentParameter = parameters;
168171

169172
// 添加 ModalDialog 到容器中
170-
DialogParameters.Add(parameters, (IsKeyboard, IsBackdrop));
173+
DialogParameters.Add(parameters, (_isKeyboard, _isBackdrop));
171174
await InvokeAsync(StateHasChanged);
172175
}
173176

0 commit comments

Comments
 (0)