Skip to content

Commit dd2d198

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents edd12b9 + f0002fd commit dd2d198

17 files changed

Lines changed: 446 additions & 237 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- ⭐【New Features】The tree node operation menu can copy the names of tables, fields, keys, indexes, and functions
66
- ⭐【New Features】Edit table structure supports setting primary keys in columns
77
- ⭐【New Features】Edit data to support cell-level undo changes
8+
- ⭐【New Features】Query data supports single-row replication of Insert, Update, table header, and row data
89
- ⚡️【Optimize】
910
- 🐞【Fixed】Fixed table structure editing floating-point decimal Settings display exception
1011

@@ -13,6 +14,7 @@
1314
- ⭐【新功能】树节点操作菜单支持复制表、字段、key、index、函数等名称
1415
- ⭐【新功能】编辑表结构支持在列中设置主键
1516
- ⭐【新功能】编辑数据支持单元格级别撤销修改
17+
- ⭐【新功能】查询数据支持单行复制Insert、Update、表头、行数据
1618
- ⚡️【优化】
1719
- 🐞【修复】修复表结构编辑浮点数小数位设置显示异常
1820

chat2db-client/src/blocks/DatabaseTableEditor/index.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { memo, useRef, useState, createContext, useEffect, useMemo } from 'react';
22
import { Button, Modal, message } from 'antd';
3+
import i18n from '@/i18n';
4+
import lodash from 'lodash';
35
import styles from './index.less';
46
import classnames from 'classnames';
57
import IndexList, { IIndexListRef } from './IndexList';
@@ -9,8 +11,7 @@ import sqlService, { IModifyTableSqlParams } from '@/service/sql';
911
import ExecuteSQL from '@/components/ExecuteSQL';
1012
import { IEditTableInfo, IWorkspaceTab, IColumnTypes } from '@/typings';
1113
import { DatabaseTypeCode, WorkspaceTabType } from '@/constants';
12-
import i18n from '@/i18n';
13-
import lodash from 'lodash';
14+
import LoadingContent from '@/components/Loading/LoadingContent';
1415
interface IProps {
1516
dataSourceId: number;
1617
databaseName: string;
@@ -93,6 +94,7 @@ export default memo((props: IProps) => {
9394
collations: [],
9495
indexTypes: [],
9596
});
97+
const [isLoading, setIsLoading] = useState<boolean>(false);
9698

9799
function changeTab(item: ITabItem) {
98100
setCurrentTab(item);
@@ -103,7 +105,7 @@ export default memo((props: IProps) => {
103105
getTableDetails();
104106
}
105107
getDatabaseFieldTypeList();
106-
}, []);
108+
}, [])
107109

108110
// 获取数据库字段类型列表
109111
const getDatabaseFieldTypeList = () => {
@@ -153,7 +155,7 @@ export default memo((props: IProps) => {
153155
indexTypes,
154156
});
155157
});
156-
};
158+
}
157159

158160
const getTableDetails = (myParams?: { tableNameProps?: string }) => {
159161
const { tableNameProps } = myParams || {};
@@ -166,13 +168,17 @@ export default memo((props: IProps) => {
166168
schemaName,
167169
refresh: true,
168170
};
171+
setIsLoading(true);
169172
sqlService.getTableDetails(params).then((res) => {
170173
const newTableDetails = lodash.cloneDeep(res);
171174
setTableDetails(newTableDetails || {});
172175
setOldTableDetails(res);
173-
});
176+
})
177+
.finally(()=>{
178+
setIsLoading(false);
179+
})
174180
}
175-
};
181+
}
176182

177183
function submit() {
178184
if (baseInfoRef.current && columnListRef.current && indexListRef.current) {
@@ -218,7 +224,7 @@ export default memo((props: IProps) => {
218224
},
219225
});
220226
}
221-
};
227+
}
222228

