Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

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

dalewfd99fc84482a
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index 4b691bffa3..ab5bbef5bb 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -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)"
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue
index c026a8c0b1..2c7094f90c 100644
--- a/apps/desktop/src/components/layout/ContentArea.vue
+++ b/apps/desktop/src/components/layout/ContentArea.vue
@@ -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>
diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.vue b/apps/desktop/src/components/redis/RedisKeyBrowser.vue
index 6091931d75..73cec3eeee 100644
--- a/apps/desktop/src/components/redis/RedisKeyBrowser.vue
+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.vue
@@ -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 = "";