feat: Persist MongoDB browser view mode preference (#370)
* feat: Persist MongoDB browser view mode preference Signed-off-by: baizhi958216 <1475289190@qq.com> * feat: Store MongoDB browser view preference in Pinia Signed-off-by: baizhi958216 <1475289190@qq.com> --------- Signed-off-by: baizhi958216 <1475289190@qq.com>
This commit is contained in:
parent
ab6c73c687
commit
24ea264c5f
|
|
@ -8,6 +8,7 @@ import { Badge } from "@/components/ui/badge";
|
|||
import DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";
|
||||
import DataGrid from "@/components/grid/DataGrid.vue";
|
||||
import * as api from "@/lib/api";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
import JsonEditNode from "./JsonEditNode.vue";
|
||||
import type { EditNode } from "@/types/editor";
|
||||
import type { QueryResult } from "@/types/database";
|
||||
|
|
@ -15,6 +16,7 @@ import { Splitpanes, Pane } from "splitpanes";
|
|||
import "splitpanes/dist/splitpanes.css";
|
||||
|
||||
const { t } = useI18n();
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
const props = defineProps<{
|
||||
connectionId: string;
|
||||
|
|
@ -23,6 +25,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
type JsonRecord = Record<string, unknown>;
|
||||
type ViewMode = "document" | "table";
|
||||
|
||||
const documents = ref<JsonRecord[]>([]);
|
||||
const total = ref(0);
|
||||
|
|
@ -36,7 +39,10 @@ const isNew = ref(false);
|
|||
const error = ref("");
|
||||
const editFields = ref<EditNode[]>([]);
|
||||
const showDeleteConfirm = ref(false);
|
||||
const viewMode = ref<"document" | "table">("document");
|
||||
const viewMode = computed<ViewMode>({
|
||||
get: () => settingsStore.editorSettings.mongoViewMode,
|
||||
set: (value) => settingsStore.updateEditorSettings({ mongoViewMode: value }),
|
||||
});
|
||||
const filterInput = ref("");
|
||||
const sortInput = ref("");
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ export interface EditorSettings {
|
|||
appLayout: "separated" | "classic";
|
||||
pageSize: number;
|
||||
redisScanPageSize: number;
|
||||
mongoViewMode: "document" | "table";
|
||||
shortcuts: ShortcutSettings;
|
||||
sidebarActivation: SidebarActivation;
|
||||
columnFormatters: Record<string, ColumnFormatterConfig>;
|
||||
|
|
@ -203,6 +204,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
|||
appLayout: "classic",
|
||||
pageSize: 100,
|
||||
redisScanPageSize: 1000,
|
||||
mongoViewMode: "document",
|
||||
shortcuts: normalizeShortcutSettings(),
|
||||
sidebarActivation: "single",
|
||||
columnFormatters: {},
|
||||
|
|
@ -242,6 +244,7 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>): Edit
|
|||
appLayout: settings.appLayout ?? DEFAULT_EDITOR_SETTINGS.appLayout,
|
||||
pageSize: normalizeResultPageSize(settings.pageSize),
|
||||
redisScanPageSize: settings.redisScanPageSize ?? DEFAULT_EDITOR_SETTINGS.redisScanPageSize,
|
||||
mongoViewMode: settings.mongoViewMode === "table" ? "table" : DEFAULT_EDITOR_SETTINGS.mongoViewMode,
|
||||
shortcuts: normalizeShortcutSettings(settings.shortcuts),
|
||||
sidebarActivation:
|
||||
settings.sidebarActivation === "single" || settings.sidebarActivation === "double"
|
||||
|
|
|
|||
Loading…
Reference in New Issue