tpi目录树,当目录下没有文件时,一直处于加载中,报脚本错

dev_hjm_a
hjm 5 years ago
parent acd913a588
commit 05a14d2a3e

@ -21,8 +21,11 @@ function getNewTreeData(treeData, curKey, child, level) {
data.forEach((item) => { data.forEach((item) => {
// 这里不能用indexOf 同一级可能出现test目录和test.py文件 // 这里不能用indexOf 同一级可能出现test目录和test.py文件
if (item.key == curKey) { if (item.key == curKey) {
child = addPrePath(child, curKey); if (child && child.length) { // 可能没有子节点
item.children = child; child = addPrePath(child, curKey);
item.children = child;
}
item.isLeaf = false;
} else { } else {
if (item.children) { if (item.children) {
loop(item.children); loop(item.children);
@ -153,6 +156,10 @@ class CodeRepositoryViewContainer extends Component {
}); });
} }
map2OldData = (treeData) => { map2OldData = (treeData) => {
if (!treeData || treeData.length == 0) {
return []
}
if (!treeData || treeData.length === 0) return treeData; if (!treeData || treeData.length === 0) return treeData;
treeData = treeData.map(item => { treeData = treeData.map(item => {
return { return {

Loading…
Cancel
Save