Skip to content

Commit

Permalink
Merge pull request #960 from chat2db/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Chat2DB-Pro authored Dec 13, 2023
2 parents 8b3754a + 7399c7f commit 78e0b94
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 88 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
## 3.1.1

`2023-12-13`

**Changelog**

- 🐞【Fixed】Table blank problem when switching Tabs
- 🐞【Fixed】DM or Oracle cannot display Schema
- 🐞【Fixed】The import connection is lost. Procedure

## 3.1.0

`2023-12-12`

**更新日志**
**Changelog**

- 🔥🔥【Optimize】The first startup time has been increased by 60%, and the second startup time has been increased by 95%
- 🔥🔥【Optimize】The first startup time has been increased by 65%
- 🔥🔥【Optimize】Changed the structure of the left tree
- 🔥🔥【Optimize】Optimized the tab switchover problem
- ⚡️ 【Optimize】All nodes are supported. The name of each node can be copied
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
## 3.1.1

`2023-12-13`

**更新日志**

- 🐞【修复】切换Tabs时,表空白问题
- 🐞【修复】DM、Oracle无法显示Schema问题
- 🐞【修复】导入连接丢失问题

## 3.1.0

`2023-12-12`

**更新日志**

- 🔥🔥【优化】首次启动时间时间提升了60%,第二次启动时间提升了95%
- 🔥🔥【优化】首次启动时间时间提升了65%
- 🔥🔥【优化】更改了左侧树的结构
- 🔥🔥【优化】优化切换tab卡顿问题
- ⚡️【优化】所有节点都支持选中,可以复制每个节点的名称
Expand Down
104 changes: 67 additions & 37 deletions chat2db-client/src/blocks/CreateConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { IConnectionDetails, IDatabase } from '@/typings';
import ConnectionEdit from '@/components/ConnectionEdit';
import { databaseTypeList } from '@/constants';
import Iconfont from '@/components/Iconfont';
import i18n from '@/i18n';
import FileUploadModal from '@/components/ImportConnection';
import {getConnectionList} from '@/pages/main/store/connection';

