From 2061e00b29c718d9be400a77773c3a03f4ed3b61 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Wed, 8 Mar 2023 16:54:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20redis=20=E9=85=8D=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=8C=83=E5=9B=B4=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/interface/database.ts | 2 +- frontend/src/lang/modules/en.ts | 2 +- frontend/src/lang/modules/zh.ts | 2 +- .../views/database/redis/setting/index.vue | 34 +++++++++++++------ .../redis/setting/persistence/index.vue | 13 ++++--- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/frontend/src/api/interface/database.ts b/frontend/src/api/interface/database.ts index 51cd0c7af..7d91224a0 100644 --- a/frontend/src/api/interface/database.ts +++ b/frontend/src/api/interface/database.ts @@ -143,7 +143,7 @@ export namespace Database { timeout: number; maxclients: number; requirepass: string; - maxmemory: number; + maxmemory: string; } export interface RedisPersistenceConf { appendonly: string; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 00d73f3fa..7896e2f93 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -396,7 +396,7 @@ export default { rdbHelper1: 'In seconds, insert', rdbHelper2: 'The data', rdbHelper3: 'Meeting either condition triggers RDB persistence', - rdbInfo: 'Rule list has 0 value, please confirm and try again!', + rdbInfo: 'Ensure that the value in the rule list ranges from 1 to 100000', }, container: { createContainer: 'Create container', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index ac1c87f6a..5c0a01d00 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -409,7 +409,7 @@ export default { rdbHelper1: '秒內,插入', rdbHelper2: '条数据', rdbHelper3: '符合任意一个条件将会触发RDB持久化', - rdbInfo: '规则列表存在 0 值,请确认后重试!', + rdbInfo: '请确认规则列表中值在 1-100000 之间', }, container: { createContainer: '创建容器', diff --git a/frontend/src/views/database/redis/setting/index.vue b/frontend/src/views/database/redis/setting/index.vue index 2f0326ee1..1242986ed 100644 --- a/frontend/src/views/database/redis/setting/index.vue +++ b/frontend/src/views/database/redis/setting/index.vue @@ -73,14 +73,19 @@
- + + + {{ $t('database.timeoutHelper') }} - + + + + {{ $t('database.maxmemoryHelper') }} @@ -178,6 +183,21 @@ interface DialogProps { const changeTab = (val: string) => { activeName.value = val; + switch (val) { + case 'conf': + loadConfFile(); + break; + case 'persistence': + persistenceRef.value!.acceptParams({ status: redisStatus.value }); + break; + case 'tuning': + case 'port': + loadform(); + break; + case 'status': + statusRef.value!.acceptParams({ status: redisStatus.value }); + break; + } }; const changeLoading = (status: boolean) => { @@ -189,11 +209,6 @@ const acceptParams = (prop: DialogProps): void => { redisName.value = prop.redisName; settingShow.value = true; loadConfFile(); - if (redisStatus.value === 'Running') { - statusRef.value!.acceptParams({ status: prop.status }); - persistenceRef.value!.acceptParams({ status: prop.status }); - loadform(); - } }; const portRef = ref(); @@ -220,7 +235,6 @@ function callback(error: any) { } } const onChangePort = async (formEl: FormInstance | undefined) => { - console.log('asdqwdwqd'); if (!formEl) return; const result = await formEl.validateField('port', callback); if (!result) { @@ -260,7 +274,7 @@ const submtiForm = async () => { let param = { timeout: form.timeout + '', maxclients: form.maxclients + '', - maxmemory: form.maxmemory + '', + maxmemory: form.maxmemory + 'mb', }; loading.value = true; await updateRedisConf(param) @@ -311,7 +325,7 @@ const loadform = async () => { form.name = res.data?.name; form.timeout = Number(res.data?.timeout); form.maxclients = Number(res.data?.maxclients); - form.maxmemory = Number(res.data?.maxmemory); + form.maxmemory = Number(res.data?.maxmemory.replaceAll('mb', '')) / 1048576; form.port = Number(res.data?.port); }; diff --git a/frontend/src/views/database/redis/setting/persistence/index.vue b/frontend/src/views/database/redis/setting/persistence/index.vue index 14082cfab..60c67f57e 100644 --- a/frontend/src/views/database/redis/setting/persistence/index.vue +++ b/frontend/src/views/database/redis/setting/persistence/index.vue @@ -48,13 +48,13 @@ - + {{ $t('database.rdbHelper1') }} - + {{ $t('database.rdbHelper2') }} @@ -89,7 +89,11 @@ - + @@ -270,7 +274,7 @@ const onSave = async (formEl: FormInstance | undefined, type: string) => { } let itemSaves = [] as Array; for (const item of form.saves) { - if (item.count === 0 || item.second === 0) { + if (item.count < 0 || item.count > 100000 || item.second < 0 || item.second > 100000) { MsgInfo(i18n.global.t('database.rdbInfo')); return; } @@ -290,6 +294,7 @@ const onSave = async (formEl: FormInstance | undefined, type: string) => { }; const loadform = async () => { + console.log('adqwdqw'); form.saves = []; const res = await redisPersistenceConf(); form.appendonly = res.data?.appendonly;