mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-23 04:55:21 +00:00
fix(redis): redis命令控制台上下文隔离
This commit is contained in:
@@ -816,38 +816,13 @@ function resumeRedisBrowserBackgroundWork() {
|
||||
registerRedisDbFlushedListener();
|
||||
}
|
||||
|
||||
async function loadPersistedRedisHistory() {
|
||||
try {
|
||||
const entries = await api.loadRedisHistory(200, 0);
|
||||
if (entries.length === 0) return;
|
||||
// Merge persisted entries into in-memory commandHistory (newest first, reversed for display order)
|
||||
const persisted: RedisCommandHistoryEntry[] = entries.reverse().map((entry) => ({
|
||||
id: ++commandHistoryId,
|
||||
prompt: `db${entry.database}>`,
|
||||
command: entry.sql,
|
||||
output: entry.details_json ? formatRedisCommandResult(JSON.parse(entry.details_json)) : entry.error || "",
|
||||
error: !entry.success,
|
||||
}));
|
||||
commandHistory.value = [...persisted, ...commandHistory.value];
|
||||
scrollCommandTerminalToEnd();
|
||||
} catch {
|
||||
// Silently ignore load errors — history is best-effort
|
||||
}
|
||||
}
|
||||
|
||||
async function clearPersistedRedisHistory() {
|
||||
try {
|
||||
await api.clearRedisHistory();
|
||||
toast(t("redis.historyCleared"));
|
||||
} catch {
|
||||
// Silently ignore
|
||||
}
|
||||
async function clearInMemoryHistory() {
|
||||
commandHistory.value = [];
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
resumeRedisBrowserBackgroundWork();
|
||||
void loadKeys();
|
||||
void loadPersistedRedisHistory();
|
||||
});
|
||||
|
||||
onActivated(resumeRedisBrowserBackgroundWork);
|
||||
@@ -976,7 +951,7 @@ defineExpose({ focusSearch });
|
||||
{{ t("redis.pubsub") }}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<Button v-if="activeSidePanel === 'command'" variant="ghost" size="icon" class="h-6 w-6" :title="t('redis.clearHistory')" @click="clearPersistedRedisHistory">
|
||||
<Button v-if="activeSidePanel === 'command'" variant="ghost" size="icon" class="h-6 w-6" :title="t('redis.clearHistory')" @click="clearInMemoryHistory">
|
||||
<History class="size-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user