From 51225d06e2d980750d101e95678a52033ed1d7f4 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Wed, 29 Apr 2026 22:01:54 +0800 Subject: [PATCH] feat: add connection delete confirmation and improve disconnect behavior --- src/App.vue | 21 --------------- src/components/sidebar/TreeItem.vue | 42 +++++++++++++++++++++++++++-- src/i18n/locales/en.ts | 6 ++++- src/i18n/locales/zh-CN.ts | 2 ++ src/stores/connectionStore.ts | 6 ++++- 5 files changed, 52 insertions(+), 25 deletions(-) diff --git a/src/App.vue b/src/App.vue index 11ed9ed82c..02541ec978 100644 --- a/src/App.vue +++ b/src/App.vue @@ -616,27 +616,6 @@ onUnmounted(() => {
-
-
-
- - {{ t('app.name') }} -
-

{{ t('welcome.title') }}

-

- {{ t('welcome.subtitle') }} -

-
-
- - -
-
-
diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue index 82a26ee491..28cf3c089c 100644 --- a/src/components/sidebar/TreeItem.vue +++ b/src/components/sidebar/TreeItem.vue @@ -4,7 +4,7 @@ import { useI18n } from "vue-i18n"; import { Database, Table, Columns3, Eye, ChevronRight, ChevronDown, Loader2, FolderOpen, Trash2, TerminalSquare, RefreshCw, - Copy, TableProperties, Key, Link, Zap, ListTree, Pencil, + Copy, TableProperties, Key, Link, Zap, ListTree, Pencil, Plug, Unplug, } from "lucide-vue-next"; import { ContextMenu, ContextMenuContent, ContextMenuItem, @@ -15,6 +15,10 @@ import { useQueryStore } from "@/stores/queryStore"; import type { TreeNode, TreeNodeType } from "@/types/database"; import * as api from "@/lib/tauri"; import DatabaseIcon from "@/components/icons/DatabaseIcon.vue"; +import { + Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; const { t } = useI18n(); const connectionStore = useConnectionStore(); @@ -175,7 +179,13 @@ async function refresh() { await toggle(); } +const showDeleteConfirm = ref(false); + function deleteConnection() { + showDeleteConfirm.value = true; +} + +function confirmDelete() { const node = props.node; if (node.connectionId) { connectionStore.disconnect(node.connectionId); @@ -193,8 +203,19 @@ function editConnection() { } } +function disconnectConnection() { + if (props.node.connectionId) { + connectionStore.disconnect(props.node.connectionId); + props.node.isExpanded = false; + props.node.children = []; + } +} + const canExpand = !leafTypes.has(props.node.type); const paddingLeft = `${props.depth * 16 + 8}px`; +const isConnected = computed(() => + props.node.type === "connection" && !!props.node.connectionId && connectionStore.connectedIds.has(props.node.connectionId) +); const CHILDREN_PAGE_SIZE = 100; const displayLimit = ref(CHILDREN_PAGE_SIZE); @@ -235,6 +256,7 @@ function showMore() { {{ isGroupLabel(node) ? t(node.label) : node.label }} +