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。

gate sql file entry points

SuLe2d49d523c53b
diff --git a/src/App.vue b/src/App.vue
index d34ff79bc0..fc99f430d3 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -130,6 +130,11 @@ const updateInfo = ref<api.UpdateInfo | null>(null);
const updateCheckMessage = ref("");
const appVersion = ref("");
const latestReleaseUrl = "https://github.com/t8y2/dbx/releases/latest";
+const sqlFileUnsupportedTypes = new Set(["redis", "mongodb", "elasticsearch"]);
+
+const hasSqlFileConnections = computed(() =>
+ connectionStore.connections.some((connection) => !sqlFileUnsupportedTypes.has(connection.db_type))
+);
const editConfig = computed(() => {
const id = connectionStore.editingConnectionId;
@@ -712,7 +717,7 @@ async function setupFileDrop() {
{{ t('transfer.dataTransfer') }}
</Button>
- <Button variant="ghost" size="sm" class="h-7 px-2 text-xs gap-1" @click="showSqlFileDialog = true" :disabled="!connectionStore.connections.length">
+ <Button variant="ghost" size="sm" class="h-7 px-2 text-xs gap-1" @click="showSqlFileDialog = true" :disabled="!hasSqlFileConnections">
<FileCode class="h-3.5 w-3.5" />
{{ t('sqlFile.title') }}
</Button>
diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue
index a5e6ee8898..af3b3e196b 100644
--- a/src/components/sidebar/TreeItem.vue
+++ b/src/components/sidebar/TreeItem.vue
@@ -33,6 +33,8 @@ const props = defineProps<{
depth: number;
}>();
+const sqlFileUnsupportedTypes = new Set(["redis", "mongodb", "elasticsearch"]);
+
function quoteIdent(name: string): string {
const config = props.node.connectionId ? connectionStore.getConfig(props.node.connectionId) : undefined;
return config?.db_type === "mysql"
@@ -344,6 +346,10 @@ function openSqlFileExecution() {
const canExpand = !leafTypes.has(props.node.type);
const canPin = computed(() => pinnableTypes.has(props.node.type));
+const canOpenSqlFileExecution = computed(() => {
+ const config = props.node.connectionId ? connectionStore.getConfig(props.node.connectionId) : undefined;
+ return !!config && !sqlFileUnsupportedTypes.has(config.db_type);
+});
const isPinned = computed(() => props.node.pinned || connectionStore.isTreeNodePinned(props.node.id));
const hasTypeMenu = computed(() => {
const t = props.node.type;
@@ -453,7 +459,7 @@ async function showMore() {
<ContextMenuItem @click="newQuery">
<TerminalSquare class="w-4 h-4" /> {{ t('contextMenu.newQuery') }}
</ContextMenuItem>
- <ContextMenuItem @click="openSqlFileExecution">
+ <ContextMenuItem v-if="canOpenSqlFileExecution" @click="openSqlFileExecution">
<FileCode class="w-4 h-4" /> {{ t('sqlFile.title') }}
</ContextMenuItem>
<ContextMenuSeparator />
@@ -473,7 +479,7 @@ async function showMore() {
<ContextMenuItem @click="newQuery">
<TerminalSquare class="w-4 h-4" /> {{ t('contextMenu.newQuery') }}
</ContextMenuItem>
- <ContextMenuItem @click="openSqlFileExecution">
+ <ContextMenuItem v-if="canOpenSqlFileExecution" @click="openSqlFileExecution">
<FileCode class="w-4 h-4" /> {{ t('sqlFile.title') }}
</ContextMenuItem>
<ContextMenuItem @click="refresh">