diff --git a/chat2db-client/src/components/Console/index.tsx b/chat2db-client/src/components/Console/index.tsx index 2eb830ba..ace767ab 100644 --- a/chat2db-client/src/components/Console/index.tsx +++ b/chat2db-client/src/components/Console/index.tsx @@ -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) { })); 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) { } } 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) { }, [isActive]); function timingAutoSave() { - // 如果没有初始化那就不自动保存 - if (!initializeSuccessful.current) { - return; - } timerRef.current = setInterval(() => { indexedDB.updateData('chat2db', 'workspaceConsoleDDL', { consoleId: executeParams.consoleId!, diff --git a/chat2db-client/src/components/SearchResult/TableBox/index.less b/chat2db-client/src/components/SearchResult/TableBox/index.less index df610102..68993c05 100644 --- a/chat2db-client/src/components/SearchResult/TableBox/index.less +++ b/chat2db-client/src/components/SearchResult/TableBox/index.less @@ -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; } diff --git a/chat2db-client/src/components/SearchResult/TableBox/index.tsx b/chat2db-client/src/components/SearchResult/TableBox/index.tsx index 4b08195b..ebd849b2 100644 --- a/chat2db-client/src/components/SearchResult/TableBox/index.tsx +++ b/chat2db-client/src/components/SearchResult/TableBox/index.tsx @@ -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) { diff --git a/chat2db-client/src/styles/global.less b/chat2db-client/src/styles/global.less index 1fc431b5..fee203c5 100644 --- a/chat2db-client/src/styles/global.less +++ b/chat2db-client/src/styles/global.less @@ -18,8 +18,8 @@ input:-webkit-autofill { } ::-webkit-scrollbar { - width: 4px; - height: 4px; + width: 6px; + height: 6px; }