Skip to content

Commit 6666447

Browse files
committed
refactor: 精简代码
1 parent 5ffc2ca commit 6666447

2 files changed

Lines changed: 7 additions & 29 deletions

File tree

src/components/BootstrapBlazor.DockView/Converters/DockViewComponentConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override void Write(Utf8JsonWriter writer, List<DockViewComponentBase> va
4242
}
4343
else if (item is DockViewComponent contentItem)
4444
{
45-
writer.WriteRawValue(JsonSerializer.Serialize(contentItem.GetState(), options));
45+
writer.WriteRawValue(JsonSerializer.Serialize(contentItem, options));
4646
}
4747
}
4848
writer.WriteEndArray();

src/components/BootstrapBlazor.DockView/Extensions/DockViewComponentStateExtensions.cs

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,20 @@ static class DockViewComponentStateExtensions
88
{
99
extension(DockViewComponentState? state)
1010
{
11+
/// <summary>
12+
/// <para lang="zh">判断组件是否需要渲染</para>
13+
/// <para lang="en">Determine whether the component needs to be rendered</para>
14+
/// </summary>
1115
public bool IsRender()
1216
{
17+
// 如果组件 Visible false 表示组件不可见,此时 Render 也不需要渲染
1318
var render = false;
1419
if (state != null)
1520
{
21+
// 组件必须可见并且 Active 时才需要渲染
1622
render = state.Render && state.Visible;
1723
}
1824
return render;
1925
}
20-
21-
public object? GetComponentState(DockViewComponent component)
22-
{
23-
if (state == null)
24-
{
25-
return null;
26-
}
27-
28-
return new
29-
{
30-
component.Class,
31-
component.Height,
32-
component.Id,
33-
component.IsFloating,
34-
IsLock = state.IsLock,
35-
component.Key,
36-
component.ShowClose,
37-
component.ShowFloat,
38-
component.ShowLock,
39-
component.ShowMaximize,
40-
component.Title,
41-
component.TitleClass,
42-
component.TitleWidth,
43-
component.Type,
44-
Visible = state.Visible,
45-
component.Width
46-
};
47-
}
4826
}
4927
}

0 commit comments

Comments
 (0)