fix(redis): resolve protected mode UI issues (#2362)

This commit is contained in:
dalew 2026-07-02 14:03:19 +08:00 committed by GitHub
parent 3888be8e5e
commit fd99fc8448
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -1660,6 +1660,7 @@ onUnmounted(() => {
:format-sql-request="formatSqlRequest"
:selected-sql="selectedSql"
:cursor-pos="cursorPos"
:block-dangerous-redis-commands="blockDangerousRedisCommands"
@update:active-output-view="activeOutputView = $event"
@fix-with-ai="fixWithAi"
@execute="tryExecute($event)"

View File

@ -110,6 +110,7 @@ const props = defineProps<{
formatSqlRequest: { id: number; tabId: string } | null;
selectedSql: string;
cursorPos: number;
blockDangerousRedisCommands: boolean;
}>();
const emit = defineEmits<{
@ -1249,7 +1250,7 @@ defineExpose({ focusSearch, refreshData, handleModRTarget, requestQueryEditorExe
<!-- Redis mode: key browser -->
<template v-else-if="activeTab.mode === 'redis'">
<div class="flex-1 min-h-0">
<RedisKeyBrowser ref="redisKeyBrowserRef" :key="activeTab.id" :connection-id="activeTab.connectionId" :db="Number(activeTab.database)" />
<RedisKeyBrowser ref="redisKeyBrowserRef" :key="activeTab.id" :connection-id="activeTab.connectionId" :db="Number(activeTab.database)" :block-dangerous-redis-commands="props.blockDangerousRedisCommands" />
</div>
</template>

View File

@ -58,6 +58,7 @@ type RedisCommandHistoryEntry = {
const props = defineProps<{
connectionId: string;
db: number;
blockDangerousRedisCommands: boolean;
}>();
const flatKeys = ref<RedisKeyInfo[]>([]);
@ -473,7 +474,7 @@ async function runRedisCommand(command: string) {
const prompt = commandPrompt.value;
commandRunning.value = true;
try {
const result = await api.redisExecuteCommand(props.connectionId, commandDb.value, command);
const result = await api.redisExecuteCommand(props.connectionId, commandDb.value, command, !props.blockDangerousRedisCommands);
appendCommandHistory({
prompt,
command,
@ -743,6 +744,13 @@ async function executeCommand() {
const safety = classifyRedisCommandSafety(command);
if (safety === "blocked") {
if (!props.blockDangerousRedisCommands) {
// blocked
commandText.value = "";
commandHistoryIndex.value = -1;
await runRedisCommand(command);
return;
}
appendCommandHistory({
prompt: commandPrompt.value,
command,
@ -754,6 +762,13 @@ async function executeCommand() {
return;
}
if (safety === "confirm") {
if (!props.blockDangerousRedisCommands) {
//
commandText.value = "";
commandHistoryIndex.value = -1;
await runRedisCommand(command);
return;
}
pendingDanger.value = { kind: "command", command };
showDangerConfirm.value = true;
commandText.value = "";