Skip to content

Commit 164518d

Browse files
committed
feat:Execute the Record sql Add replication button
1 parent 6746d23 commit 164518d

7 files changed

Lines changed: 88 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 3.1.16
2+
3+
`2023-12-25`
4+
5+
**Changelog**
6+
7+
- ⭐【New Features】Execute the Record sql Add replication button
8+
- ⭐【New Features】Run record sql to open the console directly
9+
- ⭐【New Features】The SQL column on the right of execution record and save can be expanded and dragged
10+
- 🐞【Fixed】Some databases could not display the Database/Schema structure
11+
112
## 3.1.15
213

314
`2023-12-20`
@@ -58,9 +69,9 @@
5869
- 🔥🔥【Optimize】Optimized the tab switchover problem
5970
- ⚡️ 【Optimize】All nodes are supported. The name of each node can be copied
6071
- ⚡️【Optimize】The sql console input box supports switching databases, and will not change when the left database is switched
61-
- ⭐ 【New function】Save records moved to the right toolbar, you can directly modify the name in the list
62-
- ⭐【New feature】Support mongoDB
63-
- ⭐【New function】Support for viewing all tables
72+
- ⭐ 【New Features】Save records moved to the right toolbar, you can directly modify the name in the list
73+
- ⭐【New Features】Support mongoDB
74+
- ⭐【New Features】Support for viewing all tables
6475

6576
## 3.0.14
6677

CHANGELOG_CN.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 3.1.16
2+
3+
`2023-12-25`
4+
5+
**更新日志**
6+
7+
- ⭐【新功能】执行记录sql添加复制按钮
8+
- ⭐【新功能】执行记录sql可直接打开控制台
9+
- ⭐【新功能】右侧执行记录、保存SQL栏展开大小可拖动
10+
- 🐞【修复】部分数据库无法显示数据库/Schema结构的问题
11+
112
## 3.1.15
213

314
`2023-12-20`
@@ -6,8 +17,6 @@
617

718
- 🐞【修复】每次打开应用时,偶现无法选择数据库问题
819
- 🐞【修复】兼容老数据类型无法显示删除问题
9-
- 🐞【修复】部分数据库无法显示数据库/Schema结构的问题
10-
1120

