From 65d7a0ab8f3d20e18c73666f5fb5f8a885cef263 Mon Sep 17 00:00:00 2001 From: DengQingNian <117324885+DengQingNian@users.noreply.github.com> Date: Tue, 9 Jun 2026 10:12:22 +0800 Subject: [PATCH] feat(structure): add DDL tab to table structure editor (#893) Closes #836 Co-authored-by: dqn --- .../structure/TableStructureEditor.vue | 38 +++++++++++++++++++ apps/desktop/src/i18n/locales/en.ts | 1 + apps/desktop/src/i18n/locales/es.ts | 1 + apps/desktop/src/i18n/locales/it.ts | 1 + apps/desktop/src/i18n/locales/pt-BR.ts | 1 + apps/desktop/src/i18n/locales/zh-CN.ts | 1 + apps/desktop/src/i18n/locales/zh-TW.ts | 1 + 7 files changed, 44 insertions(+) diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue index 51a00e94c8..b712d8f314 100644 --- a/apps/desktop/src/components/structure/TableStructureEditor.vue +++ b/apps/desktop/src/components/structure/TableStructureEditor.vue @@ -98,6 +98,23 @@ const activeTab = ref("columns"); const loading = ref(false); const saving = ref(false); const sqlPreviewLoading = ref(false); +const ddlContent = ref(""); +const ddlLoading = ref(false); +const ddlFetched = ref(false); + +async function fetchDdl() { + if (!props.connectionId || !props.database || !props.tableName || ddlFetched.value) return; + ddlLoading.value = true; + try { + ddlContent.value = await api.getTableDdl(props.connectionId, props.database, metadataSchema.value, props.tableName); + ddlFetched.value = true; + } catch (e: any) { + ddlContent.value = `-- Error: ${e?.message || e}`; + ddlFetched.value = true; + } finally { + ddlLoading.value = false; + } +} const errorMessage = ref(""); const columns = ref([]); const indexes = ref([]); @@ -432,6 +449,8 @@ function resetState() { warnings.value = []; foreignKeys.value = []; triggers.value = []; + ddlContent.value = ""; + ddlFetched.value = false; newTableName.value = ""; tableComment.value = ""; originalTableComment.value = ""; @@ -776,6 +795,12 @@ watch(refreshVersion, (version, previous) => { if (version === previous || !version || isCreateMode.value) return; void loadStructure(true); }); + +watch(activeTab, (tab) => { + if (tab === "ddl") { + void fetchDdl(); + } +});