fix:Scroll bar width Auto-save bug

This commit is contained in:
shanhexi
2023-10-19 09:51:52 +08:00
parent 27cbf8bb91
commit 6fe3f9621d
4 changed files with 41 additions and 20 deletions

View File

@ -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!,

View File

@ -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;
}

View File

@ -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) {

View File

@ -18,8 +18,8 @@ input:-webkit-autofill {
}
::-webkit-scrollbar {
width: 4px;
height: 4px;
width: 6px;
height: 6px;
}