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 + } }) },