feat(export): remember last export directory and support preferred directory

This commit is contained in:
lxk955 authored and GitHub committed 2026-10-04 17:40:59 +08:00
1 parent 2e98a5bb9f
commit 02bc0cf47e
28 files changed
+497 -83

No files matched your search

+4
View File
@@ -1062,6 +1062,7 @@ export interface EditorSettings {
sqlShortcuts: SqlShortcutAction[];
tableColumnTemplateFields: string[];
exportBatchSize: number;
preferredExportPath: string;
csvQuoteMode: CsvQuoteMode;
csvNullMode: CsvNullMode;
/** Global Redis key-search templates; overridden by non-empty connection templates. */
@@ -1366,6 +1367,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
sqlShortcuts: DEFAULT_SQL_SHORTCUTS,
tableColumnTemplateFields: [...DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS],
exportBatchSize: 2000,
preferredExportPath: "",
csvQuoteMode: DEFAULT_CSV_QUOTE_MODE,
csvNullMode: DEFAULT_CSV_NULL_MODE,
redisKeyTemplates: [],
@@ -2022,6 +2024,7 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
sqlShortcuts: normalizeSqlShortcuts(settings.sqlShortcuts, existing?.sqlShortcuts),
tableColumnTemplateFields: normalizeTableColumnTemplateFields(settings.tableColumnTemplateFields),
exportBatchSize: typeof settings.exportBatchSize === "number" && settings.exportBatchSize >= 100 && settings.exportBatchSize <= 100000 ? Math.round(settings.exportBatchSize) : DEFAULT_EDITOR_SETTINGS.exportBatchSize,
preferredExportPath: typeof settings.preferredExportPath === "string" ? settings.preferredExportPath.trim() : DEFAULT_EDITOR_SETTINGS.preferredExportPath,
csvQuoteMode: normalizeCsvQuoteMode(settings.csvQuoteMode),
csvNullMode: normalizeCsvNullMode(settings.csvNullMode),
redisKeyTemplates: normalizeRedisKeyTemplates(settings.redisKeyTemplates),
@@ -2848,6 +2851,7 @@ export const useSettingsStore = defineStore("settings", () => {
if (partial.sqlShortcuts !== undefined) editorSettings.value.sqlShortcuts = normalizeSqlShortcuts(partial.sqlShortcuts);
if (partial.tableColumnTemplateFields !== undefined) editorSettings.value.tableColumnTemplateFields = normalizeTableColumnTemplateFields(partial.tableColumnTemplateFields);
if (partial.exportBatchSize !== undefined) editorSettings.value.exportBatchSize = Math.min(100000, Math.max(100, Math.round(partial.exportBatchSize)));
if (partial.preferredExportPath !== undefined) editorSettings.value.preferredExportPath = typeof partial.preferredExportPath === "string" ? partial.preferredExportPath.trim() : "";
if (partial.csvQuoteMode !== undefined) editorSettings.value.csvQuoteMode = normalizeCsvQuoteMode(partial.csvQuoteMode);
if (partial.csvNullMode !== undefined) editorSettings.value.csvNullMode = normalizeCsvNullMode(partial.csvNullMode);
if (partial.redisKeyTemplates !== undefined) editorSettings.value.redisKeyTemplates = normalizeRedisKeyTemplates(partial.redisKeyTemplates);