refactor(redis): keep keys out of sidebar tree

This commit is contained in:
t8y2
2026-04-30 14:29:25 +08:00
parent 2ae954e7a3
commit 5490ed007e
5 changed files with 6 additions and 73 deletions
-52
View File
@@ -161,56 +161,6 @@ export const useConnectionStore = defineStore("connection", () => {
}
}
async function loadRedisKeys(connectionId: string, db: number, nodeId: string) {
const node = findNode(treeNodes.value, nodeId);
if (!node) return;
node.isLoading = true;
try {
const result = await api.redisScanKeys(connectionId, db, 0, "*", 200);
node.scanCursor = result.cursor;
node.hasMore = result.cursor !== 0;
node.children = result.keys.map((k) => ({
id: `${nodeId}:${k.key}`,
label: `${k.key} [${k.key_type}]${k.ttl > 0 ? ` TTL:${k.ttl}` : ""}`,
type: "redis-key" as const,
connectionId,
database: String(db),
isExpanded: false,
}));
node.isExpanded = true;
} finally {
node.isLoading = false;
}
}
async function loadMoreRedisKeys(connectionId: string, db: number, nodeId: string) {
const node = findNode(treeNodes.value, nodeId);
if (!node || node.isLoading || !node.hasMore) return;
node.isLoading = true;
try {
const result = await api.redisScanKeys(connectionId, db, node.scanCursor ?? 0, "*", 200);
const existingIds = new Set((node.children ?? []).map((child) => child.id));
const moreChildren = result.keys
.filter((k) => !existingIds.has(`${nodeId}:${k.key}`))
.map((k) => ({
id: `${nodeId}:${k.key}`,
label: `${k.key} [${k.key_type}]${k.ttl > 0 ? ` TTL:${k.ttl}` : ""}`,
type: "redis-key" as const,
connectionId,
database: String(db),
isExpanded: false,
}));
node.scanCursor = result.cursor;
node.hasMore = result.cursor !== 0;
node.children = [...(node.children ?? []), ...moreChildren];
} finally {
node.isLoading = false;
}
}
async function loadMongoDatabases(connectionId: string) {
const node = findNode(treeNodes.value, connectionId);
if (!node) return;
@@ -506,8 +456,6 @@ export const useConnectionStore = defineStore("connection", () => {
initFromDisk,
loadDatabases,
loadRedisDatabases,
loadRedisKeys,
loadMoreRedisKeys,
loadMongoDatabases,
loadMongoCollections,
loadSchemas,