feat: persist page size setting across restarts

Store the data grid page size in EditorSettings (localStorage) so the
user's chosen rows-per-page survives app restarts.
This commit is contained in:
t8y2 2026-05-14 20:48:28 +08:00
parent 8305b9670f
commit 03e2c0bea1
2 changed files with 7 additions and 1 deletions

View File

@ -84,8 +84,10 @@ import { useDataGridExport } from "@/composables/useDataGridExport";
import { useDataGridColumnResize } from "@/composables/useDataGridColumnResize";
import { useDataGridSelection } from "@/composables/useDataGridSelection";
import { useDataGridEditor } from "@/composables/useDataGridEditor";
import { useSettingsStore } from "@/stores/settingsStore";
const { t } = useI18n();
const settingsStore = useSettingsStore();
const { toast } = useToast();
const props = defineProps<{
@ -825,7 +827,7 @@ watch(
);
// --- Pagination ---
const pageSize = ref(100);
const pageSize = ref(settingsStore.editorSettings.pageSize);
const currentPage = ref(1);
const isFullPage = computed(() => props.result.rows.length >= pageSize.value);
const isResultsContext = computed(() => props.context === "results");
@ -909,6 +911,7 @@ function nextPage() {
}
function changePageSize(size: number) {
pageSize.value = size;
settingsStore.updateEditorSettings({ pageSize: size });
currentPage.value = 1;
resetGridVerticalScroll(true);
emit("paginate", 0, size, currentWhereInput(), currentOrderBy());

View File

@ -50,6 +50,7 @@ export interface EditorSettings {
executeMode: "all" | "current";
wordWrap: boolean;
appLayout: "separated" | "classic";
pageSize: number;
}
export const EDITOR_THEMES: { value: EditorTheme; label: string; dark: boolean }[] = [
@ -81,6 +82,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
executeMode: "all",
wordWrap: false,
appLayout: "classic",
pageSize: 100,
};
export const STORAGE_KEY = "dbx-editor-settings";
@ -99,6 +101,7 @@ function loadEditorSettings(): EditorSettings {
executeMode: parsed.executeMode ?? DEFAULT_EDITOR_SETTINGS.executeMode,
wordWrap: parsed.wordWrap ?? DEFAULT_EDITOR_SETTINGS.wordWrap,
appLayout: parsed.appLayout ?? DEFAULT_EDITOR_SETTINGS.appLayout,
pageSize: parsed.pageSize ?? DEFAULT_EDITOR_SETTINGS.pageSize,
};
}
} catch {