// IConnectionDetails 全部信息代表修改
// null 展示因增列表
Expand All @@ -23,6 +26,8 @@ export default memo<IProps>((props) => {
const [connectionDetail, setConnectionDetail] = useState<IEditConnectionDetail | null | undefined>(
externalConnectionDetail,
);
const [isFileUploadModalOpen, setIsFileUploadModalOpen] = useState(false);


useEffect(() => {
setConnectionDetail(externalConnectionDetail);
Expand All @@ -39,49 +44,74 @@ export default memo<IProps>((props) => {
// }

return (
<div className={classnames(styles.box, className)}>
{connectionDetail && (
<div
className={classnames(styles.createConnections, {
[styles.showCreateConnections]: connectionDetail,
})}
>
<ConnectionEdit
closeCreateConnection={() => {
setConnectionDetail(null);
}}
connectionData={connectionDetail as any}
submit={onSubmit}
/>
</div>
)}
{connectionDetail === null && (
<div className={styles.dataBaseListBox}>
<div className={styles.dataBaseList}>
{databaseTypeList.map((t) => {
return (
<div key={t.code} className={styles.databaseItem} onClick={handleCreateConnections.bind(null, t)}>
<div className={styles.databaseItemMain}>
<div className={styles.databaseItemLeft}>
<div className={styles.logoBox}>
<Iconfont code={t.icon} />
<>
<div className={classnames(styles.box, className)}>
{connectionDetail && (
<div
className={classnames(styles.createConnections, {
[styles.showCreateConnections]: connectionDetail,
})}
>
<ConnectionEdit
closeCreateConnection={() => {
setConnectionDetail(null);
}}
connectionData={connectionDetail as any}
submit={onSubmit}
/>
</div>
)}
{connectionDetail === null && (
<div className={styles.dataBaseListBox}>
<div className={styles.dataBaseList}>
{databaseTypeList.map((t) => {
return (
<div key={t.code} className={styles.databaseItem} onClick={handleCreateConnections.bind(null, t)}>
<div className={styles.databaseItemMain}>
<div className={styles.databaseItemLeft}>
<div className={styles.logoBox}>
<Iconfont code={t.icon} />
</div>
{t.name}
</div>
<div className={styles.databaseItemRight}>
<Iconfont code="&#xe631;" />
</div>
{t.name}
</div>
<div className={styles.databaseItemRight}>
<Iconfont code="&#xe631;" />
</div>
);
})}
<div className={styles.databaseItem} onClick={() => {setIsFileUploadModalOpen(true)}}>
<div className={styles.databaseItemMain}>
<div className={styles.databaseItemLeft}>
<div className={styles.logoBox}>
<Iconfont code="&#xe66c;" />
</div>
{i18n('connection.title.importConnection')}
</div>
<div className={styles.databaseItemRight}>
<Iconfont code="&#xe631;" />
</div>
</div>
);
})}
{Array.from({ length: 20 }).map((t, index) => {
return <div key={index} className={styles.databaseItemSpacer} />;
})}
</div>
{Array.from({ length: 20 }).map((t, index) => {
return <div key={index} className={styles.databaseItemSpacer} />;
})}
</div>
</div>
</div>
)}
</div>
)}
</div>
<FileUploadModal
open={isFileUploadModalOpen}
onClose={() => {
setIsFileUploadModalOpen(false);
}}
onConfirm={() => {
setIsFileUploadModalOpen(false);
getConnectionList()
}}
/>
</>
);
});

Expand Down
18 changes: 8 additions & 10 deletions chat2db-client/src/components/ConnectionEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import LoadingGracile from '@/components/Loading/LoadingGracile';
import Driver from './components/Driver';

// ----- store -----
import { useConnectionStore } from '@/pages/main/store/connection';
import { useConnectionStore, getConnectionList } from '@/pages/main/store/connection';

const { Option } = Select;

Expand All @@ -30,7 +30,6 @@ export enum submitType {
interface IProps {
closeCreateConnection: () => void;
connectionData: IConnectionDetails;
submitCallback?: any;
submit?: (data: IConnectionDetails) => Promise<any>;
}

Expand All @@ -39,7 +38,7 @@ export interface ICreateConnectionFunction {
}

const ConnectionEdit = forwardRef((props: IProps, ref: ForwardedRef<ICreateConnectionFunction>) => {
const { closeCreateConnection, submitCallback, connectionData, submit } = props;
const { closeCreateConnection, connectionData, submit } = props;
const [baseInfoForm] = Form.useForm();
const [sshForm] = Form.useForm();
const [driveData, setDriveData] = useState<any>({});
Expand Down Expand Up @@ -200,7 +199,6 @@ const ConnectionEdit = forwardRef((props: IProps, ref: ForwardedRef<ICreateConne
}

const api: any = connectionService[type](p);

api
.then((res: any) => {
if (type === submitType.TEST) {
Expand All @@ -216,13 +214,13 @@ const ConnectionEdit = forwardRef((props: IProps, ref: ForwardedRef<ICreateConne
: i18n('common.message.addedSuccessfully'),
);

setBackfillData({
...backfillData,
id: res,
});

getConnectionList();

if (type === submitType.SAVE) {
submitCallback?.();
setBackfillData({
...backfillData,
id: res,
});
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ const SelectBoundInfo = memo((props: IProps) => {

// 获取数据库列表
const getDatabaseList = () => {
if(boundInfo.dataSourceId === undefined || boundInfo.dataSourceId === null){
return
}
connectionService
.getDatabaseList({
dataSourceId: boundInfo.dataSourceId,
Expand All @@ -131,8 +134,8 @@ const SelectBoundInfo = memo((props: IProps) => {

// 获取schema列表
const getSchemaList = () => {
if (boundInfo.databaseName === null || boundInfo.databaseName === undefined) {
return;
if(boundInfo.dataSourceId === undefined || boundInfo.dataSourceId === null){
return
}
connectionService
.getSchemaList({
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/components/ImportConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ImportConnection: React.FC<IImportConnectionProps> = ({ open, onClose, onC

return (
<Modal
title="导入文件, .ncx(navicat) 或 .dbp(dbever)"
title={i18n('connection.title.importTitle')}
open={open}
onCancel={onClose}
onOk={handleConfirmUpload}
Expand Down
1 change: 1 addition & 0 deletions chat2db-client/src/components/SearchResult/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import i18n from '@/i18n';
import sqlServer, { IExecuteSqlParams } from '@/service/sql';
import { v4 as uuidV4 } from 'uuid';
import { Spin } from 'antd';
import { useWorkspaceStore } from '@/pages/main/workspace/store';

interface IProps {
className?: string;
Expand Down
1 change: 1 addition & 0 deletions chat2db-client/src/i18n/en-us/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ export default {
'connection.button.createConnection': 'Create connection',
'connection.tips.noConnection': 'You have not created any connections yet',
'connection.tips.noConnectionTips': 'You do not have permission to view the connection details, but you can connect to the connection directly',
'connection.title.importTitle': 'Import file,.ncx(navicat) or.dbp(dbever)',
};
1 change: 1 addition & 0 deletions chat2db-client/src/i18n/zh-cn/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ export default {
'connection.button.createConnection': '创建连接',
'connection.tips.noConnection': '您当前还没有创建任何连接',
'connection.tips.noConnectionTips': '无权限查看该连接详情,但你可以直接连接该连接',
'connection.title.importTitle': '导入文件, .ncx(navicat) 或 .dbp(dbever)',
};
4 changes: 2 additions & 2 deletions chat2db-client/src/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ contextBridge.exposeInMainWorld('electronApi', {

const child = spawn(path.join(__dirname, '../..', `./static/${JAVA_PATH}`), [
'-noverify',
'-jar',
'-Xmx1024M',
`-Dspring.profiles.active=${isTest ? 'test' : 'release'}`,
'-Dserver.address=127.0.0.1',
'-Dchat2db.mode=DESKTOP',
`-Dproject.path=${javaPath}`,
`-Dloader.path=${libPath}`,
`-Dclient.version=${readVersion()}`,
'-Xmx1024M',
'-jar',
javaPath,
]);

Expand Down
15 changes: 0 additions & 15 deletions chat2db-client/src/pages/main/connection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { IConnectionDetails, IConnectionListItem } from '@/typings';
// ----- components -----
import CreateConnection from '@/blocks/CreateConnection';
import Iconfont from '@/components/Iconfont';
import FileUploadModal from '@/components/ImportConnection';
import LoadingContent from '@/components/Loading/LoadingContent';
import MenuLabel from '@/components/MenuLabel';

Expand All @@ -36,7 +35,6 @@ const ConnectionsPage = () => {
});
const volatileRef = useRef<any>();
const [connectionActiveId, setConnectionActiveId] = useState<IConnectionListItem['id'] | null>(null);
const [isFileUploadModalOpen, setIsFileUploadModalOpen] = useState(false);
const [connectionDetail, setConnectionDetail] = useState<IConnectionDetails | null | undefined>(null);

// 处理列表单击事件
Expand Down Expand Up @@ -174,20 +172,7 @@ const ConnectionsPage = () => {
>
<CreateConnection connectionDetail={connectionDetail} onSubmit={onSubmit} />
</LoadingContent>
{/* <div className={styles.layoutRight}>
<CreateConnection connectionDetail={connectionDetail} onSubmit={onSubmit} />
</div> */}
</div>

<FileUploadModal
open={isFileUploadModalOpen}
onClose={() => {
setIsFileUploadModalOpen(false);
}}
onConfirm={() => {
setIsFileUploadModalOpen(false);
}}
/>
</>
);
};
Expand Down
3 changes: 2 additions & 1 deletion chat2db-client/src/pages/main/dashboard/chart-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function ChartItem(props: IChartItemProps) {
};

const handleExecuteSQL = async (sql: string, _chartData: IChartItem) => {
const { dataSourceId, databaseName } = _chartData;
const { dataSourceId, databaseName, schemaName } = _chartData;
if (!isValid(dataSourceId)) {
message.success(i18n('dashboard.editor.execute.noDataSource'));
return;
Expand All @@ -130,6 +130,7 @@ function ChartItem(props: IChartItemProps) {
sql,
dataSourceId,
databaseName,
schemaName
};
// 获取当前SQL的查询结果
const sqlResult = await sqlService.executeSql(executeSQLParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import OperationLine from '../OperationLine';
import Tree from '@/blocks/Tree';
import { treeConfig } from '@/blocks/Tree/treeConfig';
import { ITreeNode } from '@/typings';
import { TreeNodeType } from '@/constants';

interface IProps {
className?: string;
Expand All @@ -28,8 +29,9 @@ export default memo<IProps>((props) => {
setTreeData([]);
return;
}
const treeNodeType = currentConnectionDetails.supportDatabase ? TreeNodeType.DATA_SOURCE : TreeNodeType.DATABASE;
setTreeData(null);
treeConfig['dataSource']
treeConfig[treeNodeType]
.getChildren?.({
dataSourceId: currentConnectionDetails.id,
dataSourceName: currentConnectionDetails.alias,
Expand All @@ -55,7 +57,6 @@ export default memo<IProps>((props) => {
return (
<div className={classnames(styles.treeContainer, className)}>
<OperationLine getTreeData={getTreeData} searchValue={searchValue} setSearchValue={setSearchValue} />
{/* <Tree className={styles.treeBox} searchValue={searchValue} treeData={treeData} /> */}
<Tree className={styles.treeBox} searchValue={searchValue} treeData={treeData} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ const WorkspaceTabs = memo(() => {
case WorkspaceTabType.ViewAllTable:
return renderViewAllTable(item);
default:
return <div>未知类型</div>;
return <div>Unknown</div>;
}
};

Expand All @@ -231,7 +231,7 @@ const WorkspaceTabs = memo(() => {
children: <Fragment key={item.id}>{workspaceTabConnectionMap(item)}</Fragment>,
};
});
}, [workspaceTabList]);
}, [workspaceTabList, activeConsoleId]);

function renderCreateConsoleButton() {
return (
Expand Down
Loading

0 comments on commit 78e0b94

Please sign in to comment.