Commit 420acd42 authored by wenmo's avatar wenmo

数据源切换发生bug时容错

parent 94d69437
...@@ -41,21 +41,25 @@ const StudioMetaData = (props: any) => { ...@@ -41,21 +41,25 @@ const StudioMetaData = (props: any) => {
const res = showMetaDataTable(databaseId); const res = showMetaDataTable(databaseId);
res.then((result) => { res.then((result) => {
let tables = result.datas; let tables = result.datas;
for(let i=0;i<tables.length;i++){ if(tables) {
tables[i].title=tables[i].name; for (let i = 0; i < tables.length; i++) {
tables[i].key=tables[i].name; tables[i].title = tables[i].name;
tables[i].icon = <DatabaseOutlined />; tables[i].key = tables[i].name;
tables[i].children=tables[i].tables; tables[i].icon = <DatabaseOutlined/>;
for(let j=0;j<tables[i].children.length;j++){ tables[i].children = tables[i].tables;
tables[i].children[j].title=tables[i].children[j].name; for (let j = 0; j < tables[i].children.length; j++) {
tables[i].children[j].key=tables[i].name+'.'+tables[i].children[j].name; tables[i].children[j].title = tables[i].children[j].name;
tables[i].children[j].icon=<TableOutlined />; tables[i].children[j].key = tables[i].name + '.' + tables[i].children[j].name;
tables[i].children[j].isLeaf=true; tables[i].children[j].icon = <TableOutlined/>;
tables[i].children[j].schema=tables[i].name; tables[i].children[j].isLeaf = true;
tables[i].children[j].table=tables[i].children[j].name; tables[i].children[j].schema = tables[i].name;
tables[i].children[j].table = tables[i].children[j].name;
} }
} }
setTreeData(tables); setTreeData(tables);
}else{
setTreeData([]);
}
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment