feat: add Redis member detail viewer

This commit is contained in:
t8y2
2026-05-13 11:12:32 +08:00
parent 4d4c8f4224
commit fea3552774
6 changed files with 199 additions and 14 deletions
+26
View File
@@ -0,0 +1,26 @@
export type RedisMemberDetailFormat = "json" | "text";
export interface RedisMemberDetail {
text: string;
format: RedisMemberDetailFormat;
}
export function formatRedisMemberDetail(value: unknown): RedisMemberDetail {
if (typeof value === "string") {
const trimmed = value.trim();
if (trimmed) {
try {
return { text: JSON.stringify(JSON.parse(trimmed), null, 2), format: "json" };
} catch {
/* fall through to plain text */
}
}
return { text: value, format: "text" };
}
try {
return { text: JSON.stringify(value, null, 2), format: "json" };
} catch {
return { text: String(value), format: "text" };
}
}