From 1db990b5549742a99760a9dc500ac08c6e4176bf Mon Sep 17 00:00:00 2001 From: "meilin.huang" <954537473@qq.com> Date: Thu, 7 Dec 2023 11:48:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=96=B0=E5=A2=9E=E8=BE=BE?= =?UTF-8?q?=E6=A2=A6=E5=9B=BE=E6=A0=87=E3=80=81=E8=B0=83=E6=95=B4=E5=89=8D?= =?UTF-8?q?=E7=AB=AFDbDialect=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mayfly_go_web/src/assets/iconfont/iconfont.js | 2 +- .../src/assets/iconfont/iconfont.json | 7 ++++ .../src/views/ops/db/InstanceEdit.vue | 38 +++++++++++++++---- mayfly_go_web/src/views/ops/db/SqlExec.vue | 6 +-- .../ops/db/component/table/DbTableDataOp.vue | 2 +- .../ops/db/component/table/DbTableOp.vue | 4 +- .../src/views/ops/db/dialect/dm_dialect.ts | 22 +++++------ .../src/views/ops/db/dialect/index.ts | 37 ++++++++++++------ .../src/views/ops/db/dialect/mysql_dialect.ts | 22 +++++------ .../views/ops/db/dialect/postgres_dialect.ts | 22 +++++------ server/go.mod | 3 +- server/internal/db/api/db.go | 2 +- server/internal/db/dbm/conn.go | 21 ++++++---- server/internal/db/dbm/dialect_dm.go | 3 +- 14 files changed, 117 insertions(+), 74 deletions(-) diff --git a/mayfly_go_web/src/assets/iconfont/iconfont.js b/mayfly_go_web/src/assets/iconfont/iconfont.js index b9b4f4d5..7e31d647 100644 --- a/mayfly_go_web/src/assets/iconfont/iconfont.js +++ b/mayfly_go_web/src/assets/iconfont/iconfont.js @@ -1,5 +1,5 @@ (window._iconfont_svg_string_3953964 = - ''), + ''), (function (c) { var t = (t = document.getElementsByTagName('script'))[t.length - 1], a = t.getAttribute('data-injectcss'), diff --git a/mayfly_go_web/src/assets/iconfont/iconfont.json b/mayfly_go_web/src/assets/iconfont/iconfont.json index baab9418..9cdae18d 100644 --- a/mayfly_go_web/src/assets/iconfont/iconfont.json +++ b/mayfly_go_web/src/assets/iconfont/iconfont.json @@ -26,6 +26,13 @@ "unicode": "e8b7", "unicode_decimal": 59575 }, + { + "icon_id": "12295203", + "name": "达梦数据库", + "font_class": "db-dm", + "unicode": "e6f0", + "unicode_decimal": 59120 + }, { "icon_id": "10055634", "name": "云数据库MongoDB", diff --git a/mayfly_go_web/src/views/ops/db/InstanceEdit.vue b/mayfly_go_web/src/views/ops/db/InstanceEdit.vue index 2ca210e9..d182fdd5 100644 --- a/mayfly_go_web/src/views/ops/db/InstanceEdit.vue +++ b/mayfly_go_web/src/views/ops/db/InstanceEdit.vue @@ -8,10 +8,11 @@ - - - - + + + + {{ dt.label }} + @@ -86,6 +87,8 @@ import { ElMessage } from 'element-plus'; import { notBlank } from '@/common/assert'; import { RsaEncrypt } from '@/common/rsa'; import SshTunnelSelect from '../component/SshTunnelSelect.vue'; +import { getDbDialect } from './dialect'; +import SvgIcon from '@/components/svgIcon/index.vue'; const props = defineProps({ visible: { @@ -121,7 +124,7 @@ const rules = { { required: true, message: '请输入主机ip和port', - trigger: ['change', 'blur'], + trigger: ['blur'], }, ], username: [ @@ -135,6 +138,21 @@ const rules = { const dbForm: any = ref(null); +const dbTypes = [ + { + type: 'mysql', + label: 'mysql', + }, + { + type: 'postgres', + label: 'postgres', + }, + { + type: 'dm', + label: '达梦(暂不支持ssh)', + }, +]; + const state = reactive({ dialogVisible: false, tabActiveName: 'basic', @@ -143,7 +161,7 @@ const state = reactive({ type: null, name: null, host: '', - port: 3306, + port: null, username: null, password: null, params: null, @@ -170,11 +188,17 @@ watch(props, (newValue: any) => { state.form = { ...newValue.data }; state.oldUserName = state.form.username; } else { - state.form = { port: 3306 } as any; + state.form = { port: null } as any; state.oldUserName = null; } }); +const changeDbType = (val: string) => { + if (!state.form.id) { + state.form.port = getDbDialect(val).getInfo().defaultPort as any; + } +}; + const getDbPwd = async () => { state.pwd = await dbApi.getInstancePwd.request({ id: state.form.id }); }; diff --git a/mayfly_go_web/src/views/ops/db/SqlExec.vue b/mayfly_go_web/src/views/ops/db/SqlExec.vue index 405cea22..3b738699 100644 --- a/mayfly_go_web/src/views/ops/db/SqlExec.vue +++ b/mayfly_go_web/src/views/ops/db/SqlExec.vue @@ -7,7 +7,7 @@