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 NewEditor from './NewMonacoEditor';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
import indexedDB from '@/indexedDB';
|
import indexedDB from '@/indexedDB';
|
||||||
import { isEmpty } from 'lodash';
|
|
||||||
|
|
||||||
enum IPromptType {
|
enum IPromptType {
|
||||||
NL_2_SQL = 'NL_2_SQL',
|
NL_2_SQL = 'NL_2_SQL',
|
||||||
@ -135,18 +134,7 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
useEffect(() => {
|
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(() => {
|
useEffect(() => {
|
||||||
@ -166,8 +154,20 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 活跃时自动保存
|
// 活跃时自动保存
|
||||||
|
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();
|
timingAutoSave();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return () => {
|
return () => {
|
||||||
if (timerRef.current) {
|
if (timerRef.current) {
|
||||||
clearInterval(timerRef.current);
|
clearInterval(timerRef.current);
|
||||||
@ -176,10 +176,6 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
|
|||||||
}, [isActive]);
|
}, [isActive]);
|
||||||
|
|
||||||
function timingAutoSave() {
|
function timingAutoSave() {
|
||||||
// 如果没有初始化那就不自动保存
|
|
||||||
if (!initializeSuccessful.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
timerRef.current = setInterval(() => {
|
timerRef.current = setInterval(() => {
|
||||||
indexedDB.updateData('chat2db', 'workspaceConsoleDDL', {
|
indexedDB.updateData('chat2db', 'workspaceConsoleDDL', {
|
||||||
consoleId: executeParams.consoleId!,
|
consoleId: executeParams.consoleId!,
|
||||||
|
@ -61,6 +61,12 @@
|
|||||||
.art-table-row{
|
.art-table-row{
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
.art-table-header {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
.art-table-body-scroll{
|
||||||
|
padding-right: 6px;
|
||||||
|
}
|
||||||
.art-table-header-cell{
|
.art-table-header-cell{
|
||||||
padding: 0px 4px;
|
padding: 0px 4px;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,25 @@ export default function TableBox(props: ITableProps) {
|
|||||||
});
|
});
|
||||||
}, [queryResultData]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
// 每次dataList变化,都需要重新计算tableData
|
// 每次dataList变化,都需要重新计算tableData
|
||||||
if (!columns?.length) {
|
if (!columns?.length) {
|
||||||
|
@ -18,8 +18,8 @@ input:-webkit-autofill {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 4px;
|
width: 6px;
|
||||||
height: 4px;
|
height: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user