feat(settings): add Redis scan page size setting

This commit is contained in:
t8y2
2026-05-15 17:41:26 +08:00
parent 08de206644
commit 8d73e6e00d
8 changed files with 560 additions and 443 deletions
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -26,6 +26,7 @@ import RedisValueViewer from "./RedisValueViewer.vue";
import * as api from "@/lib/api";
import type { RedisKeyInfo } from "@/lib/api";
import { useConnectionStore } from "@/stores/connectionStore";
import { useSettingsStore } from "@/stores/settingsStore";
import {
buildRedisKeyTree,
collectExpandedGroupIds,
@@ -38,6 +39,7 @@ import { isCancelSearchShortcut } from "@/lib/keyboardShortcuts";
const { t } = useI18n();
const connectionStore = useConnectionStore();
const settingsStore = useSettingsStore();
const props = defineProps<{
connectionId: string;
@@ -67,7 +69,6 @@ const commandResult = ref<any>(null);
const commandError = ref("");
const commandRunning = ref(false);
const PAGE_SIZE = 200;
const keyGridStyle = {
gridTemplateColumns: "minmax(12rem, 0.35fr) 80px 1fr 60px 60px",
};
@@ -129,7 +130,7 @@ async function scanNextPage() {
props.db,
scanCursor.value,
effectivePattern.value,
PAGE_SIZE,
settingsStore.editorSettings.redisScanPageSize,
);
const existingKeys = new Set(flatKeys.value.map((key) => key.key_raw));
flatKeys.value = [...flatKeys.value, ...result.keys.filter((key) => !existingKeys.has(key.key_raw))];
+1
View File
@@ -1005,6 +1005,7 @@ export default {
title: "Settings",
editorTab: "Editor",
appearanceTab: "Appearance",
redisTab: "Redis",
aiTab: "AI",
jdbcTab: "JDBC Drivers",
securityTab: "Security",
+2
View File
@@ -983,6 +983,8 @@ export default {
title: "Configuración",
editorTab: "Editor",
appearanceTab: "Apariencia",
redisTab: "Redis",
aiTab: "IA",
jdbcTab: "Drivers JDBC",
securityTab: "Seguridad",
aboutTab: "Acerca de",
+1
View File
@@ -987,6 +987,7 @@ export default {
title: "设置",
editorTab: "编辑器",
appearanceTab: "外观",
redisTab: "Redis",
aiTab: "AI",
jdbcTab: "JDBC 驱动",
securityTab: "安全",
+16 -9
View File
@@ -51,6 +51,7 @@ export interface EditorSettings {
wordWrap: boolean;
appLayout: "separated" | "classic";
pageSize: number;
redisScanPageSize: number;
}
export const EDITOR_THEMES: { value: EditorTheme; label: string; dark: boolean }[] = [
@@ -83,26 +84,32 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
wordWrap: false,
appLayout: "classic",
pageSize: 100,
redisScanPageSize: 1000,
};
export const STORAGE_KEY = "dbx-editor-settings";
const OLD_FONT_SIZE_KEY = "dbx-query-editor-font-size";
export function normalizeEditorSettings(settings: Partial<EditorSettings>): EditorSettings {
return {
fontFamily: settings.fontFamily ?? DEFAULT_EDITOR_SETTINGS.fontFamily,
fontSize: settings.fontSize ?? DEFAULT_EDITOR_SETTINGS.fontSize,
theme: settings.theme ?? DEFAULT_EDITOR_SETTINGS.theme,
executeMode: settings.executeMode ?? DEFAULT_EDITOR_SETTINGS.executeMode,
wordWrap: settings.wordWrap ?? DEFAULT_EDITOR_SETTINGS.wordWrap,
appLayout: settings.appLayout ?? DEFAULT_EDITOR_SETTINGS.appLayout,
pageSize: settings.pageSize ?? DEFAULT_EDITOR_SETTINGS.pageSize,
redisScanPageSize: settings.redisScanPageSize ?? DEFAULT_EDITOR_SETTINGS.redisScanPageSize,
};
}
function loadEditorSettings(): EditorSettings {
// Try new format first
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (raw) {
const parsed = JSON.parse(raw) as Partial<EditorSettings>;
return {
fontFamily: parsed.fontFamily ?? DEFAULT_EDITOR_SETTINGS.fontFamily,
fontSize: parsed.fontSize ?? DEFAULT_EDITOR_SETTINGS.fontSize,
theme: parsed.theme ?? DEFAULT_EDITOR_SETTINGS.theme,
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,
};
return normalizeEditorSettings(parsed);
}
} catch {
/* ignore */