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(toolbar): move sidebar expand button to toolbar

二丫讲梵436dd7129fab
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index 4d70aa467a..ecf041c34c 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed, watch, onMounted, onUnmounted, nextTick, defineAsyncComponent, provide } from "vue";
import { useI18n } from "vue-i18n";
-import { ChevronsRight, FileText } from "@lucide/vue";
+import { FileText } from "@lucide/vue";
import { TooltipProvider } from "@/components/ui/tooltip";
import AppToolbar from "@/components/layout/AppToolbar.vue";
import AppTabBar from "@/components/layout/AppTabBar.vue";
@@ -3425,6 +3425,7 @@ onUnmounted(() => {
v-if="!isDetachedWindowContext"
:is-dark="isDark"
:theme-mode="themeMode"
+ :show-sidebar-expand="!sidebarOpen && !isZenMode"
:show-ai-panel="showAiPanel"
:active-ai-run-count="activeAiRunCount"
:awaiting-ai-run-count="awaitingAiRunCount"
@@ -3445,6 +3446,7 @@ onUnmounted(() => {
:has-connections="connectionStore.connections.length > 0"
:has-sql-file-connections="hasSqlFileConnections"
@new-connection="showConnectionDialog = true"
+ @expand-sidebar="setSidebarOpen(true)"
@new-query="newQuery"
@set-theme-mode="setThemeMode"
@toggle-ai="toggleRightSidebarPanel('ai')"
@@ -3475,11 +3477,6 @@ onUnmounted(() => {
@open-settings="(initialTab) => openSettings(initialTab ?? 'appearance')"
@add-to-ai="addToAi"
/>
- <div v-if="!isDetachedWindowContext" v-show="!sidebarOpen && !isZenMode" class="flex h-full w-8 shrink-0 items-start justify-center border-r bg-background/80 pt-2" :class="isClassicLayout ? '' : 'rounded-md border border-border/80'">
- <Button variant="ghost" size="icon" class="h-7 w-7" :title="t('sidebar.expand')" :aria-label="t('sidebar.expand')" @click="setSidebarOpen(true)">
- <ChevronsRight class="h-4 w-4" />
- </Button>
- </div>
<div v-show="!isAiPanelMaximized || isZenMode" :class="isDetachedWindowContext ? 'flex-1 min-w-0 overflow-hidden bg-background' : isClassicLayout ? 'flex-1 min-w-0 overflow-hidden' : 'flex-1 min-w-0 overflow-hidden rounded-md border border-border/80 bg-background'">
<div class="h-full flex min-h-0 min-w-0 flex-col">
diff --git a/apps/desktop/src/components/layout/AppToolbar.vue b/apps/desktop/src/components/layout/AppToolbar.vue
index 81a3622880..8b8602e008 100644
--- a/apps/desktop/src/components/layout/AppToolbar.vue
+++ b/apps/desktop/src/components/layout/AppToolbar.vue
@@ -2,7 +2,7 @@
import { computed, ref, onMounted, onBeforeUnmount, h, nextTick, watch } from "vue";
import { useI18n } from "vue-i18n";
import { invoke } from "@tauri-apps/api/core";
-import { DatabaseZap, FilePlus2, Moon, Sun, SunMoon, History, Bot, ArrowLeftRight, FileCode, BookMarked, GitCompareArrows, TableProperties, Settings, CloudDownload, Package, FileDown, FolderTree } from "@lucide/vue";
+import { ChevronsRight, DatabaseZap, FilePlus2, Moon, Sun, SunMoon, History, Bot, ArrowLeftRight, FileCode, BookMarked, GitCompareArrows, TableProperties, Settings, CloudDownload, Package, FileDown, FolderTree } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import LightDropdown from "@/components/ui/LightDropdown.vue";
@@ -27,6 +27,7 @@ const GithubIcon = {
const props = defineProps<{
isDark: boolean;
themeMode: AppThemeMode;
+ showSidebarExpand?: boolean;
showAiPanel: boolean;
activeAiRunCount: number;
/** Runs awaiting a write confirmation; the badge turns amber to outrank the
@@ -51,6 +52,7 @@ const props = defineProps<{
}>();
const emit = defineEmits<{
+ "expand-sidebar": [];
"new-connection": [];
"new-query": [];
"set-theme-mode": [mode: AppThemeMode];
@@ -379,6 +381,11 @@ function handleWindowResize() {
}
watch(collapsibleRightItemDefs, () => scheduleToolbarLayout(), { flush: "post" });
+watch(
+ () => props.showSidebarExpand,
+ () => scheduleToolbarLayout(),
+ { flush: "post" },
+);
watch(
() => settingsStore.editorSettings.uiScale,
() => {
@@ -534,6 +541,14 @@ const toolbarStyle = computed(() => {
<template>
<div ref="toolbarEl" class="app-toolbar h-10 flex items-center gap-1 px-2 border-b bg-muted/30 shrink-0 overflow-hidden" :style="toolbarStyle" data-tauri-drag-region @dblclick="onToolbarDblClick">
+ <Tooltip v-if="showSidebarExpand">
+ <TooltipTrigger as-child>
+ <Button variant="ghost" size="icon" class="toolbar-action-button h-8 w-8 shrink-0" :aria-label="t('sidebar.expand')" @click="emit('expand-sidebar')">
+ <ChevronsRight class="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>{{ t("sidebar.expand") }}</TooltipContent>
+ </Tooltip>
<Button variant="ghost" size="sm" :class="toolbarTextButtonClass" @click="emit('new-connection')">
<span class="inline-flex items-center gap-1">
<DatabaseZap class="h-3.5 w-3.5" />
diff --git a/apps/desktop/src/lib/__tests__/app/rightSidebarPanels.spec.ts b/apps/desktop/src/lib/__tests__/app/rightSidebarPanels.spec.ts
index f33a57645e..96cab7276e 100644
--- a/apps/desktop/src/lib/__tests__/app/rightSidebarPanels.spec.ts
+++ b/apps/desktop/src/lib/__tests__/app/rightSidebarPanels.spec.ts
@@ -72,7 +72,10 @@ describe("right sidebar panel entry points", () => {
expect(appSource).toContain("isToggleZenModeShortcut(e, shortcuts) && supportsZenMode(activeTab.value?.mode)");
expect(appSource).toContain('@toggle-zen-mode="toggleZenMode"');
expect(appSource).toContain('v-show="sidebarOpen && !isZenMode"');
- expect(appSource).toContain('v-show="!sidebarOpen && !isZenMode"');
+ expect(appSource).toContain(':show-sidebar-expand="!sidebarOpen && !isZenMode"');
+ expect(toolbarSource).toContain('<Tooltip v-if="showSidebarExpand">');
+ expect(toolbarSource).toContain("@click=\"emit('expand-sidebar')\"");
+ expect(appSource).toContain('@expand-sidebar="setSidebarOpen(true)"');
expect(appSource).toContain('v-show="!isAiPanelMaximized || isZenMode"');
expect(appSource).toContain('v-show="!isZenMode"');
});