From 74d57982c9ffee87de4b93407cc85d93c2182dcd Mon Sep 17 00:00:00 2001 From: zipg Date: Fri, 26 Jun 2026 14:03:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=A7=E8=A1=8C=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=89=8D=E6=8F=90=E7=A4=BA=E9=80=89=E6=8B=A9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improve:执行查询前提示选择数据库 * Fix:补齐连接配置测试字段 --------- Co-authored-by: staff --- apps/desktop/src/App.vue | 19 ++++++- .../src/components/layout/EditorToolbar.vue | 56 ++++++++++++++++++- .../src/composables/useSqlExecution.ts | 17 ++++++ apps/desktop/src/i18n/locales/en.ts | 1 + apps/desktop/src/i18n/locales/zh-CN.ts | 1 + 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index fe2a019b5..65fcc3446 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -205,6 +205,16 @@ async function resolveActiveExecutableSql(snapshot?: SqlExecutionSnapshot) { } const blockDangerousRedisCommands = ref(true); +const databaseRequiredSignal = ref(0); +const databaseRequiredTabId = ref(null); + +function promptActiveDatabaseSelection() { + const tab = activeTab.value; + if (!tab) return; + databaseRequiredTabId.value = tab.id; + databaseRequiredSignal.value += 1; + toast(t("editor.selectDatabaseRequired"), 2500); +} const { dangerSql, pendingDangerSql, showDangerDialog, suppressDangerConfirm, tryExecute, doExecute, cancelActiveExecution, tryExplain, onDangerConfirm, explainMode } = useSqlExecution({ activeTab, @@ -213,6 +223,7 @@ const { dangerSql, pendingDangerSql, showDangerDialog, suppressDangerConfirm, tr resolveExecutableSql: resolveActiveExecutableSql, activeOutputView, blockDangerousRedisCommands, + onMissingDatabase: promptActiveDatabaseSelection, }); function requestActiveEditorExecute() { @@ -938,7 +949,12 @@ async function changeActiveConnection(connectionId: string) { function changeActiveDatabase(database: string) { const tab = activeTab.value; - if (tab) queryStore.updateDatabase(tab.id, database); + if (tab) { + queryStore.updateDatabase(tab.id, database); + if (databaseRequiredTabId.value === tab.id && database) { + databaseRequiredTabId.value = null; + } + } } async function setActiveDatabaseAsDefault() { @@ -1486,6 +1502,7 @@ onUnmounted(() => { :explain-mode="explainMode" :block-dangerous-redis-commands="blockDangerousRedisCommands" :sql-keyword-case="settingsStore.editorSettings.sqlFormatter.keywordCase" + :database-required-signal="databaseRequiredTabId === activeTab.id ? databaseRequiredSignal : 0" @update:explain-mode="(m: 'explain' | 'autotrace') => (explainMode = m)" @update:block-dangerous-redis-commands="(v: boolean) => (blockDangerousRedisCommands = v)" @execute="requestActiveEditorExecute()" diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue index a95a1ca00..5e8c3282c 100644 --- a/apps/desktop/src/components/layout/EditorToolbar.vue +++ b/apps/desktop/src/components/layout/EditorToolbar.vue @@ -1,5 +1,5 @@