From c50570f2b50e55fcd25b06f6b2157092f1869991 Mon Sep 17 00:00:00 2001 From: uuutt2023 <584193570@qq.com> Date: Wed, 15 Apr 2026 21:11:05 +0800 Subject: [PATCH 1/6] fix: prevent numeric input reset to 0 on text selection blur --- dashboard/src/components/shared/ConfigItemRenderer.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/components/shared/ConfigItemRenderer.vue b/dashboard/src/components/shared/ConfigItemRenderer.vue index 0cdddcde61..7bc46193f9 100644 --- a/dashboard/src/components/shared/ConfigItemRenderer.vue +++ b/dashboard/src/components/shared/ConfigItemRenderer.vue @@ -161,7 +161,7 @@ Date: Wed, 15 Apr 2026 21:41:43 +0800 Subject: [PATCH 2/6] fix(dashboard): optimize blur handler to avoid unnecessary emit Only emit update when numericTemp is not null to avoid unnecessary event cycles and potential side-effects. --- dashboard/src/components/shared/ConfigItemRenderer.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard/src/components/shared/ConfigItemRenderer.vue b/dashboard/src/components/shared/ConfigItemRenderer.vue index 7bc46193f9..530d8e1790 100644 --- a/dashboard/src/components/shared/ConfigItemRenderer.vue +++ b/dashboard/src/components/shared/ConfigItemRenderer.vue @@ -161,7 +161,7 @@ Date: Wed, 15 Apr 2026 22:04:20 +0800 Subject: [PATCH 3/6] feat(dashboard): add form validation for numeric inputs - Add toValidNumber() function with comprehensive boundary handling - Add handleNumericBlur() to prevent unintended resets on text selection - Handle null, undefined, empty string, and NaN cases properly - Only emit updates when user actually modifies the value --- .../components/shared/ConfigItemRenderer.vue | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/dashboard/src/components/shared/ConfigItemRenderer.vue b/dashboard/src/components/shared/ConfigItemRenderer.vue index 530d8e1790..1db86102e3 100644 --- a/dashboard/src/components/shared/ConfigItemRenderer.vue +++ b/dashboard/src/components/shared/ConfigItemRenderer.vue @@ -147,8 +147,8 @@ > Date: Wed, 15 Apr 2026 22:11:33 +0800 Subject: [PATCH 4/6] refactor(dashboard): use Number.isFinite for consistent numeric validation - Replace parseFloat with Number() for more consistent type coercion - Use Number.isFinite() pattern consistent with restartAstrBot.ts - Better handling of edge cases (Infinity, -Infinity) --- dashboard/src/components/shared/ConfigItemRenderer.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/src/components/shared/ConfigItemRenderer.vue b/dashboard/src/components/shared/ConfigItemRenderer.vue index 1db86102e3..f965b96884 100644 --- a/dashboard/src/components/shared/ConfigItemRenderer.vue +++ b/dashboard/src/components/shared/ConfigItemRenderer.vue @@ -285,8 +285,8 @@ function toValidNumber(val) { if (typeof val === 'number') { return isNaN(val) ? 0 : val } - const n = parseFloat(val) - return isNaN(n) ? 0 : n + const n = Number(val) + return Number.isFinite(n) ? n : 0 } function handleNumericBlur() { From 18adfac9e3c75357d968576436336f54412b1738 Mon Sep 17 00:00:00 2001 From: uuutt2023 <584193570@qq.com> Date: Wed, 15 Apr 2026 22:13:28 +0800 Subject: [PATCH 5/6] refactor(dashboard): simplify handleNumericBlur by reducing nesting --- dashboard/src/components/shared/ConfigItemRenderer.vue | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dashboard/src/components/shared/ConfigItemRenderer.vue b/dashboard/src/components/shared/ConfigItemRenderer.vue index f965b96884..d7e58abbf0 100644 --- a/dashboard/src/components/shared/ConfigItemRenderer.vue +++ b/dashboard/src/components/shared/ConfigItemRenderer.vue @@ -290,11 +290,9 @@ function toValidNumber(val) { } function handleNumericBlur() { - if (numericTemp.value !== null && numericTemp.value !== undefined) { - if (numericTemp.value === '') { - } else { - emitUpdate(toValidNumber(numericTemp.value)) - } + // 只有当用户实际输入了有效值时才触发更新 + if (numericTemp.value !== null && numericTemp.value !== undefined && numericTemp.value !== '') { + emitUpdate(toValidNumber(numericTemp.value)) } numericTemp.value = null } From 90851491df1276f642cbf9ac5592d3867a21722a Mon Sep 17 00:00:00 2001 From: uuutt2023 <584193570@qq.com> Date: Wed, 15 Apr 2026 23:01:18 +0800 Subject: [PATCH 6/6] refactor(dashboard): replace comment with variable name hasValidInput --- dashboard/src/components/shared/ConfigItemRenderer.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/src/components/shared/ConfigItemRenderer.vue b/dashboard/src/components/shared/ConfigItemRenderer.vue index d7e58abbf0..1dac1806f0 100644 --- a/dashboard/src/components/shared/ConfigItemRenderer.vue +++ b/dashboard/src/components/shared/ConfigItemRenderer.vue @@ -290,8 +290,8 @@ function toValidNumber(val) { } function handleNumericBlur() { - // 只有当用户实际输入了有效值时才触发更新 - if (numericTemp.value !== null && numericTemp.value !== undefined && numericTemp.value !== '') { + const hasValidInput = numericTemp.value !== null && numericTemp.value !== undefined && numericTemp.value !== '' + if (hasValidInput) { emitUpdate(toValidNumber(numericTemp.value)) } numericTemp.value = null