Skip to content

Commit 14da0c0

Browse files
committed
loading
1 parent cc78133 commit 14da0c0

13 files changed

Lines changed: 231 additions & 126 deletions

File tree

chat2db-client/src/components/CreateConnection/components/Driver/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { memo, useState, useEffect } from 'react';
22
import styles from './index.less';
33
import classnames from 'classnames';
44
import { i18n, isEn } from '@/i18n';
5-
import { Form, Modal, Input, Select, Spin } from 'antd';
5+
import { Form, Modal, Input, Select } from 'antd';
66
import connectionService, { IDriverResponse } from '@/service/connection';
77
import { DatabaseTypeCode, ConnectionEnvType, databaseMap } from '@/constants';
88
import UploadDriver from '@/components/UploadDriver';

chat2db-client/src/components/CreateConnection/config/dataSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const sshConfig: IConnectionConfig['ssh'] = {
109109
},
110110
{
111111
defaultValue: '',
112-
inputType: InputType.INPUT,
112+
inputType: InputType.PASSWORD,
113113
labelNameCN: '密码短语',
114114
labelNameEN: 'Passphrase',
115115
name: 'passphrase',

chat2db-client/src/components/CreateConnection/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ function RenderForm(props: IRenderFormProps) {
486486
{FormItemTypes[t.inputType]()}
487487
</div>
488488
{t.selects?.map((item) => {
489-
console.log(t.defaultValue,)
490489
if (t.defaultValue === item.value) {
491490
return item.items?.map((t) => renderFormItem(t));
492491
}

chat2db-client/src/components/Loading/Loading/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { memo } from 'react';
22
import styles from './index.less';
33
import classnames from 'classnames';
4-
import { Spin } from 'antd';
54
import './index.less'
65

76
interface IProps {

chat2db-client/src/components/Loading/LoadingContent/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import StateIndicator from '@/components/StateIndicator';
55

66
interface IProps<T> {
77
className?: string;
8-
data: T | null | undefined;
8+
data?: T | null | undefined | true;
99
empty?: React.ReactNode;
1010
handleEmpty?: boolean;
11+
isLoading?: boolean;
1112
}
1213

1314
export default function LoadingContent<T>(props: PropsWithChildren<IProps<T>>) {
14-
const { children, className, data, handleEmpty = false, empty } = props;
15-
const isLoading = !data;
15+
const { children, className, data = true, handleEmpty = false, empty, isLoading } = props;
1616
const isEmpty = !isLoading && handleEmpty && !(data as any).length;
1717

1818
const renderContent = () => {
19-
if (isLoading) {
19+
if (isLoading || !data) {
2020
return <StateIndicator state="loading" />;
2121
}
2222

@@ -28,6 +28,8 @@ export default function LoadingContent<T>(props: PropsWithChildren<IProps<T>>) {
2828
};
2929

3030
return (
31-
<div className={classnames(styles.box, className)}>{renderContent()}</div>
31+
<div className={classnames(styles.box, className)}>{
32+
renderContent()
33+
}</div>
3234
);
3335
}

chat2db-client/src/components/Loading/LoadingLiquid/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { memo } from 'react';
22
import styles from './index.less';
33
import classnames from 'classnames';
4-
import { Spin } from 'antd';
54
import './index.less'
65

76
interface IProps {

chat2db-client/src/components/UploadDriver/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default memo<IProps>(function UploadDriver(props) {
3434
})
3535
}
3636
},
37+
accept: "application/java-archive"
3738
};
3839

3940
useEffect(() => {

chat2db-client/src/models/workspace.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ export interface IWorkspaceModelType {
3939
};
4040
effects: {
4141
fetchDatabaseAndSchema: Effect;
42+
fetchDatabaseAndSchemaLoading: Effect;
4243
fetchGetSavedConsole: Effect;
4344
fetchGetCurTableList: Effect;
45+
fetchGetSavedConsoleLoading: Effect;
4446
};
4547
}
4648

@@ -114,7 +116,18 @@ const WorkspaceModel: IWorkspaceModelType = {
114116
catch {
115117

116118
}
119+
},
120+
*fetchDatabaseAndSchemaLoading({ payload }, { put }) {
121+
try {
122+
const res = (yield sqlService.getDatabaseSchemaList(payload)) as MetaSchemaVO;
123+
yield put({
124+
type: 'setDatabaseAndSchema',
125+
payload: res,
126+
});
127+
}
128+
catch {
117129

130+
}
118131
},
119132
*fetchGetSavedConsole({ payload, callback }, { put }) {
120133
try {
@@ -130,6 +143,20 @@ const WorkspaceModel: IWorkspaceModelType = {
130143
catch {
131144
}
132145
},
146+
*fetchGetSavedConsoleLoading({ payload, callback }, { put }) {
147+
try {
148+
const res = (yield historyService.getSavedConsoleList({
149+
pageNo: 1,
150+
pageSize: 999,
151+
...payload
152+
})) as IPageResponse<IConsole>;
153+
if (callback && typeof callback === 'function') {
154+
callback(res);
155+
}
156+
}
157+
catch {
158+
}
159+
},
133160
*fetchGetCurTableList({ payload, callback }, { put, call }) {
134161
try {
135162
const res = (yield treeConfig[TreeNodeType.TABLES].getChildren!({

chat2db-client/src/pages/main/connection/index.tsx

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function Connections(props: IProps) {
8484
[styles.menuItemActive]: curConnection.id === key,
8585
})}
8686
onDoubleClick={handleMenuItemDoubleClick.bind(null, t)}
87-
onClick={() => {
87+
onClick={(event) => {
8888
setCurConnection(t.meta);
8989
}}
9090
>
@@ -106,7 +106,8 @@ function Connections(props: IProps) {
106106
key: 'Delete',
107107
label: i18n('common.button.delete'),
108108
onClick: async ({ domEvent }) => {
109-
domEvent.preventDefault();
109+
// 禁止冒泡到menuItem
110+
domEvent.stopPropagation();
110111
await connectionService.remove({ id: key });
111112
setCurConnection({});
112113
getConnectionList();
@@ -157,29 +158,29 @@ function Connections(props: IProps) {
157158
/>
158159
</div>
159160
) : (
160-
<div className={styles.dataBaseList}>
161-
{databaseTypeList.map((t) => {
162-
return (
163-
<div key={t.code} className={styles.databaseItem} onClick={handleCreateConnections.bind(null, t)}>
164-
<div className={styles.databaseItemMain}>
165-
<div className={styles.databaseItemLeft}>
166-
<div className={styles.logoBox}>
167-
<Iconfont code={t.icon} />
161+
<div className={styles.dataBaseList}>
162+
{databaseTypeList.map((t) => {
163+
return (
164+
<div key={t.code} className={styles.databaseItem} onClick={handleCreateConnections.bind(null, t)}>
165+
<div className={styles.databaseItemMain}>
166+
<div className={styles.databaseItemLeft}>
167+
<div className={styles.logoBox}>
168+
<Iconfont code={t.icon} />
169+
</div>
170+
{t.name}
171+
</div>
172+
<div className={styles.databaseItemRight}>
173+
<Iconfont code="&#xe631;" />
168174
</div>
169-
{t.name}
170-
</div>
171-
<div className={styles.databaseItemRight}>
172-
<Iconfont code="&#xe631;" />
173175
</div>
174176
</div>
175-
</div>
176-
);
177-
})}
178-
{Array.from({ length: 20 }).map((t, index) => {
179-
return <div key={index} className={styles.databaseItemSpacer}></div>;
180-
})}
181-
</div>
182-
)}
177+
);
178+
})}
179+
{Array.from({ length: 20 }).map((t, index) => {
180+
return <div key={index} className={styles.databaseItemSpacer}></div>;
181+
})}
182+
</div>
183+
)}
183184
</div>
184185
</div>
185186
);

chat2db-client/src/pages/main/workspace/components/WorkspaceLeft/index.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,10 @@
164164
margin-right: 10px;
165165
}
166166
}
167+
168+
.refreshIconBox{
169+
cursor: pointer;
170+
&:hover{
171+
color: var(--color-primary)
172+
}
173+
}

0 commit comments

Comments
 (0)