From f5dcdb1e845335eaccd1a2bc60ab705f637fedac Mon Sep 17 00:00:00 2001 From: "www.zerocode.net.cn" Date: Sun, 8 Sep 2024 18:51:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(database-config):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E6=A8=A1=E6=9D=BF=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=92=8C=E8=BF=9E=E6=8E=A5=E5=8E=86=E5=8F=B2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除了数据库配置表单中未使用的模板保存和连接历史功能,以简化组件并提高可维护性。 Refactor the DatabaseConfigForm component by removing the unused saveAsTemplate and showConnectionHistory functions. This change simplifies the component and improves maintainability. --- src/pages/database-config/DatabaseConfigForm.tsx | 14 ++------------ src/utils/databaseUtils.ts | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/pages/database-config/DatabaseConfigForm.tsx b/src/pages/database-config/DatabaseConfigForm.tsx index 6fe722a..7668358 100644 --- a/src/pages/database-config/DatabaseConfigForm.tsx +++ b/src/pages/database-config/DatabaseConfigForm.tsx @@ -19,7 +19,7 @@ import { import React, { useEffect, useState } from 'react'; const { Option } = Select; -const { Title, Text } = Typography; +const { Text } = Typography; const DATABASE_CONFIG_URL = '/ncnb/dataSources'; @@ -71,16 +71,6 @@ const DatabaseConfigForm: React.FC = ({ initialValues, } }; - const saveAsTemplate = () => { - message.success('模板保存成功'); - // 实际实现中,这里应该调用API保存模板 - }; - - const showConnectionHistory = () => { - message.info('显示连接历史'); - // 实际实现中,这里应该打开一个显示连接历史的模态框或抽屉 - }; - const dbTypeMap: Record = { mysql: 'MySQL', postgresql: 'PostgreSQL', @@ -170,7 +160,7 @@ const DatabaseConfigForm: React.FC = ({ initialValues, port: 3306, ...initialValues, }} - onValuesChange={(changedValues, allValues) => { + onValuesChange={(changedValues) => { if (connectionType === 'host' && !changedValues.url) { updateJdbcUrl(); } diff --git a/src/utils/databaseUtils.ts b/src/utils/databaseUtils.ts index d207fdf..1793bbc 100644 --- a/src/utils/databaseUtils.ts +++ b/src/utils/databaseUtils.ts @@ -34,7 +34,7 @@ export const getDriverClassName = (type: string) => { } }; -export const generateJdbcUrl = (type: string, host: string, port: string, databaseName: string) => { +export const generateJdbcUrl = (type: string, host: string, port: number, databaseName: string) => { switch (type.toLowerCase()) { case 'mysql': return `jdbc:mysql://${host}:${port}/${databaseName}`;