Skip to content

Commit 87897d1

Browse files
author
fanjin.fjy
committed
feat: code optimize
1 parent e6ea923 commit 87897d1

18 files changed

Lines changed: 119 additions & 259 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"cascader",
77
"Dserver",
88
"Dspring",
9+
"echart",
910
"echarts",
1011
"favicons",
1112
"iconfont",

chat2db-client/src/blocks/Setting/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
margin: -16px;
9898
height: 70vh;
9999
overflow-y: auto;
100+
border-radius: var(--border-radius-l-g);
100101
}
101102

102103
.menus {

chat2db-client/src/i18n/en-us/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
'common.text.is': 'no',
44
'common.button.affirm': 'Affirm',
55
'common.button.edit': 'Edit',
6+
'common.button.confirm': 'Confirm',
67
'common.button.cancel': 'Cancel',
78
'common.data.hour': '{1} {hour|hours}',
89
'common.data.minute': '{1} {minute|minutes}',
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export default {
2-
'dashboard.title': 'dashboard',
3-
'dashboard.edit': "Edit",
4-
'dashboard.delete': "Delete",
2+
'dashboard.title': 'Dashboard',
3+
'dashboard.edit': 'Edit',
4+
'dashboard.modal.editTitle': 'Edit Dashboard',
5+
'dashboard.modal.addTitle': 'Add Dashboard',
6+
'dashboard.modal.name.placeholder': "Please enter dashboard's name.",
7+
'dashboard.delete': 'Delete',
8+
59
};

chat2db-client/src/i18n/zh-cn/common.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
'common.text.is': '是',
44
'common.button.affirm': '确认',
55
'common.button.edit': '修改',
6+
'common.button.confirm': '确认',
67
'common.button.cancel': '取消',
78
'common.data.hour': '{1}小时',
89
'common.data.minute': '{1}分钟',
@@ -21,10 +22,10 @@ export default {
2122
'common.button.save': '保存',
2223
'common.button.取消execute': '执行',
2324
'common.message.successfulConfig': '配置成功',
24-
'common.text.successful':'成功',
25-
'common.text.failure':'失败',
26-
'common.message.modifySuccessfully':'修改成功',
25+
'common.text.successful': '成功',
26+
'common.text.failure': '失败',
27+
'common.message.modifySuccessfully': '修改成功',
2728
'common.message.addedSuccessfully': '添加成功',
28-
'common.text.custom':'自定义',
29-
'common.button.delete':'删除'
30-
}
29+
'common.text.custom': '自定义',
30+
'common.button.delete': '删除',
31+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export default {
22
'dashboard.title': '仪表盘',
33
'dashboard.edit': '编辑',
4+
'dashboard.modal.editTitle': '编辑仪表盘',
5+
'dashboard.modal.addTitle': '新增仪表盘',
6+
'dashboard.modal.name.placeholder': "请输入仪表盘名",
47
'dashboard.delete': '删除',
58
};

chat2db-client/src/models/database.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

chat2db-client/src/models/workspace.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { getCurrentWorkspaceDatabase, setCurrentWorkspaceDatabase } from '@/util
22
import sqlService, { MetaSchemaVO } from '@/service/sql';
33
import { DatabaseTypeCode } from '@/constants';
44
import { Effect, Reducer } from 'umi';
5-
import { ITreeNode } from '@/typings'
5+
import { ITreeNode } from '@/typings';
66

77
export type ICurWorkspaceParams = {
88
dataSourceId: number;
99
databaseSourceName: string;
1010
databaseType: DatabaseTypeCode;
1111
databaseName?: string;
1212
schemaName?: string;
13-
}
13+
};
1414

