update src/utils/tree.ts.

tree.ts中的treeToString错误,修复

Signed-off-by: 口口口 <17975121@qq.com>
pull/523/head
口口口 2024-08-23 06:00:05 +00:00 committed by Gitee
parent 0f420bf39b
commit a57536c494
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 11 additions and 2 deletions

View File

@ -374,15 +374,18 @@ export const treeToString = (tree: any[], nodeId) => {
return node.name
}
let str = ''
let list = <any[]>[]
function performAThoroughValidation(arr) {
for (const item of arr) {
if (item.id === nodeId) {
str += ` / ${item.name}`
list.push(item.name)
// str += ` / ${item.name}`
return true
} else if (typeof item.children !== 'undefined' && item.children.length !== 0) {
str += ` / ${item.name}`
// str += ` / ${item.name}`
if (performAThoroughValidation(item.children)) {
list.push(item.name)
return true
}
}
@ -391,10 +394,16 @@ export const treeToString = (tree: any[], nodeId) => {
}
for (const item of tree) {
list = []
str = `${item.name}`
if (performAThoroughValidation(item.children)) {
break
}
}
if (list.length > 0) {
list.reverse().forEach((name) => {
str += ` / ${name}`
})
}
return str
}