Skip to content

Commit 6fe3f96

Browse files
committed
fix:Scroll bar width Auto-save bug
1 parent 27cbf8b commit 6fe3f96

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

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

+14-18
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import configService from '@/service/config';
2121
// import NewEditor from './NewMonacoEditor';
2222
import styles from './index.less';
2323
import indexedDB from '@/indexedDB';
24-
import { isEmpty } from 'lodash';
2524

2625
enum IPromptType {
2726
NL_2_SQL = 'NL_2_SQL',
@@ -135,18 +134,7 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
135134
}));
136135

137136
useEffect(() => {
138-
indexedDB
139-
.getDataByCursor('chat2db', 'workspaceConsoleDDL', {
140-
consoleId: executeParams.consoleId!,
141-
userId: getCookie('CHAT2DB.USER_ID'),
142-
})
143-
.then((res: any) => {
144-
const value = res?.[0]?.ddl || '';
145-
if (value) {
146-
editorRef?.current?.setValue(value, 'reset');
147-
initializeSuccessful.current = true;
148-
}
149-
});
137+
150138
}, []);
151139

152140
useEffect(() => {
@@ -166,7 +154,19 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
166154
}
167155
} else {
168156
// 活跃时自动保存
169-
timingAutoSave();
157+
indexedDB
158+
.getDataByCursor('chat2db', 'workspaceConsoleDDL', {
159+
consoleId: executeParams.consoleId!,
160+
userId: getCookie('CHAT2DB.USER_ID'),
161+
})
162+
.then((res: any) => {
163+
const value = res?.[0]?.ddl || '';
164+
if (value) {
165+
editorRef?.current?.setValue(value, 'reset');
166+
initializeSuccessful.current = true;
167+
timingAutoSave();
168+
}
169+
});
170170
}
171171
return () => {
172172
if (timerRef.current) {
@@ -176,10 +176,6 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
176176
}, [isActive]);
177177

178178
function timingAutoSave() {
179-
// 如果没有初始化那就不自动保存
180-
if (!initializeSuccessful.current) {
181-
return;
182-
}
183179
timerRef.current = setInterval(() => {
184180
indexedDB.updateData('chat2db', 'workspaceConsoleDDL', {
185181
consoleId: executeParams.consoleId!,

chat2db-client/src/components/SearchResult/TableBox/index.less

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
.art-table-row{
6262
height: 32px;
6363
}
64+
.art-table-header {
65+
background: transparent !important;
66+
}
67+
.art-table-body-scroll{
68+
padding-right: 6px;
69+
}
6470
.art-table-header-cell{
6571
padding: 0px 4px;
6672
}

chat2db-client/src/components/SearchResult/TableBox/index.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ export default function TableBox(props: ITableProps) {
120120
});
121121
}, [queryResultData]);
122122

123+
// 判断art-table-body是否出现了滚动条
124+
// useEffect(() => {
125+
// const tableBody = document.querySelector('.art-table-body');
126+
// const tableHeader = document.querySelector('.art-table-header');
127+
// if (!tableBody) {
128+
// return;
129+
// }
130+
// const tableBodyHeight = tableBody.clientHeight;
131+
// const tableBoxHeight = tableBoxRef.current?.clientHeight || 0;
132+
// if(!tableHeader){
133+
// return;
134+
// }
135+
// if (tableBodyHeight > tableBoxHeight) {
136+
// tableHeader.classList.add('art-table-body-scroll');
137+
// } else {
138+
// tableHeader.classList.remove('art-table-body-scroll');
139+
// }
140+
// }, [tableData]);
141+
123142
useEffect(() => {
124143
// 每次dataList变化,都需要重新计算tableData
125144
if (!columns?.length) {

chat2db-client/src/styles/global.less

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ input:-webkit-autofill {
1818
}
1919

2020
::-webkit-scrollbar {
21-
width: 4px;
22-
height: 4px;
21+
width: 6px;
22+
height: 6px;
2323
}
2424

2525

0 commit comments

Comments
 (0)