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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(grid): add first-page and last-page pagination buttons
t8y24f48ddc823da
diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vueindex 9e5a6e644f..c72506448a 100644--- a/src/components/grid/DataGrid.vue+++ b/src/components/grid/DataGrid.vue@@ -16,6 +16,8 @@ import {Save,ChevronLeft,ChevronRight,+ ChevronsLeft,+ ChevronsRight,Search,Inbox,SearchX,@@ -60,7 +62,12 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltipimport DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";import type { QueryResult, ColumnInfo, DatabaseType } from "@/types/database";import * as api from "@/lib/api";-import { buildTableSelectSql, quoteTableIdentifier } from "@/lib/tableSelectSql";+import {+ buildTableSelectSql,+ qualifiedTableName,+ normalizeWhereInput,+ quoteTableIdentifier,+} from "@/lib/tableSelectSql";import { isHiddenGridColumn, usesSyntheticRowIdKey } from "@/lib/tableEditing";import { formatGridSqlLiteral } from "@/lib/dataGridSql";import { matchesRowStatusFilter, type RowStatus, type RowStatusFilter } from "@/lib/gridRowStatus";@@ -810,6 +817,12 @@ function currentOrderBy(): string | undefined {);}+function firstPage() {+ if (currentPage.value <= 1) return;+ currentPage.value = 1;+ resetGridVerticalScroll(true);+ emit("paginate", 0, pageSize.value, currentWhereInput(), currentOrderBy());+}function prevPage() {if (currentPage.value <= 1) return;currentPage.value--;@@ -829,6 +842,30 @@ function changePageSize(size: number) {emit("paginate", 0, size, currentWhereInput(), currentOrderBy());}+async function lastPage() {+ if (!props.connectionId || !props.tableMeta) return;+ const table = qualifiedTableName({+ databaseType: props.databaseType,+ schema: props.tableMeta.schema,+ tableName: props.tableMeta.tableName,+ });+ const predicate = normalizeWhereInput(currentWhereInput());+ const where = predicate ? ` WHERE (${predicate})` : "";+ const sql = `SELECT COUNT(*) AS cnt FROM ${table}${where}`;+ try {+ const result = await api.executeQuery(props.connectionId, props.database ?? "", sql, props.tableMeta.schema);+ const total = Number(result.rows?.[0]?.[0] ?? 0);+ if (total <= 0) return;+ const lastPageNum = Math.ceil(total / pageSize.value);+ if (lastPageNum <= currentPage.value) return;+ currentPage.value = lastPageNum;+ resetGridVerticalScroll(true);+ emit("paginate", (lastPageNum - 1) * pageSize.value, pageSize.value, currentWhereInput(), currentOrderBy());+ } catch {+ // COUNT query failed — ignore silently+ }+}+// --- Editing (composable) ---interface RowItem {@@ -2585,6 +2622,9 @@ defineExpose({</DropdownMenuItem></DropdownMenuContent></DropdownMenu>+ <Button variant="ghost" size="icon" class="h-5 w-5" :disabled="currentPage <= 1" @click="firstPage">+ <ChevronsLeft class="h-3 w-3" />+ </Button><Button variant="ghost" size="icon" class="h-5 w-5" :disabled="currentPage <= 1" @click="prevPage"><ChevronLeft class="h-3 w-3" /></Button>@@ -2592,6 +2632,9 @@ defineExpose({<Button variant="ghost" size="icon" class="h-5 w-5" :disabled="!isFullPage" @click="nextPage"><ChevronRight class="h-3 w-3" /></Button>+ <Button variant="ghost" size="icon" class="h-5 w-5" :disabled="!isFullPage" @click="lastPage">+ <ChevronsRight class="h-3 w-3" />+ </Button></span><DropdownMenu>