From 5a479d416e2bc6c5a4d97d21ff5ab9db919e4049 Mon Sep 17 00:00:00 2001 From: Jokul Date: Sat, 11 Jul 2026 15:22:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20Scan=20Count=20=E4=BB=8E=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=AE=BE=E7=BD=AE=E7=A7=BB=E5=88=B0=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ConnectionConfig 新增 scanCount 字段 (默认 100) - NewConnectionDialog 基本信息区新增 Scan Count 输入框 - key.ts 改为从 activeConnection.scanCount 读取 - SettingsView 移除 Scan Count 设置项 - app store 移除 scanCount 和 setScanCount - 主进程 store ConnectionConfig 同步新增字段 --- src/main/store.ts | 1 + src/renderer/src/components/NewConnectionDialog.vue | 7 +++++++ src/renderer/src/components/SettingsView.vue | 12 ------------ src/renderer/src/stores/app.ts | 8 +------- src/renderer/src/stores/connection.ts | 1 + src/renderer/src/stores/key.ts | 4 ++-- 6 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/main/store.ts b/src/main/store.ts index 07faa2a..db66e10 100644 --- a/src/main/store.ts +++ b/src/main/store.ts @@ -26,6 +26,7 @@ interface ConnectionConfig { sentinelMasterName: string sentinelNodePassword: string separator: string + scanCount?: number order: number createdAt: number color?: string diff --git a/src/renderer/src/components/NewConnectionDialog.vue b/src/renderer/src/components/NewConnectionDialog.vue index 6833f85..f1d9be0 100644 --- a/src/renderer/src/components/NewConnectionDialog.vue +++ b/src/renderer/src/components/NewConnectionDialog.vue @@ -28,6 +28,7 @@ const form = reactive({ sentinelNodePassword: '', cluster: false, separator: ':', + scanCount: 100, sshEnabled: false, sshHost: '', sshPort: 22, @@ -66,6 +67,7 @@ watch(() => props.visible, async (v) => { sentinelNodePassword: props.connection.sentinelNodePassword || '', cluster: props.connection.cluster || false, separator: props.connection.separator, + scanCount: props.connection.scanCount ?? 100, sshEnabled: props.connection.sshEnabled || false, sshHost: props.connection.sshHost || '', sshPort: props.connection.sshPort || 22, @@ -84,6 +86,7 @@ watch(() => props.visible, async (v) => { sentinelMasterName: '', sentinelNodePassword: '', cluster: false, separator: ':', + scanCount: 100, sshEnabled: false, sshHost: '', sshPort: 22, sshUsername: '', sshPassword: '', sshPrivateKeyPath: '', sshPassphrase: '', }) @@ -203,6 +206,7 @@ async function handleSave() { sshPrivateKeyPath: form.sshPrivateKeyPath, sshPassphrase: form.sshPassphrase, separator: form.separator || ':', + scanCount: form.scanCount, order: props.connection?.order ?? connStore.connections.length, createdAt: props.connection?.createdAt ?? Date.now(), } @@ -258,6 +262,9 @@ async function handleSave() { + + + diff --git a/src/renderer/src/components/SettingsView.vue b/src/renderer/src/components/SettingsView.vue index 02d8526..4d43ca6 100644 --- a/src/renderer/src/components/SettingsView.vue +++ b/src/renderer/src/components/SettingsView.vue @@ -50,18 +50,6 @@ const fontOptions = [ -
- - -
-
{ const theme = ref((localStorage.getItem('theme') as ThemeMode) || 'system') const isDark = ref(true) const fontSize = ref(Number(localStorage.getItem('fontSize')) || 13) - const scanCount = ref(Number(localStorage.getItem('scanCount')) || 100) const zoom = ref(Number(localStorage.getItem('zoom')) || 1.0) const fontFamily = ref(localStorage.getItem('fontFamily') || 'Cascadia Code') @@ -41,11 +40,6 @@ export const useAppStore = defineStore('app', () => { localStorage.setItem('fontSize', String(size)) } - function setScanCount(count: number) { - scanCount.value = count - localStorage.setItem('scanCount', String(count)) - } - function setZoom(value: number) { zoom.value = value localStorage.setItem('zoom', String(value)) @@ -62,5 +56,5 @@ export const useAppStore = defineStore('app', () => { document.body.style.zoom = String(zoom.value) document.documentElement.style.setProperty('--font-mono', fontFamily.value) - return { theme, isDark, fontSize, scanCount, zoom, fontFamily, setTheme, setFontSize, setScanCount, setZoom, setFontFamily } + return { theme, isDark, fontSize, zoom, fontFamily, setTheme, setFontSize, setZoom, setFontFamily } }) diff --git a/src/renderer/src/stores/connection.ts b/src/renderer/src/stores/connection.ts index 7d80a6d..4eac32e 100644 --- a/src/renderer/src/stores/connection.ts +++ b/src/renderer/src/stores/connection.ts @@ -27,6 +27,7 @@ export interface ConnectionConfig { sentinelMasterName: string sentinelNodePassword: string separator: string + scanCount?: number order: number createdAt: number color?: string diff --git a/src/renderer/src/stores/key.ts b/src/renderer/src/stores/key.ts index 9e107d6..db95de3 100644 --- a/src/renderer/src/stores/key.ts +++ b/src/renderer/src/stores/key.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia' import { ref } from 'vue' -import { useAppStore } from './app' +import { useConnectionStore } from './connection' export interface KeyItem { name: string @@ -93,7 +93,7 @@ export const useKeyStore = defineStore('key', () => { loading.value = true try { const result: ScanResult = await window.electronAPI.redis.scanKeys( - connId, cursor, pattern.value, useAppStore().scanCount + connId, cursor, pattern.value, useConnectionStore().activeConnection?.scanCount ?? 100 ) const newKeys = result.keys.map(k => ({ name: k,