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。

feat: support batch table export selection

t8y2be0c2b4775e0
diff --git a/apps/desktop/src/components/export/DatabaseExportDialog.vue b/apps/desktop/src/components/export/DatabaseExportDialog.vue
index 975871e151..c6add1d91f 100644
--- a/apps/desktop/src/components/export/DatabaseExportDialog.vue
+++ b/apps/desktop/src/components/export/DatabaseExportDialog.vue
@@ -27,6 +27,7 @@ const props = defineProps<{
prefillDatabase?: string;
prefillSchema?: string;
prefillTable?: string;
+ prefillTables?: string[];
}>();
// Connection / Database / Schema selectors
@@ -61,6 +62,7 @@ const exportDone = ref(false);
const exportError = ref<string | null>(null);
const exportCancelled = ref(false);
const pendingPrefillTable = ref("");
+const pendingPrefillTables = ref<string[]>([]);
const sqlConnections = computed(() =>
store.connections.filter((c) => !["redis", "mongodb", "elasticsearch"].includes(c.db_type)),
@@ -125,7 +127,7 @@ async function loadSchemas(preferredSchema = "") {
schema.value = selected;
}
-async function loadTables(preferredTable = "") {
+async function loadTables(preferredTable = "", preferredTables: string[] = []) {
if (!connectionId.value || !database.value || !schema.value) return;
loadingTables.value = true;
tableError.value = null;
@@ -135,7 +137,13 @@ async function loadTables(preferredTable = "") {
const tableInfos = await api.listTables(connectionId.value, database.value, schema.value);
const names = tableInfos.map((table) => table.name);
tables.value = names;
- selectedTables.value = preferredTable && names.includes(preferredTable) ? [preferredTable] : [...names];
+ const preferredSet = new Set(preferredTables.filter((name) => names.includes(name)));
+ selectedTables.value =
+ preferredSet.size > 0
+ ? names.filter((name) => preferredSet.has(name))
+ : preferredTable && names.includes(preferredTable)
+ ? [preferredTable]
+ : [...names];
} catch (e: any) {
tableError.value = e?.message || String(e);
} finally {
@@ -250,6 +258,7 @@ function resetState() {
selectedTables.value = [];
tableError.value = null;
pendingPrefillTable.value = "";
+ pendingPrefillTables.value = [];
includeStructure.value = true;
includeData.value = true;
includeObjects.value = true;
@@ -299,8 +308,10 @@ watch(schema, (value) => {
selectedTables.value = [];
tableError.value = null;
const preferredTable = pendingPrefillTable.value;
+ const preferredTables = pendingPrefillTables.value;
pendingPrefillTable.value = "";
- if (value) loadTables(preferredTable).catch((e) => toast(String(e), 5000));
+ pendingPrefillTables.value = [];
+ if (value) loadTables(preferredTable, preferredTables).catch((e) => toast(String(e), 5000));
});
watch(
@@ -309,6 +320,7 @@ watch(
if (val) {
resetState();
pendingPrefillTable.value = props.prefillTable ?? "";
+ pendingPrefillTables.value = props.prefillTables ?? [];
if (props.prefillConnectionId) {
skipConnectionWatch.value = true;
connectionId.value = props.prefillConnectionId;
diff --git a/apps/desktop/src/components/layout/AppDialogs.vue b/apps/desktop/src/components/layout/AppDialogs.vue
index 32f5686b98..0831634f87 100644
--- a/apps/desktop/src/components/layout/AppDialogs.vue
+++ b/apps/desktop/src/components/layout/AppDialogs.vue
@@ -186,6 +186,7 @@ watch(
:prefill-database="dialogs.databaseExportPrefillDatabase.value"
:prefill-schema="dialogs.databaseExportPrefillSchema.value"
:prefill-table="dialogs.databaseExportPrefillTable.value"
+ :prefill-tables="dialogs.databaseExportPrefillTables.value"
/>
<ConfigPassphraseDialog
v-if="dialogs.showConfigPassphraseDialog.value"
diff --git a/apps/desktop/src/composables/useDialogSources.ts b/apps/desktop/src/composables/useDialogSources.ts
index 0521e8ee2b..23d3664480 100644
--- a/apps/desktop/src/composables/useDialogSources.ts
+++ b/apps/desktop/src/composables/useDialogSources.ts
@@ -51,6 +51,7 @@ const databaseExportPrefillConnectionId = ref("");
const databaseExportPrefillDatabase = ref("");
const databaseExportPrefillSchema = ref("");
const databaseExportPrefillTable = ref("");
+const databaseExportPrefillTables = ref<string[]>([]);
let watchersRegistered = false;
@@ -178,6 +179,7 @@ export function useDialogSources() {
databaseExportPrefillDatabase.value = v.database;
databaseExportPrefillSchema.value = v.schema ?? "";
databaseExportPrefillTable.value = v.tableName ?? "";
+ databaseExportPrefillTables.value = v.tableNames ?? [];
showDatabaseExportDialog.value = true;
connectionStore.databaseExportSource = null;
}
@@ -295,6 +297,7 @@ export function useDialogSources() {
databaseExportPrefillDatabase,
databaseExportPrefillSchema,
databaseExportPrefillTable,
+ databaseExportPrefillTables,
onExportClick,
onExportConfirm,
onImportClick,
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index c4d7ccd9e6..560b186405 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -897,6 +897,13 @@ export default {
search: "Search tables, views, functions, or procedures...",
loading: "Loading objects...",
empty: "No objects found",
+ selectedTables: "{count} tables selected",
+ exportSelected: "Export selected",
+ dropSelected: "Drop selected",
+ clearSelection: "Clear selection",
+ confirmBatchDropTitle: "Drop Selected Tables",
+ confirmBatchDropMessage: "Are you sure you want to drop {count} selected tables? This cannot be undone.",
+ batchDropSuccess: "Dropped {count} tables",
},
structureEditor: {
title: "Edit Table Structure",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 30bc29b9c4..7038e2b99e 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -790,6 +790,14 @@ export default {
search: "Buscar tablas, vistas, funciones o procedimientos...",
loading: "Cargando objetos...",
empty: "No se encontraron objetos",
+ selectedTables: "{count} tablas seleccionadas",
+ exportSelected: "Exportar seleccionadas",
+ dropSelected: "Eliminar seleccionadas",
+ clearSelection: "Limpiar selección",
+ confirmBatchDropTitle: "Eliminar tablas seleccionadas",
+ confirmBatchDropMessage:
+ "¿Seguro que quieres eliminar {count} tablas seleccionadas? Esta acción no se puede deshacer.",
+ batchDropSuccess: "{count} tablas eliminadas",
},
structureEditor: {
title: "Editar estructura de tabla",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index d8dd42ef1c..4246ebc6e4 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -878,6 +878,13 @@ export default {
search: "搜索表、视图、函数或存储过程...",
loading: "正在加载对象...",
empty: "没有找到对象",
+ selectedTables: "已选择 {count} 张表",
+ exportSelected: "导出所选",
+ dropSelected: "删除所选",
+ clearSelection: "清空选择",
+ confirmBatchDropTitle: "删除所选表",
+ confirmBatchDropMessage: "确定要删除已选择的 {count} 张表吗?此操作不可撤销。",
+ batchDropSuccess: "已删除 {count} 张表",
},
structureEditor: {
title: "编辑表结构",
diff --git a/apps/desktop/src/stores/connectionStore.ts b/apps/desktop/src/stores/connectionStore.ts
index a707599544..93c58860db 100644
--- a/apps/desktop/src/stores/connectionStore.ts
+++ b/apps/desktop/src/stores/connectionStore.ts
@@ -122,6 +122,7 @@ export const useConnectionStore = defineStore("connection", () => {
database: string;
schema?: string;
tableName?: string;
+ tableNames?: string[];
} | null>(null);
const sidebarLayout = ref<SidebarLayout>(emptyLayout());
let layoutPersistTimer: ReturnType<typeof setTimeout> | null = null;