diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 000badf35420b5d8d273b54a1bd3a789c160deba..283f80fbb2d5d234a7d5d09d12aa424f25db1885 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.10.8 + 6.10.9 diff --git a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs index 52446a971795532c469a897444ed50bd1e2b0e39..9f449d617f6f3d521eee348c4be7cbb0ba14639f 100644 --- a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs +++ b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs @@ -319,10 +319,7 @@ public partial class AutoComplete { if (disposing) { - if (Interop != null) - { - Interop.Dispose(); - } + Interop?.Dispose(); } return base.DisposeAsyncCore(disposing); diff --git a/src/BootstrapBlazor/Components/Button/Button.razor.cs b/src/BootstrapBlazor/Components/Button/Button.razor.cs index 3f855a2e5014fdfae4be5d78e4d5b8a7bc37e9c7..2faa488c5e4bbf832c2dfed1e71360034a8f1fd5 100644 --- a/src/BootstrapBlazor/Components/Button/Button.razor.cs +++ b/src/BootstrapBlazor/Components/Button/Button.razor.cs @@ -22,12 +22,6 @@ public partial class Button /// protected EventCallback OnClickButton { get; set; } - /// - /// 获得 ValidateForm 实例 - /// - [CascadingParameter] - protected ValidateForm? ValidateForm { get; set; } - /// /// 获得/设置 html button 实例 /// @@ -66,12 +60,6 @@ public partial class Button IsAsyncLoading = false; } }); - - if (IsAsync && ValidateForm != null) - { - // 开启异步操作时与 ValidateForm 联动 - ValidateForm.RegisterAsyncSubmitButton(this); - } } /// @@ -117,15 +105,4 @@ public partial class Button await OnClick.InvokeAsync(); } } - - /// - /// 触发按钮异步操作方法 - /// - /// true 时显示正在操作 false 时表示结束 - internal void TriggerAsync(bool loading) - { - IsAsyncLoading = loading; - ButtonIcon = loading ? LoadingIcon : Icon; - SetDisable(loading); - } } diff --git a/src/BootstrapBlazor/Components/Button/ButtonBase.cs b/src/BootstrapBlazor/Components/Button/ButtonBase.cs index 9282bfcdaf5e91ea30e33e3d4e1473f02c309187..572d8787d8b2c85660c5e5821f557e7d55f390b9 100644 --- a/src/BootstrapBlazor/Components/Button/ButtonBase.cs +++ b/src/BootstrapBlazor/Components/Button/ButtonBase.cs @@ -153,6 +153,12 @@ public abstract class ButtonBase : IdComponentBase, IAsyncDisposable [Parameter] public string TooltipTrigger { get; set; } = "hover focus"; + /// + /// 获得 ValidateForm 实例 + /// + [CascadingParameter] + protected ValidateForm? ValidateForm { get; set; } + /// /// 获得/设置 是否当前正在异步执行操作 /// @@ -166,6 +172,12 @@ public abstract class ButtonBase : IdComponentBase, IAsyncDisposable base.OnInitialized(); ButtonIcon = Icon; + + if (IsAsync && ValidateForm != null) + { + // 开启异步操作时与 ValidateForm 联动 + ValidateForm.RegisterAsyncSubmitButton(this); + } } /// @@ -223,6 +235,17 @@ public abstract class ButtonBase : IdComponentBase, IAsyncDisposable StateHasChanged(); } + /// + /// 触发按钮异步操作方法 + /// + /// true 时显示正在操作 false 时表示结束 + internal void TriggerAsync(bool loading) + { + IsAsyncLoading = loading; + ButtonIcon = loading ? LoadingIcon : Icon; + SetDisable(loading); + } + /// /// 显示 Tooltip 方法 /// diff --git a/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor b/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor index 127fbc1a1ba475e851095a4a15ddff7cc4705a21..6365a8f9174f4dbdd23168c9281eb3aaad580de9 100644 --- a/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor +++ b/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor @@ -4,9 +4,9 @@ - @if (!string.IsNullOrEmpty(Icon)) + @if (!string.IsNullOrEmpty(ButtonIcon)) { - + } @if (!string.IsNullOrEmpty(Text)) { diff --git a/src/BootstrapBlazor/Components/Timer/Timer.razor.cs b/src/BootstrapBlazor/Components/Timer/Timer.razor.cs index b12ad882c7fef4d1aa68110103b57f4525630313..56206c56c8c35e40953f3783f212f7042bd9ca0f 100644 --- a/src/BootstrapBlazor/Components/Timer/Timer.razor.cs +++ b/src/BootstrapBlazor/Components/Timer/Timer.razor.cs @@ -138,7 +138,7 @@ public partial class Timer : IDisposable if (Vibrate) { Vibrate = false; - await JSRuntime.InvokeVoidAsync("", "bb_vibrate"); + await JSRuntime.InvokeVoidAsync(identifier: "bb.Utility.vibrate"); } } @@ -184,13 +184,13 @@ public partial class Timer : IDisposable if (!CancelTokenSource.IsCancellationRequested) { Value = TimeSpan.Zero; - await InvokeAsync(() => + await InvokeAsync(async () => { Vibrate = IsVibrate; StateHasChanged(); if (OnTimeout != null) { - OnTimeout(); + await OnTimeout(); } }); } @@ -218,10 +218,7 @@ public partial class Timer : IDisposable private async Task OnClickCancel() { Value = TimeSpan.Zero; - if (CancelTokenSource != null) - { - CancelTokenSource.Cancel(); - } + CancelTokenSource?.Cancel(); if (OnCancel != null) { await OnCancel(); diff --git a/src/BootstrapBlazor/Components/Validate/ValidateBase.cs b/src/BootstrapBlazor/Components/Validate/ValidateBase.cs index 961d20f2bd9b2347bee767de0abb2a28abe9fdbd..14ce05df068d0536672310c5746c2ed79d56ba79 100644 --- a/src/BootstrapBlazor/Components/Validate/ValidateBase.cs +++ b/src/BootstrapBlazor/Components/Validate/ValidateBase.cs @@ -160,15 +160,23 @@ public abstract class ValidateBase : DisplayBase, IValidateCompo [NotNull] public string? ParsingErrorMessage { get; set; } - private string? _id; /// /// 获得/设置 当前组件 Id /// [Parameter] + [NotNull] public override string? Id { - get { return (ValidateForm != null && !string.IsNullOrEmpty(ValidateForm.Id) && FieldIdentifier != null) ? $"{ValidateForm.Id}_{FieldIdentifier.Value.Model.GetHashCode()}_{FieldIdentifier.Value.FieldName}" : _id; } - set { _id = value; } + get + { + return (!string.IsNullOrEmpty(ValidateForm?.Id) && FieldIdentifier != null) + ? $"{ValidateForm.Id}_{FieldIdentifier.Value.Model.GetHashCode()}_{FieldIdentifier.Value.FieldName}" + : base.Id; + } + set + { + base.Id = value; + } } /// diff --git a/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs b/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs index 227778b50b4ed136930a6602570a2270363043cd..8f0d77415460c1fd6828f0d823567e66d3a15f15 100644 --- a/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs +++ b/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs @@ -452,13 +452,13 @@ public partial class ValidateForm : IAsyncDisposable private bool _invalid = false; - private List