Skip to content

Commit 2244e2a

Browse files
committed
merge
2 parents ac19fc6 + ebbc1fd commit 2244e2a

17 files changed

Lines changed: 840 additions & 217 deletions

File tree

chat2db-client/src/components/Console/ChatInput/index.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
.tableSelectBlock {
4444
// margin-right: 8px;
4545
cursor: pointer;
46-
padding: 4px;
47-
border-radius: 4px 12px;
46+
padding: 4px 8px;
47+
border-radius: 8px;
4848

4949
&:hover {
5050
background-color: var(--color-bg-subtle);

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

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { ChangeEvent, useEffect, useState } from 'react';
22
import styles from './index.less';
33
import AIImg from '@/assets/img/ai.svg';
4-
import { Button, Checkbox, Dropdown, Input, Modal, Popover, Select, Spin } from 'antd';
4+
import { Button, Checkbox, Dropdown, Input, Modal, Popover, Select, Spin, Tooltip, Radio, Space } from 'antd';
55
import i18n from '@/i18n/';
66
import Iconfont from '@/components/Iconfont';
77
import { WarningOutlined } from '@ant-design/icons';
@@ -12,12 +12,14 @@ interface IProps {
1212
value?: string;
1313
result?: string;
1414
tables?: string[];
15+
syncTableModel: number;
1516
selectedTables?: string[];
1617
remainingUse?: IRemainingUse;
1718
aiType: AiSqlSourceType;
1819
remainingBtnLoading: boolean;
1920
disabled?: boolean;
2021
onPressEnter: (value: string) => void;
22+
onSelectTableSyncModel: (model: number) => void;
2123
onSelectTables?: (tables: string[]) => void;
2224
onClickRemainBtn: Function;
2325
}
@@ -37,31 +39,45 @@ const ChatInput = (props: IProps) => {
3739
};
3840

3941
const renderSelectTable = () => {
40-
const { tables, selectedTables, onSelectTables } = props;
42+
const { tables, syncTableModel, onSelectTableSyncModel, selectedTables, onSelectTables } = props;
4143
const options = (tables || []).map((t) => ({ value: t, label: t }));
4244
return (
4345
<div className={styles.aiSelectedTable}>
44-
<span className={styles.aiSelectedTableTips}>
45-
{/* <WarningOutlined style={{color: 'yellow'}}/> */}
46-
{i18n('chat.input.remain.tooltip')}
47-
</span>
48-
<Select
49-
showSearch
50-
mode="multiple"
51-
allowClear
52-
options={options}
53-
placeholder={i18n('chat.input.tableSelect.placeholder')}
54-
value={selectedTables}
55-
onChange={(v) => {
56-
onSelectTables && onSelectTables(v);
57-
}}
58-
/>
46+
<Radio.Group
47+
onChange={(v) => onSelectTableSyncModel(v.target.value)}
48+
value={syncTableModel}
49+
style={{ marginBottom: '8px' }}
50+
>
51+
<Space direction="horizontal">
52+
<Radio value={0}>自动</Radio>
53+
<Radio value={1}>手动</Radio>
54+
</Space>
55+
</Radio.Group>
56+
{syncTableModel === 0 ? (
57+
i18n('chat.input.syncTable.tips')
58+
) : (
59+
<>
60+
<span className={styles.aiSelectedTableTips}>{i18n('chat.input.remain.tooltip')}</span>
61+
<Select
62+
showSearch
63+
mode="multiple"
64+
allowClear
65+
options={options}
66+
placeholder={i18n('chat.input.tableSelect.placeholder')}
67+
value={selectedTables}
68+
onChange={(v) => {
69+
onSelectTables && onSelectTables(v);
70+
}}
71+
/>
72+
</>
73+
)}
5974
</div>
6075
);
6176
};
6277

6378
const renderSuffix = () => {
64-
const remainCnt = props?.remainingUse?.remainingUses ?? '-';
79+
// const remainCnt = props?.remainingUse?.remainingUses ?? '-';
80+
const hasBubble = localStorage.getItem('syncTableBubble');
6581
return (
6682
<div className={styles.suffixBlock}>
6783
<Button
@@ -75,11 +91,22 @@ const ChatInput = (props: IProps) => {
7591
>
7692
<Iconfont code="&#xe643;" className={styles.enterIcon} />
7793
</Button>
78-
<div className={styles.tableSelectBlock}>
79-
<Popover content={renderSelectTable()} placement="bottom">
80-
<Iconfont code="&#xe618;" />
81-
</Popover>
82-
</div>
94+
<Tooltip
95+
title={<span style={{ color: window._AppThemePack.colorText }}>{i18n('chat.input.syncTable.tempTips')}</span>}
96+
defaultOpen={!hasBubble}
97+
color={window._AppThemePack.colorBgBase}
98+
trigger={'click'}
99+
onOpenChange={() => {
100+
localStorage.setItem('syncTableBubble', 'true');
101+
}}
102+
>
103+
<div className={styles.tableSelectBlock}>
104+
<Popover content={renderSelectTable()} placement="bottom">
105+
<Iconfont code="&#xe618;" />
106+
</Popover>
107+
</div>
108+
</Tooltip>
109+
83110
{/* {props.aiType === AiSqlSourceType.CHAT2DBAI && (
84111
<Spin spinning={!!props.remainingBtnLoading} size="small">
85112
<div
@@ -110,6 +137,6 @@ const ChatInput = (props: IProps) => {
110137
/>
111138
</div>
112139
);
113-
}
140+
};
114141

115142
export default ChatInput;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function Console(props: IProps) {
9393
const chatResult = useRef('');
9494
const editorRef = useRef<IExportRefFunction>();
9595
const [selectedTables, setSelectedTables] = useState<string[]>([]);
96+
const [syncTableModel, setSyncTableModel] = useState<number>(0);
9697
const [isLoading, setIsLoading] = useState(false);
9798
const [aiContent, setAiContent] = useState('');
9899
const [isAiDrawerOpen, setIsAiDrawerOpen] = useState(false);
@@ -233,7 +234,7 @@ function Console(props: IProps) {
233234
dataSourceId,
234235
databaseName,
235236
schemaName,
236-
tableNames: selectedTables,
237+
tableNames: syncTableModel ? selectedTables : null,
237238
});
238239

239240
const handleMessage = (message: string) => {
@@ -429,6 +430,8 @@ function Console(props: IProps) {
429430
setSelectedTables(tables);
430431
}}
431432
onClickRemainBtn={handleClickRemainBtn}
433+
syncTableModel={syncTableModel}
434+
onSelectTableSyncModel={(model: number) => setSyncTableModel(model)}
432435
/>
433436
)}
434437
{/* <div key={uuid()}>{chatContent.current}</div> */}

0 commit comments

Comments
 (0)