@@ -14,21 +14,7 @@ const databases = ref([])
1414const tables = ref ([])
1515const currentDatabase = ref (' ' )
1616
17- interface Tree {
18- label: string
19- children? : Tree []
20- }
21- const tablesTree: Tree [] = []
22- watch (tables , (t ) => {
23- // clear tablesTree
24- tablesTree .splice (0 , tablesTree .length )
25- t .forEach ((i ) => {
26- tablesTree .push ({
27- label: i ,
28- })
29- })
30- console .log (tablesTree )
31- })
17+ const tablesTree = ref ([])
3218watch (store , (s ) => {
3319 stores .value .forEach ((e : Store ) => {
3420 if (e .name === s ) {
@@ -75,12 +61,20 @@ const ormDataHandler = (data) => {
7561
7662 databases .value = data .meta .databases
7763 tables .value = data .meta .tables
64+ currentDatabase .value = data .meta .currentDatabase
7865 queryResult .value = result
7966 columns .value = Array .from (cols ).sort ((a , b ) => {
8067 if (a === ' id' ) return - 1 ;
8168 if (b === ' id' ) return 1 ;
8269 return a .localeCompare (b );
8370 })
71+
72+ tablesTree .value = []
73+ tables .value .forEach ((i ) => {
74+ tablesTree .value .push ({
75+ label: i ,
76+ })
77+ })
8478}
8579
8680const keyValueDataHandler = (data ) => {
@@ -129,7 +123,7 @@ const executeQuery = async () => {
129123 <el-option v-for =" item in databases" :key =" item" :label =" item"
130124 :value =" item" ></el-option >
131125 </el-select >
132- <el-tree :data =" tablesTree" />
126+ <el-tree :data =" tablesTree" node-key = " label " />
133127 </el-aside >
134128 <el-container >
135129 <el-header >
0 commit comments