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(grid): add exact column lookup mode

二丫讲梵9752940fba3d
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index da103bc380..cfb07fb959 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -19,6 +19,7 @@ import {
Upload,
FileUp,
Trash2,
+ Check,
ChevronDown,
ChevronUp,
ChevronLeft,
@@ -293,7 +294,7 @@ import { normalizeResultPageSize, resultPageSizeMenuOptions } from "@/lib/dataGr
import { dataGridPageSizeSettingsPatch, preferredDataGridPageSize, resolveDataGridPageSizePreference, type DataGridPageSizePreference } from "@/lib/dataGrid/dataGridPageSizePreference";
import { continuousQueryResultMaxRows, effectiveQueryResultMaxRows } from "@/lib/dataGrid/queryResultRowLimit";
import { allNullColumnIndexes, identicalValueColumnIndexes } from "@/lib/dataGrid/dataGridColumnVisibility";
-import { buildDataGridColumnLookupItems, dataGridColumnCommentFor, filterDataGridColumnLookupItems } from "@/lib/dataGrid/dataGridColumnLookup";
+import { buildDataGridColumnLookupItems, dataGridColumnCommentFor, filterDataGridColumnLookupItems, type DataGridColumnLookupMatchMode } from "@/lib/dataGrid/dataGridColumnLookup";
import { uniqueDataGridColumnOrderKeys } from "@/lib/dataGrid/dataGridColumnOrder";
import { dataGridColumnLayoutScopeKey, TABLE_DATA_GRID_COLUMN_ORDER_CHANGED_EVENT, tableDataGridColumnOrderScopeKey } from "@/lib/dataGrid/dataGridColumnLayoutStorage";
import { createPendingSelectionSummary, formatSelectionAggregate, formatSelectionAverage, summarizeSelection, type SelectionSummaryOptions } from "@/lib/dataGrid/gridSelection";
@@ -2292,6 +2293,7 @@ let highlightedColumnTimer = 0;
const goToColumnOpen = ref(false);
const goToColumnSearch = ref("");
+const goToColumnMatchMode = ref<DataGridColumnLookupMatchMode>("fuzzy");
const goToColumnSearchInput = ref<HTMLInputElement>();
const goToColumnListRef = ref<HTMLElement>();
const goToColumnSelectedIndex = ref(0);
@@ -2390,7 +2392,7 @@ const goToColumnItems = computed(() =>
}),
);
const filteredGoToColumns = computed(() => {
- return filterDataGridColumnLookupItems(goToColumnItems.value, goToColumnSearch.value);
+ return filterDataGridColumnLookupItems(goToColumnItems.value, goToColumnSearch.value, goToColumnMatchMode.value);
});
const visibleColumns = computed(() => visibleColumnIndexes.value.map((index) => props.result.columns[index]));
const visibleColumnIndexIndicators = computed(() =>
@@ -2581,6 +2583,11 @@ watch(goToColumnSearch, () => {
scrollGoToColumnSelectionIntoView();
});
+watch(goToColumnMatchMode, () => {
+ goToColumnSelectedIndex.value = 0;
+ scrollGoToColumnSelectionIntoView();
+});
+
watch(filteredGoToColumns, (columns) => {
if (goToColumnSelectedIndex.value >= columns.length) goToColumnSelectedIndex.value = Math.max(columns.length - 1, 0);
});
@@ -15431,7 +15438,37 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
</div>
<div class="relative m-2 shrink-0">
<Search class="pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
- <input ref="goToColumnSearchInput" v-model="goToColumnSearch" :placeholder="t('grid.searchColumn')" class="h-8 w-full rounded-md border bg-transparent pl-7 pr-6 text-xs outline-none focus-visible:border-ring/50 focus-visible:ring-1 focus-visible:ring-ring/25" />
+ <input
+ ref="goToColumnSearchInput"
+ v-model="goToColumnSearch"
+ :placeholder="t('grid.searchColumn')"
+ :aria-label="t('grid.searchColumn')"
+ class="h-8 w-full rounded-md border bg-transparent pl-7 pr-28 text-xs outline-none focus-visible:border-ring/50 focus-visible:ring-1 focus-visible:ring-ring/25"
+ />
+ <DropdownMenu>
+ <DropdownMenuTrigger as-child>
+ <button
+ type="button"
+ class="absolute right-7 top-1/2 inline-flex -translate-y-1/2 items-center gap-0.5 rounded px-1 text-[10px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground"
+ :title="goToColumnMatchMode === 'exact' ? t('grid.useFuzzyColumnSearch') : t('grid.useExactColumnSearch')"
+ :aria-label="goToColumnMatchMode === 'exact' ? t('grid.useFuzzyColumnSearch') : t('grid.useExactColumnSearch')"
+ @keydown.stop
+ >
+ {{ goToColumnMatchMode === "exact" ? t("grid.exactColumnSearch") : t("grid.fuzzyColumnSearch") }}
+ <ChevronDown class="h-3 w-3" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" class="!w-auto !min-w-0 whitespace-nowrap">
+ <DropdownMenuItem class="justify-between gap-2 text-xs" @select="goToColumnMatchMode = 'fuzzy'">
+ {{ t("grid.fuzzyColumnSearch") }}
+ <Check v-if="goToColumnMatchMode === 'fuzzy'" class="h-3 w-3" />
+ </DropdownMenuItem>
+ <DropdownMenuItem class="justify-between gap-2 text-xs" @select="goToColumnMatchMode = 'exact'">
+ {{ t("grid.exactColumnSearch") }}
+ <Check v-if="goToColumnMatchMode === 'exact'" class="h-3 w-3" />
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
<button v-if="goToColumnSearch" type="button" class="absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground" @click="goToColumnSearch = ''">
<X class="h-3.5 w-3.5" />
</button>
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index 30b4951f12..cdc3460300 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -2567,6 +2567,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Mövcud eni doldur",
columnWidthModeContent: "Məzmun eni",
searchColumn: "Sütun/şərh axtar...",
+ fuzzyColumnSearch: "Qeyri-dəqiq uyğunluq",
+ exactColumnSearch: "Dəqiq uyğunluq",
+ useExactColumnSearch: "Dəqiq sütun adı uyğunlaşdırmasından istifadə et",
+ useFuzzyColumnSearch: "Qeyri-dəqiq sütun axtarışından istifadə et",
noColumnsFound: "Sütun tapılmadı",
queryError: "Sorğu xətası",
saveErrorTitle: "Dəyişiklikləri yadda saxlamaq alınmadı",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 55d56bb24a..27cf0e3caa 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -3265,6 +3265,10 @@ export default {
columnWidthModeFill: "Fill available width",
columnWidthModeContent: "Content width",
searchColumn: "Search column/comment...",
+ fuzzyColumnSearch: "Fuzzy match",
+ exactColumnSearch: "Exact match",
+ useExactColumnSearch: "Use exact column-name matching",
+ useFuzzyColumnSearch: "Use fuzzy column search",
noColumnsFound: "No columns found",
queryError: "Query Error",
saveErrorTitle: "Failed to Save Changes",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index d0fc150bc2..a32a67a49c 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -2890,6 +2890,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Llenar ancho disponible",
columnWidthModeContent: "Ancho del contenido",
searchColumn: "Buscar columna/comentario...",
+ fuzzyColumnSearch: "Coincidencia difusa",
+ exactColumnSearch: "Coincidencia exacta",
+ useExactColumnSearch: "Usar coincidencia exacta del nombre de columna",
+ useFuzzyColumnSearch: "Usar búsqueda difusa de columnas",
noColumnsFound: "No se encontraron columnas",
tableInfo: "Información de tabla",
tableInfoOverview: "Resumen",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index 4f5e7016d0..56f7a19e56 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -2872,6 +2872,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Isi lebar yang tersedia",
columnWidthModeContent: "Lebar sesuai konten",
searchColumn: "Cari kolom/komentar...",
+ fuzzyColumnSearch: "Pencocokan fuzzy",
+ exactColumnSearch: "Pencocokan tepat",
+ useExactColumnSearch: "Gunakan pencocokan nama kolom yang tepat",
+ useFuzzyColumnSearch: "Gunakan pencarian kolom fuzzy",
noColumnsFound: "Tidak ada kolom yang ditemukan",
queryError: "Galat Kueri",
saveErrorTitle: "Gagal Menyimpan Perubahan",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 938773a997..a50f39e579 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -2820,6 +2820,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Riempi larghezza disponibile",
columnWidthModeContent: "Larghezza contenuto",
searchColumn: "Cerca colonna/commento...",
+ fuzzyColumnSearch: "Corrispondenza fuzzy",
+ exactColumnSearch: "Corrispondenza esatta",
+ useExactColumnSearch: "Usa la corrispondenza esatta del nome della colonna",
+ useFuzzyColumnSearch: "Usa la ricerca fuzzy delle colonne",
noColumnsFound: "Nessuna colonna trovata",
queryError: "Errore Query",
saveErrorTitle: "Impossibile salvare le modifiche",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index a5b10dab28..a9679e1156 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -2825,6 +2825,10 @@ export default withEnglishFallback({
columnWidthModeFill: "使用可能幅を埋める",
columnWidthModeContent: "コンテンツ幅",
searchColumn: "列/コメントを検索...",
+ fuzzyColumnSearch: "あいまい一致",
+ exactColumnSearch: "完全一致",
+ useExactColumnSearch: "列名の完全一致を使用",
+ useFuzzyColumnSearch: "列のあいまい検索を使用",
noColumnsFound: "列が見つかりません",
queryError: "クエリエラー",
saveErrorTitle: "変更の保存に失敗しました",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 5a72a27b0c..af5a7f0c5d 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -2865,6 +2865,10 @@ export default withEnglishFallback({
columnWidthModeFill: "사용 가능 너비 채우기",
columnWidthModeContent: "콘텐츠 너비",
searchColumn: "컬럼/주석 검색...",
+ fuzzyColumnSearch: "퍼지 일치",
+ exactColumnSearch: "정확히 일치",
+ useExactColumnSearch: "정확한 컬럼명 일치 사용",
+ useFuzzyColumnSearch: "퍼지 컬럼 검색 사용",
noColumnsFound: "컬럼이 없습니다",
queryError: "쿼리 오류",
saveErrorTitle: "변경사항 저장 실패",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 438a71696e..a24967a225 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -2820,6 +2820,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Preencher largura disponível",
columnWidthModeContent: "Largura do conteúdo",
searchColumn: "Buscar coluna/comentário...",
+ fuzzyColumnSearch: "Correspondência difusa",
+ exactColumnSearch: "Correspondência exata",
+ useExactColumnSearch: "Usar correspondência exata do nome da coluna",
+ useFuzzyColumnSearch: "Usar pesquisa difusa de colunas",
noColumnsFound: "Nenhuma coluna encontrada",
queryError: "Erro na Consulta",
saveErrorTitle: "Falha ao salvar alterações",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index c18e1c5901..17af1bbf89 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -3003,6 +3003,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Заполнить доступную ширину",
columnWidthModeContent: "По содержимому",
searchColumn: "Поиск столбца или комментария...",
+ fuzzyColumnSearch: "Нечёткое совпадение",
+ exactColumnSearch: "Точное совпадение",
+ useExactColumnSearch: "Использовать точное совпадение имени столбца",
+ useFuzzyColumnSearch: "Использовать нечёткий поиск столбцов",
noColumnsFound: "Столбцы не найдены",
queryError: "Ошибка запроса",
saveErrorTitle: "Не удалось сохранить изменения",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index a658b495bc..3cc8fd8a56 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -3211,6 +3211,10 @@ export default withEnglishFallback({
columnWidthModeFill: "เติมความกว้างที่ใช้ได้",
columnWidthModeContent: "ความกว้างเนื้อหา",
searchColumn: "ค้นหาคอลัมน์/คอมเมนต์...",
+ fuzzyColumnSearch: "การจับคู่แบบคลุมเครือ",
+ exactColumnSearch: "การจับคู่แบบตรงทั้งหมด",
+ useExactColumnSearch: "ใช้การจับคู่ชื่อคอลัมน์แบบตรงทั้งหมด",
+ useFuzzyColumnSearch: "ใช้การค้นหาคอลัมน์แบบคลุมเครือ",
noColumnsFound: "ไม่พบคอลัมน์",
queryError: "ข้อผิดพลาด Query",
saveErrorTitle: "บันทึกการเปลี่ยนแปลงไม่สำเร็จ",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index 5795250429..dc1fc5bb50 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -2560,6 +2560,10 @@ export default withEnglishFallback({
columnWidthModeFill: "Kullanılabilir genişliği doldur",
columnWidthModeContent: "İçerik genişliği",
searchColumn: "Sütun/açıklama ara...",
+ fuzzyColumnSearch: "Bulanık eşleşme",
+ exactColumnSearch: "Tam eşleşme",
+ useExactColumnSearch: "Tam sütun adı eşleştirmesini kullan",
+ useFuzzyColumnSearch: "Bulanık sütun aramasını kullan",
noColumnsFound: "Sütun bulunamadı",
queryError: "Sorgu Hatası",
saveErrorTitle: "Değişiklikler Kaydedilemedi",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index b90e1bed2b..2b24655ca6 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -3199,6 +3199,10 @@ export default withEnglishFallback({
columnWidthModeFill: "填满可用宽度",
columnWidthModeContent: "按内容宽度",
searchColumn: "搜索列/注释...",
+ fuzzyColumnSearch: "模糊匹配",
+ exactColumnSearch: "精确匹配",
+ useExactColumnSearch: "使用精确列名匹配",
+ useFuzzyColumnSearch: "使用模糊列搜索",
noColumnsFound: "未找到列",
queryError: "查询出错",
saveErrorTitle: "数据修改保存失败",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index e729fc8227..fe560a15d2 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -2824,6 +2824,10 @@ export default withEnglishFallback({
columnWidthModeFill: "填滿可用寬度",
columnWidthModeContent: "依內容寬度",
searchColumn: "搜尋欄/註解...",
+ fuzzyColumnSearch: "模糊匹配",
+ exactColumnSearch: "精確匹配",
+ useExactColumnSearch: "使用精確欄名匹配",
+ useFuzzyColumnSearch: "使用模糊欄位搜尋",
noColumnsFound: "未找到欄",
dataUnavailable: "資料表資料需要重新載入。",
viewSnapshotSelectionNotRestored: "已還原上次的檢視位置,但過大的選取範圍未能保留。",
diff --git a/apps/desktop/src/lib/dataGrid/dataGridColumnLookup.ts b/apps/desktop/src/lib/dataGrid/dataGridColumnLookup.ts
index 8c03874a4b..09c189fece 100644
--- a/apps/desktop/src/lib/dataGrid/dataGridColumnLookup.ts
+++ b/apps/desktop/src/lib/dataGrid/dataGridColumnLookup.ts
@@ -15,6 +15,8 @@ export interface DataGridColumnLookupOptions {
commentByColumn?: ReadonlyMap<string, string>;
}
+export type DataGridColumnLookupMatchMode = "fuzzy" | "exact";
+
function normalizedSearchText(value: string): string {
return value.trim();
}
@@ -51,8 +53,12 @@ export function buildDataGridColumnLookupItems(options: DataGridColumnLookupOpti
});
}
-export function filterDataGridColumnLookupItems<ColumnLookupItem extends DataGridColumnLookupItem>(items: readonly ColumnLookupItem[], query: string): ColumnLookupItem[] {
+export function filterDataGridColumnLookupItems<ColumnLookupItem extends DataGridColumnLookupItem>(items: readonly ColumnLookupItem[], query: string, matchMode: DataGridColumnLookupMatchMode = "fuzzy"): ColumnLookupItem[] {
const normalizedQuery = normalizedSearchText(query);
if (!normalizedQuery) return [...items];
+ if (matchMode === "exact") {
+ const normalizedQueryLower = normalizedQuery.toLocaleLowerCase();
+ return items.filter((item) => [item.name, item.sourceName].filter((value): value is string => !!value).some((value) => value.trim().toLocaleLowerCase() === normalizedQueryLower));
+ }
return items.filter((item) => [item.name, item.sourceName, item.comment].filter((value): value is string => !!value).some((value) => matchesIdentifierSearch(value, normalizedQuery)));
}