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。

fix(grid): preserve page size when reloading data after save

t8y29463ff07a77f
diff --git a/src/App.vue b/src/App.vue
index 8cbdbcc7f0..88e866edd2 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -618,8 +618,14 @@ onUnmounted(() => {
@editor-cursor-change="(p: number) => (cursorPos = p)"
@format-error="toast(t('toolbar.formatSqlFailed'))"
@reload="
- (sql?: string, searchText?: string, whereInput?: string, orderBy?: string) =>
- onReloadData(sql, searchText, whereInput, orderBy)
+ (
+ sql?: string,
+ searchText?: string,
+ whereInput?: string,
+ orderBy?: string,
+ limit?: number,
+ offset?: number,
+ ) => onReloadData(sql, searchText, whereInput, orderBy, limit, offset)
"
@paginate="onPaginate"
@sort="onSort"
diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue
index 043d444adb..a66f1cc437 100644
--- a/src/components/grid/DataGrid.vue
+++ b/src/components/grid/DataGrid.vue
@@ -101,7 +101,7 @@ const props = defineProps<{
}>();
const emit = defineEmits<{
- reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string];
+ reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number];
paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string];
sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string];
}>();
@@ -857,6 +857,8 @@ const editor = useDataGridEditor({
rowStatusFilter,
initialEditColumn: firstVisibleColumnIndex,
getRowItem,
+ pageSize,
+ currentPage,
emit,
});
@@ -904,6 +906,8 @@ async function onToolbarRefresh() {
searchText.value,
whereFilterInput.value.trim() || undefined,
orderByInput.value.trim() || undefined,
+ pageSize.value,
+ (currentPage.value - 1) * pageSize.value,
);
}
@@ -919,6 +923,8 @@ function onToolbarRollback() {
searchText.value,
whereFilterInput.value.trim() || undefined,
orderByInput.value.trim() || undefined,
+ pageSize.value,
+ (currentPage.value - 1) * pageSize.value,
);
}
diff --git a/src/components/layout/ContentArea.vue b/src/components/layout/ContentArea.vue
index 670c00b9e3..aac3ee4805 100644
--- a/src/components/layout/ContentArea.vue
+++ b/src/components/layout/ContentArea.vue
@@ -40,7 +40,7 @@ const emit = defineEmits<{
editorSelectionChange: [value: string];
editorCursorChange: [pos: number];
formatError: [];
- reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string];
+ reload: [sql?: string, searchText?: string, whereInput?: string, orderBy?: string, limit?: number, offset?: number];
paginate: [offset: number, limit: number, whereInput?: string, orderBy?: string];
sort: [column: string, columnIndex: number, direction: "asc" | "desc" | null, whereInput?: string];
executeSql: [sql: string];
@@ -283,8 +283,14 @@ function onHandleCloseColumnPanel() {
:table-meta="activeTab.tableMeta"
:on-execute-sql="async (sql: string) => emit('executeSql', sql)"
@reload="
- (sql?: string, searchText?: string, whereInput?: string, orderBy?: string) =>
- emit('reload', sql, searchText, whereInput, orderBy)
+ (
+ sql?: string,
+ searchText?: string,
+ whereInput?: string,
+ orderBy?: string,
+ limit?: number,
+ offset?: number,
+ ) => emit('reload', sql, searchText, whereInput, orderBy, limit, offset)
"
@paginate="
(offset: number, limit: number, whereInput?: string, orderBy?: string) =>
@@ -381,8 +387,14 @@ function onHandleCloseColumnPanel() {
:table-meta="activeTab.tableMeta"
:on-execute-sql="async (sql: string) => emit('executeSql', sql)"
@reload="
- (sql?: string, searchText?: string, whereInput?: string, orderBy?: string) =>
- emit('reload', sql, searchText, whereInput, orderBy)
+ (
+ sql?: string,
+ searchText?: string,
+ whereInput?: string,
+ orderBy?: string,
+ limit?: number,
+ offset?: number,
+ ) => emit('reload', sql, searchText, whereInput, orderBy, limit, offset)
"
@paginate="
(offset: number, limit: number, whereInput?: string, orderBy?: string) =>
diff --git a/src/composables/useDataGridActions.ts b/src/composables/useDataGridActions.ts
index df7fc7ccbc..46a2f33bfe 100644
--- a/src/composables/useDataGridActions.ts
+++ b/src/composables/useDataGridActions.ts
@@ -51,12 +51,19 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
await queryStore.executeTabSql(tab.id, sql);
}
- async function onReloadData(sql?: string, _searchText?: string, whereInput?: string, orderBy?: string) {
+ async function onReloadData(
+ sql?: string,
+ _searchText?: string,
+ whereInput?: string,
+ orderBy?: string,
+ limit?: number,
+ offset?: number,
+ ) {
const tab = activeTab.value;
if (!tab) return;
if (tab.mode === "data" && tab.tableMeta) {
tab.whereInput = whereInput ?? "";
- queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy }));
+ queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy, limit, offset }));
await queryStore.executeCurrentTab();
return;
}
diff --git a/src/composables/useDataGridEditor.ts b/src/composables/useDataGridEditor.ts
index 0dc9fc0488..3d9b2b983f 100644
--- a/src/composables/useDataGridEditor.ts
+++ b/src/composables/useDataGridEditor.ts
@@ -66,8 +66,18 @@ export interface UseDataGridEditorOptions {
rowStatusFilter: Ref<RowStatusFilter>;
initialEditColumn?: ComputedRef<number>;
getRowItem: (rowId: number) => RowItem | undefined;
+ pageSize: Ref<number>;
+ currentPage: Ref<number>;
emit: {
- (event: "reload", sql?: string, searchText?: string, whereInput?: string, orderBy?: string): void;
+ (
+ event: "reload",
+ sql?: string,
+ searchText?: string,
+ whereInput?: string,
+ orderBy?: string,
+ limit?: number,
+ offset?: number,
+ ): void;
};
}
@@ -91,6 +101,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
rowStatusFilter,
initialEditColumn,
getRowItem,
+ pageSize,
+ currentPage,
emit,
} = options;
@@ -486,6 +498,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
searchText.value,
whereFilterInput.value.trim() || undefined,
orderByInput.value.trim() || undefined,
+ pageSize.value,
+ (currentPage.value - 1) * pageSize.value,
);
return;
}
@@ -571,6 +585,8 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
searchText.value,
whereFilterInput.value.trim() || undefined,
orderByInput.value.trim() || undefined,
+ pageSize.value,
+ (currentPage.value - 1) * pageSize.value,
);
}