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.0 KB
Raw Blame
<script setup lang="ts">
import { computed } from "vue";
import { Bot, LocateFixed, Wrench } from "@lucide/vue";
import { useI18n } from "vue-i18n";
import { Button } from "@/components/ui/button";
import type { BackendError } from "@/lib/backend/errorUtils";
import { isConnectionTimeoutErrorMessage, isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";

const props = defineProps<{
  errorMessage: string;
  backendError?: BackendError;
  connectionId?: string;
  /** Driver-reported error position, when the backend provides one. */
  errorPosition?: { line: number; column: number };
}>();

const emit = defineEmits<{
  changeConnectionTimeout: [];
  changeQueryTimeout: [];
  fixWithAi: [errorMessage: string];
  locateError: [];
}>();

const { t } = useI18n();
const showConnectionTimeout = computed(() => !!props.connectionId && isConnectionTimeoutErrorMessage(props.errorMessage, props.backendError));
const showQueryTimeout = computed(() => !!props.connectionId && !showConnectionTimeout.value && isQueryTimeoutErrorMessage(props.errorMessage, props.backendError));
const showLocateError = computed(() => !!props.errorPosition);
</script>

<template>
  <Button v-if="showLocateError" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('locateError')">
    <LocateFixed class="h-3.5 w-3.5" />
    {{ t("editor.locateError", { line: errorPosition!.line, column: errorPosition!.column }) }}
  </Button>
  <Button v-if="showConnectionTimeout" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('changeConnectionTimeout')">
    <Wrench class="h-3.5 w-3.5" />
    {{ t("editor.changeConnectionTimeout") }}
  </Button>
  <Button v-if="showQueryTimeout" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('changeQueryTimeout')">
    <Wrench class="h-3.5 w-3.5" />
    {{ t("editor.changeQueryTimeout") }}
  </Button>
  <Button variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('fixWithAi', errorMessage)">
    <Bot class="h-3.5 w-3.5" />
    {{ t("ai.fixWithAi") }}
  </Button>
</template>