Skip to content

Commit 2682bea

Browse files
author
fanjin.fjy
committed
fix conflict
1 parent a89dca8 commit 2682bea

10 files changed

Lines changed: 287 additions & 151 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"echarts",
1111
"favicons",
1212
"iconfont",
13+
"monaco",
1314
"nsis",
1415
"pgsql",
1516
"Sercurity",

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

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum IPromptTypeText {
3434
export type IAppendValue = {
3535
text: any;
3636
range?: IRangeType;
37-
}
37+
};
3838

3939
interface IProps {
4040
/** 是否是活跃的console,用于快捷键 */
@@ -44,23 +44,34 @@ interface IProps {
4444
/** 是否开启AI输入 */
4545
hasAiChat: boolean;
4646
/** 是否可以开启SQL转到自然语言的相关ai操作 */
47-
hasAi2Lang: boolean;
48-
/** 运行或保存sql需要的父级参数 */
47+
hasAi2Lang?: boolean;
48+
hasSaveBtn?: boolean;
49+
value?: string;
50+
onChangeValue?: Function;
4951
executeParams: {
50-
databaseName: string;
51-
dataSourceId: number;
52-
type: DatabaseTypeCode;
53-
consoleId: number;
52+
databaseName?: string;
53+
dataSourceId?: number;
54+
type?: DatabaseTypeCode;
55+
consoleId?: number;
5456
schemaName?: string;
55-
consoleName: string;
57+
consoleName?: string;
5658
};
5759
onExecuteSQL: (value: any) => void;
5860
workspaceModel: IWorkspaceModelType;
5961
dispatch: any;
6062
}
6163

62-
function Console(props: IProps, ref: any) {
63-
const { hasAiChat = true, executeParams, appendValue, isActive, dispatch } = props;
64+
function Console(props: IProps) {
65+
const {
66+
hasAiChat = true,
67+
executeParams,
68+
appendValue,
69+
isActive,
70+
dispatch,
71+
hasSaveBtn = true,
72+
value,
73+
onChangeValue,
74+
} = props;
6475
const uid = useMemo(() => uuidv4(), []);
6576
const chatResult = useRef('');
6677
const editorRef = useRef<IExportRefFunction>();
@@ -70,7 +81,7 @@ function Console(props: IProps, ref: any) {
7081
if (appendValue) {
7182
editorRef?.current?.setValue(appendValue.text, appendValue.range);
7283
}
73-
}, [appendValue])
84+
}, [appendValue]);
7485

