Pre Merge pull request !523 from 口口口/N/A

pull/523/MERGE
口口口 2025-08-31 03:31:01 +00:00 committed by Gitee
commit 68693ce42d
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,6 +374,7 @@ export const treeToString = (tree: any[], nodeId) => {
return node.name
}
let str = ''
let list = <any[]>[]
function performAThoroughValidation(arr) {
if (typeof arr === 'undefined' || !Array.isArray(arr) || arr.length === 0) {
@ -381,11 +382,13 @@ export const treeToString = (tree: any[], nodeId) => {
}
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
}
}
@ -394,10 +397,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
}