Feature:支持模式选择搜索

Co-authored-by: staff <staff@qimaos-MacBook-Pro.local>
This commit is contained in:
zipgandstaff authored and GitHub committed 2026-07-01 15:44:36 +08:00
1 parent fee7c2846e
commit 5e8af8df2e
9 files changed
+40 -24

No files matched your search

@@ -3,7 +3,6 @@ import { computed, ref, watch, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
import { Play, Loader2, Square, Database, Check, Table2, AlignLeft, GitBranch, Save, FolderOpen, Layers, X, Shield, Upload } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { SearchableSelect } from "@/components/ui/searchable-select";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
import TruncatedTextTooltip from "@/components/ui/TruncatedTextTooltip.vue";
@@ -312,27 +311,30 @@ function connectionById(connectionId: string): ConnectionConfig | undefined {
</Button>
</div>
<div v-if="showSchemaSelector" class="flex items-center gap-1">
<Layers class="h-3.5 w-3.5 shrink-0" />
<Select
<SearchableSelect
:model-value="activeSchemaValue"
@update:model-value="(v: any) => emit('changeSchema', v || undefined)"
:options="activeSchemaOptions.length ? activeSchemaOptions : activeSchemaValue ? [activeSchemaValue] : []"
:placeholder="t('editor.selectSchema')"
:search-placeholder="t('editor.searchSchema')"
:empty-text="t('grid.noSearchResults')"
:loading-text="t('common.loading')"
:loading="!!activeConnection && isLoadingSchemas(activeConnection.id, schemaDatabaseKey)"
trigger-class="gap-1.5"
@update:model-value="(schema) => emit('changeSchema', schema || undefined)"
@update:open="
(open: boolean) => {
if (open && activeConnection) loadSchemaOptions(activeConnection.id, schemaDatabaseKey).catch(() => {});
}
"
>
<SelectTrigger class="h-6 w-auto max-w-56 border-0 bg-transparent px-1 text-xs shadow-none focus:ring-0">
<SelectValue :placeholder="activeConnection && isLoadingSchemas(activeConnection.id, schemaDatabaseKey) ? t('common.loading') : t('editor.selectSchema')">
{{ activeSchemaValue || t("editor.selectSchema") }}
</SelectValue>
</SelectTrigger>
<SelectContent position="popper">
<SelectItem v-for="schema in activeSchemaOptions" :key="schema" :value="schema">
{{ schema }}
</SelectItem>
</SelectContent>
</Select>
<template #trigger-label="{ label, loading }">
<Layers class="h-3.5 w-3.5 shrink-0" />
<span class="truncate">{{ loading ? t("common.loading") : label }}</span>
</template>
<template #option-label="{ label }">
<TruncatedTextTooltip :text="label" class="min-w-0 flex-1" side="left" :side-offset="8" />
</template>
</SearchableSelect>
</div>
</div>
<div v-if="activeTab.mode === 'data' && activeTab.tableMeta" class="ml-2 inline-flex shrink-0 items-center gap-1 rounded border border-border bg-muted/30 px-2 py-0.5 font-medium text-muted-foreground tabular-nums">
@@ -41,7 +41,7 @@ import {
import { useI18n } from "vue-i18n";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { SearchableSelect } from "@/components/ui/searchable-select";
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
import DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";
import ProcedureExecutionDialog from "@/components/objects/ProcedureExecutionDialog.vue";
@@ -1540,14 +1540,21 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
</button>
</div>
</div>
<Select v-if="needsSchema" :model-value="selectedSchema" :disabled="loadingSchemas" @update:model-value="onSchemaChange">
<SelectTrigger class="h-7 w-36 text-xs">
<SelectValue :placeholder="loadingSchemas ? t('objects.loadingSchemas') : t('objects.schema')" />
</SelectTrigger>
<SelectContent>
<SelectItem v-for="schema in schemas" :key="schema" :value="schema">{{ schema }}</SelectItem>
</SelectContent>
</Select>
<SearchableSelect
v-if="needsSchema"
:model-value="selectedSchema || ''"
:options="schemas"
:placeholder="t('objects.schema')"
:search-placeholder="t('editor.searchSchema')"
:empty-text="t('grid.noSearchResults')"
:loading-text="t('objects.loadingSchemas')"
:loading="loadingSchemas"
:disabled="loadingSchemas"
trigger-variant="outline"
trigger-class="h-7 w-36 max-w-36 px-2 text-xs font-normal"
content-class="w-56"
@update:model-value="onSchemaChange"
/>
<Button variant="ghost" size="icon" class="h-7 w-7" :disabled="loadingObjects" @click="reload">
<RefreshCw class="h-3.5 w-3.5" :class="{ 'animate-spin': loadingObjects }" />
</Button>