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
feat(driver-store): add storage usage breakdown
t8y2d7dc4c959a49
diff --git a/apps/desktop/src/components/config/DriverStoreDialog.vue b/apps/desktop/src/components/config/DriverStoreDialog.vueindex 35ed02f7a0..f466813a07 100644--- a/apps/desktop/src/components/config/DriverStoreDialog.vue+++ b/apps/desktop/src/components/config/DriverStoreDialog.vue@@ -14,7 +14,7 @@ import { isTauriRuntime } from "@/lib/tauriRuntime";import { countAvailableDriverUpdates } from "@/lib/agentDriverUpdateBadge";import type { JdbcDriverInfo, JdbcPluginStatus } from "@/types/database";import * as api from "@/lib/api";-import type { AgentDriverInfo, JavaRuntimeConfig } from "@/lib/api";+import type { AgentDriverInfo, DriverStoreUsage, JavaRuntimeConfig } from "@/lib/api";import {addDriverInstallQueue,driverInstallProgressPercent,@@ -47,6 +47,7 @@ const progress = ref<DriverInstallProgress | null>(null);const javaRuntimeConfig = ref<JavaRuntimeConfig>({ mode: "managed", custom_java_path: null });const customJavaPath = ref("");const savingJavaRuntime = ref(false);+const driverStoreUsage = ref<DriverStoreUsage | null>(null);let unlisten: (() => void) | null = null;@@ -81,6 +82,24 @@ const progressText = computed(() => {const progressNumber = computed(() => driverInstallProgressPercent(progress.value));const updatableCount = computed(() => drivers.value.filter((d) => d.update_available).length);+const usageSummary = computed(() => {+ const usage = driverStoreUsage.value;+ if (!usage) return [];+ return [+ { key: "total", label: "总计", bytes: usage.total_bytes },+ { key: "jre", label: "托管 JRE", bytes: usage.jre_bytes },+ { key: "agent", label: "内置驱动 Agent", bytes: usage.agent_driver_bytes },+ { key: "jdbc-plugin", label: "JDBC 插件", bytes: usage.jdbc_plugin_bytes },+ { key: "jdbc-driver", label: "JDBC 驱动 JAR", bytes: usage.jdbc_driver_bytes },+ ];+});+const jreUsageByKey = computed(() => {+ const map = new Map<string, number>();+ for (const item of driverStoreUsage.value?.jres || []) {+ map.set(String(item.id), Number(item.bytes || 0));+ }+ return map;+});function updateAgentDrivers(nextDrivers: AgentDriverInfo[]) {drivers.value = nextDrivers;@@ -122,6 +141,7 @@ function removeQueuedDriverInstall(dbType: string) {async function refreshAgents() {updateAgentDrivers(await api.listInstalledAgents());+ void loadDriverStoreUsage();}async function forceRefresh() {@@ -347,6 +367,11 @@ function formatBytes(bytes: number) {return `${(bytes / 1024 / 1024).toFixed(1)} MB`;}+function jreUsageLabel(key: string) {+ const bytes = jreUsageByKey.value.get(String(key)) || 0;+ return bytes > 0 ? formatBytes(bytes) : "";+}+async function loadJdbcDrivers() {if (isWeb) return;isLoadingJdbcDrivers.value = true;@@ -356,6 +381,15 @@ async function loadJdbcDrivers() {toast(String(e?.message || e), 5000);} finally {isLoadingJdbcDrivers.value = false;+ void loadDriverStoreUsage();+ }+}++async function loadDriverStoreUsage() {+ try {+ driverStoreUsage.value = await api.getDriverStoreUsage();+ } catch {+ driverStoreUsage.value = null;}}@@ -426,6 +460,7 @@ async function importJdbcDriverPaths(paths: string[]) {try {jdbcDrivers.value = await api.importJdbcDrivers(paths);jdbcDriverPathInput.value = "";+ void loadDriverStoreUsage();toast(t("settings.jdbcImportSuccess", { count: paths.length }));} catch (e: any) {toast(String(e?.message || e), 5000);@@ -459,6 +494,7 @@ async function importJdbcDriverPathInput() {async function deleteJdbcDriver(path: string) {try {jdbcDrivers.value = await api.deleteJdbcDriver(path);+ void loadDriverStoreUsage();toast(t("settings.jdbcDeleteSuccess"));} catch (e: any) {toast(String(e?.message || e), 5000);@@ -470,6 +506,7 @@ async function deleteJdbcDriver(path: string) {onMounted(async () => {updateAgentDrivers(await api.listInstalledAgentsLocal());void loadJavaRuntimeConfig();+ void loadDriverStoreUsage();api.listInstalledAgents().then((result) => {updateAgentDrivers(result);@@ -501,31 +538,52 @@ onUnmounted(() => {<div class="flex-1 min-h-0 overflow-y-auto"><div class="max-w-4xl mx-auto px-6 py-6"><Tabs default-value="agent">+ <div class="mb-5 rounded-xl border bg-muted/20 p-4">+ <div class="flex items-center justify-between gap-3">+ <div class="text-sm font-medium">空间占用明细</div>+ <div class="text-xs text-muted-foreground">+ {{ usageSummary.length ? `总计 ${formatBytes(usageSummary[0].bytes)}` : "统计中..." }}+ </div>+ </div>+ <div v-if="usageSummary.length" class="mt-3 grid grid-cols-2 gap-2 sm:grid-cols-5">+ <div+ v-for="item in usageSummary"+ :key="item.key"+ class="rounded-lg border bg-background/50 px-2.5 py-2 text-center"+ >+ <div class="text-[11px] text-muted-foreground">{{ item.label }}</div>+ <div class="mt-0.5 text-xs font-medium">{{ formatBytes(item.bytes) }}</div>+ </div>+ </div>+ </div>+<div class="flex items-center justify-between"><TabsList class="w-fit"><TabsTrigger value="agent">内置驱动</TabsTrigger><TabsTrigger value="jdbc">JDBC 驱动</TabsTrigger></TabsList>- <Button- variant="ghost"- size="sm"- class="h-7 rounded-full text-xs gap-1 text-muted-foreground"- :disabled="importingZip"- @click="importOfflineZip"- >- <FileUp class="h-3.5 w-3.5" />- {{ importingZip ? "导入中..." : "导入离线包" }}- </Button>- <Button- variant="ghost"- size="sm"- class="h-7 rounded-full text-xs gap-1 text-muted-foreground"- :disabled="refreshing"- @click="forceRefresh"- >- <RefreshCw class="h-3.5 w-3.5" :class="{ 'animate-spin': refreshing }" />- 刷新- </Button>+ <div class="flex items-center gap-2">+ <Button+ variant="ghost"+ size="sm"+ class="h-7 rounded-full text-xs gap-1 text-muted-foreground"+ :disabled="importingZip"+ @click="importOfflineZip"+ >+ <FileUp class="h-3.5 w-3.5" />+ {{ importingZip ? "导入中..." : "导入离线包" }}+ </Button>+ <Button+ variant="ghost"+ size="sm"+ class="h-7 rounded-full text-xs gap-1 text-muted-foreground"+ :disabled="refreshing"+ @click="forceRefresh"+ >+ <RefreshCw class="h-3.5 w-3.5" :class="{ 'animate-spin': refreshing }" />+ 刷新+ </Button>+ </div></div><!-- Agent Tab -->@@ -578,6 +636,12 @@ onUnmounted(() => {<div class="text-sm font-medium">JRE {{ jre.key }} 运行时</div></div><div class="flex shrink-0 items-center gap-3">+ <span+ v-if="jreUsageLabel(jre.key)"+ class="rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground"+ >+ {{ jreUsageLabel(jre.key) }}+ </span><Check v-if="jre.installed" class="h-4 w-4 text-green-600" /><span v-else class="text-xs text-muted-foreground">未安装</span><DriverInstallProgressCircle@@ -726,7 +790,10 @@ onUnmounted(() => {<FileUp class="h-3.5 w-3.5" /></Button><template v-else>- <Check class="h-4 w-4 text-green-600" />+ <Check+ v-if="!(driver.update_available && isDriverProgressActive(driver.db_type))"+ class="h-4 w-4 text-green-600"+ /><Buttonv-if="driver.update_available && isDriverQueued(driver.db_type)"size="sm"diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.tsindex 72d033a308..f639e44bfb 100644--- a/apps/desktop/src/lib/api.ts+++ b/apps/desktop/src/lib/api.ts@@ -46,6 +46,7 @@ export const installJdbcPluginLocal = forward("installJdbcPluginLocal");export const uninstallJdbcPlugin = forward("uninstallJdbcPlugin");export const listInstalledAgentsLocal = forward("listInstalledAgentsLocal");export const listInstalledAgents = forward("listInstalledAgents");+export const getDriverStoreUsage = forward("getDriverStoreUsage");export const installAgent = forward("installAgent");export const upgradeAllAgents = forward("upgradeAllAgents");export const uninstallAgent = forward("uninstallAgent");@@ -195,6 +196,8 @@ export type {AiChatMessage,AiConversation,AgentDriverInfo,+ DriverStoreUsage,+ DriverStoreUsageItem,JavaRuntimeMode,JavaRuntimeConfig,DriverInstallProgress,diff --git a/apps/desktop/src/lib/http.ts b/apps/desktop/src/lib/http.tsindex f514a7c757..a77fc3d3dc 100644--- a/apps/desktop/src/lib/http.ts+++ b/apps/desktop/src/lib/http.ts@@ -27,6 +27,7 @@ import type {AiStreamChunk,AiConversation,AiModelInfo,+ DriverStoreUsage,DesktopSettings,DriverInstallProgress,JavaRuntimeConfig,@@ -172,6 +173,10 @@ export async function listInstalledAgents(): Promise<AgentDriverInfo[]> {return get("/api/agents/installed");}+export async function getDriverStoreUsage(): Promise<DriverStoreUsage> {+ return get("/api/agents/storage-usage");+}+export async function installAgent(dbType: string): Promise<void> {await post("/api/agents/install", { dbType });}diff --git a/apps/desktop/src/lib/tauri.ts b/apps/desktop/src/lib/tauri.tsindex 28c02a02ff..14f9d00124 100644--- a/apps/desktop/src/lib/tauri.ts+++ b/apps/desktop/src/lib/tauri.ts@@ -51,6 +51,21 @@ export interface JavaRuntimeConfig {custom_java_path: string | null;}+export interface DriverStoreUsageItem {+ id: string;+ bytes: number;+}++export interface DriverStoreUsage {+ total_bytes: number;+ jre_bytes: number;+ agent_driver_bytes: number;+ jdbc_plugin_bytes: number;+ jdbc_driver_bytes: number;+ jres: DriverStoreUsageItem[];+ agent_drivers: DriverStoreUsageItem[];+}+export interface DesktopSettings {show_tray_icon: boolean;}@@ -443,6 +458,10 @@ export async function listInstalledAgents(): Promise<AgentDriverInfo[]> {return invoke("list_installed_agents");}+export async function getDriverStoreUsage(): Promise<DriverStoreUsage> {+ return invoke("get_driver_store_usage");+}+export async function installAgent(dbType: string): Promise<void> {return invoke("install_agent", { dbType });}diff --git a/crates/dbx-core/src/agent_manager.rs b/crates/dbx-core/src/agent_manager.rsindex f6af233f23..6270b67f0a 100644--- a/crates/dbx-core/src/agent_manager.rs+++ b/crates/dbx-core/src/agent_manager.rs@@ -195,6 +195,23 @@ pub struct AgentDriverInfo {pub jre_installed: bool,}+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct DriverStoreUsageItem {+ pub id: String,+ pub bytes: u64,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct DriverStoreUsage {+ pub total_bytes: u64,+ pub jre_bytes: u64,+ pub agent_driver_bytes: u64,+ pub jdbc_plugin_bytes: u64,+ pub jdbc_driver_bytes: u64,+ pub jres: Vec<DriverStoreUsageItem>,+ pub agent_drivers: Vec<DriverStoreUsageItem>,+}+pub struct AgentManager {base_dir: PathBuf,app_version: String,@@ -281,6 +298,68 @@ impl AgentManager {self.driver_jar_path(db_type).exists()}+ pub fn collect_driver_store_usage(&self, plugin_root: &Path) -> DriverStoreUsage {+ let mut jres = Vec::new();+ let mut jre_bytes = 0u64;+ if let Ok(entries) = std::fs::read_dir(&self.base_dir) {+ for entry in entries.flatten() {+ let path = entry.path();+ if !path.is_dir() {+ continue;+ }+ let Some(name) = path.file_name().and_then(|v| v.to_str()) else {+ continue;+ };+ if !name.starts_with("jre-") {+ continue;+ }+ let key = name.trim_start_matches("jre-").to_string();+ let bytes = path_size_bytes(&path);+ jre_bytes = jre_bytes.saturating_add(bytes);+ jres.push(DriverStoreUsageItem { id: key, bytes });+ }+ }+ jres.sort_by(|left, right| left.id.cmp(&right.id));++ let mut agent_drivers = Vec::new();+ let mut agent_driver_bytes = 0u64;+ let drivers_root = self.base_dir.join("drivers");+ if let Ok(entries) = std::fs::read_dir(&drivers_root) {+ for entry in entries.flatten() {+ let path = entry.path();+ if !path.is_dir() {+ continue;+ }+ let Some(id) = path.file_name().and_then(|v| v.to_str()) else {+ continue;+ };+ let bytes = path_size_bytes(&path);+ agent_driver_bytes = agent_driver_bytes.saturating_add(bytes);+ agent_drivers.push(DriverStoreUsageItem { id: id.to_string(), bytes });+ }+ }+ agent_drivers.sort_by(|left, right| left.id.cmp(&right.id));++ let jdbc_root = plugin_root.join("jdbc");+ let jdbc_driver_root = jdbc_root.join("drivers");+ let jdbc_driver_bytes = path_size_bytes(&jdbc_driver_root);+ let jdbc_total_bytes = path_size_bytes(&jdbc_root);+ let jdbc_plugin_bytes = jdbc_total_bytes.saturating_sub(jdbc_driver_bytes);++ DriverStoreUsage {+ total_bytes: jre_bytes+ .saturating_add(agent_driver_bytes)+ .saturating_add(jdbc_plugin_bytes)+ .saturating_add(jdbc_driver_bytes),+ jre_bytes,+ agent_driver_bytes,+ jdbc_plugin_bytes,+ jdbc_driver_bytes,+ jres,+ agent_drivers,+ }+ }+pub fn resolve_java_runtime(&self, state: &AgentState, jre_key: &str) -> Result<PathBuf, String> {match state.java_runtime.mode {JavaRuntimeMode::Managed => {@@ -429,6 +508,27 @@ impl AgentManager {}}+fn path_size_bytes(path: &Path) -> u64 {+ if let Ok(meta) = std::fs::symlink_metadata(path) {+ if meta.is_file() {+ return meta.len();+ }+ if !meta.is_dir() {+ return 0;+ }+ } else {+ return 0;+ }++ let mut total = 0u64;+ if let Ok(entries) = std::fs::read_dir(path) {+ for entry in entries.flatten() {+ total = total.saturating_add(path_size_bytes(&entry.path()));+ }+ }+ total+}+fn java_executable_name() -> &'static str {if cfg!(windows) {"java.exe"diff --git a/crates/dbx-web/src/main.rs b/crates/dbx-web/src/main.rsindex 54bf6af838..50c5cb895b 100644--- a/crates/dbx-web/src/main.rs+++ b/crates/dbx-web/src/main.rs@@ -89,6 +89,7 @@ async fn main() {// Agent drivers.route("/agents/installed-local", get(routes::agents::list_installed_agents_local)).route("/agents/installed", get(routes::agents::list_installed_agents))+ .route("/agents/storage-usage", get(routes::agents::get_driver_store_usage)).route("/agents/install", post(routes::agents::install_agent)).route("/agents/upgrade-all", post(routes::agents::upgrade_all_agents)).route("/agents/uninstall", post(routes::agents::uninstall_agent))diff --git a/crates/dbx-web/src/routes/agents.rs b/crates/dbx-web/src/routes/agents.rsindex e8aca12944..0a064cda89 100644--- a/crates/dbx-web/src/routes/agents.rs+++ b/crates/dbx-web/src/routes/agents.rs@@ -4,8 +4,8 @@ use axum::extract::{Multipart, Path, State};use axum::response::sse::{Event, Sse};use axum::Json;use dbx_core::agent_manager::{- AgentDriverInfo, AgentManager, AgentRegistry, AgentState, InstalledDriver, JavaRuntimeConfig, JavaRuntimeMode,- DEFAULT_JRE_KEY,+ AgentDriverInfo, AgentManager, AgentRegistry, AgentState, DriverStoreUsage, InstalledDriver, JavaRuntimeConfig,+ JavaRuntimeMode, DEFAULT_JRE_KEY,};use dbx_core::agent_service::{build_agent_list, download_temp_path, fetch_registry, find_local_agent_jar, github_url_to_r2_path,@@ -48,6 +48,10 @@ pub async fn list_installed_agents(State(state): State<Arc<WebState>>) -> ResultOk(Json(build_agent_list(&state.app.agent_manager, registry.as_ref())))}+pub async fn get_driver_store_usage(State(state): State<Arc<WebState>>) -> Result<Json<DriverStoreUsage>, AppError> {+ Ok(Json(state.app.agent_manager.collect_driver_store_usage(state.app.plugins.root_dir())))+}+pub async fn install_agent(State(state): State<Arc<WebState>>,Json(req): Json<AgentTypeRequest>,diff --git a/src-tauri/src/commands/agents.rs b/src-tauri/src/commands/agents.rsindex 899cb35baf..1d50d9875b 100644--- a/src-tauri/src/commands/agents.rs+++ b/src-tauri/src/commands/agents.rs@@ -3,7 +3,8 @@ use std::sync::Arc;use tauri::{Emitter, State};use dbx_core::agent_manager::{- AgentDriverInfo, AgentManager, InstalledDriver, JavaRuntimeConfig, JavaRuntimeMode, DEFAULT_JRE_KEY,+ AgentDriverInfo, AgentManager, DriverStoreUsage, InstalledDriver, JavaRuntimeConfig, JavaRuntimeMode,+ DEFAULT_JRE_KEY,};use dbx_core::agent_service::{build_agent_list, download_temp_path, fetch_registry, find_local_agent_jar, github_url_to_r2_path,@@ -23,6 +24,11 @@ pub async fn list_installed_agents(state: State<'_, Arc<AppState>>) -> Result<VeOk(build_agent_list(&state.agent_manager, registry.as_ref()))}+#[tauri::command]+pub async fn get_driver_store_usage(state: State<'_, Arc<AppState>>) -> Result<DriverStoreUsage, String> {+ Ok(state.agent_manager.collect_driver_store_usage(state.plugins.root_dir()))+}+#[tauri::command]pub async fn install_agent(app: tauri::AppHandle,diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 4c3118a5f7..113ada1f08 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -349,6 +349,7 @@ pub fn run() {commands::text_export::export_query_result_markdown,commands::agents::list_installed_agents,commands::agents::list_installed_agents_local,+ commands::agents::get_driver_store_usage,commands::agents::install_agent,commands::agents::upgrade_all_agents,commands::agents::uninstall_agent,