223229
return (
224230
<Context.Provider
@@ -232,7 +238,7 @@ export default memo((props: IProps) => {
232238
databaseType,
233239
}}
234240
>
235-
<div className={classnames(styles.box)}>
241+
<LoadingContent coverLoading isLoading={isLoading} className={classnames(styles.box)}>
236242
<div className={styles.header}>
237243
<div className={styles.tabList} style={{ '--i': currentTab.index } as any}>
238244
{tabList.map((item) => {
@@ -262,7 +268,8 @@ export default memo((props: IProps) => {
262268
);
263269
})}
264270
</div>
265-
</div>
271+
</LoadingContent>
272+
266273
<Modal
267274
title={i18n('editTable.title.sqlPreview')}
268275
open={!!viewSqlModal}

chat2db-client/src/components/Console/MonacoEditor/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function MonacoEditor(props: IProps, ref: ForwardedRef<IExportRefFunction>) {
160160

161161
const colors = {
162162
'editor.lineHighlightBackground': colorPrimary + '14', // 当前行背景色
163-
'editor.selectionBackground': colorPrimary + '20', // 选中文本的背景色
163+
'editor.selectionBackground': colorPrimary + '50', // 选中文本的背景色
164164
// 'editorLineNumber.foreground': colorPrimary, // 行号颜色
165165
'editorLineNumber.activeForeground': colorPrimary, // 当前行号颜色
166166
// 'editorCursor.foreground': colorPrimary, // 光标颜色

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function MyNotification() {
117117
onCancel={() => {
118118
setOpen(false);
119119
}}
120+
zIndex={99999}
120121
>
121122
<div className={styles.errorDetail}>{props?.errorDetail}</div>
122123
</Modal>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default memo<IProps>((props) => {
7272
<div className={classnames(styles.iconBox, { [styles.failureIconBox]: item.status !== 'success' })}>
7373
<Iconfont code="&#xe650;" />
7474
</div>
75-
<span className={styles.timeSpan}>[2023-10-15 14:50:29]</span>
75+
<span className={styles.timeSpan}>[{item.useTime}]</span>
7676
{!!item.operationRows && <span>{item.operationRows} rows</span>}
7777
{!!item.useTime && <span>affected in {item.useTime} ms</span>}
7878
</div>

chat2db-client/src/components/SearchResult/RightClickMenu/index.tsx

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,87 @@
1-
import React, { memo } from 'react';
1+
import React, { memo, useMemo } from 'react';
22
import { Dropdown } from 'antd';
33
import i18n from '@/i18n';
44
import MenuLabel from '@/components/MenuLabel';
55

66
interface IProps {
77
className?: string;
88
children?: React.ReactNode;
9+
menuList: IMenu[]
10+
}
11+
12+
export interface IMenu {
13+
key: string;
14+
callback?: () => void;
15+
children?: {
16+
callback: () => void;
17+
}[]
18+
}
19+
20+
export enum AllSupportedMenusType {
21+
CopyCell = 'copy-cell',
22+
CopyRow = 'copy-row',
23+
CloneRow = 'clone-row',
24+
DeleteRow = 'delete-row',
925
}
1026

1127
export default memo<IProps>((props) => {
12-
const { children } = props;
13-
const items = [
14-
{
28+
const { children, menuList } = props;
29+
const allSupportedMenus = {
30+
[AllSupportedMenusType.CopyCell]: {
1531
label: <MenuLabel icon="&#xec7a;" label="拷贝" />,
16-
key: '0',
32+
key: AllSupportedMenusType.CopyCell,
1733
},
18-
{
34+
[AllSupportedMenusType.CopyRow]: {
1935
label: <MenuLabel icon="&#xec7a;" label="拷贝行" />,
20-
key: '1',
36+
key: AllSupportedMenusType.CopyRow,
2137
children: [
2238
{
2339
label: 'Insert 语句',
24-
key: '1-1',
25-
onClick: () => {},
40+
key: 'copy-row-1',
2641
},
2742
{
2843
label: 'Update 语句',
29-
key: '1-2',
30-
onClick: () => {},
44+
key: 'copy-row-2',
3145
},
3246
{
3347
label: '制表符分隔值(数据)',
34-
key: '1-3',
35-
onClick: () => {},
48+
key: 'copy-row-3',
3649
},
3750
{
3851
label: '制表符分隔值(字段名)',
39-
key: '1-4',
40-
onClick: () => {},
52+
key: 'copy-row-4',
4153
},
4254
{
4355
label: '制表符分隔值(字段名和数据)',
44-
key: '1-5',
45-
onClick: () => {},
56+
key: 'copy-row-5',
4657
},
4758
]
4859
},
49-
{
60+
[AllSupportedMenusType.CloneRow]: {
5061
label: <MenuLabel icon="&#xec7a;" label="克隆行" />,
51-
key: '2',
52-
onClick: () => {},
62+
key: AllSupportedMenusType.CloneRow,
5363
},
54-
{
64+
65+
[AllSupportedMenusType.DeleteRow]: {
5566
label: <MenuLabel icon="&#xe6a7;" label="删除行" />,
56-
key: '3',
57-
onClick: () => {},
58-
},
59-
]
67+
key: AllSupportedMenusType.DeleteRow,
68+
}
69+
}
70+
71+
const items = useMemo(()=>{
72+
return menuList.map((menu) => {
73+
return {
74+
...allSupportedMenus[menu.key],
75+
onClick: menu.callback,
76+
children: menu.children?.map((child,index) => {
77+
return {
78+
...allSupportedMenus[menu.key]['children'][index],
79+
onClick: child.callback,
80+
}
81+
})
82+
}
83+
})
84+
}, [menuList])
6085

6186
return <Dropdown menu={{ items }} trigger={["contextMenu"]} >
6287
{children}

chat2db-client/src/components/SearchResult/TableBox/index.less

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
flex-direction: column;
2424
:global {
2525
.art-table {
26-
table colgroup col {
27-
min-width: 120px;
28-
}
2926
table colgroup col:nth-of-type(1) {
3027
min-width: 60px;
3128
}
@@ -80,6 +77,11 @@
8077
.art-table-header-cell {
8178
padding: 0px 4px;
8279
}
80+
.art-table-header-row .art-table-header-cell:nth-of-type(1){
81+
.resize-handle{
82+
display: none;
83+
}
84+
}
8385
}
8486
}
8587

@@ -247,6 +249,9 @@
247249
.tableHoverBox {
248250
background-color: var(--color-primary-hover);
249251
}
252+
.cellValueNull {
253+
color: var(--color-bg-base);
254+
}
250255
}
251256
.tableItemSuccess {
252257
background-color: var(--color-success-bg);

0 commit comments

Comments
 (0)