Skip to content

Commit 161471a

Browse files
committed
refactor: 更改 FirstRender 参数值逻辑
1 parent c095c99 commit 161471a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public partial class DockViewV2 : IDisposable
172172
[NotNull]
173173
private DockViewOptions? _options = null;
174174
private ConcurrentDictionary<string, DockViewComponentState> _componentStates = new();
175+
private bool _firstLoad = true;
175176

176177
/// <summary>
177178
/// <inheritdoc/>
@@ -203,9 +204,9 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
203204
/// <summary>
204205
/// <inheritdoc />
205206
/// </summary>
206-
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, GetOptions(true));
207+
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, GetOptions());
207208

208-
private DockViewConfig GetOptions(bool firstRender = false) => new()
209+
private DockViewConfig GetOptions() => new()
209210
{
210211
EnableLocalStorage = EnableLocalStorage ?? _options.EnableLocalStorage ?? false,
211212
LocalStorageKey = $"{GetPrefixKey()}-{Name}-{GetVersion()}",
@@ -225,7 +226,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
225226
SplitterCallback = nameof(SplitterCallbackAsync),
226227
Contents = _components,
227228
LoadTabs = nameof(LoadTabs),
228-
FirstRender = firstRender
229+
FirstRender = _firstLoad
229230
};
230231

231232
private string GetVersion() => Version ?? _options.Version ?? "v1";
@@ -265,6 +266,7 @@ private Task OnThemeChangedAsync(string themeName)
265266
[JSInvokable]
266267
public async Task InitializedCallbackAsync()
267268
{
269+
_firstLoad = false;
268270
if (OnInitializedCallbackAsync != null)
269271
{
270272
await OnInitializedCallbackAsync();

0 commit comments

Comments
 (0)