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。

2.2 KB
Raw Blame
<script setup lang="ts">
import { computed, ref, useAttrs } from "vue";
import ContentArea from "./ContentArea.vue";
import { createContentSurfaceEventForwarders } from "@/lib/tabs/contentSurfaceEvents";
import type { ContentAreaSurfaceEmits, ContentAreaSurfaceProps, QueryResultSurfaceHandle, StatementRange } from "./querySurfaces";

defineOptions({ inheritAttrs: false });

const props = defineProps<ContentAreaSurfaceProps>();
const emit = defineEmits<ContentAreaSurfaceEmits>();

const attrs = useAttrs();
const resultClass = computed(() => (typeof attrs.class === "string" ? attrs.class : undefined));
const surfaceProps = computed<ContentAreaSurfaceProps>(() => ({
  activeTab: props.activeTab,
  activeConnection: props.activeConnection,
  executableSql: props.executableSql,
  activeOutputView: props.activeOutputView,
  formatSqlRequest: props.formatSqlRequest,
  compressSqlRequest: props.compressSqlRequest,
  keywordCaseRequest: props.keywordCaseRequest,
  selectedSql: props.selectedSql,
  cursorPos: props.cursorPos,
  blockDangerousRedisCommands: props.blockDangerousRedisCommands,
}));
const contentEmits = createContentSurfaceEventForwarders(emit);
const bindings = computed(() => ({ ...surfaceProps.value, ...contentEmits }));
const contentAreaRef = ref<InstanceType<typeof ContentArea> | null>(null);

defineExpose<QueryResultSurfaceHandle>({
  focusSearch: (target: Element | null = null) => contentAreaRef.value?.focusSearch(target) ?? false,
  refreshData: () => contentAreaRef.value?.refreshData() ?? false,
  toggleResultsPane: () => contentAreaRef.value?.toggleResultsPane() ?? false,
  handleModRTarget: (target: Element) => contentAreaRef.value?.handleModRTarget(target) ?? false,
  previewStatementRange: (range: StatementRange | null) => contentAreaRef.value?.previewStatementRange(range) ?? false,
  focusStatementRange: (range: StatementRange | null) => contentAreaRef.value?.focusStatementRange(range) ?? false,
  focusErrorPosition: (offset: number) => contentAreaRef.value?.focusErrorPosition(offset) ?? false,
});
</script>

<template>
  <div class="min-h-0 overflow-hidden" :class="resultClass">
    <ContentArea ref="contentAreaRef" v-bind="bindings" result-only class="h-full" />
  </div>
</template>