Skip to content

Commit d9541d9

Browse files
committed
fix:Console and resulting Tabs mouse wheel not scrolling
1 parent 5bfa34c commit d9541d9

12 files changed

Lines changed: 159 additions & 72 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- 🐞【Fixed】Fixed table structure editing floating-point decimal Settings display exception
2626
- 🐞【Fixed】Fixed switching the saved sql on the console will eliminate the problem
2727
- 🐞【Fixed】After multiple tables are paged, the context cannot select a table other than the current page
28+
- 🐞【Fixed】Console and resulting Tabs mouse wheel not scrolling
2829

2930
## 3.0.9
3031

CHANGELOG_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- 🐞【修复】修复表结构编辑浮点数小数位设置显示异常
2828
- 🐞【修复】修复切换控制台保存的sql会消失问题
2929
- 🐞【修复】表多的分页后,上下文选不到当前分页以外的表
30+
- 🐞【修复】console和结果的Tabs鼠标滚轮无法滚动的问题
3031

3132

3233

chat2db-client/src/blocks/DatabaseTableEditor/ColumnList/index.less

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@
8585
// }
8686
// }
8787

88-
.keyBox{
88+
.keyBox {
8989
width: 26px;
9090
height: 26px;
9191
display: flex;
9292
justify-content: center;
9393
align-items: center;
9494
cursor: pointer;
9595
position: relative;
96-
i{
96+
i {
9797
color: var(--color-warning);
9898
}
99-
span{
99+
span {
100100
position: absolute;
101101
font-weight: bold;
102102
right: 4px;
@@ -105,6 +105,10 @@
105105
}
106106
}
107107

108+
.disabledKeyBox {
109+
cursor: default;
110+
}
111+
108112
.operationBar {
109113
display: flex;
110114
justify-content: end;

chat2db-client/src/blocks/DatabaseTableEditor/ColumnList/index.tsx

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useContext, useEffect, useState, useRef, forwardRef, ForwardedRef, useImperativeHandle } from 'react';
22
import styles from './index.less';
3+
import classnames from 'classnames';
34
import { MenuOutlined } from '@ant-design/icons';
45
import { DndContext, type DragEndEvent } from '@dnd-kit/core';
56
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
@@ -221,10 +222,17 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
221222
<div>
222223
<Checkbox
223224
onChange={() => {
225+
if (databaseType === DatabaseTypeCode.SQLITE && record.editStatus !== EditColumnOperationType.Add) {
226+
return null;
227+
}
224228
handelNullable(record);
225229
}}
226230
checked={nullable === NullableType.Null}
227-
disabled={editingConfig?.supportNullable === false || !!record.primaryKey}
231+
disabled={
232+
editingConfig?.supportNullable === false ||
233+
!!record.primaryKey ||
234+
(databaseType === DatabaseTypeCode.SQLITE && record.editStatus !== EditColumnOperationType.Add)
235+
}
228236
/>
229237
</div>
230238
);
@@ -238,8 +246,14 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
238246
return (
239247
<div>
240248
<div
241-
className={styles.keyBox}
249+
className={classnames(styles.keyBox, {
250+
[styles.disabledKeyBox]:
251+
databaseType === DatabaseTypeCode.SQLITE && record.editStatus !== EditColumnOperationType.Add,
252+
})}
242253
onClick={() => {
254+
if (databaseType === DatabaseTypeCode.SQLITE && record.editStatus !== EditColumnOperationType.Add) {
255+
return null;
256+
}
243257
handelPrimaryKey(record);
244258
}}
245259
>
@@ -289,26 +303,29 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
289303

290304
const handelPrimaryKey = (_data: IColumnItemNew) => {
291305
const newData = dataSource.map((item) => {
292-
let primaryKeyOrder:null | number = item.primaryKeyOrder;
306+
let primaryKeyOrder: null | number = item.primaryKeyOrder;
293307

294308
// 取消主键if
295-
if(_data.primaryKey) {
309+
if (_data.primaryKey) {
296310
// 如果取消的时当前的字段,主键顺序为null
297-
if(_data.key === item.key){
311+
if (_data.key === item.key) {
298312
primaryKeyOrder = null;
299-
}else{
313+
} else {
300314
// 如果当前字段是主键,取消主键的时候,比当前字段顺序大的字段顺序-1
301-
if(_data.primaryKeyOrder && item.primaryKeyOrder && item.primaryKeyOrder >= _data.primaryKeyOrder){
302-
primaryKeyOrder = item.primaryKeyOrder - 1;
315+
if (_data.primaryKeyOrder && item.primaryKeyOrder && item.primaryKeyOrder >= _data.primaryKeyOrder) {
316+
primaryKeyOrder = item.primaryKeyOrder - 1;
303317
}
304318
}
305-
}else{
319+
} else {
306320
// 增加主键if
307321
// 增加主键的时候,主键顺序为当前表的最大主键顺序+1
308-
if( _data.key === item.key){
309-
primaryKeyOrder = Math.max(...dataSource.map(i => {
310-
return i.primaryKeyOrder || 0
311-
})) + 1;
322+
if (_data.key === item.key) {
323+
primaryKeyOrder =
324+
Math.max(
325+
...dataSource.map((i) => {
326+
return i.primaryKeyOrder || 0;
327+
}),
328+
) + 1;
312329
}
313330
// 对于当前字段之前的字段,主键顺序不变
314331
}
@@ -335,7 +352,6 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
335352
primaryKeyOrder,
336353
};
337354
});
338-
console.log(newData)
339355
setDataSource(newData);
340356
};
341357

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import sqlService, { IExportParams, IExecuteSqlParams } from '@/service/sql';
2626

2727
// store
2828
import { useCommonStore } from '@/store/common';
29+
import { useWorkspaceStore } from '@/store/workspace';
2930

3031
// 依赖组件
3132
import ExecuteSQL from '@/components/ExecuteSQL';
@@ -141,6 +142,7 @@ export default function TableBox(props: ITableProps) {
141142
setFocusedContent: state.setFocusedContent,
142143
};
143144
});
145+
const activeSearchResult = useWorkspaceStore((state) => state.activeTab.activeSearchResult);
144146

145147
const handleExportSQLResult = async (exportType: ExportTypeEnum, exportSize: ExportSizeEnum) => {
146148
const params: IExportParams = {
@@ -1208,7 +1210,7 @@ export default function TableBox(props: ITableProps) {
12081210

12091211
return (
12101212
<div className={classnames(className, styles.tableBox, { [styles.noDataTableBox]: !tableData.length })}>
1211-
{renderContent()}
1213+
{activeSearchResult.id === queryResultData.uuid && renderContent()}
12121214
<Modal
12131215
title={viewTableCellData?.name}
12141216
open={!!viewTableCellData?.name}

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

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import React, {
1010
Fragment,
1111
} from 'react';
1212
import classnames from 'classnames';
13-
import Tabs,{ ITabItem } from '@/components/Tabs';
13+
import Tabs, { ITabItem } from '@/components/Tabs';
1414
import Iconfont from '@/components/Iconfont';
1515
import StateIndicator from '@/components/StateIndicator';
1616
// import Output from '@/components/Output';
@@ -23,6 +23,7 @@ import i18n from '@/i18n';
2323
import sqlServer, { IExecuteSqlParams } from '@/service/sql';
2424
import { v4 as uuidV4 } from 'uuid';
2525
import { Spin } from 'antd';
26+
import { useWorkspaceStore } from '@/store/workspace';
2627

2728
interface IProps {
2829
className?: string;
@@ -43,10 +44,10 @@ export interface ISearchResultRef {
4344

4445
export default forwardRef((props: IProps, ref: ForwardedRef<ISearchResultRef>) => {
4546
const { className, sql, executeSqlParams } = props;
46-
// const [currentTab, setCurrentTab] = useState<string | number | undefined>();
4747
const [resultDataList, setResultDataList] = useState<IManageResultData[]>();
4848
const [tableLoading, setTableLoading] = useState(false);
4949
const controllerRef = useRef<AbortController>();
50+
const setActiveSearchResult = useWorkspaceStore((state) => state.setActiveSearchResult);
5051

5152
useEffect(() => {
5253
if (sql) {
@@ -73,23 +74,25 @@ export default forwardRef((props: IProps, ref: ForwardedRef<ISearchResultRef>) =
7374

7475
controllerRef.current = new AbortController();
7576
// 获取当前SQL的查询结果
76-
sqlServer.executeSql(executeSQLParams, {
77-
signal: controllerRef.current.signal,
78-
}).then((res) => {
79-
const sqlResult = res.map((_res) => ({
80-
..._res,
81-
uuid: uuidV4(),
82-
}));
83-
84-
setResultDataList(sqlResult);
85-
})
86-
.finally(() => {
87-
setTableLoading(false);
88-
});
77+
sqlServer
78+
.executeSql(executeSQLParams, {
79+
signal: controllerRef.current.signal,
80+
})
81+
.then((res) => {
82+
const sqlResult = res.map((_res) => ({
83+
..._res,
84+
uuid: uuidV4(),
85+
}));
86+
87+
setResultDataList(sqlResult);
88+
})
89+
.finally(() => {
90+
setTableLoading(false);
91+
});
8992
};
9093

91-
const onChange = useCallback(() => {
92-
// setCurrentTab(uuid);
94+
const onChange = useCallback((uuid) => {
95+
setActiveSearchResult(uuid);
9396
}, []);
9497

9598
const renderResult = (queryResultData) => {
@@ -155,7 +158,7 @@ export default forwardRef((props: IProps, ref: ForwardedRef<ISearchResultRef>) =
155158
}, [resultDataList]);
156159

157160
const onEdit = useCallback(
158-
(type: 'add' | 'remove', data:ITabItem[]) => {
161+
(type: 'add' | 'remove', data: ITabItem[]) => {
159162
if (type === 'remove') {
160163
const newResultDataList = resultDataList?.filter((d) => {
161164
return data.findIndex((item) => item.key === d.uuid) === -1;
@@ -205,10 +208,8 @@ export default forwardRef((props: IProps, ref: ForwardedRef<ISearchResultRef>) =
205208
{tabsList?.length ? (
206209
<Tabs
207210
hideAdd
208-
// concealTabHeader={outputTabAndTabsList?.length === 1}
209211
className={styles.tabs}
210212
onChange={onChange as any}
211-
// activeKey={currentTab}
212213
onEdit={onEdit as any}
213214
items={tabsList}
214215
concealTabHeader={tabsList.length === 1}

chat2db-client/src/components/Tabs/index.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
.tabsNav {
2626
display: flex;
27-
overflow: auto;
27+
overflow-x: scroll;
2828
height: 32px;
2929
flex-shrink: 0;
3030
background-color: var(--color-bg-base);

0 commit comments

Comments
 (0)