From e5203a27ecb11ae7bf03452f18afdb067669b2f2 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Thu, 12 Dec 2024 14:32:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?doc:=20=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Extensions/JSModuleExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Extensions/JSModuleExtensions.cs b/src/BootstrapBlazor/Extensions/JSModuleExtensions.cs index 083de5700f7..967356dc7b0 100644 --- a/src/BootstrapBlazor/Extensions/JSModuleExtensions.cs +++ b/src/BootstrapBlazor/Extensions/JSModuleExtensions.cs @@ -31,8 +31,8 @@ public static async Task LoadModule(this IJSRuntime jsRuntime, string fileName = $"{fileName}?v={version}"; } - var jSObjectReference = await jsRuntime.InvokeAsync(identifier: "import", fileName); - return new JSModule(jSObjectReference); + var jSObjectReference = await jsRuntime.InvokeAsync(identifier: "import", fileName); + return new JSModule(jSObjectReference); } /// From e59440e8a49dfcc3a2e1fa57af7854d786999b4a Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Thu, 12 Dec 2024 14:42:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E9=AB=98=20Items=20=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/TreeView/TreeView.razor.cs | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs index b3c4ec90b64..258e0edc55f 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs +++ b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs @@ -822,35 +822,37 @@ private void OnTouchEnd() TouchStart = false; } - private List> Rows => GetTreeRows(Items); - private List>? _rows = null; -#if NET9_0_OR_GREATER - private readonly Lock _object = new(); -#else - private readonly object _object = new(); -#endif + private List> Rows + { + get + { + _rows ??= GetTreeRows(Items); + return _rows; + } + } - private List> GetTreeRows(List> items) + /// + /// 将带层次结构的数据转换为扁平化数据 + /// + /// + /// + private static List> GetTreeRows(List> items) { - lock (_object) + var rows = new List>(); + if (items != null) { - var rows = new List>(); - if (items != null) + foreach (var item in items) { - foreach (var item in items) + rows.Add(item); + if (item.IsExpand) { - rows.Add(item); - if (item.IsExpand) - { - rows.AddRange(GetTreeRows(item.Items)); - } + rows.AddRange(GetTreeRows(item.Items)); } } - _rows ??= rows; - return rows; } + return rows; } private static string? GetTreeRowStyle(TreeViewItem item) From f1f33683e4d60ee3c459a1f9dd389328862edc26 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Thu, 12 Dec 2024 15:29:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20Reset=20=E6=B8=85=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs index 258e0edc55f..6fd7f2c6a03 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs +++ b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs @@ -351,6 +351,7 @@ protected override async Task OnParametersSetAsync() { if (IsReset) { + _rows = null; TreeNodeStateCache.Reset(); } else