@@ -3,7 +3,7 @@ import styles from './index.less';
33import classnames from 'classnames' ;
44import { IConnectionDetails , IDatabase } from '@/typings' ;
55import ConnectionEdit , { ICreateConnectionFunction } from '@/components/ConnectionEdit' ;
6- import { DatabaseTypeCode , databaseMap , databaseTypeList } from '@/constants' ;
6+ import { databaseTypeList } from '@/constants' ;
77import Iconfont from '@/components/Iconfont' ;
88
99interface IProps {
@@ -12,24 +12,18 @@ interface IProps {
1212 connectionDetail ?: IConnectionDetails ; // 如果你想编辑,就直接传入完成的数据就好
1313}
1414
15- export default memo < IProps > ( function CreateConnection ( props ) {
15+ export default memo < IProps > ( ( props ) => {
1616 const { className, onSubmit, connectionDetail } = props ;
1717 const [ curConnection , setCurConnection ] = useState < Partial < IConnectionDetails > > ( { } ) ;
1818 const createConnectionRef = useRef < ICreateConnectionFunction > ( ) ;
1919
20-
2120 useEffect ( ( ) => {
2221 if ( connectionDetail ) {
23- setCurConnection ( connectionDetail )
22+ setCurConnection ( connectionDetail ) ;
2423 } else {
25- setCurConnection ( { } )
24+ setCurConnection ( { } ) ;
2625 }
27- } , [ connectionDetail ] )
28-
29-
30- function getData ( ) {
31- console . log ( createConnectionRef . current ?. getData ( ) )
32- }
26+ } , [ connectionDetail ] ) ;
3327
3428 function handleCreateConnections ( database : IDatabase ) {
3529 setCurConnection ( {
@@ -38,50 +32,52 @@ export default memo<IProps>(function CreateConnection(props) {
3832 }
3933
4034 function handleSubmit ( data : IConnectionDetails ) {
41- onSubmit ?.( data )
35+ onSubmit ?.( data ) ;
4236 }
4337
44- return < div className = { classnames ( styles . box , className ) } >
45- { curConnection && Object . keys ( curConnection ) . length ? (
46- < div
47- className = { classnames ( styles . createConnections , {
48- [ styles . showCreateConnections ] : Object . keys ( curConnection ) . length ,
49- } ) }
50- >
51- {
52- < ConnectionEdit
53- ref = { createConnectionRef as any }
54- closeCreateConnection = { ( ) => {
55- setCurConnection ( { } ) ;
56- } }
57- connectionData = { curConnection as any }
58- submit = { handleSubmit }
59- />
60- }
61- </ div >
62- ) : (
63- < div className = { styles . dataBaseList } >
64- { databaseTypeList . map ( ( t ) => {
65- return (
66- < div key = { t . code } className = { styles . databaseItem } onClick = { handleCreateConnections . bind ( null , t ) } >
67- < div className = { styles . databaseItemMain } >
68- < div className = { styles . databaseItemLeft } >
69- < div className = { styles . logoBox } >
70- < Iconfont code = { t . icon } />
38+ return (
39+ < div className = { classnames ( styles . box , className ) } >
40+ { curConnection && Object . keys ( curConnection ) . length ? (
41+ < div
42+ className = { classnames ( styles . createConnections , {
43+ [ styles . showCreateConnections ] : Object . keys ( curConnection ) . length ,
44+ } ) }
45+ >
46+ {
47+ < ConnectionEdit
48+ ref = { createConnectionRef as any }
49+ closeCreateConnection = { ( ) => {
50+ setCurConnection ( { } ) ;
51+ } }
52+ connectionData = { curConnection as any }
53+ submit = { handleSubmit }
54+ />
55+ }
56+ </ div >
57+ ) : (
58+ < div className = { styles . dataBaseList } >
59+ { databaseTypeList . map ( ( t ) => {
60+ return (
61+ < div key = { t . code } className = { styles . databaseItem } onClick = { handleCreateConnections . bind ( null , t ) } >
62+ < div className = { styles . databaseItemMain } >
63+ < div className = { styles . databaseItemLeft } >
64+ < div className = { styles . logoBox } >
65+ < Iconfont code = { t . icon } />
66+ </ div >
67+ { t . name }
68+ </ div >
69+ < div className = { styles . databaseItemRight } >
70+ < Iconfont code = "" />
7171 </ div >
72- { t . name }
73- </ div >
74- < div className = { styles . databaseItemRight } >
75- < Iconfont code = "" />
7672 </ div >
7773 </ div >
78- </ div >
79- ) ;
80- } ) }
81- { Array . from ( { length : 20 } ) . map ( ( t , index ) => {
82- return < div key = { index } className = { styles . databaseItemSpacer } > </ div > ;
83- } ) }
84- </ div >
85- ) }
86- </ div >
87- } )
74+ ) ;
75+ } ) }
76+ { Array . from ( { length : 20 } ) . map ( ( t , index ) => {
77+ return < div key = { index } className = { styles . databaseItemSpacer } /> ;
78+ } ) }
79+ </ div >
80+ ) }
81+ </ div >
82+ ) ;
83+ } ) ;
0 commit comments