diff --git a/apps/desktop/src/components/config/DriverStoreDialog.vue b/apps/desktop/src/components/config/DriverStoreDialog.vue index 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(null); const javaRuntimeConfig = ref({ mode: "managed", custom_java_path: null }); const customJavaPath = ref(""); const savingJavaRuntime = ref(false); +const driverStoreUsage = ref(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(); + 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(() => {
+
+
+
空间占用明细
+
+ {{ usageSummary.length ? `总计 ${formatBytes(usageSummary[0].bytes)}` : "统计中..." }} +
+
+
+
+
{{ item.label }}
+
{{ formatBytes(item.bytes) }}
+
+
+
+
内置驱动 JDBC 驱动 - - +
+ + +
@@ -578,6 +636,12 @@ onUnmounted(() => {
JRE {{ jre.key }} 运行时
+ + {{ jreUsageLabel(jre.key) }} + 未安装 {