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(driver-store): badge-style version/size, refresh button, fix dameng icon

t8y2e87876c92365
diff --git a/crates/dbx-core/src/db/redis_driver.rs b/crates/dbx-core/src/db/redis_driver.rs
index 083bfddea7..1ef0e61ad3 100644
--- a/crates/dbx-core/src/db/redis_driver.rs
+++ b/crates/dbx-core/src/db/redis_driver.rs
@@ -628,6 +628,15 @@ pub async fn list_push(con: &mut redis::aio::MultiplexedConnection, key: &[u8],
redis::cmd("RPUSH").arg(key).arg(value).query_async::<()>(con).await.map_err(|e| e.to_string())
}
+pub async fn list_set(
+ con: &mut redis::aio::MultiplexedConnection,
+ key: &[u8],
+ index: i64,
+ value: &str,
+) -> Result<(), String> {
+ redis::cmd("LSET").arg(key).arg(index).arg(value).query_async::<()>(con).await.map_err(|e| e.to_string())
+}
+
pub async fn list_remove(con: &mut redis::aio::MultiplexedConnection, key: &[u8], index: i64) -> Result<(), String> {
let placeholder = "__DELETED_PLACEHOLDER__";
redis::cmd("LSET").arg(key).arg(index).arg(placeholder).query_async::<()>(con).await.map_err(|e| e.to_string())?;
diff --git a/crates/dbx-core/src/redis_ops.rs b/crates/dbx-core/src/redis_ops.rs
index 79d93d2e7c..6b58e48000 100644
--- a/crates/dbx-core/src/redis_ops.rs
+++ b/crates/dbx-core/src/redis_ops.rs
@@ -186,6 +186,26 @@ pub async fn redis_list_push_in_db_core(
}
}
+pub async fn redis_list_set_in_db_core(
+ state: &AppState,
+ connection_id: &str,
+ db: u32,
+ key_raw: &str,
+ index: i64,
+ value: &str,
+) -> Result<(), String> {
+ let connections = state.connections.read().await;
+ match connections.get(connection_id).ok_or("Not found")? {
+ PoolKind::Redis(con) => {
+ let mut con = con.lock().await;
+ let key = redis_driver::redis_key_raw_to_bytes(key_raw)?;
+ redis_driver::select_db(&mut con, db).await?;
+ redis_driver::list_set(&mut con, &key, index, value).await
+ }
+ _ => Err("Not a Redis connection".to_string()),
+ }
+}
+
pub async fn redis_list_remove_core(
state: &AppState,
connection_id: &str,
diff --git a/src-tauri/src/commands/agents.rs b/src-tauri/src/commands/agents.rs
index 5133899bc1..f5f2022d5d 100644
--- a/src-tauri/src/commands/agents.rs
+++ b/src-tauri/src/commands/agents.rs
@@ -134,6 +134,12 @@ pub async fn check_jre_installed(state: State<'_, Arc<AppState>>) -> Result<bool
Ok(state.agent_manager.is_jre_installed())
}
+#[tauri::command]
+pub async fn invalidate_agent_registry_cache() -> Result<(), String> {
+ *REGISTRY_CACHE.lock().await = None;
+ Ok(())
+}
+
#[tauri::command]
pub async fn reinstall_jre(app: tauri::AppHandle, state: State<'_, Arc<AppState>>) -> Result<(), String> {
let am = &state.agent_manager;
diff --git a/src-tauri/src/commands/redis_cmd.rs b/src-tauri/src/commands/redis_cmd.rs
index 70767c06e3..d9f28223b0 100644
--- a/src-tauri/src/commands/redis_cmd.rs
+++ b/src-tauri/src/commands/redis_cmd.rs
@@ -87,6 +87,18 @@ pub async fn redis_list_push(
dbx_core::redis_ops::redis_list_push_in_db_core(&state, &connection_id, db, &key_raw, &value).await
}
+#[tauri::command]
+pub async fn redis_list_set(
+ state: State<'_, Arc<AppState>>,
+ connection_id: String,
+ db: u32,
+ key_raw: String,
+ index: i64,
+ value: String,
+) -> Result<(), String> {
+ dbx_core::redis_ops::redis_list_set_in_db_core(&state, &connection_id, db, &key_raw, index, &value).await
+}
+
#[tauri::command]
pub async fn redis_list_remove(
state: State<'_, Arc<AppState>>,
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 45a306493a..41722c1ade 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -113,6 +113,7 @@ pub fn run() {
commands::redis_cmd::redis_hash_set,
commands::redis_cmd::redis_hash_del,
commands::redis_cmd::redis_list_push,
+ commands::redis_cmd::redis_list_set,
commands::redis_cmd::redis_list_remove,
commands::redis_cmd::redis_set_add,
commands::redis_cmd::redis_set_remove,
@@ -148,6 +149,7 @@ pub fn run() {
commands::agents::uninstall_agent,
commands::agents::check_jre_installed,
commands::agents::reinstall_jre,
+ commands::agents::invalidate_agent_registry_cache,
])
.build(tauri::generate_context!())
.expect("error while building tauri application")
diff --git a/src-web/src/main.rs b/src-web/src/main.rs
index 6f2c14992a..297829d8bf 100644
--- a/src-web/src/main.rs
+++ b/src-web/src/main.rs
@@ -114,6 +114,7 @@ async fn main() {
.route("/redis/hash-set", post(routes::redis::hash_set))
.route("/redis/hash-del", post(routes::redis::hash_del))
.route("/redis/list-push", post(routes::redis::list_push))
+ .route("/redis/list-set", post(routes::redis::list_set))
.route("/redis/list-remove", post(routes::redis::list_remove))
.route("/redis/set-add", post(routes::redis::set_add))
.route("/redis/set-remove", post(routes::redis::set_remove))
diff --git a/src-web/src/routes/redis.rs b/src-web/src/routes/redis.rs
index dd6b067ef0..ec092f0748 100644
--- a/src-web/src/routes/redis.rs
+++ b/src-web/src/routes/redis.rs
@@ -195,6 +195,18 @@ pub async fn list_push(
Ok(Json(()))
}
+pub async fn list_set(
+ State(state): State<Arc<WebState>>,
+ Json(req): Json<RedisListRequest>,
+) -> Result<Json<()>, AppError> {
+ let index = req.index.unwrap_or(0);
+ let value = req.value.as_deref().unwrap_or("");
+ dbx_core::redis_ops::redis_list_set_in_db_core(&state.app, &req.connection_id, req.db, &req.key_raw, index, value)
+ .await
+ .map_err(AppError)?;
+ Ok(Json(()))
+}
+
pub async fn list_remove(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisListRequest>,
diff --git a/src/components/config/DriverStoreDialog.vue b/src/components/config/DriverStoreDialog.vue
index af35c4fa9f..00d7724b5a 100644
--- a/src/components/config/DriverStoreDialog.vue
+++ b/src/components/config/DriverStoreDialog.vue
@@ -4,7 +4,7 @@ import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import type { UnlistenFn } from "@tauri-apps/api/event";
import { useI18n } from "vue-i18n";
-import { FolderOpen, Trash2, Download, RotateCcw, Loader2 } from "lucide-vue-next";
+import { FolderOpen, Trash2, Download, RotateCcw, Loader2, RefreshCw } from "lucide-vue-next";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -41,6 +41,7 @@ const drivers = ref<AgentDriverInfo[]>([]);
const jreInstalled = ref(false);
const installing = ref<string | null>(null);
const reinstallingJre = ref(false);
+const refreshing = ref(false);
const progress = ref<InstallProgress | null>(null);
let unlisten: UnlistenFn | null = null;
@@ -68,6 +69,16 @@ async function refreshAgents() {
drivers.value = await invoke<AgentDriverInfo[]>("list_installed_agents");
}
+async function forceRefresh() {
+ refreshing.value = true;
+ try {
+ await invoke("invalidate_agent_registry_cache");
+ await refreshAgents();
+ } finally {
+ refreshing.value = false;
+ }
+}
+
async function installDriver(dbType: string) {
const label = drivers.value.find((d) => d.db_type === dbType)?.label ?? dbType;
installing.value = dbType;
@@ -249,10 +260,22 @@ 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">
- <TabsList class="w-fit">
- <TabsTrigger value="agent">内置驱动</TabsTrigger>
- <TabsTrigger value="jdbc">JDBC 驱动</TabsTrigger>
- </TabsList>
+ <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 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>
<!-- Agent Tab -->
<TabsContent value="agent" class="mt-5 space-y-5">
@@ -306,9 +329,29 @@ onUnmounted(() => {
<div class="min-w-0 flex-1">
<div class="text-sm font-medium">{{ driver.label }}</div>
</div>
- <div class="text-xs text-muted-foreground text-right shrink-0">
- <span v-if="driver.installed">v{{ driver.installed_version }}</span>
- <span v-else-if="formatSize(driver.size)">{{ formatSize(driver.size) }}</span>
+ <div class="flex shrink-0 items-center gap-1.5">
+ <template v-if="driver.installed">
+ <span class="rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground"
+ >v{{ driver.installed_version }}</span
+ >
+ <span
+ v-if="driver.update_available"
+ class="rounded-full bg-amber-500/15 px-2 py-0.5 text-[11px] text-amber-600"
+ >→ v{{ driver.version }}</span
+ >
+ </template>
+ <template v-else>
+ <span
+ v-if="driver.version"
+ class="rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground"
+ >v{{ driver.version }}</span
+ >
+ </template>
+ <span
+ v-if="formatSize(driver.size)"
+ class="rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground"
+ >{{ formatSize(driver.size) }}</span
+ >
</div>
<div class="flex shrink-0 items-center gap-2">
<Button
diff --git a/src/components/icons/DatabaseIcon.vue b/src/components/icons/DatabaseIcon.vue
index 2e1fc99236..b76279484f 100644
--- a/src/components/icons/DatabaseIcon.vue
+++ b/src/components/icons/DatabaseIcon.vue
@@ -27,6 +27,7 @@ const assetIcons: Record<string, string> = {
snowflake: "snowflake",
h2: "h2",
dm: "dm",
+ dameng: "dm",
presto: "presto",
hive: "hive",
apache_kylin: "apache_kylin",