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: add error handling and user feedback for connection toggle in TreeItem component

t8y228428ee5c5fc
diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue
index e415affb44..f1ed847439 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() {