From dc3224e035ea3096f1e83675910bfdc15f4af013 Mon Sep 17 00:00:00 2001 From: limengnan <420004014@qq.com> Date: Mon, 7 Jul 2025 09:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=8E=92=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-visualization/RealTimeListTree.vue | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue b/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue index 34f501d..731ab3d 100644 --- a/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue +++ b/core/core-frontend/src/components/data-visualization/RealTimeListTree.vue @@ -105,6 +105,7 @@ const transformIndex = index => { return componentData.value.length - 1 - index } const areaDataPush = component => { + if ( component && !component.isLock && @@ -114,8 +115,30 @@ const areaDataPush = component => { !['GroupArea', 'DeTabs'].includes(component.component) ) { areaData.value.components.push(component) + + // 修改排序。以原始数据排序为准 + areaData.value.components.sort((a, b) => + idOrder.indexOf(a.id) - idOrder.indexOf(b.id) + ); } + } +const idOrder = componentData.value.map(item => item.id); + +// 2. 按照 idOrder 的顺序对 areaData.value.components 进行排序 +areaData.value.components.sort((a, b) => { + const indexA = idOrder.indexOf(a.id); + const indexB = idOrder.indexOf(b.id); + + // 确保两个 id 都在排序列表中 + if (indexA === -1 || indexB === -1) { + // 如果某个 id 不在排序列表中,可以自行决定如何处理 + // 这里我们将不在列表中的项排在后面 + return indexA === -1 ? (indexB === -1 ? 0 : 1) : -1; + } + + return indexA - indexB; +}); const hiddenAreaActive = computed( () => canvasState.value.curPointArea === 'hidden' && !curComponent.value