From e87876c923656962a20ea4093ae2ce62b1eedfc5 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Wed, 13 May 2026 12:26:56 +0800 Subject: [PATCH] feat(driver-store): badge-style version/size, refresh button, fix dameng icon - Show version and size as rounded badges instead of plain text - Display remote version with amber badge when update available - Add refresh button to clear registry cache and reload - Add invalidate_agent_registry_cache Tauri command - Fix dameng icon mapping (dameng -> dm) --- crates/dbx-core/src/db/redis_driver.rs | 9 ++++ crates/dbx-core/src/redis_ops.rs | 20 +++++++ src-tauri/src/commands/agents.rs | 6 +++ src-tauri/src/commands/redis_cmd.rs | 12 +++++ src-tauri/src/lib.rs | 2 + src-web/src/main.rs | 1 + src-web/src/routes/redis.rs | 12 +++++ src/components/config/DriverStoreDialog.vue | 59 ++++++++++++++++++--- src/components/icons/DatabaseIcon.vue | 1 + 9 files changed, 114 insertions(+), 8 deletions(-) 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>) -> Result Result<(), String> { + *REGISTRY_CACHE.lock().await = None; + Ok(()) +} + #[tauri::command] pub async fn reinstall_jre(app: tauri::AppHandle, state: State<'_, Arc>) -> 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>, + 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>, 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>, + Json(req): Json, +) -> Result, 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>, Json(req): Json, 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([]); const jreInstalled = ref(false); const installing = ref(null); const reinstallingJre = ref(false); +const refreshing = ref(false); const progress = ref(null); let unlisten: UnlistenFn | null = null; @@ -68,6 +69,16 @@ async function refreshAgents() { drivers.value = await invoke("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(() => {
- - 内置驱动 - JDBC 驱动 - +
+ + 内置驱动 + JDBC 驱动 + + +
@@ -306,9 +329,29 @@ onUnmounted(() => {
{{ driver.label }}
-
- v{{ driver.installed_version }} - {{ formatSize(driver.size) }} +
+ + + {{ formatSize(driver.size) }}