From ecdc86a478d863cdaeea26c9245f733c8efa3486 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Wed, 6 May 2026 18:51:53 +0800 Subject: [PATCH] feat(connection): add file picker for SQLite/DuckDB and fix default host (#121) Add a browse button next to the file path input for SQLite and DuckDB connections, allowing users to select database files via system dialog instead of manually typing paths. Clear the default host value when switching to file-based database types. --- .../connection/ConnectionDialog.vue | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/connection/ConnectionDialog.vue b/src/components/connection/ConnectionDialog.vue index 7e8a711aee..95e58301f8 100644 --- a/src/components/connection/ConnectionDialog.vue +++ b/src/components/connection/ConnectionDialog.vue @@ -214,6 +214,9 @@ function applyProfile(val: string, preserveConnectionFields = false) { form.value.port = profile.port; form.value.username = profile.user; form.value.url_params = profile.urlParams || ""; + if (profile.type === "sqlite" || profile.type === "duckdb") { + form.value.host = ""; + } } } @@ -514,6 +517,24 @@ async function browseSshKeyPath() { } } } + +async function browseDbFilePath() { + if (isTauriRuntime()) { + const { open } = await import("@tauri-apps/plugin-dialog"); + const filters = + form.value.db_type === "duckdb" + ? [{ name: "DuckDB", extensions: ["duckdb", "db"] }] + : [{ name: "SQLite", extensions: ["db", "sqlite", "sqlite3"] }]; + const selected = await open({ + title: "Select Database File", + multiple: false, + filters, + }); + if (selected && typeof selected === "string") { + form.value.host = selected; + } + } +}