调整版本树使用的数据结构和后端一致

This commit is contained in:
X1627315083@163.com
2026-02-24 13:20:05 +08:00
parent 5c00b54f27
commit 927bb6de67
9 changed files with 215 additions and 35 deletions

View File

@@ -101,17 +101,17 @@ export function findAndAddChild(items, targetId, newChild) {
// 如果找到目标节点
if (item.id === targetId) {
// 初始化child数组如果不存在
if (!item.child) {
item.child = []
if (!item.children) {
item.children = []
}
// 添加新子节点
item.child.push(newChild)
item.children.push(newChild)
return true
}
// 递归搜索子节点
if (item.child && item.child.length > 0) {
const found = findAndAddChild(item.child, targetId, newChild)
if (item.children && item.children.length > 0) {
const found = findAndAddChild(item.children, targetId, newChild)
if (found) return true
}
}
@@ -135,8 +135,8 @@ export function findAndRemoveChild(items, targetId) {
}
// 递归搜索子节点
if (item.child && item.child.length > 0) {
const found = findAndRemoveChild(item.child, targetId)
if (item.children && item.children.length > 0) {
const found = findAndRemoveChild(item.children, targetId)
if (found) return true
}
}