feat(agent): pluggable database drivers via JDBC agent subprocess

Migrate domestic database support (DaMeng, KingBase, Vastbase, GoldenDB) from
built-in ODBC/protocol drivers to standalone Java agent processes communicating
via stdin/stdout JSON-RPC 2.0. Agents are distributed as fat JARs with embedded
JDBC drivers, downloaded on-demand from GitHub Releases with proxy fallback.

- Add AgentDriverClient for subprocess lifecycle + JSON-RPC communication
- Add AgentManager for JRE/JAR install state management
- Add Tauri commands for driver install/uninstall/list
- Add DriverManager UI panel in settings dialog
- Extend DatabaseType with Kingbase, Vastbase, Goldendb variants
- Migrate Dameng from ODBC (dm_driver.rs) to JDBC agent
- Delete dm_driver.rs (343 lines)
- Add GitHub proxy fallback for downloads (update.hwdns.net, gh-proxy.org)

Agent code lives at https://github.com/t8y2/dbx-agents
This commit is contained in:
t8y2
2026-05-13 04:44:52 +08:00
parent 8ef1999ec9
commit e85f9df1fe
20 changed files with 769 additions and 470 deletions
+94
View File
@@ -0,0 +1,94 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { Button } from "@/components/ui/button";
interface AgentDriverInfo {
db_type: string;
label: string;
version: string;
size: number;
installed: boolean;
installed_version: string | null;
update_available: boolean;
}
const drivers = ref<AgentDriverInfo[]>([]);
const jreInstalled = ref(false);
const installing = ref<string | null>(null);
onMounted(async () => {
await refresh();
});
async function refresh() {
jreInstalled.value = await invoke<boolean>("check_jre_installed");
drivers.value = await invoke<AgentDriverInfo[]>("list_installed_agents");
}
async function installDriver(dbType: string) {
installing.value = dbType;
try {
await invoke("install_agent", { dbType });
await refresh();
} catch (e: any) {
alert(e);
} finally {
installing.value = null;
}
}
async function uninstallDriver(dbType: string) {
try {
await invoke("uninstall_agent", { dbType });
await refresh();
} catch (e: any) {
alert(e);
}
}
function formatSize(bytes: number): string {
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
}
</script>
<template>
<div class="space-y-4 p-4">
<h3 class="text-lg font-medium">驱动管理</h3>
<div class="text-sm text-muted-foreground">
JRE: {{ jreInstalled ? "✓ 已安装" : "未安装" }}
<span v-if="!jreInstalled" class="ml-2 text-xs">(首次安装驱动时自动下载)</span>
</div>
<div class="space-y-2">
<div
v-for="driver in drivers"
:key="driver.db_type"
class="flex items-center justify-between rounded-md border p-3"
>
<div>
<span class="font-medium">{{ driver.label }}</span>
<span v-if="driver.installed" class="ml-2 text-xs text-muted-foreground">
v{{ driver.installed_version }}
</span>
<span class="ml-2 text-xs text-muted-foreground">{{ formatSize(driver.size) }}</span>
</div>
<div>
<Button
v-if="!driver.installed"
size="sm"
:disabled="installing !== null"
@click="installDriver(driver.db_type)"
>
{{ installing === driver.db_type ? "安装中..." : "安装" }}
</Button>
<div v-else class="flex items-center gap-2">
<span class="text-sm text-green-600">✓ 已安装</span>
<Button size="sm" variant="ghost" @click="uninstallDriver(driver.db_type)">卸载</Button>
</div>
</div>
</div>
</div>
</div>
</template>