From 3c4c16dc06adabe8e0a4497fb2e545dc341b6ae9 Mon Sep 17 00:00:00 2001 From: gggaiitx <62124152+gggaiitx@users.noreply.github.com> Date: Sun, 12 Jul 2026 10:07:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=8D=95=E5=87=BB=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=A4=B1=E6=95=88=EF=BC=8C=E5=8F=B3=E9=94=AE=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?DDL=E3=80=81=E6=BA=90=E7=A0=81=E7=AD=89=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E5=8F=B3=E4=BE=A7=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/objects/ObjectBrowser.vue | 37 ++++--------------- .../table/objectBrowserRowAction.spec.ts | 30 ++++++++------- .../src/lib/table/objectBrowserRowAction.ts | 19 ++++++---- 3 files changed, 36 insertions(+), 50 deletions(-) diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue index eb4886ed11..e9d225e96a 100644 --- a/apps/desktop/src/components/objects/ObjectBrowser.vue +++ b/apps/desktop/src/components/objects/ObjectBrowser.vue @@ -77,7 +77,6 @@ import { useExportTracker, type ExportTask } from "@/composables/useExportTracke import { useSettingsStore } from "@/stores/settingsStore"; import { useQueryStore } from "@/stores/queryStore"; import QueryEditor from "@/components/editor/QueryEditor.vue"; -import DdlViewDialog from "./DdlViewDialog.vue"; import { sqlFormatDialectForDbType, type SqlFormatDialect } from "@/lib/sql/sqlFormatter"; import { isCancelSearchShortcut } from "@/lib/editor/keyboardShortcuts"; import { executeWithProductionSqlGuard } from "@/lib/database/productionExecutionGuard"; @@ -196,8 +195,6 @@ const duplicateTarget = ref(null); const duplicateTableName = ref(""); const showProcedureExecutionConfirm = ref(false); const procedureExecutionTarget = ref(null); -const ddlDialogTarget = ref(null); -const showDdlDialog = ref(false); const selectedTableIds = ref>(new Set()); const expandedPartitionParentIds = ref>(new Set()); const showBatchDropConfirm = ref(false); @@ -741,7 +738,7 @@ function onRowClick(row: ObjectBrowserRow, event: MouseEvent) { } // Single click: defer when the row has a distinct double-click action so a // following second click can cancel it (e.g. TABLE single→table-info, double→open-table). - if (shouldDeferSingleClick(row, action, activation)) { + if (shouldDeferSingleClick(row, action)) { if (singleClickTimer) clearTimeout(singleClickTimer); singleClickTimer = setTimeout(() => { singleClickTimer = null; @@ -815,9 +812,9 @@ const filteredTableDdlContent = computed(() => { }); }); -async function openTableInfo(row: ObjectBrowserRow) { +async function openTableInfo(row: ObjectBrowserRow, initialTab?: TableInfoTab) { // Toggle off if clicking the same table - if (sidePanelRow.value?.id === row.id && sidePanelMode.value === "table-info") { + if (sidePanelRow.value?.id === row.id && sidePanelMode.value === "table-info" && !initialTab) { closeSidePanel(); return; } @@ -831,8 +828,8 @@ async function openTableInfo(row: ObjectBrowserRow) { tableForeignKeys.value = []; tableTriggers.value = []; tableInfoSearchQuery.value = ""; - // Determine first available tab - const firstTab = tableInfoTabs.value[0]?.id ?? "ddl"; + // Determine initial tab: explicit request > first available > ddl + const firstTab = initialTab ?? tableInfoTabs.value[0]?.id ?? "ddl"; await selectTableInfoTab(firstTab); } @@ -855,7 +852,7 @@ async function fetchTableDdl() { tableDdlLoading.value = true; try { const schema = row.schema || selectedSchema.value || props.database; - const ddl = await api.getTableDdl(props.connection.id, props.database || "", schema, row.name); + const ddl = await api.getTableDdl(props.connection.id, props.database || "", schema, row.name, tableDdlObjectType(row.type)); if (sidePanelGuard.isStale(epoch)) return; tableDdlContent.value = ddl; } catch (e: any) { @@ -2233,10 +2230,7 @@ function getTableMenuItems(item: ObjectBrowserRow): ContextMenuItem[] { { label: t("contextMenu.viewData"), action: () => openViewData(item), icon: Table2 }, { label: t("contextMenu.viewDdl"), - action: () => { - ddlDialogTarget.value = item; - showDdlDialog.value = true; - }, + action: () => openTableInfo(item, "ddl"), icon: FileCode, }, ...(canOpenStructureEditor.value ? [{ label: t("contextMenu.editStructure"), action: () => openStructureEditor(item), icon: PencilRuler }] : []), @@ -2287,10 +2281,7 @@ function getViewMenuItems(item: ObjectBrowserRow): ContextMenuItem[] { { label: t("contextMenu.viewSource"), action: () => openSource(item), icon: Code2 }, { label: t("contextMenu.viewDdl"), - action: () => { - ddlDialogTarget.value = item; - showDdlDialog.value = true; - }, + action: () => openTableInfo(item, "ddl"), icon: ScrollText, }, ...(canRename(item) ? [{ label: t("contextMenu.renameObject"), action: () => requestRename(item), icon: Pencil }] : []), @@ -3043,18 +3034,6 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] { - -