diff --git a/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj b/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj index 10bdaeff..6951692f 100644 --- a/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj +++ b/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj @@ -1,7 +1,7 @@  - 10.0.5 + 10.0.6 diff --git a/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.cs b/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.cs deleted file mode 100644 index 6df36f40..00000000 --- a/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.cs +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Rendering; -using System.Text.Json.Serialization; - -namespace BootstrapBlazor.Components; - -/// -/// DockContentItem 配置项子项对标 content 配置项内部 content 配置 -/// DockContentItem configuration item sub-item corresponds to the content configuration item inside the content configuration item -/// -public class DockViewComponent : DockViewComponentBase -{ - /// - /// 获得/设置 组件是否显示 Header 默认 true 显示 - /// Gets or sets whether the component header is displayed. Default is true. - /// - [Parameter] - public bool ShowHeader { get; set; } = true; - - /// - /// 获得/设置 组件 Title - /// Gets or sets the component title. - /// - [Parameter] - public string? Title { get; set; } - - /// - /// 获得/设置 组件 Title 宽度 默认 null 未设置 - /// Gets or sets the component title width. Default is null (not set). - /// - [Parameter] - public int? TitleWidth { get; set; } - - /// - /// 获得/设置 组件 Title 样式 默认 null 未设置 - /// Gets or sets the component title style. Default is null (not set). - /// - [Parameter] - public string? TitleClass { get; set; } - - /// - /// 获得/设置 Title 模板 默认 null 未设置 - /// Gets or sets the title template. Default is null (not set). - /// - [Parameter] - [JsonIgnore] - public RenderFragment? TitleTemplate { get; set; } - - /// - /// 获得/设置 组件 Class 默认 null 未设置 - /// Gets or sets the component class. Default is null (not set). - /// - [Parameter] - public string? Class { get; set; } - - /// - /// 获得/设置 组件是否可见 默认 true 可见 - /// Gets or sets whether the component is visible. Default is true. - /// - [Parameter] - public bool Visible { get; set; } = true; - - /// - /// 获得/设置 组件是否允许关闭 默认 null 使用 DockView 的配置 - /// Gets or sets whether the component is allowed to be closed. Default is null (uses DockView configuration). - /// - [Parameter] - public bool? ShowClose { get; set; } - - /// - /// 获得/设置 组件唯一标识值 默认 null 未设置时取 Title 作为唯一标识 - /// Gets or sets the unique identifier for the component. Default is null, uses Title as the identifier if not set. - /// - [Parameter] - public string? Key { get; set; } - - /// - /// 获得/设置 是否锁定 默认 null 未设置时取 DockView 的配置 - /// Gets or sets whether the component is locked. Default is null (uses DockView configuration). - /// - /// 锁定后无法拖动 - [Parameter] - public bool? IsLock { get; set; } - - /// - /// 获得/设置 是否显示锁定按钮 默认 null 未设置时取 DockView 的配置 - /// Gets or sets whether the lock button is displayed. Default is null (uses DockView configuration). - /// - [Parameter] - public bool? ShowLock { get; set; } - - /// - /// 获得/设置 是否悬浮 默认 null 未设置时取 DockView 的配置 - /// Gets or sets whether the component is floating. Default is null (uses DockView configuration). - /// - [Parameter] - public bool? IsFloating { get; set; } - - /// - /// 获得/设置 是否显示可悬浮按钮 默认 null 未设置时取 DockView 的配置 - /// Gets or sets whether the float button is displayed. Default is null (uses DockView configuration). - /// - [Parameter] - public bool? ShowFloat { get; set; } - - /// - /// 获得/设置 是否显示最大化按钮 默认 null 未设置时取 DockView 的配置 - /// Gets or sets whether the maximize button is displayed. Default is null (uses DockView configuration). - /// - [Parameter] - public bool? ShowMaximize { get; set; } - - /// - /// 获得/设置 是否一直显示 默认 null 未设置时取 DockView 的配置 - /// Gets or sets whether the component is always displayed. Default is null (uses DockView configuration). - /// - [Parameter] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string? Renderer { get; set; } - - /// - /// 获得/设置 是否显示标题前置图标 默认 false 不显示 - /// Gets or sets whether the title bar icon is displayed. Default is false. - /// - [Parameter] - [JsonIgnore] - public bool ShowTitleBar { get; set; } - - /// - /// 获得/设置 标题前置图标 默认 null 未设置使用默认图标 - /// Gets or sets the title bar icon. Default is null, uses the default icon if not set. - /// - [Parameter] - [JsonIgnore] - public string? TitleBarIcon { get; set; } - - /// - /// 获得/设置 标题前置图标 Url 默认 null 未设置使用默认图标 - /// Gets or sets the title bar icon URL. Default is null, uses the default icon if not set. - /// - [Parameter] - [JsonIgnore] - public string? TitleBarIconUrl { get; set; } - - /// - /// 获得/设置 标题前置图标点击回调方法 默认 null - /// Gets or sets the callback method for clicking the title bar icon. Default is null. - /// - [Parameter] - [JsonIgnore] - public Func? OnClickTitleBarCallback { get; set; } - - [CascadingParameter] - [NotNull] - private DockViewV2? DockView { get; set; } - - /// - /// - /// - protected override void OnInitialized() - { - base.OnInitialized(); - - Type = DockViewContentType.Component; - } - - /// - /// - /// - /// - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(10, "id", Id); - builder.AddAttribute(20, "class", "bb-dockview-panel"); - builder.AddAttribute(30, "data-bb-key", Key); - builder.AddAttribute(40, "data-bb-title", Title); - - if (TitleTemplate != null) - { - builder.OpenElement(50, "div"); - builder.AddAttribute(51, "class", "bb-dockview-item-title"); - builder.AddContent(53, TitleTemplate); - builder.CloseElement(); - } - else if (ShowTitleBar) - { - builder.OpenComponent(60); - builder.AddAttribute(61, nameof(DockViewTitleBar.BarIcon), TitleBarIcon); - builder.AddAttribute(62, nameof(DockViewTitleBar.BarIconUrl), TitleBarIconUrl); - builder.AddAttribute(63, nameof(DockViewTitleBar.OnClickBarCallback), OnClickBar); - builder.CloseComponent(); - } - - if (DockView.ShowTab(Key)) - { - builder.AddContent(70, ChildContent); - } - builder.CloseElement(); - } - - private async Task OnClickBar() - { - if (OnClickTitleBarCallback != null) - { - await OnClickTitleBarCallback(); - } - } - - /// - /// 设置 Visible 参数方法 - /// Sets the Visible parameter. - /// - /// - public void SetVisible(bool visible) - { - Visible = visible; - } -} diff --git a/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor b/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor new file mode 100644 index 00000000..c6500815 --- /dev/null +++ b/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor @@ -0,0 +1,18 @@ +@inherits DockViewComponentBase + +
+ @if (TitleTemplate != null) + { +
+ @TitleTemplate +
+ } + else if (ShowTitleBar) + { + + } + @if (Visible) + { + @ChildContent + } +
diff --git a/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor.cs b/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor.cs new file mode 100644 index 00000000..bfc7563a --- /dev/null +++ b/src/components/BootstrapBlazor.DockView/Components/DockViewComponent.razor.cs @@ -0,0 +1,162 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +using Microsoft.AspNetCore.Components; +using System.Text.Json.Serialization; + +namespace BootstrapBlazor.Components; + +/// +/// DockContentItem 配置项子项对标 content 配置项内部 content 配置 +/// +public partial class DockViewComponent +{ + /// + /// 获得/设置 组件是否显示 Header 默认 true 显示 + /// + [Parameter] + public bool ShowHeader { get; set; } = true; + + /// + /// 获得/设置 组件 Title + /// + [Parameter] + public string? Title { get; set; } + + /// + /// 获得/设置 组件 Title 宽度 默认 null 未设置 + /// + [Parameter] + public int? TitleWidth { get; set; } + + /// + /// 获得/设置 组件 Title 样式 默认 null 未设置 + /// + [Parameter] + public string? TitleClass { get; set; } + + /// + /// 获得/设置 Title 模板 默认 null 未设置 + /// + [Parameter] + [JsonIgnore] + public RenderFragment? TitleTemplate { get; set; } + + /// + /// 获得/设置 组件 Class 默认 null 未设置 + /// + [Parameter] + public string? Class { get; set; } + + /// + /// 获得/设置 组件是否可见 默认 true 可见 + /// + [Parameter] + public bool Visible { get; set; } = true; + + /// + /// 获得/设置 组件是否允许关闭 默认 null 使用 DockView 的配置 + /// + [Parameter] + public bool? ShowClose { get; set; } + + /// + /// 获得/设置 组件唯一标识值 默认 null 未设置时取 Title 作为唯一标识 + /// + [Parameter] + public string? Key { get; set; } + + /// + /// 获得/设置 是否锁定 默认 null 未设置时取 DockView 的配置 + /// + /// 锁定后无法拖动 + [Parameter] + public bool? IsLock { get; set; } + + /// + /// 获得/设置 是否显示锁定按钮 默认 null 未设置时取 DockView 的配置 + /// + [Parameter] + public bool? ShowLock { get; set; } + + /// + /// 获得/设置 是否悬浮 默认 null 未设置时取 DockView 的配置 + /// + [Parameter] + public bool? IsFloating { get; set; } + + /// + /// 获得/设置 是否显示可悬浮按钮 默认 null 未设置时取 DockView 的配置 + /// + [Parameter] + public bool? ShowFloat { get; set; } + + /// + /// 获得/设置 是否显示最大化按钮 默认 null 未设置时取 DockView 的配置 + /// + [Parameter] + public bool? ShowMaximize { get; set; } + + /// + /// 获得/设置 是否一直显示 默认 null 未设置时取 DockView 的配置 + /// + [Parameter] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? Renderer { get; set; } + + /// + /// 获得/设置 是否显示标题前置图标 默认 false 不显示 + /// + [Parameter] + [JsonIgnore] + public bool ShowTitleBar { get; set; } + + /// + /// 获得/设置 标题前置图标 默认 null 未设置使用默认图标 + /// + [Parameter] + [JsonIgnore] + public string? TitleBarIcon { get; set; } + + /// + /// 获得/设置 标题前置图标 Url 默认 null 未设置使用默认图标 + /// + [Parameter] + [JsonIgnore] + public string? TitleBarIconUrl { get; set; } + + /// + /// 获得/设置 标题前置图标点击回调方法 默认 null + /// + [Parameter] + [JsonIgnore] + public Func? OnClickTitleBarCallback { get; set; } + + /// + /// + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Type = DockViewContentType.Component; + } + + private async Task OnClickBar() + { + if (OnClickTitleBarCallback != null) + { + await OnClickTitleBarCallback(); + } + } + + /// + /// 设置 Visible 参数方法 + /// + /// + public void SetVisible(bool visible) + { + Visible = visible; + } +} diff --git a/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.cs b/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.cs index abbb5afd..6130b6e0 100644 --- a/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.cs +++ b/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.cs @@ -310,6 +310,7 @@ public Task LoadTabs(List tabs) /// public bool ShowTab(string? key) { + // TODO: Partial 模式下使用临时回滚稍后完善 if (Renderer == DockViewRenderMode.Always) { return true; diff --git a/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.js b/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.js index eed527ae..e6d04dab 100644 --- a/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.js +++ b/src/components/BootstrapBlazor.DockView/Components/DockViewV2.razor.js @@ -33,7 +33,7 @@ export async function init(id, invoke, options) { invoke.invokeMethodAsync(options.splitterCallback); }); dockview.on('loadTabs', tabs => { - invoke.invokeMethodAsync(options.loadTabs, tabs); + }); EventHandler.on(document, 'changed.bb.theme', updateTheme);