1515
export interface IState {
1616
// 当前连接下的及联databaseAndSchema数据
@@ -21,20 +21,20 @@ export interface IState {
2121
doubleClickTreeNodeData: ITreeNode | undefined;
2222
}
2323

24-
export interface IWorkspaceModelType {
25-
namespace: 'workspace',
26-
state: IState,
24+
export interface IWorkspaceModelType {
25+
namespace: 'workspace';
26+
state: IState;
2727
reducers: {
2828
setDatabaseAndSchema: Reducer<IState['databaseAndSchema']>;
2929
setCurWorkspaceParams: Reducer<IState['curWorkspaceParams']>;
3030
setDoubleClickTreeNodeData: Reducer<any>; //TS TODO:
3131
};
3232
effects: {
33-
fetchdatabaseAndSchema: Effect;
33+
fetchDatabaseAndSchema: Effect;
3434
};
3535
}
3636

37-
const WorkspaceModel:IWorkspaceModelType = {
37+
const WorkspaceModel: IWorkspaceModelType = {
3838
namespace: 'workspace',
3939

4040
state: {
@@ -69,10 +69,10 @@ const WorkspaceModel:IWorkspaceModelType = {
6969
},
7070

7171
effects: {
72-
*fetchdatabaseAndSchema(p, action) {
73-
const { call, put } = action
74-
console.log(p,action)
75-
const res = (yield sqlService.getDatabaseSchemaList({ dataSourceId: 2 }))
72+
*fetchDatabaseAndSchema({ payload }, action) {
73+
const { put } = action;
74+
// ts-ignore
75+
const res = yield sqlService.getDatabaseSchemaList(payload);
7676
yield put({
7777
type: 'setDatabaseAndSchema',
7878
payload: res,
@@ -81,4 +81,4 @@ const WorkspaceModel:IWorkspaceModelType = {
8181
},
8282
};
8383

84-
export default WorkspaceModel
84+
export default WorkspaceModel;

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import i18n from '@/i18n';
44
import CreateConnection from '@/components/CreateConnection';
55
import Iconfont from '@/components/Iconfont';
66
import connectionService from '@/service/connection';
7-
87
import { DatabaseTypeCode, databaseMap, databaseTypeList } from '@/constants';
9-
108
import { IDatabase, IConnectionDetails } from '@/typings';
119
import { Button, Dropdown, Modal } from 'antd';
1210
import { MoreOutlined } from '@ant-design/icons';
@@ -62,17 +60,17 @@ function Connections(props: IProps) {
6260
[connectionList],
6361
);
6462

65-
const menuItemDoubleClick = (t: any) => {
63+
const handleMenuItemDoubleClick = (t?: any) => {
6664
dispatch({
6765
type: 'connection/setCurConnection',
6866
payload: t.meta,
6967
});
7068

7169
dispatch({
7270
type: 'mainPage/updateCurPage',
73-
payload: 'workspace'
74-
})
75-
}
71+
payload: 'workspace',
72+
});
73+
};
7674

7775
const renderMenu = () => {
7876
return (
@@ -85,7 +83,7 @@ function Connections(props: IProps) {
8583
className={classnames(styles.menuItem, {
8684
[styles.menuItemActive]: curConnection.id === key,
8785
})}
88-
onDoubleClick={menuItemDoubleClick.bind(null, t)}
86+
onDoubleClick={handleMenuItemDoubleClick.bind(null, t)}
8987
onClick={() => {
9088
setCurConnection(t.meta);
9189
}}
@@ -97,6 +95,13 @@ function Connections(props: IProps) {
9795
<Dropdown
9896
menu={{
9997
items: [
98+
{
99+
key: 'EnterWorkSpace',
100+
label: i18n('connection.button.connect'),
101+
onClick: () => {
102+
handleMenuItemDoubleClick(t);
103+
},
104+
},
100105
{
101106
key: 'Delete',
102107
label: i18n('common.button.delete'),
@@ -180,7 +185,9 @@ function Connections(props: IProps) {
180185
);
181186
}
182187

183-
export default connect(({ connection, workspace }: { connection: IConnectionModelType; workspace: IWorkspaceModelType }) => ({
184-
connectionModel: connection,
185-
workspaceModel: workspace,
186-
}))(Connections);
188+
export default connect(
189+
({ connection, workspace }: { connection: IConnectionModelType; workspace: IWorkspaceModelType }) => ({
190+
connectionModel: connection,
191+
workspaceModel: workspace,
192+
}),
193+
)(Connections);

chat2db-client/src/pages/main/dashboard/chart-item/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function ChartItem(props: IChartItemProps) {
179179
return (
180180
<div className={styles.editorBlock}>
181181
<div className={styles.editor}>
182-
<Console
182+
{/* <Console
183183
executeParams={{
184184
// databaseName: currentWorkspaceData.databaseName,
185185
// dataSourceId: currentWorkspaceData.dataSourceId,
@@ -195,7 +195,7 @@ function ChartItem(props: IChartItemProps) {
195195
console.log('onExecuteSQL', result);
196196
// setResultData(result);
197197
}}
198-
/>
198+
/> */}
199199
</div>
200200
<Form
201201
form={form}

0 commit comments

Comments
 (0)