1
1
<template >
2
- <a-layout class =" main" >
3
- <a-layout-header class =" header" >
2
+ <div class =" main" >
3
+ <div class =" header" >
4
4
<div class =" btn" >
5
5
<a-dropdown >
6
6
<a-button ghost >操作</a-button >
57
57
</template >
58
58
</a-dropdown >
59
59
</div >
60
- </a-layout-header >
61
- <a-layout >
62
- <a-layout-sider width = " 200 " class = " menu " >
60
+ </div >
61
+ <div class = " content " >
62
+ <div class = " menu " :key = " refreshKey1 " :style = " { 'width': menuWidth + 'px' } " >
63
63
<a-spin :spinning =" currloading" >
64
64
<div class =" search" >
65
65
<a-input-search v-model:value =" searchValue"
74
74
@select =" onSelect"
75
75
:tree-data =" treeData"
76
76
>
77
- <template #switcherIcon =" { switcherCls } " ><down-outlined :class =" switcherCls" /></template >
77
+ <template #switcherIcon =" { switcherCls } " >
78
+ <down-outlined :class =" switcherCls" />
79
+ </template >
78
80
<template #icon =" { type , selected } " >
79
81
<template v-if =" type === ' db' " >
80
82
<database-outlined />
85
87
<template v-if =" type === ' table' " >
86
88
<table-outlined />
87
89
</template >
90
+ <template v-if =" type === ' tablenull' " >
91
+ <borderless-table-outlined />
92
+ </template >
88
93
</template >
89
94
</a-tree >
90
95
<a-empty v-if =" !treeData.length" description =" 暂无数据库列表" />
91
96
</div >
92
97
</a-spin >
93
- </a-layout-sider >
94
- <a-layout class =" work" style =" padding : 0 8px 8px " >
98
+ </div >
99
+ <div class =" drap-line" @mousedown =" leftResize" ></div >
100
+ <div class =" work" :key =" refreshKey2" :style =" { 'width': 'calc(100% - '+ (menuWidth + 20) + ')px' }" >
95
101
<a-spin :spinning =" currloading" >
96
102
<div class =" tools" >
97
103
<a-tooltip title =" 执行" >
102
108
<a-button :icon =" h(RedoOutlined)" >撤销</a-button >
103
109
</a-tooltip >
104
110
</div >
105
- <a-layout-content class =" content"
106
- :style =" { background: '#fff', padding: '6px', margin: 0, minHeight: '280px' }" >
111
+ <div class =" context" >
107
112
<div class =" sql" >
108
113
<a-textarea class =" input" ref =" textarea"
109
114
v-model:value =" optValue" @click =" handleClick"
129
134
总记录行数:{{ pagination.total }} | 当前查询页大小:{{ pagination.pageSize }}
130
135
</div >
131
136
</div >
132
- </a-layout-content >
137
+ </div >
133
138
</a-spin >
134
- </a-layout >
135
- </a-layout >
139
+ </div >
140
+ </div >
136
141
<a-modal v-model:open =" openDbListDialog" title =" 数据库列表" width =" 680px" height =" 550px" >
137
142
<div class =" db-dialog" >
138
143
<a-table class =" table"
238
243
<a-button key =" submit" type =" primary" :loading =" submitOpenDbLoading" @click =" submitOpenDb" >连接</a-button >
239
244
</template >
240
245
</a-modal >
241
- </a-layout >
246
+ </div >
242
247
</template >
243
248
244
249
<script lang="ts" setup>
245
250
import { cloneDeep } from ' lodash-es' ;
246
251
import { h , ref , watch , onMounted , UnwrapRef , reactive } from ' vue' ;
247
- import { WifiOutlined ,ApiOutlined ,UserOutlined ,AppstoreOutlined ,DatabaseOutlined ,FileAddOutlined ,CaretRightOutlined ,RedoOutlined , DownOutlined , TabletOutlined , TableOutlined , FrownOutlined , FrownFilled } from ' @ant-design/icons-vue' ;
252
+ import { WifiOutlined ,ApiOutlined ,UserOutlined ,BorderlessTableOutlined ,DatabaseOutlined ,FileAddOutlined ,CaretRightOutlined ,RedoOutlined , DownOutlined , TabletOutlined , TableOutlined , FrownOutlined , FrownFilled } from ' @ant-design/icons-vue' ;
248
253
import { getDb ,getMode ,getTable } from ' ../api/menu' ;
249
254
import { getSearch ,execute } from ' ../api/search' ;
250
255
import { connectDb } from ' ../api/datasource' ;
@@ -310,6 +315,36 @@ import { life } from '../api/life';
310
315
clearCurrDbData ();
311
316
}
312
317
}
318
+ const menuWidth = ref (350 ); // 菜单宽度
319
+ const refreshKey1 = ref <number >(0 );
320
+ const refreshKey2 = ref <number >(0 );
321
+ const mouseEventX = ref <number >(0 );
322
+
323
+ const leftResize = (e : MouseEvent ) => {
324
+ // 解决拖动会选中文字的问题\
325
+ document .onselectstart = function () {
326
+ return false ;
327
+ };
328
+ const changeWidth = (documentE : MouseEvent ) => {
329
+ menuWidth .value = documentE .clientX ;
330
+ refreshKey1 .value = refreshKey1 .value + 1 ;
331
+ refreshKey2 .value = refreshKey1 .value + 1 ;
332
+ };
333
+ const mouseMove = (documentE : MouseEvent ) => {
334
+ mouseEventX .value = documentE .clientX ;
335
+ changeWidth (documentE );
336
+ };
337
+ const mouseUp = () => {
338
+ document .removeEventListener (' mousemove' , mouseMove );
339
+ document .removeEventListener (' mouseup' , mouseUp );
340
+ // 拖拽完记得重新设置可以选中
341
+ document .onselectstart = function () {
342
+ return true ;
343
+ };
344
+ };
345
+ document .addEventListener (' mousemove' , mouseMove );
346
+ document .addEventListener (' mouseup' , mouseUp );
347
+ };
313
348
const selectedMenu: MenuProps [' onClick' ] = ({ key }) => {
314
349
if (key == ' 1' ) {
315
350
submitOpenDbList ();
@@ -534,7 +569,7 @@ import { life } from '../api/life';
534
569
treeNode .dataRef .children = res .data .map (c => {
535
570
return {
536
571
title: c .name ,
537
- key: c .name ,
572
+ key: treeNode . title + ' _ ' + c .name ,
538
573
isLeaf: false ,
539
574
type: ' mode' ,
540
575
database: treeNode .title
@@ -548,15 +583,14 @@ import { life } from '../api/life';
548
583
})
549
584
} else if (treeNode .dataRef .type === ' mode' ) {
550
585
getTable (treeNode .dataRef .database , treeNode .title , currDatabase .value .type ).then (res => {
551
- if (! res .data || res .data .length == 0 ) {
552
- treeNode .dataRef .children = res .data .map (c => {
553
- return {
554
- title: ' 暂无表数据' ,
555
- key: ' 暂无表数据' ,
556
- isLeaf: true ,
557
- type: ' tablenull' ,
558
- }
559
- });
586
+ if (! res .data || ! res .data || res .data .length < 1 ) {
587
+ treeNode .dataRef .children = [{
588
+ title: ' 暂无表数据' ,
589
+ key: ' 暂无表数据' ,
590
+ isLeaf: true ,
591
+ disabled: true ,
592
+ type: ' tablenull' ,
593
+ }];
560
594
} else {
561
595
treeNode .dataRef .children = res .data .map (c => {
562
596
return {
@@ -783,6 +817,8 @@ import { life } from '../api/life';
783
817
height : 100% ;
784
818
overflow-y : hidden ;
785
819
overflow-x : hidden ;
820
+ display : flex ;
821
+ flex-direction : column ;
786
822
787
823
.header {
788
824
height : 50px ;
@@ -794,6 +830,7 @@ import { life } from '../api/life';
794
830
flex-direction : row ;
795
831
align-items : center ;
796
832
justify-content : space-between ;
833
+ background-color : rgb (24 , 24 , 40 );
797
834
798
835
.btn {
799
836
width : 150px ;
@@ -814,93 +851,111 @@ import { life } from '../api/life';
814
851
}
815
852
}
816
853
}
817
- .menu {
818
- width : 300px !important ;
819
- max-width : 300px !important ;
820
- min-width : 300px !important ;
821
- height : calc (100% - 16px );
822
- display : flex ;
823
- flex-direction : column ;
824
- padding : 8px ;
825
- background-color : #fff ;
826
854
827
- .search {
828
- height : 45px ;
829
- width : 100% ;
830
- display : flex ;
831
- flex-direction : row ;
832
- align-items : center ;
833
- justify-content : center ;
834
- }
855
+ .content {
856
+ height : calc (100% - 50px );
857
+ width : 100% ;
858
+ display : flex ;
859
+ flex-direction : row ;
835
860
836
- .tree {
837
- width : 100% ;
838
- max-height : calc (100vh - 45px );
839
- overflow-y : auto ;
840
- }
841
- }
842
- .work {
843
- height : calc (100vh - 80px );
844
- width : calc (100% - 350px );
861
+
862
+ .menu {
863
+ height : calc (100% - 16px );
864
+ display : flex ;
865
+ flex-direction : column ;
866
+ padding : 8px ;
867
+ background-color : #fff ;
845
868
846
- .tools {
847
- width : 100% ;
848
- height : 40px ;
849
- padding : 0 12px ;
850
- display : flex ;
851
- flex-direction : row ;
852
- align-items : center ;
853
- justify-content : flex-start ;
854
- }
855
- .content {
856
- width : 100% ;
857
- height : 100% ;
858
- display : flex ;
859
- flex-direction : column ;
860
- padding : 0 ;
861
- margin : 0 ;
869
+ .search {
870
+ height : 45px ;
871
+ width : 100% ;
872
+ display : flex ;
873
+ flex-direction : row ;
874
+ align-items : center ;
875
+ justify-content : center ;
876
+ }
862
877
863
- .sql {
864
- width : 100% ;
865
- min-height : 105px ;
866
- .input {
867
- height : calc (100% - 8px );
868
- margin : 4px ;
869
- width : calc (100% - 8px );
870
- }
871
- }
872
- .data {
873
- width : 100% ;
874
- height : 100% ;
878
+ .tree {
879
+ width : 100% ;
880
+ max-height : calc (100vh - 45px );
881
+ overflow-y : auto ;
882
+ }
883
+ }
884
+ .drap-line {
885
+ height : 100% ;
886
+ width : 5px ;
887
+ background-color : #d0cece ;
888
+ border-radius : 6px ;
889
+ cursor : col-resize ;
890
+ z-index : 999 ;
891
+ }
892
+ .work {
893
+ height : calc (100vh - 80px );
894
+ padding : 0 0 8px 8px ;
895
+ flex : 1 ;
875
896
876
- .table {
877
- width : 100% ;
878
- height : calc (100% - 30px );
879
- }
880
- .table-line {
881
- width : 100% ;
882
- height : 30px ;
883
- font-size : 12px ;
884
- color : #333333 ;
885
- padding : 0 6px ;
886
- display : flex ;
887
- flex-direction : row ;
888
- align-items : center ;
889
- justify-content : flex-start ;
890
- background-color : #f5f5f5 ;
891
- border-radius : 8px ;
892
- }
897
+ .tools {
898
+ width : 100% ;
899
+ height : 40px ;
900
+ padding : 0 12px ;
901
+ display : flex ;
902
+ flex-direction : row ;
903
+ align-items : center ;
904
+ justify-content : flex-start ;
905
+ }
906
+ .context {
907
+ width : 100% ;
908
+ height : 100% ;
909
+ display : flex ;
910
+ flex-direction : column ;
911
+ padding : 0 ;
912
+ margin : 0 ;
913
+ background : ' #fff' ;
914
+ padding : ' 6px' ;
915
+ min-height : ' 280px' ;
893
916
894
- .msg {
917
+ .sql {
918
+ width : 100% ;
919
+ min-height : 105px ;
920
+ .input {
921
+ height : calc (100% - 8px );
922
+ margin : 4px ;
923
+ width : calc (100% - 8px );
924
+ }
925
+ }
926
+ .data {
895
927
width : 100% ;
896
928
height : 100% ;
897
- display : flex ;
898
- flex-direction : column ;
899
- align-items : flex-start ;
900
- justify-content : flex-start ;
901
- }
902
- }
903
- }
929
+
930
+ .table {
931
+ width : 100% ;
932
+ height : calc (100% - 30px );
933
+ }
934
+ .table-line {
935
+ width : 100% ;
936
+ height : 30px ;
937
+ font-size : 12px ;
938
+ color : #333333 ;
939
+ padding : 0 6px ;
940
+ display : flex ;
941
+ flex-direction : row ;
942
+ align-items : center ;
943
+ justify-content : flex-start ;
944
+ background-color : #f5f5f5 ;
945
+ border-radius : 8px ;
946
+ }
947
+
948
+ .msg {
949
+ width : 100% ;
950
+ height : 100% ;
951
+ display : flex ;
952
+ flex-direction : column ;
953
+ align-items : flex-start ;
954
+ justify-content : flex-start ;
955
+ }
956
+ }
957
+ }
958
+ }
904
959
}
905
960
}
906
961
.db-dialog {
0 commit comments