Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(desktop): keep saving structure export sql

t8y236923fa581fe
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue
index c70e4a99d9..ba01c354e9 100644
--- a/apps/desktop/src/components/sidebar/TreeItem.vue
+++ b/apps/desktop/src/components/sidebar/TreeItem.vue
@@ -797,6 +797,7 @@ const showBatchDropConfirm = ref(false);
const showStructurePreviewDialog = ref(false);
const structurePreviewSql = ref("");
const structurePreviewTitle = ref("");
+const structurePreviewDefaultFileName = ref("structure.sql");
const structurePreviewError = ref("");
const isLoadingStructurePreview = ref(false);
const showEmptyTableConfirm = ref(false);
@@ -1688,6 +1689,7 @@ async function exportStructure() {
targets.length === 1
? t("contextMenu.exportStructurePreviewTitle", { name: targets[0]!.label })
: t("contextMenu.exportStructurePreviewTitleMultiple", { count: targets.length });
+ structurePreviewDefaultFileName.value = targets.length === 1 ? `${targets[0]!.label}.sql` : "structures.sql";
showStructurePreviewDialog.value = true;
try {
const parts: string[] = [];
@@ -1749,6 +1751,16 @@ async function copyStructurePreview() {
}
}
+async function saveStructurePreview() {
+ if (!structurePreviewSql.value) return;
+ try {
+ await saveFileContent(structurePreviewSql.value, structurePreviewDefaultFileName.value, "SQL", "sql");
+ toast(t("grid.exported"));
+ } catch (e: any) {
+ toast(t("grid.exportFailed", { message: e?.message || String(e) }), 5000);
+ }
+}
+
async function exportData(format: "csv" | "json" | "sql") {
const node = props.node;
if (!node.connectionId || !node.database) return;
@@ -3009,10 +3021,18 @@ function treeItemMenuItems(): ContextMenuItem[] {
</div>
<DialogFooter>
<Button variant="outline" @click="showStructurePreviewDialog = false">{{ t("dangerDialog.cancel") }}</Button>
- <Button :disabled="isLoadingStructurePreview || !structurePreviewSql" @click="copyStructurePreview">
+ <Button
+ variant="outline"
+ :disabled="isLoadingStructurePreview || !structurePreviewSql"
+ @click="copyStructurePreview"
+ >
<Clipboard class="h-4 w-4" />
{{ t("contextMenu.copyStructure") }}
</Button>
+ <Button :disabled="isLoadingStructurePreview || !structurePreviewSql" @click="saveStructurePreview">
+ <Download class="h-4 w-4" />
+ {{ t("contextMenu.saveStructure") }}
+ </Button>
</DialogFooter>
</DialogContent>
</Dialog>
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index f8469cad95..6117f14600 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -922,6 +922,7 @@ export default {
exportStructurePreviewTitleMultiple: "Structure - {count} objects",
exportStructureLoading: "Loading structure...",
copyStructure: "Copy Structure",
+ saveStructure: "Save SQL",
exportStructureCopied: "Structure copied",
createTable: "Create Table",
dropTable: "Drop Table",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 9c937c89af..4d87636460 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -818,6 +818,7 @@ export default {
exportStructurePreviewTitleMultiple: "Estructura - {count} objetos",
exportStructureLoading: "Cargando estructura...",
copyStructure: "Copiar estructura",
+ saveStructure: "Guardar SQL",
exportStructureCopied: "Estructura copiada",
createTable: "Crear tabla",
dropTable: "Eliminar tabla",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index b7e7bb6203..05a6d94bd5 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -903,6 +903,7 @@ export default {
exportStructurePreviewTitleMultiple: "表结构 - {count} 个对象",
exportStructureLoading: "正在读取表结构...",
copyStructure: "复制表结构",
+ saveStructure: "保存 SQL",
exportStructureCopied: "表结构已复制",
createTable: "新建表",
dropTable: "删除表",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 56e513e759..9aca1bd1a2 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -903,6 +903,7 @@ export default {
exportStructurePreviewTitleMultiple: "資料表結構 - {count} 個物件",
exportStructureLoading: "正在讀取資料表結構...",
copyStructure: "複製資料表結構",
+ saveStructure: "儲存 SQL",
exportStructureCopied: "資料表結構已複製",
createTable: "建立資料表",
dropTable: "刪除資料表",