mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-06 18:24:29 +08:00
fix:Scroll bar width Auto-save bug
This commit is contained in:
@ -21,7 +21,6 @@ import configService from '@/service/config';
|
||||
// import NewEditor from './NewMonacoEditor';
|
||||
import styles from './index.less';
|
||||
import indexedDB from '@/indexedDB';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
enum IPromptType {
|
||||
NL_2_SQL = 'NL_2_SQL',
|
||||
@ -135,18 +134,7 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
indexedDB
|
||||
.getDataByCursor('chat2db', 'workspaceConsoleDDL', {
|
||||
consoleId: executeParams.consoleId!,
|
||||
userId: getCookie('CHAT2DB.USER_ID'),
|
||||
})
|
||||
.then((res: any) => {
|
||||
const value = res?.[0]?.ddl || '';
|
||||
if (value) {
|
||||
editorRef?.current?.setValue(value, 'reset');
|
||||
initializeSuccessful.current = true;
|
||||
}
|
||||
});
|
||||
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -166,7 +154,19 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
|
||||
}
|
||||
} else {
|
||||
// 活跃时自动保存
|
||||
timingAutoSave();
|
||||
indexedDB
|
||||
.getDataByCursor('chat2db', 'workspaceConsoleDDL', {
|
||||
consoleId: executeParams.consoleId!,
|
||||
userId: getCookie('CHAT2DB.USER_ID'),
|
||||
})
|
||||
.then((res: any) => {
|
||||
const value = res?.[0]?.ddl || '';
|
||||
if (value) {
|
||||
editorRef?.current?.setValue(value, 'reset');
|
||||
initializeSuccessful.current = true;
|
||||
timingAutoSave();
|
||||
}
|
||||
});
|
||||
}
|
||||
return () => {
|
||||
if (timerRef.current) {
|
||||
@ -176,10 +176,6 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
|
||||
}, [isActive]);
|
||||
|
||||
function timingAutoSave() {
|
||||
// 如果没有初始化那就不自动保存
|
||||
if (!initializeSuccessful.current) {
|
||||
return;
|
||||
}
|
||||
timerRef.current = setInterval(() => {
|
||||
indexedDB.updateData('chat2db', 'workspaceConsoleDDL', {
|
||||
consoleId: executeParams.consoleId!,
|
||||
|
@ -61,6 +61,12 @@
|
||||
.art-table-row{
|
||||
height: 32px;
|
||||
}
|
||||
.art-table-header {
|
||||
background: transparent !important;
|
||||
}
|
||||
.art-table-body-scroll{
|
||||
padding-right: 6px;
|
||||
}
|
||||
.art-table-header-cell{
|
||||
padding: 0px 4px;
|
||||
}
|
||||
|
@ -120,6 +120,25 @@ export default function TableBox(props: ITableProps) {
|
||||
});
|
||||
}, [queryResultData]);
|
||||
|
||||
// 判断art-table-body是否出现了滚动条
|
||||
// useEffect(() => {
|
||||
// const tableBody = document.querySelector('.art-table-body');
|
||||
// const tableHeader = document.querySelector('.art-table-header');
|
||||
// if (!tableBody) {
|
||||
// return;
|
||||
// }
|
||||
// const tableBodyHeight = tableBody.clientHeight;
|
||||
// const tableBoxHeight = tableBoxRef.current?.clientHeight || 0;
|
||||
// if(!tableHeader){
|
||||
// return;
|
||||
// }
|
||||
// if (tableBodyHeight > tableBoxHeight) {
|
||||
// tableHeader.classList.add('art-table-body-scroll');
|
||||
// } else {
|
||||
// tableHeader.classList.remove('art-table-body-scroll');
|
||||
// }
|
||||
// }, [tableData]);
|
||||
|
||||
useEffect(() => {
|
||||
// 每次dataList变化,都需要重新计算tableData
|
||||
if (!columns?.length) {
|
||||
|
@ -18,8 +18,8 @@ input:-webkit-autofill {
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user