Skip to content

Commit bbacf38

Browse files
committed
Click Save and save to the server automatically
1 parent 1b5e40b commit bbacf38

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • chat2db-client/src/components/Console

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
173173
};
174174
}, [isActive]);
175175

176-
function timingAutoSave() {
176+
function timingAutoSave(status?: ConsoleStatus) {
177+
if (timerRef.current) {
178+
clearInterval(timerRef.current);
179+
}
177180
timerRef.current = setInterval(() => {
178-
if(executeParams.status === ConsoleStatus.RELEASE){
181+
if(executeParams.status === ConsoleStatus.RELEASE || status === ConsoleStatus.RELEASE){
179182
const p: any = {
180183
id: executeParams.consoleId,
181184
ddl: editorRef?.current?.getAllContent(),
@@ -188,7 +191,7 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
188191
userId: getCookie('CHAT2DB.USER_ID'),
189192
});
190193
}
191-
}, 2000);
194+
}, 5000);
192195
}
193196

194197
const tableListName = useMemo(() => {
@@ -388,6 +391,7 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
388391
indexedDB.deleteData('chat2db', 'workspaceConsoleDDL', executeParams.consoleId!);
389392
message.success(i18n('common.tips.saveSuccessfully'));
390393
props.onConsoleSave && props.onConsoleSave();
394+
timingAutoSave(ConsoleStatus.RELEASE);
391395
});
392396
};
393397

0 commit comments

Comments
 (0)