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。

feat: add AI assistant SQL handling functions for query tab management

t8y2c8c13eacaca8
diff --git a/src/App.vue b/src/App.vue
index cd361157b6..e60c37f57a 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -168,6 +168,25 @@ function toggleLocale() { setLocale(currentLocale() === "zh-CN" ? "en" : "zh-CN"
function openGitHub() { openUrl("https://github.com/t8y2/dbx"); }
function openMcpGuide() { openUrl("https://github.com/t8y2/dbx/blob/main/docs/mcp-guide.md"); }
+function ensureQueryTab(): string {
+ const tab = activeTab.value;
+ if (tab && tab.mode === "query") return tab.id;
+ const connId = connectionStore.activeConnectionId || connectionStore.connections[0]?.id || "";
+ const db = tab?.database || "";
+ return queryStore.createTab(connId, db, undefined, "query");
+}
+
+function onAiReplaceSql(sql: string) {
+ const tabId = ensureQueryTab();
+ queryStore.updateSql(tabId, sql);
+}
+
+function onAiExecuteSql(sql: string) {
+ const tabId = ensureQueryTab();
+ queryStore.updateSql(tabId, sql);
+ nextTick(() => tryExecute());
+}
+
function handleKeydown(e: KeyboardEvent) {
if (isCloseTabShortcut(e)) {
e.preventDefault();
@@ -280,8 +299,8 @@ onUnmounted(() => { window.removeEventListener("keydown", handleKeydown, true);
<div class="panel-resize-handle panel-resize-handle--left" @mousedown="startAiPanelResize" />
<div class="h-full min-h-0 overflow-hidden">
<AiAssistant ref="aiAssistantRef" :tab="activeTab" :connection="activeConnection"
- @replace-sql="(sql: string) => { const tab = activeTab; if (tab) queryStore.updateSql(tab.id, sql) }"
- @execute-sql="tryExecute" @close="toggleAiPanel"
+ @replace-sql="onAiReplaceSql"
+ @execute-sql="onAiExecuteSql" @close="toggleAiPanel"
/>
</div>
</div>