refactor: Scan Count 从全局设置移到连接配置

- ConnectionConfig 新增 scanCount 字段 (默认 100)
- NewConnectionDialog 基本信息区新增 Scan Count 输入框
- key.ts 改为从 activeConnection.scanCount 读取
- SettingsView 移除 Scan Count 设置项
- app store 移除 scanCount 和 setScanCount
- 主进程 store ConnectionConfig 同步新增字段
This commit is contained in:
2026-07-11 15:22:58 +08:00
parent ac0e6af233
commit 5a479d416e
6 changed files with 12 additions and 21 deletions
+1
View File
@@ -26,6 +26,7 @@ interface ConnectionConfig {
sentinelMasterName: string sentinelMasterName: string
sentinelNodePassword: string sentinelNodePassword: string
separator: string separator: string
scanCount?: number
order: number order: number
createdAt: number createdAt: number
color?: string color?: string
@@ -28,6 +28,7 @@ const form = reactive({
sentinelNodePassword: '', sentinelNodePassword: '',
cluster: false, cluster: false,
separator: ':', separator: ':',
scanCount: 100,
sshEnabled: false, sshEnabled: false,
sshHost: '', sshHost: '',
sshPort: 22, sshPort: 22,
@@ -66,6 +67,7 @@ watch(() => props.visible, async (v) => {
sentinelNodePassword: props.connection.sentinelNodePassword || '', sentinelNodePassword: props.connection.sentinelNodePassword || '',
cluster: props.connection.cluster || false, cluster: props.connection.cluster || false,
separator: props.connection.separator, separator: props.connection.separator,
scanCount: props.connection.scanCount ?? 100,
sshEnabled: props.connection.sshEnabled || false, sshEnabled: props.connection.sshEnabled || false,
sshHost: props.connection.sshHost || '', sshHost: props.connection.sshHost || '',
sshPort: props.connection.sshPort || 22, sshPort: props.connection.sshPort || 22,
@@ -84,6 +86,7 @@ watch(() => props.visible, async (v) => {
sentinelMasterName: '', sentinelNodePassword: '', sentinelMasterName: '', sentinelNodePassword: '',
cluster: false, cluster: false,
separator: ':', separator: ':',
scanCount: 100,
sshEnabled: false, sshHost: '', sshPort: 22, sshEnabled: false, sshHost: '', sshPort: 22,
sshUsername: '', sshPassword: '', sshPrivateKeyPath: '', sshPassphrase: '', sshUsername: '', sshPassword: '', sshPrivateKeyPath: '', sshPassphrase: '',
}) })
@@ -203,6 +206,7 @@ async function handleSave() {
sshPrivateKeyPath: form.sshPrivateKeyPath, sshPrivateKeyPath: form.sshPrivateKeyPath,
sshPassphrase: form.sshPassphrase, sshPassphrase: form.sshPassphrase,
separator: form.separator || ':', separator: form.separator || ':',
scanCount: form.scanCount,
order: props.connection?.order ?? connStore.connections.length, order: props.connection?.order ?? connStore.connections.length,
createdAt: props.connection?.createdAt ?? Date.now(), createdAt: props.connection?.createdAt ?? Date.now(),
} }
@@ -258,6 +262,9 @@ async function handleSave() {
<el-form-item label="Key Separator"> <el-form-item label="Key Separator">
<el-input v-model="form.separator" placeholder=":" class="form-input" /> <el-input v-model="form.separator" placeholder=":" class="form-input" />
</el-form-item> </el-form-item>
<el-form-item label="Scan Count">
<el-input-number v-model="form.scanCount" :min="10" :max="10000" :step="10" controls-position="right" class="form-input" />
</el-form-item>
</div> </div>
</div> </div>
<!-- Advanced Options --> <!-- Advanced Options -->
@@ -50,18 +50,6 @@ const fontOptions = [
</el-select> </el-select>
</div> </div>
<div class="settings-group">
<label class="settings-label">{{ t('settings.scanCount') }}</label>
<el-input-number
:model-value="appStore.scanCount"
@change="appStore.setScanCount($event || 100)"
:min="10"
:max="10000"
:step="10"
size="small"
/>
</div>
<div class="settings-group"> <div class="settings-group">
<label class="settings-label">{{ t('settings.fontSize') }}</label> <label class="settings-label">{{ t('settings.fontSize') }}</label>
<el-input-number <el-input-number
+1 -7
View File
@@ -7,7 +7,6 @@ export const useAppStore = defineStore('app', () => {
const theme = ref<ThemeMode>((localStorage.getItem('theme') as ThemeMode) || 'system') const theme = ref<ThemeMode>((localStorage.getItem('theme') as ThemeMode) || 'system')
const isDark = ref(true) const isDark = ref(true)
const fontSize = ref<number>(Number(localStorage.getItem('fontSize')) || 13) const fontSize = ref<number>(Number(localStorage.getItem('fontSize')) || 13)
const scanCount = ref<number>(Number(localStorage.getItem('scanCount')) || 100)
const zoom = ref<number>(Number(localStorage.getItem('zoom')) || 1.0) const zoom = ref<number>(Number(localStorage.getItem('zoom')) || 1.0)
const fontFamily = ref<string>(localStorage.getItem('fontFamily') || 'Cascadia Code') const fontFamily = ref<string>(localStorage.getItem('fontFamily') || 'Cascadia Code')
@@ -41,11 +40,6 @@ export const useAppStore = defineStore('app', () => {
localStorage.setItem('fontSize', String(size)) localStorage.setItem('fontSize', String(size))
} }
function setScanCount(count: number) {
scanCount.value = count
localStorage.setItem('scanCount', String(count))
}
function setZoom(value: number) { function setZoom(value: number) {
zoom.value = value zoom.value = value
localStorage.setItem('zoom', String(value)) localStorage.setItem('zoom', String(value))
@@ -62,5 +56,5 @@ export const useAppStore = defineStore('app', () => {
document.body.style.zoom = String(zoom.value) document.body.style.zoom = String(zoom.value)
document.documentElement.style.setProperty('--font-mono', fontFamily.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 }
}) })
+1
View File
@@ -27,6 +27,7 @@ export interface ConnectionConfig {
sentinelMasterName: string sentinelMasterName: string
sentinelNodePassword: string sentinelNodePassword: string
separator: string separator: string
scanCount?: number
order: number order: number
createdAt: number createdAt: number
color?: string color?: string
+2 -2
View File
@@ -1,6 +1,6 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ref } from 'vue' import { ref } from 'vue'
import { useAppStore } from './app' import { useConnectionStore } from './connection'
export interface KeyItem { export interface KeyItem {
name: string name: string
@@ -93,7 +93,7 @@ export const useKeyStore = defineStore('key', () => {
loading.value = true loading.value = true
try { try {
const result: ScanResult = await window.electronAPI.redis.scanKeys( 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 => ({ const newKeys = result.keys.map(k => ({
name: k, name: k,