1221
## 3.1.14
1322

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

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@
3636
margin-right: 4px;
3737
font-weight: 500;
3838
}
39-
.iconBox {
39+
.timeBoxIcon {
4040
transform: rotate(90deg);
4141
margin-right: 4px;
4242
i {
4343
color: var(--color-success);
4444
}
45+
&:hover {
46+
cursor: default;
47+
background-color: transparent;
48+
}
4549
}
4650
.failureIconBox {
4751
i {
@@ -51,16 +55,26 @@
5155
> div {
5256
line-height: 22px;
5357
}
54-
.sqlPlace {
55-
color: var(--color-warning-text);
56-
}
57-
.sqlPlace,
58-
.sqlBox {
59-
padding-left: 18px;
60-
}
6158
padding: 2px 0px;
6259
}
6360
}
64-
.sqlBox {
61+
62+
.executedDatabaseBox,.sqlBox{
63+
display: flex;
64+
.iconBox{
65+
margin-right: 4px;
66+
flex-shrink: 0;
67+
}
68+
}
69+
70+
.executedDatabaseBox{
71+
.executedDatabase {
72+
color: var(--color-warning-text);
73+
white-space: nowrap;
74+
}
6575
}
76+
// .sqlBox {
77+
// .sqlContent{
78+
// }
79+
// }
6680
}

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

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import ScrollLoading from '@/components/ScrollLoading';
66
import historyService, { IHistoryRecord } from '@/service/history';
77
import * as monaco from 'monaco-editor';
88
import i18n from '@/i18n';
9+
import { copy } from '@/utils';
10+
import { createConsole } from '@/pages/main/workspace/store/console';
11+
import { Popover } from 'antd';
912

1013
interface IProps {
1114
className?: string;
@@ -34,7 +37,8 @@ export default memo<IProps>((props) => {
3437
const promiseList = res.data.map((item) => {
3538
return new Promise((resolve) => {
3639
// 不换行
37-
const ddl = (item.ddl || '')?.replace(/\n/g, ' ');
40+
// const ddl = (item.ddl || '')?.replace(/\n/g, ' ');
41+
const ddl = item.ddl || '';
3842
monaco.editor.colorize(ddl, 'sql', {}).then((_res) => {
3943
resolve({
4044
...item,
@@ -49,6 +53,22 @@ export default memo<IProps>((props) => {
4953
});
5054
};
5155

56+
const copySql = (text: IDatasource['ddl']) => {
57+
copy(text || '');
58+
}
59+
60+
const openSql = (data: IDatasource) => {
61+
createConsole({
62+
ddl: data.ddl || '',
63+
dataSourceId: data.dataSourceId!,
64+
dataSourceName: data.dataSourceName!,
65+
databaseType: data.type!,
66+
databaseName: data.databaseName!,
67+
schemaName: data.schemaName!,
68+
// operationType: WorkspaceTabType,
69+
})
70+
}
71+
5272
return (
5373
<div className={classnames(styles.output, className)}>
5474
<div className={styles.outputTitle}>
@@ -64,19 +84,29 @@ export default memo<IProps>((props) => {
6484
>
6585
<>
6686
{dataSource.map((item, index) => {
67-
const nameList = [item.databaseName, item.schemaName];
87+
const nameList = [item.dataSourceName, item.databaseName, item.schemaName];
6888
return (
6989
<div key={index} className={styles.outputItem}>
7090
<div className={styles.timeBox}>
71-
<div className={classnames(styles.iconBox, { [styles.failureIconBox]: item.status !== 'success' })}>
72-
<Iconfont code="&#xe650;" />
73-
</div>
91+
<Iconfont classNameBox={classnames(styles.timeBoxIcon, { [styles.failureIconBox]: item.status !== 'success' })} box boxSize={20} code="&#xe650;" />
7492
<span className={styles.timeSpan}>[{item.gmtCreate}]</span>
7593
{/* {!!item.operationRows && <span>{item.operationRows} rows</span>} */}
7694
{!!item.useTime && <span>{i18n('common.text.executionTime', item.useTime)}</span>}
7795
</div>
78-
<div className={styles.sqlPlace}>{nameList.filter((name) => name).join(' > ')}</div>
79-
<div className={styles.sqlBox} dangerouslySetInnerHTML={{ __html: item.highlightedCode }} />
96+
<div className={styles.executedDatabaseBox}>
97+
<Popover mouseEnterDelay={0.8} content={i18n('workspace.tips.openExecutiveLogging')}>
98+
<Iconfont classNameBox={styles.iconBox} box boxSize={20} code="&#xe6bb;" onClick={()=>{openSql(item)}} />
99+
</Popover>
100+
<div className={styles.executedDatabase}>
101+
{nameList.filter((name) => name).join(' > ')}
102+
</div>
103+
</div>
104+
<div className={styles.sqlBox}>
105+
<Popover mouseEnterDelay={0.8} content={i18n('common.button.copy')}>
106+
<Iconfont classNameBox={styles.iconBox} box boxSize={20} code="&#xec7a;" onClick={()=>{copySql(item.ddl)}} />
107+
</Popover>
108+
<div className={styles.sqlContent} dangerouslySetInnerHTML={{ __html: item.highlightedCode }} />
109+
</div>
80110
</div>
81111
);
82112
})}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ export default {
3333
'workspace.tree.delete.table.tip': 'Are you sure you want to delete the table {1}?',
3434
'workspace.tips.noConnection': 'You have not created a connection yet',
3535
'workspace.tips.maxConsole': 'You can only open up to 20 consoles',
36+
'workspace.tips.openExecutiveLogging': 'Open this executive logging',
3637
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ export default {
3232
'workspace.tree.delete.table.tip': '确定要删除表{1}吗?',
3333
'workspace.tips.noConnection': '你还没有创建连接',
3434
'workspace.tips.maxConsole': '最多只能打开20个控制台',
35+
'workspace.tips.openExecutiveLogging': '打开执行记录',
3536
};

chat2db-client/src/service/history.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface IHistoryRecord {
7171
/**
7272
* ddl语言类型
7373
*/
74-
type?: null | string;
74+
type?: DatabaseTypeCode | null;
7575
/**
7676
* 使用时长
7777
*/

0 commit comments

Comments
 (0)