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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(connection): hide installed driver hint
t8y2433297e549e9
diff --git a/src/components/connection/ConnectionDialog.vue b/src/components/connection/ConnectionDialog.vueindex 7c8d12ccc8..511b3cd6a7 100644--- a/src/components/connection/ConnectionDialog.vue+++ b/src/components/connection/ConnectionDialog.vue@@ -1,5 +1,6 @@<script setup lang="ts">import { computed, nextTick, ref, watch } from "vue";+import { invoke } from "@tauri-apps/api/core";import { uuid } from "@/lib/utils";import { useI18n } from "vue-i18n";import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";@@ -17,7 +18,7 @@ import * as api from "@/lib/api";import { isTauriRuntime } from "@/lib/tauriRuntime";import { applyParsedConnectionUrl, parseConnectionUrl } from "@/lib/connectionUrl";import { connectionUrlPlaceholder as getUrlPlaceholder } from "@/lib/connectionPresentation";-import { supportsDriverManagement } from "@/lib/databaseCapabilities";+import { showAgentDriverInstallHint, type AgentDriverInstallState } from "@/lib/agentDriverInstallHint";import { ArrowLeft, ChevronRight, Copy, ExternalLink, FolderOpen, Grid3X3, Link2, List, Search } from "lucide-vue-next";type DbOption = { value: string; label: string };@@ -87,6 +88,7 @@ const customDriverName = ref("");const mongoUseUrl = ref(false);const jdbcDriverPathsInput = ref("");const jdbcDrivers = ref<JdbcDriverInfo[]>([]);+const agentDrivers = ref<AgentDriverInstallState[]>([]);const selectedJdbcDriverPath = ref("");const connectionUrlInput = ref("");const dialogStep = ref<DialogStep>("select");@@ -461,6 +463,9 @@ const isJdbcConnection = computed(() => form.value.db_type === "jdbc");const connectionUrlPlaceholder = computed(() => getUrlPlaceholder(form.value.db_type));const canUseSsh = computed(() => form.value.db_type !== "sqlite");const canUseProxy = computed(() => form.value.db_type !== "sqlite" && form.value.db_type !== "duckdb");+const shouldShowAgentDriverInstallHint = computed(() =>+ showAgentDriverInstallHint(form.value.db_type, agentDrivers.value),+);const testResultMessage = computed(() => {if (!testResult.value) return "";return testResult.value.ok ? t("connection.testSuccess") : testResult.value.message;@@ -581,6 +586,7 @@ watch(open, (value) => {resetForm();}void loadJdbcDrivers();+ void loadAgentDrivers();});watch(canUseSsh, (value) => {@@ -698,6 +704,22 @@ async function loadJdbcDrivers() {}}+async function loadAgentDrivers() {+ if (!isDesktop) return;+ try {+ agentDrivers.value = await invoke<AgentDriverInstallState[]>("list_installed_agents_local");+ invoke<AgentDriverInstallState[]>("list_installed_agents")+ .then((drivers) => {+ agentDrivers.value = drivers;+ })+ .catch(() => {+ /* keep local state */+ });+ } catch {+ agentDrivers.value = [];+ }+}+function addJdbcDriverPath(path: string) {const existing = jdbcDriverPathsInput.value.split(/\r?\n/)@@ -1130,7 +1152,7 @@ function openExternalUrl(url: string) {<Input v-model="form.database" class="col-span-3" :placeholder="databasePlaceholder" /></div>- <div v-if="supportsDriverManagement(form.db_type)" class="grid grid-cols-4 items-center gap-4">+ <div v-if="shouldShowAgentDriverInstallHint" class="grid grid-cols-4 items-center gap-4"><span /><p class="col-span-3 text-xs text-muted-foreground">需要在顶部导航栏「驱动管理」中安装对应的驱动才能连接。diff --git a/src/lib/agentDriverInstallHint.ts b/src/lib/agentDriverInstallHint.tsnew file mode 100644index 0000000000..809bbc086c--- /dev/null+++ b/src/lib/agentDriverInstallHint.ts@@ -0,0 +1,15 @@+import type { DatabaseType } from "@/types/database";+import { supportsDriverManagement } from "./databaseCapabilities";++export interface AgentDriverInstallState {+ db_type: string;+ installed: boolean;+}++export function showAgentDriverInstallHint(+ dbType: DatabaseType | undefined,+ drivers: readonly AgentDriverInstallState[],+): boolean {+ if (!supportsDriverManagement(dbType)) return false;+ return drivers.find((driver) => driver.db_type === dbType)?.installed !== true;+}diff --git a/tests/agentDriverInstallHint.test.ts b/tests/agentDriverInstallHint.test.tsnew file mode 100644index 0000000000..f9a686410e--- /dev/null+++ b/tests/agentDriverInstallHint.test.ts@@ -0,0 +1,15 @@+import assert from "node:assert/strict";+import test from "node:test";+import { showAgentDriverInstallHint } from "../src/lib/agentDriverInstallHint.ts";++test("hides the agent driver install hint when the selected driver is installed", () => {+ assert.equal(showAgentDriverInstallHint("informix", [{ db_type: "informix", installed: true }]), false);+});++test("shows the agent driver install hint when the selected driver is missing", () => {+ assert.equal(showAgentDriverInstallHint("informix", [{ db_type: "informix", installed: false }]), true);+});++test("does not show agent driver install hints for built-in database types", () => {+ assert.equal(showAgentDriverInstallHint("mysql", [{ db_type: "informix", installed: false }]), false);+});