feat: ReJson/TairJson support

- string.ts: rejsonGet, rejsonSet, rejsonDel using JSON.GET/SET/DEL
- IPC + preload for rejsonGet/rejsonSet
- New ReJsonEditor.vue: Monaco JSON editor with JSON.GET/SET
- KeyDetail: dispatch ReJSON-RL/json/tair-json types to ReJsonEditor
This commit is contained in:
2026-07-07 21:58:17 +08:00
parent 1511427e62
commit b85e67541b
7 changed files with 128 additions and 2 deletions
+8
View File
@@ -159,6 +159,14 @@ export function registerIpcHandlers(): void {
await redis.setStringValue(id, key, value)
}))
// ReJson
ipcMain.handle('redis:rejsonGet', async (_e, id: string, key: string, path: string) => {
return redis.rejsonGet(id, key, path)
})
ipcMain.handle('redis:rejsonSet', withLog('JSON.SET', async (_e, id: string, key: string, path: string, value: string) => {
await redis.rejsonSet(id, key, path, value)
}))
// Redis - Hash
ipcMain.handle('redis:hashScan', async (_e, id: string, key: string, cursor: string, count: number) => {
return redis.getHashFields(id, key, cursor, count)
+20 -1
View File
@@ -1,5 +1,5 @@
// src/main/redis/string.ts
// String 操作
// String + ReJson 操作
import { getClient } from './connection'
export async function getStringValue(id: string, key: string): Promise<string | null> {
@@ -13,3 +13,22 @@ export async function setStringValue(id: string, key: string, value: string): Pr
if (!client) throw new Error(`Client ${id} not found`)
await client.set(key, value)
}
// ReJson operations
export async function rejsonGet(id: string, key: string, path: string = '.'): Promise<string> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return (client as any).call('JSON.GET', key, path)
}
export async function rejsonSet(id: string, key: string, path: string, value: string): Promise<void> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
await (client as any).call('JSON.SET', key, path, value)
}
export async function rejsonDel(id: string, key: string, path: string = '.'): Promise<number> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return (client as any).call('JSON.DEL', key, path)
}
+2
View File
@@ -68,6 +68,8 @@ export interface ElectronAPI {
getKeyTTL: (id: string, key: string) => Promise<number>
getString: (id: string, key: string) => Promise<string | null>
setString: (id: string, key: string, value: string) => Promise<void>
rejsonGet: (id: string, key: string, path: string) => Promise<string>
rejsonSet: (id: string, key: string, path: string, value: string) => Promise<void>
deleteKey: (id: string, key: string) => Promise<void>
hashScan: (id: string, key: string, cursor: string, count: number) =>
Promise<{ cursor: string; fields: [string, string][] }>
+5
View File
@@ -43,6 +43,11 @@ const electronAPI = {
getString: (id: string, key: string): Promise<string | null> => ipcRenderer.invoke('redis:getString', id, key),
setString: (id: string, key: string, value: string): Promise<void> =>
ipcRenderer.invoke('redis:setString', id, key, value),
// ReJson
rejsonGet: (id: string, key: string, path: string): Promise<string> =>
ipcRenderer.invoke('redis:rejsonGet', id, key, path),
rejsonSet: (id: string, key: string, path: string, value: string): Promise<void> =>
ipcRenderer.invoke('redis:rejsonSet', id, key, path, value),
deleteKey: (id: string, key: string): Promise<void> => ipcRenderer.invoke('redis:deleteKey', id, key),
hashScan: (id: string, key: string, cursor: string, count: number): Promise<any> =>
ipcRenderer.invoke('redis:hashScan', id, key, cursor, count),