Fix:修复开启彩虹线条时切换结构会报错的问题

This commit is contained in:
街角小林 2024-03-29 15:51:32 +08:00
parent 38576a4860
commit 02957e1fcf
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "simple-mind-map", "name": "simple-mind-map",
"version": "0.9.9-fix.1", "version": "0.9.9-fix.2",
"description": "一个简单的web在线思维导图", "description": "一个简单的web在线思维导图",
"authors": [ "authors": [
{ {

View File

@ -48,7 +48,9 @@ class RainbowLines {
// 获取一个节点的第二层级的祖先节点 // 获取一个节点的第二层级的祖先节点
getSecondLayerAncestor(node) { getSecondLayerAncestor(node) {
if (node.layerIndex === 1) { if (node.layerIndex === 0) {
return null
} else if (node.layerIndex === 1) {
return node return node
} else { } else {
let res = null let res = null
@ -78,6 +80,7 @@ class RainbowLines {
const { rainbowLinesConfig } = this.mindMap.opt const { rainbowLinesConfig } = this.mindMap.opt
if (!rainbowLinesConfig || !rainbowLinesConfig.open) return '' if (!rainbowLinesConfig || !rainbowLinesConfig.open) return ''
const ancestor = this.getSecondLayerAncestor(node) const ancestor = this.getSecondLayerAncestor(node)
if (!ancestor) return
const index = getNodeDataIndex(ancestor) const index = getNodeDataIndex(ancestor)
const colorsList = this.getColorsList() const colorsList = this.getColorsList()
return colorsList[index % colorsList.length] return colorsList[index % colorsList.length]