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。

refactor: extract GITHUB_PROXIES constant shared by update and agent modules

t8y2ff80e767d6f2
diff --git a/crates/dbx-core/src/lib.rs b/crates/dbx-core/src/lib.rs
index 59c8d5d3bf..36143057ba 100644
--- a/crates/dbx-core/src/lib.rs
+++ b/crates/dbx-core/src/lib.rs
@@ -20,3 +20,5 @@ pub mod table_import;
pub mod transfer;
pub mod types;
pub mod update;
+
+pub const GITHUB_PROXIES: &[&str] = &["https://update.hwdns.net/", "https://gh-proxy.org/", ""];
diff --git a/crates/dbx-core/src/update.rs b/crates/dbx-core/src/update.rs
index b93c5aef63..b70d68a9c8 100644
--- a/crates/dbx-core/src/update.rs
+++ b/crates/dbx-core/src/update.rs
@@ -1,10 +1,6 @@
use serde::{Deserialize, Serialize};
-const LATEST_JSON_URLS: &[&str] = &[
- "https://update.hwdns.net/https://github.com/t8y2/dbx/releases/latest/download/latest.json",
- "https://gh-proxy.org/https://github.com/t8y2/dbx/releases/latest/download/latest.json",
- "https://github.com/t8y2/dbx/releases/latest/download/latest.json",
-];
+const LATEST_JSON_PATH: &str = "https://github.com/t8y2/dbx/releases/latest/download/latest.json";
const GITHUB_RELEASE_API_PREFIX: &str = "https://api.github.com/repos/t8y2/dbx/releases/tags/v";
const RELEASE_URL_PREFIX: &str = "https://github.com/t8y2/dbx/releases/tag/v";
@@ -40,9 +36,10 @@ pub async fn fetch_latest_release() -> Result<TauriRelease, String> {
.build()
.map_err(|e| format!("Failed to create HTTP client: {e}"))?;
let mut last_err = String::new();
- for url in LATEST_JSON_URLS {
+ for proxy in crate::GITHUB_PROXIES {
+ let url = format!("{proxy}{LATEST_JSON_PATH}");
match client
- .get(*url)
+ .get(&url)
.header(reqwest::header::USER_AGENT, "dbx-update-checker")
.send()
.await
diff --git a/src-tauri/src/commands/agents.rs b/src-tauri/src/commands/agents.rs
index 7d4d03fc3e..8832ad18a6 100644
--- a/src-tauri/src/commands/agents.rs
+++ b/src-tauri/src/commands/agents.rs
@@ -5,13 +5,7 @@ use tauri::State;
use dbx_core::agent_manager::{AgentDriverInfo, AgentManager, AgentRegistry, InstalledDriver};
use dbx_core::connection::AppState;
-const REGISTRY_URLS: &[&str] = &[
- "https://update.hwdns.net/https://github.com/t8y2/dbx-agents/releases/latest/download/agent-registry.json",
- "https://gh-proxy.org/https://github.com/t8y2/dbx-agents/releases/latest/download/agent-registry.json",
- "https://github.com/t8y2/dbx-agents/releases/latest/download/agent-registry.json",
-];
-
-const DOWNLOAD_PROXIES: &[&str] = &["https://update.hwdns.net/", "https://gh-proxy.org/", ""];
+const REGISTRY_PATH: &str = "https://github.com/t8y2/dbx-agents/releases/latest/download/agent-registry.json";
#[tauri::command]
pub async fn list_installed_agents(state: State<'_, Arc<AppState>>) -> Result<Vec<AgentDriverInfo>, String> {
@@ -105,9 +99,10 @@ async fn fetch_registry() -> Result<AgentRegistry, String> {
.build()
.map_err(|e| format!("Failed to create HTTP client: {e}"))?;
let mut last_err = String::new();
- for url in REGISTRY_URLS {
+ for proxy in dbx_core::GITHUB_PROXIES {
+ let url = format!("{proxy}{REGISTRY_PATH}");
match client
- .get(*url)
+ .get(&url)
.header(reqwest::header::USER_AGENT, "dbx-agent-manager")
.send()
.await
@@ -133,7 +128,7 @@ async fn download_with_proxy(url: &str, dest: &std::path::Path) -> Result<(), St
.build()
.map_err(|e| format!("Failed to create HTTP client: {e}"))?;
let mut last_err = String::new();
- for proxy in DOWNLOAD_PROXIES {
+ for proxy in dbx_core::GITHUB_PROXIES {
let full_url = format!("{proxy}{url}");
log::info!("[agent] downloading from {full_url}");
match client