Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

feat(plugins): support local JDBC plugin installation

t8y2081a3568325d
diff --git a/src-tauri/src/commands/plugins.rs b/src-tauri/src/commands/plugins.rs
index df4b950639..f61fe923f6 100644
--- a/src-tauri/src/commands/plugins.rs
+++ b/src-tauri/src/commands/plugins.rs
@@ -42,6 +42,17 @@ pub async fn install_jdbc_plugin(state: State<'_, Arc<AppState>>) -> Result<Jdbc
jdbc_plugin_status_from_state(&state)
}
+#[tauri::command]
+pub async fn install_jdbc_plugin_local(
+ state: State<'_, Arc<AppState>>,
+ path: String,
+) -> Result<JdbcPluginStatus, String> {
+ let bytes = std::fs::read(&path).map_err(|e| format!("Failed to read file: {e}"))?;
+ let plugin_dir = state.plugins.root_dir().join("jdbc");
+ install_jdbc_plugin_zip(&bytes, &plugin_dir)?;
+ jdbc_plugin_status_from_state(&state)
+}
+
#[tauri::command]
pub async fn uninstall_jdbc_plugin(state: State<'_, Arc<AppState>>) -> Result<JdbcPluginStatus, String> {
let plugin_dir = state.plugins.root_dir().join("jdbc");
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 1b2f8ea829..fb7d141b2c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -93,6 +93,7 @@ pub fn run() {
commands::plugins::delete_jdbc_driver,
commands::plugins::jdbc_plugin_status,
commands::plugins::install_jdbc_plugin,
+ commands::plugins::install_jdbc_plugin_local,
commands::plugins::uninstall_jdbc_plugin,
commands::schema::list_databases,
commands::schema::list_tables,
diff --git a/src/components/config/DriverStoreDialog.vue b/src/components/config/DriverStoreDialog.vue
index 1dd1dc7652..9ddf0fb109 100644
--- a/src/components/config/DriverStoreDialog.vue
+++ b/src/components/config/DriverStoreDialog.vue
@@ -281,6 +281,27 @@ async function installJdbcPlugin() {
}
}
+async function installJdbcPluginLocal() {
+ if (isWeb || isInstallingJdbcPlugin.value) return;
+ const { open } = await import("@tauri-apps/plugin-dialog");
+ const selected = await open({
+ title: "选择 JDBC 插件 zip 文件",
+ multiple: false,
+ filters: [{ name: "ZIP", extensions: ["zip"] }],
+ });
+ if (typeof selected !== "string") return;
+ isInstallingJdbcPlugin.value = true;
+ try {
+ jdbcPluginStatus.value = await invoke<JdbcPluginStatus>("install_jdbc_plugin_local", { path: selected });
+ toast(t("settings.jdbcPluginInstallSuccess"));
+ await loadJdbcDrivers();
+ } catch (e: any) {
+ toast(String(e?.message || e), 5000);
+ } finally {
+ isInstallingJdbcPlugin.value = false;
+ }
+}
+
async function uninstallJdbcPlugin() {
if (isWeb || isUninstallingJdbcPlugin.value) return;
isUninstallingJdbcPlugin.value = true;
@@ -636,6 +657,16 @@ onUnmounted(() => {
>
{{ isInstallingJdbcPlugin ? t("common.loading") : t("settings.jdbcPluginInstall") }}
</Button>
+ <Button
+ v-if="!jdbcPluginStatus?.installed"
+ type="button"
+ variant="outline"
+ :disabled="isInstallingJdbcPlugin"
+ @click="installJdbcPluginLocal"
+ >
+ <FolderOpen class="h-3.5 w-3.5 mr-1" />
+ 本地安装
+ </Button>
</div>
</div>
</div>