From d6f5c25c17198a1c0e5e28f4db59ee34a96f88a2 Mon Sep 17 00:00:00 2001 From: Bacon2994 <108093786+Bacon2994@users.noreply.github.com> Date: Fri, 8 May 2026 10:31:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(redis):=20=E4=BC=98=E5=8C=96=20UTF-8=20?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E4=B8=8E=E6=8F=90=E7=A4=BA=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/dbx-core/src/db/redis_driver.rs | 11 +++++++++++ src/components/redis/RedisValueViewer.vue | 2 +- src/i18n/locales/en.ts | 1 + src/i18n/locales/zh-CN.ts | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/dbx-core/src/db/redis_driver.rs b/crates/dbx-core/src/db/redis_driver.rs index d2b30912c5..61c8a0f8b3 100644 --- a/crates/dbx-core/src/db/redis_driver.rs +++ b/crates/dbx-core/src/db/redis_driver.rs @@ -349,6 +349,10 @@ fn redis_bytes_need_escape(bytes: &[u8]) -> bool { } fn redis_bytes_to_display(bytes: &[u8]) -> String { + if let Ok(text) = std::str::from_utf8(bytes) { + return text.replace('\\', "\\\\"); + } + let mut output = String::new(); for &byte in bytes { match byte { @@ -498,6 +502,13 @@ mod tests { assert_eq!(redis_key_bytes_to_display(&bytes), "\\xac\\xed\\x00\\x05t\\x00A\\\\"); } + #[test] + fn preserves_utf8_keys_as_readable_text() { + let bytes = "用户:配置".as_bytes(); + + assert_eq!(redis_key_bytes_to_display(bytes), "用户:配置"); + } + #[test] fn round_trips_raw_key_transport() { let bytes = b"\xAC\xED\x00\x05t\x00token"; diff --git a/src/components/redis/RedisValueViewer.vue b/src/components/redis/RedisValueViewer.vue index 8868a68b6f..6a887b4b40 100644 --- a/src/components/redis/RedisValueViewer.vue +++ b/src/components/redis/RedisValueViewer.vue @@ -189,7 +189,7 @@ onMounted(load); @input="handleStringInput" />
- 二进制字符串按转义文本只读展示;当前不支持直接编辑原始字节值。 + {{ t("redis.binaryStringReadonlyHint") }}