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。

add: 在结果集中增加数据过滤的功能 (#163)

rarnu8a249a219427
diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue
index 831fe975fb..c42c9f1aa3 100644
--- a/src/components/grid/DataGrid.vue
+++ b/src/components/grid/DataGrid.vue
@@ -424,9 +424,10 @@ watch(() => props.result.columns.length, initColumnWidths);
const pageSize = ref(100);
const currentPage = ref(1);
const isFullPage = computed(() => props.result.rows.length >= pageSize.value);
-const canUseWhereSearch = computed(() => !!props.tableMeta && !!props.onExecuteSql);
+const isResultsContext = computed(() => props.context === "results");
+const canUseWhereSearch = computed(() => !!props.tableMeta && !!props.onExecuteSql && !isResultsContext.value);
const isWhereSearch = computed(() => canUseWhereSearch.value && /^\s*where\b/i.test(searchText.value));
-const wherePredicate = computed(() => normalizeWhereInput(searchText.value));
+const wherePredicate = computed(() => (canUseWhereSearch.value ? normalizeWhereInput(searchText.value) : undefined));
const activeWhereInput = computed(() => (isWhereSearch.value && wherePredicate.value ? searchText.value : undefined));
const clientSearchText = computed(() => (isWhereSearch.value ? "" : searchText.value));
@@ -1285,14 +1286,8 @@ defineExpose({
<ContextMenuTrigger as-child>
<div v-if="hasData" class="flex-1 flex flex-col overflow-hidden">
<!-- Search bar -->
- <div
- v-if="useTransaction || props.context === 'table-data'"
- class="flex items-center gap-1 px-2 py-1 border-b shrink-0 bg-muted/20 relative"
- >
- <Search
- class="w-3.5 h-3.5 text-muted-foreground shrink-0"
- :style="props.context === 'table-data' ? '' : 'visibility: hidden'"
- />
+ <div class="flex items-center gap-1 px-2 py-1 border-b shrink-0 bg-muted/20 relative">
+ <Search class="w-3.5 h-3.5 text-muted-foreground shrink-0" />
<input
ref="searchInputRef"
v-model="searchText"
@@ -1303,7 +1298,6 @@ defineExpose({
:placeholder="canUseWhereSearch ? t('grid.searchOrWhere') : t('grid.search')"
@keydown="onSearchKeydown"
@click="updateSuggestionPosition"
- :style="props.context === 'table-data' ? '' : 'visibility: hidden'"
/>
<span
ref="measureRef"
@@ -1360,7 +1354,7 @@ defineExpose({
{{ t("grid.refresh") }}
</Button>
<Select
- v-if="editable && tableMeta"
+ v-if="useTransaction && editable && tableMeta"
:model-value="rowStatusFilter"
@update:model-value="(value: any) => setRowStatusFilter(String(value))"
>
@@ -1376,7 +1370,7 @@ defineExpose({
</SelectContent>
</Select>
<Button
- v-if="editable && tableMeta"
+ v-if="useTransaction && editable && tableMeta"
variant="ghost"
size="sm"
class="h-5 text-xs px-1.5 shrink-0"
@@ -1385,6 +1379,7 @@ defineExpose({
<Plus class="w-3 h-3 mr-1" /> {{ t("grid.addRow") }}
</Button>
<Button
+ v-if="useTransaction"
:variant="transactionActive ? 'default' : 'secondary'"
size="sm"
class="h-5 text-xs px-1.5"
@@ -1396,6 +1391,7 @@ defineExpose({
{{ t("grid.commit") }}
</Button>
<Button
+ v-if="useTransaction"
variant="outline"
size="sm"
class="h-5 text-xs px-1.5"