Skip to content

Commit 0c234b2

Browse files
committed
refactor: 更改变量可见性
1 parent a71f49a commit 0c234b2

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/BootstrapBlazor/Components/Table/Table.razor.Edit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ protected async Task QueryData(bool triggerByPagination = false)
484484
else
485485
{
486486
ResetSelectedRows(Items);
487-
RowsCache = null;
487+
_rowsCache = null;
488488
}
489489
return;
490490

@@ -513,7 +513,7 @@ async Task OnQuery(QueryPageOptions queryOption)
513513
}
514514

515515
// 更新数据后清除缓存防止新数据不显示
516-
RowsCache = null;
516+
_rowsCache = null;
517517
return;
518518

519519
void ProcessData()

src/BootstrapBlazor/Components/Table/Table.razor.Toolbar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ protected async Task<bool> SaveModelAsync(EditContext context, ItemChangedType c
648648
if (DynamicContext != null)
649649
{
650650
await DynamicContext.SetValue(context.Model);
651-
RowsCache = null;
651+
_rowsCache = null;
652652
valid = true;
653653
}
654654
else
@@ -1095,7 +1095,7 @@ private void ResetDynamicContext()
10951095

10961096
private void QueryDynamicItems(QueryPageOptions queryOption, IDynamicObjectContext? context)
10971097
{
1098-
RowsCache = null;
1098+
_rowsCache = null;
10991099
if (context != null)
11001100
{
11011101
var items = context.GetItems();

src/BootstrapBlazor/Components/Table/Table.razor.TreeNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected Func<Task> ToggleTreeRow(TItem item) => async () =>
107107
IsLoadChildren = false;
108108

109109
// 清除缓存
110-
RowsCache = null;
110+
_rowsCache = null;
111111

112112
// 更新 UI
113113
StateHasChanged();

src/BootstrapBlazor/Components/Table/Table.razor.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ protected override void OnParametersSet()
928928
IsPagination = false;
929929
}
930930

931-
RowsCache = null;
931+
_rowsCache = null;
932932

933933
if (IsExcel)
934934
{
@@ -1266,21 +1266,17 @@ protected async Task LoopQueryAsync()
12661266
/// </summary>
12671267
private IEnumerable<TItem> QueryItems { get; set; } = [];
12681268

1269-
[NotNull]
1270-
private List<TItem>? RowsCache { get; set; }
1269+
private List<TItem>? _rowsCache;
12711270

12721271
/// <summary>
12731272
/// 获得 当前表格所有 Rows 集合
12741273
/// </summary>
1275-
public List<TItem> Rows
1274+
private List<TItem> Rows
12761275
{
12771276
get
12781277
{
1279-
// https://gitee.com/LongbowEnterprise/BootstrapBlazor/issues/I5JG5D
1280-
// 如果 QueryItems 无默认值
1281-
// 页面 OnInitializedAsync 二刷再 OnAfterRender 过程中导致 QueryItems 变量为空 ToList 报错
1282-
RowsCache ??= IsTree ? TreeRows.GetAllItems() : [.. (Items ?? QueryItems)];
1283-
return RowsCache;
1278+
_rowsCache ??= IsTree ? TreeRows.GetAllItems() : [.. (Items ?? QueryItems)];
1279+
return _rowsCache;
12841280
}
12851281
}
12861282

0 commit comments

Comments
 (0)