From bc2a5b214fc1fc76065cfd697fa8b0dd67b91117 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Mon, 20 Nov 2023 16:46:00 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E9=80=89=E4=B8=AD=E5=A4=9A=E4=B8=AA=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=BE=E6=A0=87=E6=97=B6=EF=BC=8C=E6=89=80?= =?UTF-8?q?=E6=9C=89=E8=8A=82=E7=82=B9=E5=9B=BE=E6=A0=87=E9=83=BD=E4=BC=9A?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E4=B8=BA=E7=AC=AC=E4=B8=80=E4=B8=AA=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=9B=BE=E6=A0=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Edit/components/NodeIconSidebar.vue | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/web/src/pages/Edit/components/NodeIconSidebar.vue b/web/src/pages/Edit/components/NodeIconSidebar.vue index acb88ebb..f4145466 100644 --- a/web/src/pages/Edit/components/NodeIconSidebar.vue +++ b/web/src/pages/Edit/components/NodeIconSidebar.vue @@ -101,9 +101,14 @@ export default { handleNodeActive(...args) { this.activeNodes = [...args[1]] if (this.activeNodes.length > 0) { - let firstNode = this.activeNodes[0] - this.nodeImage = firstNode.getData('image') || '' - this.iconList = firstNode.getData('icon') || [] // 回显图标 + if (this.activeNodes.length === 1) { + let firstNode = this.activeNodes[0] + this.nodeImage = firstNode.getData('image') || '' + this.iconList = firstNode.getData('icon') || [] // 回显图标 + } else { + this.nodeImage = [] + this.iconList = [] + } } else { this.iconList = [] this.nodeImage = '' @@ -121,27 +126,31 @@ export default { // 设置icon setIcon(type, name) { - let key = type + '_' + name - let index = this.iconList.findIndex(item => { - return item === key - }) - // 删除icon - if (index !== -1) { - this.iconList.splice(index, 1) - } else { - let typeIndex = this.iconList.findIndex(item => { - return item.split('_')[0] === type - }) - // 替换icon - if (typeIndex !== -1) { - this.iconList.splice(typeIndex, 1, key) - } else { - // 增加icon - this.iconList.push(key) - } - } this.activeNodes.forEach(node => { - node.setIcon([...this.iconList]) + const iconList = [...(node.getData('icon') || [])] + let key = type + '_' + name + let index = iconList.findIndex(item => { + return item === key + }) + // 删除icon + if (index !== -1) { + iconList.splice(index, 1) + } else { + let typeIndex = iconList.findIndex(item => { + return item.split('_')[0] === type + }) + // 替换icon + if (typeIndex !== -1) { + iconList.splice(typeIndex, 1, key) + } else { + // 增加icon + iconList.push(key) + } + } + node.setIcon(iconList) + if (this.activeNodes.length === 1) { + this.iconList = iconList + } }) },