7586
const onPressChatInput = (value: string) => {
7687
const params = formatParams({
@@ -99,7 +110,7 @@ function Console(props: IProps, ref: any) {
99110
};
100111

101112
const closeEventSource = connectToEventSource({
102-
url: `/api/ai/chat1?${params}`,
113+
url: `/api/ai/chat?${params}`,
103114
uid,
104115
onMessage: handleMessage,
105116
onError: handleError,
@@ -133,41 +144,44 @@ function Console(props: IProps, ref: any) {
133144
};
134145

135146
const saveConsole = (value?: string) => {
136-
const a = editorRef.current?.getAllContent()
147+
const a = editorRef.current?.getAllContent();
137148

138149
let p = {
139150
id: executeParams.consoleId,
140-
status: ConsoleStatus.RELEASE
151+
status: ConsoleStatus.RELEASE,
141152
};
142153
historyServer.updateSavedConsole(p).then((res) => {
143154
message.success('保存成功');
144155
dispatch({
145-
type: 'workspace/fetchGetSavedConsole'
146-
})
156+
type: 'workspace/fetchGetSavedConsole',
157+
});
147158
// notification.open({
148159
// type: 'success',
149160
// message: '保存成功',
150161
// });
151162
});
152163
};
153164

154-
const addAction = useMemo(() => ([
155-
{
156-
id: 'explainSQL',
157-
label: '解释SQL',
158-
action: (selectedText: string) => handleAIRelativeOperation(IPromptType.SQL_EXPLAIN, selectedText),
159-
},
160-
{
161-
id: 'optimizeSQL',
162-
label: '优化SQL',
163-
action: (selectedText: string) => handleAIRelativeOperation(IPromptType.SQL_OPTIMIZER, selectedText),
164-
},
165-
{
166-
id: 'changeSQL',
167-
label: 'SQL转化',
168-
action: (selectedText: string) => handleAIRelativeOperation(IPromptType.SQL_2_SQL, selectedText),
169-
},
170-
]), [])
165+
const addAction = useMemo(
166+
() => [
167+
{
168+
id: 'explainSQL',
169+
label: '解释SQL',
170+
action: (selectedText: string) => handleAIRelativeOperation(IPromptType.SQL_EXPLAIN, selectedText),
171+
},
172+
{
173+
id: 'optimizeSQL',
174+
label: '优化SQL',
175+
action: (selectedText: string) => handleAIRelativeOperation(IPromptType.SQL_OPTIMIZER, selectedText),
176+
},
177+
{
178+
id: 'changeSQL',
179+
label: 'SQL转化',
180+
action: (selectedText: string) => handleAIRelativeOperation(IPromptType.SQL_2_SQL, selectedText),
181+
},
182+
],
183+
[],
184+
);
171185

172186
const handleAIRelativeOperation = (id: string, selectedText: string) => {
173187
console.log('handleAIRelativeOperation', id, selectedText);
@@ -191,12 +205,14 @@ function Console(props: IProps, ref: any) {
191205
<div className={styles.console_options_wrapper}>
192206
<div className={styles.console_options_left}>
193207
<Button type="primary" className={styles.run_button} onClick={executeSQL}>
194-
<Iconfont code='&#xe637;' />
208+
<Iconfont code="&#xe637;" />
195209
RUN
196210
</Button>
197-
<Button type="default" className={styles.save_button} onClick={() => { saveConsole() }}>
198-
SAVE
199-
</Button>
211+
{hasSaveBtn && (
212+
<Button type="default" className={styles.save_button} onClick={() => saveConsole()}>
213+
SAVE
214+
</Button>
215+
)}
200216
</div>
201217
<Button
202218
type="text"
@@ -213,7 +229,7 @@ function Console(props: IProps, ref: any) {
213229
}
214230

215231
const dvaModel = connect(({ workspace }: { workspace: IWorkspaceModelType }) => ({
216-
workspaceModel: workspace
217-
}))
232+
workspaceModel: workspace,
233+
}));
218234

219235
export default dvaModel(Console);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if (__ENV === 'local') {
99
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
1010
@font-face {
1111
font-family: 'iconfont'; /* Project id 3633546 */
12-
src: url('//at.alicdn.com/t/c/font_3633546_cvbwebl7aa.woff2?t=1687877639500') format('woff2'),
13-
url('//at.alicdn.com/t/c/font_3633546_cvbwebl7aa.woff?t=1687877639500') format('woff'),
14-
url('//at.alicdn.com/t/c/font_3633546_cvbwebl7aa.ttf?t=1687877639500') format('truetype');
12+
src: url('//at.alicdn.com/t/a/font_3633546_uuxqox310h.woff2?t=1687943954391') format('woff2'),
13+
url('//at.alicdn.com/t/a/font_3633546_uuxqox310h.woff?t=1687943954391') format('woff'),
14+
url('//at.alicdn.com/t/a/font_3633546_uuxqox310h.ttf?t=1687943954391') format('truetype');
1515
}
1616
`
1717
let style = document.createElement("style");

chat2db-client/src/models/connection.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import { getCurConnection } from '@/utils/localStorage';
77
/**
88
* 数据源相关 - 链接池、数据库、schema、表
99
*/
10-
export interface ConnectionModelState {
10+
export interface IConnectionModelState {
1111
curConnection?: IConnectionDetails;
1212
connectionList: IConnectionDetails[];
1313
}
1414

1515
export interface IConnectionModelType {
1616
namespace: 'connection';
17-
state: ConnectionModelState;
17+
state: IConnectionModelState;
1818
reducers: {
1919
// 设置连接池列表
20-
setConnectionList: Reducer<ConnectionModelState>;
21-
setCurConnection: Reducer<ConnectionModelState>;
20+
setConnectionList: Reducer<IConnectionModelState>;
21+
setCurConnection: Reducer<IConnectionModelState>;
2222
};
2323
effects: {
2424
fetchConnectionList: Effect;

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
}
9999

100100

101-
.emptyData {
101+
.emptyChartBlock {
102102
width: 100%;
103103
padding: 20px 0;
104104
display: flex;
@@ -108,20 +108,45 @@
108108
}
109109

110110
.emptyDataImage {
111-
margin-bottom: 8px;
111+
font-size: 56px;
112+
color: #666666;
113+
margin-bottom: 16px;
114+
}
115+
116+
.emptyDataText {
117+
font-size: 12px;
118+
color: rgba(0, 0, 0, 0.40);
119+
line-height: 14px;
120+
margin-bottom: 40px;
112121
}
113122

114123

124+
115125
.editorBlock {
116126
display: flex;
117-
border: 1px solid #eee;
127+
// border: 1px solid #eee;
118128
flex-wrap: wrap;
119129
}
120130

121131
.editor {
122132
flex: 1;
123-
border-right: 1px solid #eee;
133+
border: 1px solid #eee;
124134
min-width: 320px;
125135
min-height: 320px;
136+
max-height: 640px;
137+
display: flex;
138+
flex-direction: column;
139+
position: relative;
140+
}
141+
142+
.dataSourceSelect {
143+
position: absolute;
144+
bottom: 8px;
145+
right: 24px;
146+
}
126147

148+
.chartParamsForm{
149+
min-width: 280px;
150+
padding: 20px;
151+
border: 1px solid #eee;
127152
}

0 commit comments

Comments
 (0)