Skip to content

Commit 5487c23

Browse files
committed
fix: Optimize sync table
1 parent 74d0ff6 commit 5487c23

4 files changed

Lines changed: 44 additions & 33 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: 8px;
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: 33 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, Tooltip, Radio } 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';
@@ -43,34 +43,41 @@ const ChatInput = (props: IProps) => {
4343
const options = (tables || []).map((t) => ({ value: t, label: t }));
4444
return (
4545
<div className={styles.aiSelectedTable}>
46-
<Radio.Group onChange={(v) => onSelectTableSyncModel(v.target.value)} value={syncTableModel}>
47-
<Radio value={0}>{i18n('chat.input.syncTable.tips')}</Radio>
48-
<Radio value={1} style={{ marginTop: '8px', display: 'flex' }}>
49-
<>
50-
<span className={styles.aiSelectedTableTips}>
51-
{/* <WarningOutlined style={{color: 'yellow'}}/> */}
52-
{i18n('chat.input.remain.tooltip')}
53-
</span>
54-
<Select
55-
showSearch
56-
mode="multiple"
57-
allowClear
58-
options={options}
59-
placeholder={i18n('chat.input.tableSelect.placeholder')}
60-
value={selectedTables}
61-
onChange={(v) => {
62-
onSelectTables && onSelectTables(v);
63-
}}
64-
/>
65-
</>
66-
</Radio>
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>
6755
</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+
)}
6874
</div>
6975
);
7076
};
7177

7278
const renderSuffix = () => {
7379
// const remainCnt = props?.remainingUse?.remainingUses ?? '-';
80+
const hasBubble = localStorage.getItem('syncTableBubble');
7481
return (
7582
<div className={styles.suffixBlock}>
7683
<Button
@@ -85,8 +92,10 @@ const ChatInput = (props: IProps) => {
8592
<Iconfont code="&#xe643;" className={styles.enterIcon} />
8693
</Button>
8794
<Tooltip
88-
title="🎉上线自动同步所有表功能"
89-
open={!localStorage.getItem('syncTableBubble')}
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'}
9099
onOpenChange={() => {
91100
localStorage.setItem('syncTableBubble', 'true');
92101
}}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
export default {
22
'chat.input.remain': '{1} remaining',
3-
'chat.input.tableSelect.placeholder':'Please choose tables',
4-
'chat.input.tableSelect.error.TooManyTable':'You can only select up to 8 tables',
3+
'chat.input.tableSelect.placeholder': 'Please choose tables',
4+
'chat.input.tableSelect.error.TooManyTable': 'You can only select up to 8 tables',
55
'chat.input.remain.dialog.tips':
6-
'Subscribe our official WeChat account, send 推广 to get more chances to experience.',
7-
"chat.input.syncTable.tips":'Mode One: Automatically synchronize all tables to the AI context',
8-
'chat.input.remain.tooltip': 'Mode Two: Table schema added to prompt.',
6+
'Subscribe our official WeChat account, send 推广 to get more chances to experience.',
7+
'chat.input.syncTable.tips': 'The automatically synchronize all table structures to the AI context',
8+
'chat.input.remain.tooltip': 'The manually selected table will be synchronized to the AI context',
9+
'chat.input.syncTable.tempTips': '🎉Update: Automatically synchronize all table structures to the AI context',
910
};

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
'chat.input.tableSelect.placeholder': '请选择表',
44
'chat.input.tableSelect.error.TooManyTable': '最多选择8张表',
55
'chat.input.remain.dialog.tips': '关注公众号,发送"推广"获取更多体验次数',
6-
'chat.input.syncTable.tips': '模式一: 自动同步所有表给AI上下文',
7-
'chat.input.remain.tooltip': '模式二: 选中表的schema将会被添加到prompt中',
6+
'chat.input.syncTable.tips': '自动同步所有表结构给AI上下文',
7+
'chat.input.remain.tooltip': '手动选中的表的结构将会同步给AI上下文',
8+
'chat.input.syncTable.tempTips': '🎉上线:自动同步所有表结构到AI上下文',
89
};

0 commit comments

Comments
 (0)