fix: 选择数据源-没有数据源的空文件夹不显示在列表

This commit is contained in:
dataeaseShu 2024-01-18 10:21:33 +08:00
parent ce7ce6b17c
commit a7d3fc21f4

View File

@ -212,6 +212,18 @@ const dfsName = (arr, id) => {
return name return name
} }
const dfsChild = arr => {
return arr.filter(ele => {
if (ele.leaf) {
return true
}
if (!!ele.children?.length) {
ele.children = dfsChild(ele.children || [])
}
return !!ele.children?.length
})
}
const getDsName = (id: string) => { const getDsName = (id: string) => {
return dfsName(state.dataSourceList, id) return dfsName(state.dataSourceList, id)
} }
@ -860,9 +872,9 @@ const getDatasource = () => {
getDatasourceList().then(res => { getDatasourceList().then(res => {
const _list = (res as unknown as DataSource[]) || [] const _list = (res as unknown as DataSource[]) || []
if (_list && _list.length > 0 && _list[0].id === '0') { if (_list && _list.length > 0 && _list[0].id === '0') {
state.dataSourceList = _list[0].children state.dataSourceList = dfsChild(_list[0].children)
} else { } else {
state.dataSourceList = _list state.dataSourceList = dfsChild(_list)
} }
}) })
} }