From 103f8531751a689646ec518e792749d02e588361 Mon Sep 17 00:00:00 2001 From: zhaijunlei <276318515@qq.com> Date: Mon, 30 Jun 2025 11:17:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Ddockview=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=9A=90=E8=97=8F=E7=9A=84=E7=AA=97=E5=8F=A3=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=97=B6=E4=BD=8D=E7=BD=AE=E5=92=8C=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/js/dockview-config.js | 27 ++++++++++--------- .../wwwroot/js/dockview-group.js | 2 +- .../wwwroot/js/dockview-utils.js | 6 ++++- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js index 88b27585..a4bd202b 100644 --- a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js +++ b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js @@ -55,7 +55,8 @@ const renewConfigFromOptions = (config, options) => { if (panel) { optionPanel.params = { ...panel.params, - ...optionPanel.params + ...optionPanel.params, + visible: panel.params.visible } config.panels[panel.id] = optionPanel } @@ -232,6 +233,10 @@ const getTree = (contentItem, { width, height, orientation }, parent, panels, ge if (contentItem.type === 'row' || contentItem.type === 'column') { obj.type = 'branch'; obj.size = getSize(boxSize, contentItem.width || contentItem.height) || size + if(contentItem.content.length == 0 || contentItem.content.every(item => !item.visible)){ + obj.size = 0 + } + obj.data = contentItem.content.map(item => getTree(item, { width, height, orientation }, contentItem, panels, getGroupId, options)) } else if (contentItem.type === 'group') { @@ -279,24 +284,22 @@ const getLeafNode = (contentItem, size, boxSize, parent, panels, getGroupId, opt const visible = contentItem.visible !== false; const data = { type: 'leaf', - visible, + visible: true, size: getSize(boxSize, contentItem.width || contentItem.height) || size, data: { id: getGroupId(), activeView: contentItem.id, hideHeader: contentItem.showHeader === false, - views: visible ? [contentItem.id] : [] + views: [contentItem.id] } }; - if (visible) { - panels[contentItem.id] = { - id: contentItem.id, - title: contentItem.title, - renderer: contentItem.renderer || options.renderer, - tabComponent: contentItem.componentName, - contentComponent: contentItem.componentName, - params: { ...contentItem, parentId: parent.id } - } + panels[contentItem.id] = { + id: contentItem.id, + title: contentItem.title, + renderer: contentItem.renderer || options.renderer, + tabComponent: contentItem.componentName, + contentComponent: contentItem.componentName, + params: { ...contentItem, parentId: parent.id } } return data; } diff --git a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js index da3689a0..6c95ed4d 100644 --- a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js +++ b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js @@ -97,7 +97,7 @@ const addPanelWidthGroupId = (dockview, panel, index) => { renderer: panel.renderer, component: panel.component, position: { referenceGroup: group, index: index || 0 }, - params: { ...panel.params, rect, packup } + params: { ...panel.params, rect, packup, visible: true } }) dockview._panelVisibleChanged?.fire({ title: panel.title, status: true }); } diff --git a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js index 2568a408..edead338 100644 --- a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js +++ b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js @@ -91,7 +91,11 @@ const initDockview = (dockview, options, template) => { const delPanelsStr = localStorage.getItem(dockview.params.options.localStorageKey + '-panels') const delPanels = delPanelsStr && JSON.parse(delPanelsStr) || [] panels.forEach(panel => { - dockview._panelVisibleChanged?.fire({ title: panel.title, status: true }); + const visible = panel.params.visible + if(!visible){ + dockview.removePanel(panel) + } + dockview._panelVisibleChanged?.fire({ title: panel.title, status: visible }); }) delPanels.forEach(panel => { dockview._panelVisibleChanged?.fire({ title: panel.title, status: false }); From 2077f8d9c14c96db3f722716d6cfc2b80aa25920 Mon Sep 17 00:00:00 2001 From: zhaijunlei <276318515@qq.com> Date: Mon, 30 Jun 2025 13:51:17 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0EmptyContent?= =?UTF-8?q?=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/js/dockview-config.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js index a4bd202b..714c5303 100644 --- a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js +++ b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-config.js @@ -198,6 +198,7 @@ const removePanel = (branch, panel, parent) => { const getConfigFromContent = options => { const { width, height } = { width: 800, height: 600 }; const getGroupId = getGroupIdFunc() + options = filterEmptyContent(options) const panels = {}, rootType = options.content[0].type const orientation = rootType === 'column' ? 'VERTICAL' : 'HORIZONTAL'; const root = getTree(options.content[0], { width, height, orientation }, options, panels, getGroupId, options) @@ -212,7 +213,17 @@ const getGroupIdFunc = () => { let currentId = 0; return () => `${currentId++}`; } - +const filterEmptyContent = function(data) { + if (!data || typeof data !== 'object') return data; + + if (Array.isArray(data.content)) { + data.content = data.content + .map(item => filterEmptyContent(item)) + .filter(item => !(Array.isArray(item.content) && item.content.length === 0)); + } + + return data; +} const getTree = (contentItem, { width, height, orientation }, parent, panels, getGroupId, options) => { const length = parent.content.length; const boxSize = orientation === 'HORIZONTAL' ? width : height; @@ -233,10 +244,6 @@ const getTree = (contentItem, { width, height, orientation }, parent, panels, ge if (contentItem.type === 'row' || contentItem.type === 'column') { obj.type = 'branch'; obj.size = getSize(boxSize, contentItem.width || contentItem.height) || size - if(contentItem.content.length == 0 || contentItem.content.every(item => !item.visible)){ - obj.size = 0 - } - obj.data = contentItem.content.map(item => getTree(item, { width, height, orientation }, contentItem, panels, getGroupId, options)) } else if (contentItem.type === 'group') { From eac7515c71630bf8fb22b00bad78ddb4b7ca25ba Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 30 Jun 2025 14:59:36 +0800 Subject: [PATCH 3/4] chore: bump version 9.1.15 --- .../BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj b/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj index fa2c8aa5..89d7223d 100644 --- a/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj +++ b/src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj @@ -1,7 +1,7 @@  - 9.1.14 + 9.1.15 From 86c559e0821c3811e47a6df76850b3eb2c3c2206 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 30 Jun 2025 15:17:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js index edead338..3bafb2f5 100644 --- a/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js +++ b/src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js @@ -92,7 +92,7 @@ const initDockview = (dockview, options, template) => { const delPanels = delPanelsStr && JSON.parse(delPanelsStr) || [] panels.forEach(panel => { const visible = panel.params.visible - if(!visible){ + if (!visible) { dockview.removePanel(panel) } dockview._panelVisibleChanged?.fire({ title: panel.title, status: visible });