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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(ui): deactivate settings when activating tabs
lexmin0412dd8f4a0f871f
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex 24f6db234c..a4acc4e582 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -127,7 +127,6 @@ const showConnectionDialog = ref(false);const connectionDialogPrefill = ref<ConnectionDeepLinkDraft | null>(null);const connectionDialogInitialTab = ref<ConfigTab | undefined>(undefined);const settingsPageTabOpen = ref(false);-const settingsPageActive = ref(false);const settingsInitialTab = ref("appearance");const settingsInitialSection = ref<string | undefined>(undefined);const showQueryEditorDdlDialog = ref(false);@@ -135,7 +134,7 @@ const driverStoreTabOpen = ref(false);const driverStoreActive = ref(false);const settingsReturnSurface = ref<"query" | "driverStore" | "welcome">("welcome");const showDriverStore = computed(() => driverStoreTabOpen.value && driverStoreActive.value);-const showSettingsPage = computed(() => settingsPageTabOpen.value && settingsPageActive.value);+const showSettingsPage = computed(() => settingsPageTabOpen.value && settingsStore.settingsPageActive);const showQuickOpen = ref(false);const agentDriverUpdateCount = ref(0);const showHistory = ref(false);@@ -276,7 +275,7 @@ const updateNotificationsEnabled = computed(() => settingsStore.editorSettings.ufunction openSettings(initialTab = "appearance", initialSection?: string) {settingsInitialTab.value = initialTab;settingsInitialSection.value = initialSection;- if (!settingsPageActive.value) {+ if (!settingsStore.settingsPageActive) {settingsReturnSurface.value = showDriverStore.value ? "driverStore" : activeTab.value ? "query" : "welcome";}activateSettingsPage();@@ -284,13 +283,13 @@ function openSettings(initialTab = "appearance", initialSection?: string) {function activateSettingsPage() {settingsPageTabOpen.value = true;- settingsPageActive.value = true;+ settingsStore.settingsPageActive = true;driverStoreActive.value = false;}function closeSettingsPage() {settingsPageTabOpen.value = false;- settingsPageActive.value = false;+ settingsStore.settingsPageActive = false;if (settingsReturnSurface.value === "driverStore" && driverStoreTabOpen.value) {driverStoreActive.value = true;return;@@ -301,7 +300,7 @@ function closeSettingsPage() {function openDriverStorePage() {driverStoreTabOpen.value = true;driverStoreActive.value = true;- settingsPageActive.value = false;+ settingsStore.settingsPageActive = false;}function closeDriverStorePage() {@@ -432,7 +431,7 @@ watch(}if (id) newQueryContextSource.value = "tab";if (id && driverStoreActive.value) driverStoreActive.value = false;- if (id && settingsPageActive.value) settingsPageActive.value = false;+ if (id && settingsStore.settingsPageActive) settingsStore.settingsPageActive = false;selectedSql.value = "";activeOutputView.value = "result";if (id) queryStore.reloadEvictedTab(id);@@ -1422,7 +1421,7 @@ function activateQueryTab(tabId: string): boolean {dispatchBeforeTabSwitch(tabId);queryStore.activeTabId = tabId;driverStoreActive.value = false;- settingsPageActive.value = false;+ settingsStore.settingsPageActive = false;return true;}@@ -1798,13 +1797,13 @@ onUnmounted(() => {:driver-store-open="driverStoreTabOpen":driver-store-active="driverStoreActive":settings-page-open="settingsPageTabOpen"- :settings-page-active="settingsPageActive"+ :settings-page-active="settingsStore.settingsPageActive":agent-driver-update-count="toolbarAgentDriverUpdateCount"@activate-driver-store="openDriverStorePage"@activate-settings-page="activateSettingsPage"@activate-tab="driverStoreActive = false;- settingsPageActive = false;+ settingsStore.settingsPageActive = false;"@close-driver-store="closeDriverStorePage"@close-settings-page="closeSettingsPage"@@ -1817,7 +1816,7 @@ onUnmounted(() => {<DriverStorePage v-if="driverStoreTabOpen" v-show="driverStoreActive" class="flex-1 min-h-0" :update-notifications-enabled="updateNotificationsEnabled" @update-count-change="updateAgentDriverUpdateCount" /><EditorSettingsPagev-if="settingsPageTabOpen"- v-show="settingsPageActive"+ v-show="settingsStore.settingsPageActive"variant="page":open="settingsPageTabOpen":initial-tab="settingsInitialTab"@@ -1826,7 +1825,7 @@ onUnmounted(() => {class="flex-1 min-h-0"@update:open="(open: boolean) => (open ? activateSettingsPage() : closeSettingsPage())"/>- <div v-if="activeTab" v-show="!driverStoreActive && !settingsPageActive" class="flex flex-col flex-1 min-h-0">+ <div v-if="activeTab" v-show="!driverStoreActive && !settingsStore.settingsPageActive" class="flex flex-col flex-1 min-h-0"><EditorToolbarv-if="activeTab.mode === 'query' && !isPreviewTab(activeTab)":active-tab="activeTab"@@ -1932,7 +1931,7 @@ onUnmounted(() => {</KeepAlive></div><WelcomeScreen- v-else-if="!driverStoreActive && !settingsPageActive"+ v-else-if="!driverStoreActive && !settingsStore.settingsPageActive":connection-stats="connectionStats":recent-connections="recentConnections":saved-sql-history-items="savedSqlHistoryItems"diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vueindex 0a1b26d272..0288074ca6 100644--- a/apps/desktop/src/components/sidebar/TreeItem.vue+++ b/apps/desktop/src/components/sidebar/TreeItem.vue@@ -1214,21 +1214,21 @@ async function openData() {};if (existingSameTableTab && canActivateExistingDataTableTab(existingSameTableTab)) {- queryStore.activeTabId = existingSameTableTab.id;+ queryStore.switchTab(existingSameTableTab.id);logPhase("existing-tab-activated", { table: node.label });return;}const tabId = (() => {if (existingSameTableTab) {- queryStore.activeTabId = existingSameTableTab.id;+ queryStore.switchTab(existingSameTableTab.id);resetReusedDataTabState(existingSameTableTab);return existingSameTableTab.id;}if (settingsStore.editorSettings.reuseDataTab) {const existing = queryStore.tabs.find((tab) => tab.mode === "data" && tab.connectionId === node.connectionId && tab.database === node.database);if (existing) {- queryStore.activeTabId = existing.id;+ queryStore.switchTab(existing.id);resetReusedDataTabState(existing);return existing.id;}diff --git a/apps/desktop/src/composables/useNavigationTargets.ts b/apps/desktop/src/composables/useNavigationTargets.tsindex 7c4775f6b7..57222479db 100644--- a/apps/desktop/src/composables/useNavigationTargets.ts+++ b/apps/desktop/src/composables/useNavigationTargets.ts@@ -41,7 +41,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTabexisting.title = tabTitle;existing.schema = target.schema;existing.tableInfoTab = options.tableInfoTab;- queryStore.activeTabId = existing.id;+ queryStore.switchTab(existing.id);return existing.id;}}diff --git a/apps/desktop/src/stores/__tests__/queryStore.switchTab.spec.ts b/apps/desktop/src/stores/__tests__/queryStore.switchTab.spec.tsnew file mode 100644index 0000000000..7728b89b87--- /dev/null+++ b/apps/desktop/src/stores/__tests__/queryStore.switchTab.spec.ts@@ -0,0 +1,71 @@+import { createPinia, setActivePinia } from "pinia";+import { beforeEach, describe, expect, it, vi } from "vitest";++describe("queryStore switchTab", () => {+ beforeEach(() => {+ vi.resetModules();+ vi.unstubAllGlobals();+ setActivePinia(createPinia());+ });++ it("deactivates settings page when switching to the same tab", async () => {+ const { useQueryStore } = await import("@/stores/queryStore");+ const { useSettingsStore } = await import("@/stores/settingsStore");+ const queryStore = useQueryStore();+ const settingsStore = useSettingsStore();++ // Create a data tab+ const tabId = queryStore.createTab("pg-1", "app", "users", "data", "public");+ queryStore.activeTabId = tabId;++ // Simulate settings page being active+ settingsStore.settingsPageActive = true;++ // Switch to the same tab (simulating reuseDataTab scenario)+ queryStore.switchTab(tabId);++ // Settings page should be deactivated+ expect(settingsStore.settingsPageActive).toBe(false);+ // Active tab should still be the same+ expect(queryStore.activeTabId).toBe(tabId);+ });++ it("deactivates settings page when switching to a different tab", async () => {+ const { useQueryStore } = await import("@/stores/queryStore");+ const { useSettingsStore } = await import("@/stores/settingsStore");+ const queryStore = useQueryStore();+ const settingsStore = useSettingsStore();++ // Create two data tabs+ const tab1Id = queryStore.createTab("pg-1", "app", "users", "data", "public");+ const tab2Id = queryStore.createTab("pg-1", "app", "orders", "data", "public");+ queryStore.activeTabId = tab1Id;++ // Simulate settings page being active+ settingsStore.settingsPageActive = true;++ // Switch to a different tab+ queryStore.switchTab(tab2Id);++ // Settings page should be deactivated+ expect(settingsStore.settingsPageActive).toBe(false);+ // Active tab should be the new tab+ expect(queryStore.activeTabId).toBe(tab2Id);+ });++ it("deactivates settings page when reopening an existing special tab", async () => {+ const { useQueryStore } = await import("@/stores/queryStore");+ const { useSettingsStore } = await import("@/stores/settingsStore");+ const queryStore = useQueryStore();+ const settingsStore = useSettingsStore();++ const tabId = queryStore.openObjectBrowser("pg-1", "app", "public");+ settingsStore.settingsPageActive = true;++ const reopenedTabId = queryStore.openObjectBrowser("pg-1", "app", "public");++ expect(reopenedTabId).toBe(tabId);+ expect(queryStore.activeTabId).toBe(tabId);+ expect(settingsStore.settingsPageActive).toBe(false);+ });+});diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.tsindex 84299bc432..c1bacbb2ae 100644--- a/apps/desktop/src/stores/queryStore.ts+++ b/apps/desktop/src/stores/queryStore.ts@@ -305,6 +305,7 @@ function getI18nT() {export const useQueryStore = defineStore("query", () => {const t = getI18nT();+ const settingsStore = useSettingsStore();const tabs = ref<QueryTab[]>([]);const activeTabId = ref<string | null>(null);const isOpenTabsLoaded = ref(false);@@ -818,7 +819,7 @@ export const useQueryStore = defineStore("query", () => {if (title) {const existing = findTabByIdentity(connectionId, database, title, mode, schema);if (existing) {- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}}@@ -847,7 +848,7 @@ export const useQueryStore = defineStore("query", () => {const title = schema ? `${schema} objects` : `${database} objects`;const existing = tabs.value.find((tab) => tab.mode === "objects" && tab.connectionId === connectionId && tab.database === database && (tab.objectBrowser?.schema || "") === (schema || ""));if (existing) {- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -873,10 +874,15 @@ export const useQueryStore = defineStore("query", () => {return id;}+ function switchTab(tabId: string) {+ activeTabId.value = tabId;+ settingsStore.settingsPageActive = false;+ }+function openUserAdmin(connectionId: string) {const existing = tabs.value.find((tab) => tab.mode === "users" && tab.connectionId === connectionId);if (existing) {- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -901,7 +907,7 @@ export const useQueryStore = defineStore("query", () => {function openDamengJobAdmin(connectionId: string) {const existing = tabs.value.find((tab) => tab.mode === "dameng-jobs" && tab.connectionId === connectionId);if (existing) {- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -927,7 +933,7 @@ export const useQueryStore = defineStore("query", () => {const title = `${database}.${bucketName}`;const existing = tabs.value.find((tab) => tab.mode === "mongo-bucket" && tab.connectionId === connectionId && tab.database === database && tab.mongoBucket?.bucketName === bucketName);if (existing) {- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -954,7 +960,7 @@ export const useQueryStore = defineStore("query", () => {function openMongoGridFs(connectionId: string, database: string) {const existing = tabs.value.find((tab) => tab.mode === "mongo-gridfs" && tab.connectionId === connectionId && tab.database === database);if (existing) {- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -980,7 +986,7 @@ export const useQueryStore = defineStore("query", () => {if (existing) {if (target?.tenant) existing.mqTenant = target.tenant;if (target?.initialTab) existing.mqInitialTab = target.initialTab;- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -1011,7 +1017,7 @@ export const useQueryStore = defineStore("query", () => {if (existing) {existing.nacosNamespaceName = namespaceName;if (!existing.customTitle) existing.title = `${useConnectionStore().getConfig(connectionId)?.name || "Nacos"}:${namespaceName}`;- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -1048,7 +1054,7 @@ export const useQueryStore = defineStore("query", () => {const existing = tabs.value.find((tab) => tab.mode === "structure" && tab.connectionId === connectionId && tab.database === database && (tab.structureTableName || "") === resolvedTableName);if (existing) {applyTableStructureInitialTab(existing, initialTab, initialTarget);- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}}@@ -1674,7 +1680,7 @@ export const useQueryStore = defineStore("query", () => {existing.editorSelection = restored.selection;existing.editorViewport = restored.viewport;}- activeTabId.value = existing.id;+ switchTab(existing.id);return existing.id;}@@ -3445,6 +3451,7 @@ export const useQueryStore = defineStore("query", () => {hasDirtyTabs,isConfirmingAppClose,createTab,+ switchTab,closeTab,forceClosePendingTab,forceCloseAllPendingTabs,diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.tsindex 30ec07369c..fd7ac363fb 100644--- a/apps/desktop/src/stores/settingsStore.ts+++ b/apps/desktop/src/stores/settingsStore.ts@@ -824,6 +824,7 @@ function saveEditorSettings(settings: EditorSettings) {}export const useSettingsStore = defineStore("settings", () => {+ const settingsPageActive = ref(false);const aiConfig = ref<AiConfig>(normalizeAiConfig({ provider: "claude" }));const isAiConfigLoaded = ref(false);const aiProviderConfigs = ref<Partial<Record<AiProvider, AiConfig>>>({});@@ -1071,6 +1072,7 @@ export const useSettingsStore = defineStore("settings", () => {}return {+ settingsPageActive,aiConfig,isAiConfigLoaded,aiProviderConfigs,