From 91c47ebb7c553e889740c27318383f157e2a1770 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Apr 2026 14:45:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseComponents/BootstrapModuleComponentBase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs b/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs index fc5b4a2c8f4..e949eb39f62 100644 --- a/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs +++ b/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs @@ -8,8 +8,8 @@ namespace BootstrapBlazor.Components; /// -/// Bootstrap Blazor JavaScript 隔离基类 -/// Bootstrap blazor JavaScript isolation base class +/// BootstrapBlazor JavaScript 隔离基类 +/// BootstrapBlazor JavaScript isolation base class /// public abstract class BootstrapModuleComponentBase : IdComponentBase, IAsyncDisposable { @@ -198,7 +198,7 @@ protected async Task InvokeVoidAsync(string identifier, CancellationToken cancel } /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously + /// 异步释放资源 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously /// /// From 0ae6ffc8f1b3f2216e23ae9c5fe2ec66ba799fd2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 19 Apr 2026 14:46:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(DynamicElement):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=A7=94=E6=89=98=E9=94=80=E6=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseComponents/DynamicElement.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/BaseComponents/DynamicElement.cs b/src/BootstrapBlazor/Components/BaseComponents/DynamicElement.cs index 385c6581832..9418053363c 100644 --- a/src/BootstrapBlazor/Components/BaseComponents/DynamicElement.cs +++ b/src/BootstrapBlazor/Components/BaseComponents/DynamicElement.cs @@ -12,7 +12,7 @@ namespace BootstrapBlazor.Components; /// 动态元素组件 /// Dynamic element component /// -public class DynamicElement : BootstrapComponentBase +public class DynamicElement : BootstrapComponentBase, IAsyncDisposable { /// /// 获得/设置 TagName 属性 默认为 div @@ -176,4 +176,29 @@ private async Task OnTriggerContextMenu(MouseEventArgs e) await OnContextMenu(e); } } + + /// + /// 异步释放资源 + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously + /// + /// + protected virtual async ValueTask DisposeAsync(bool disposing) + { + if (disposing) + { + OnClick = null; + OnDoubleClick = null; + OnContextMenu = null; + ChildContent = null; + } + } + + /// + /// + /// + public async ValueTask DisposeAsync() + { + await DisposeAsync(true); + GC.SuppressFinalize(this); + } }