From 28428ee5c5fcee754696f60cf3f3a68ab7b7e8cf Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 1 May 2026 10:11:27 +0800 Subject: [PATCH] feat: add error handling and user feedback for connection toggle in TreeItem component --- src/components/sidebar/TreeItem.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue index e415affb4..f1ed84743 100644 --- a/src/components/sidebar/TreeItem.vue +++ b/src/components/sidebar/TreeItem.vue @@ -14,6 +14,7 @@ import { } from "@/components/ui/context-menu"; import { useConnectionStore } from "@/stores/connectionStore"; import { useQueryStore } from "@/stores/queryStore"; +import { useToast } from "@/composables/useToast"; import type { TreeNode, TreeNodeType } from "@/types/database"; import * as api from "@/lib/tauri"; import DatabaseIcon from "@/components/icons/DatabaseIcon.vue"; @@ -25,6 +26,7 @@ import { Button } from "@/components/ui/button"; const { t } = useI18n(); const connectionStore = useConnectionStore(); const queryStore = useQueryStore(); +const { toast } = useToast(); const props = defineProps<{ node: TreeNode; @@ -98,6 +100,7 @@ async function toggle() { if (node.isLoading) return; if (node.isExpanded) { node.isExpanded = false; return; } + try { if (node.type === "connection" && node.connectionId) { const config = connectionStore.getConfig(node.connectionId); if (config?.db_type === "redis") { @@ -136,6 +139,9 @@ async function toggle() { } else if (node.type === "group-triggers" && node.connectionId && node.database && node.tableName) { await connectionStore.loadTriggers(node.connectionId, node.database, node.tableName, node.schema); } + } catch (e: any) { + toast(t("connection.connectFailed", { message: e?.message || String(e) }), 5000); + } } function onClick() {