diff --git a/src/renderer/src/components/key/DbSelector.vue b/src/renderer/src/components/key/DbSelector.vue index 0ce50dd..2cc4167 100644 --- a/src/renderer/src/components/key/DbSelector.vue +++ b/src/renderer/src/components/key/DbSelector.vue @@ -90,16 +90,16 @@ async function fetchDbInfo() { } try { - const info = await connStore.getInfo() + // Use INFO keyspace directly for reliable parsing + const info: any = await window.electronAPI.redis.execute( + connStore.activeId, 'INFO', ['keyspace'] + ) const keyspace: Record = {} - const match = info.match(/# Keyspace[\s\S]*?(?=\n#|$)/) - if (match) { - const lines = match[0].split('\n') - for (const line of lines) { - const dbMatch = line.match(/^db(\d+):keys=(\d+)/) - if (dbMatch) { - keyspace[parseInt(dbMatch[1], 10)] = parseInt(dbMatch[2], 10) - } + const lines = String(info).split('\n') + for (const line of lines) { + const dbMatch = line.match(/^db(\d+):keys=(\d+)/) + if (dbMatch) { + keyspace[parseInt(dbMatch[1], 10)] = parseInt(dbMatch[2], 10) } } for (let i = 0; i < dbCount.value; i++) { @@ -127,8 +127,13 @@ watch( watch( () => connStore.activeId, - () => { + async () => { loadCustomNames() + if (connStore.isConnected) { + selectedDb.value = 0 + keyStore.currentDb = 0 + await fetchDbInfo() + } } ) @@ -143,6 +148,8 @@ function formatCount(n: number): string { if (n >= 10000) return `${(n / 1000).toFixed(0)}k` return String(n) } + +defineExpose({ refreshDbCounts: fetchDbInfo })