157af4399f
- 恢复 IPC 类型声明 (src/electron-api.d.ts),修复 31 个 TS2339 错误 - 修复构建断裂:vite.config.ts 改回 electron.vite.config.ts - 修复 2 个 verbatimModuleSyntax type-import 报错 - 修正 .gitignore 构建产物路径 (electron-dist/ -> dist-electron/ + release/) - 清理 55+ 处过时路径注释 - 更新 AGENTS.md 架构文档与 IPC 通道表 - 修正 docs/ROADMAP.md 过时引用
30 lines
1003 B
TypeScript
30 lines
1003 B
TypeScript
// Hash 操作
|
|
import { getClient } from './connection'
|
|
|
|
export async function getHashFields(
|
|
id: string, key: string, cursor: string, count: number
|
|
): Promise<{ cursor: string; fields: [string, string][] }> {
|
|
const client = getClient(id)
|
|
if (!client) throw new Error(`Client ${id} not found`)
|
|
const [nextCursor, raw] = await client.hscan(key, cursor, 'COUNT', count)
|
|
const fields: [string, string][] = []
|
|
for (let i = 0; i < raw.length; i += 2) {
|
|
fields.push([raw[i], raw[i + 1]])
|
|
}
|
|
return { cursor: nextCursor, fields }
|
|
}
|
|
|
|
export async function setHashField(
|
|
id: string, key: string, field: string, value: string
|
|
): Promise<void> {
|
|
const client = getClient(id)
|
|
if (!client) throw new Error(`Client ${id} not found`)
|
|
await client.hset(key, field, value)
|
|
}
|
|
|
|
export async function deleteHashField(id: string, key: string, field: string): Promise<void> {
|
|
const client = getClient(id)
|
|
if (!client) throw new Error(`Client ${id} not found`)
|
|
await client.hdel(key, field)
|
|
}
|