feat(desktop): add connection-level database browser

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-12 02:20:05 +08:00
1 parent 44dbd0e0e7
commit fee3ed1d5a
46 files changed
+781 -29

No files matched your search

@@ -40,6 +40,20 @@ describe("queryStore database open state", () => {
expect(store.isDatabaseOpen("pg-1", "analytics")).toBe(false);
}, 10_000);
it("reuses one database browser tab per connection", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
const firstId = store.openDatabaseBrowser("pg-1");
const secondId = store.openDatabaseBrowser("pg-1");
const otherConnectionId = store.openDatabaseBrowser("pg-2");
expect(secondId).toBe(firstId);
expect(otherConnectionId).not.toBe(firstId);
expect(store.tabs.filter((tab) => tab.mode === "databases")).toHaveLength(2);
expect(store.tabs.find((tab) => tab.id === firstId)).toMatchObject({ connectionId: "pg-1", database: "", mode: "databases" });
});
it("keeps object browser viewport per tab and clears it on schema change", async () => {
const { useQueryStore } = await import("@/stores/queryStore");
const store = useQueryStore();
+24
View File
@@ -1702,6 +1702,29 @@ export const useQueryStore = defineStore("query", () => {
return id;
}
function openDatabaseBrowser(connectionId: string) {
const existing = tabs.value.find((tab) => tab.mode === "databases" && tab.connectionId === connectionId);
if (existing) {
switchTab(existing.id);
return existing.id;
}
const id = uuid();
tabs.value.push({
id,
title: "Databases",
connectionId,
database: "",
sql: "",
isExecuting: false,
isCancelling: false,
isExplaining: false,
mode: "databases",
});
activeTabId.value = id;
return id;
}
function switchTab(tabId: string) {
activeTabId.value = tabId;
settingsStore.settingsPageActive = false;
@@ -5736,6 +5759,7 @@ export const useQueryStore = defineStore("query", () => {
commitTransaction,
rollbackTransaction,
renameTab,
openDatabaseBrowser,
openObjectBrowser,
openMongoGridFs,
openMongoBucket,