feat: P3 batch 2 - sidebar resize, DB features, Status/SlowLog, editor improvements

- Resizable sidebar (200-500px, localStorage persistence)
- DB auto-detection (CONFIG GET databases) + key count in dropdown
- DB memory (last selected DB per connection)
- Status auto-refresh toggle + search filter + key statistics table
- SlowLog config display (threshold + max len)
- Large value protection (>20MB placeholder + download)
- Hash field TTL (HEXPIRE support detection)
- Editor inline filters (Hash/Set/Zset)
- Zset ASC/DESC sort toggle
- CLI auto-sync SELECT + refresh key list on write commands
- i18n keys for all features (zh-CN + en)
This commit is contained in:
2026-07-07 22:44:59 +08:00
parent 5505434325
commit 75c3a854d6
12 changed files with 533 additions and 45 deletions
+33 -2
View File
@@ -42,8 +42,17 @@ export const useConnectionStore = defineStore('connection', () => {
const serverInfoMap = ref<Record<string, string>>({})
const healthMap = ref<Record<string, boolean>>({})
const currentDb = ref<number>(0)
const lastDbMap = ref<Record<string, number>>({})
const healthTimers = new Map<string, ReturnType<typeof setInterval>>()
// Load lastDbMap from localStorage
try {
const saved = localStorage.getItem('lastDbMap')
if (saved) {
lastDbMap.value = JSON.parse(saved)
}
} catch { /* ignore */ }
const activeConnection = computed(() =>
connections.value.find((c: ConnectionConfig) => c.id === activeId.value) ?? null
)
@@ -123,6 +132,14 @@ export const useConnectionStore = defineStore('connection', () => {
connectedIds.value.push(conn.id)
activeId.value = conn.id
serverInfoMap.value[conn.id] = await window.electronAPI.redis.getInfo(conn.id)
// Restore last selected DB for this connection
const lastDb = lastDbMap.value[conn.id] ?? 0
if (lastDb !== 0) {
try {
await window.electronAPI.redis.selectDb(conn.id, lastDb)
} catch { /* ignore */ }
}
currentDb.value = lastDb
startHealthCheck(conn.id)
} else {
error.value = result.error || 'Connection failed'
@@ -134,9 +151,16 @@ export const useConnectionStore = defineStore('connection', () => {
}
}
function switchTo(id: string) {
async function switchTo(id: string) {
if (connectedIds.value.includes(id)) {
activeId.value = id
const lastDb = lastDbMap.value[id] ?? 0
if (lastDb !== currentDb.value) {
try {
await window.electronAPI.redis.selectDb(id, lastDb)
} catch { /* ignore */ }
}
currentDb.value = lastDb
}
}
@@ -253,6 +277,12 @@ export const useConnectionStore = defineStore('connection', () => {
return data
}
function saveLastDb(connId: string, db: number) {
lastDbMap.value[connId] = db
currentDb.value = db
localStorage.setItem('lastDbMap', JSON.stringify(lastDbMap.value))
}
async function importConnections(jsonStr: string): Promise<number> {
try {
const imported = JSON.parse(jsonStr) as ConnectionConfig[]
@@ -274,9 +304,10 @@ export const useConnectionStore = defineStore('connection', () => {
}
return {
connections, activeId, connectedIds, connecting, error, serverInfo, healthOk, currentDb,
connections, activeId, connectedIds, connecting, error, serverInfo, healthOk, currentDb, lastDbMap,
activeConnection, isConnected,
loadConnections, decryptPassword, getInfo, saveConnection, deleteConnection, reorderConnections,
connect, disconnect, disconnectById, switchTo, isConnectedById, testConnection, exportConnections, importConnections,
saveLastDb,
}
})