From 527a88fc998d17c5ef9c3a7e435a737d23ebd82f Mon Sep 17 00:00:00 2001
From: wisonic-s <51065359+wisonic-s@users.noreply.github.com>
Date: Mon, 7 Apr 2025 10:39:38 +0800
Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E9=A5=BC=E5=9B=BE=E5=86=85=E5=A4=96=E5=BE=84=E8=BE=93?=
=?UTF-8?q?=E5=85=A5=E6=A0=A1=E9=AA=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/BasicStyleSelector.vue | 29 +++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue
index 0eac596a43..3f4a31c912 100644
--- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue
+++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue
@@ -316,6 +316,31 @@ const mergeCell = computed(() => {
}
return false
})
+
+const preventInvalidKeydown = event => {
+ const invalidKeys = ['e', 'E', '+', '-', '.']
+ if (invalidKeys.includes(event.key)) {
+ event.preventDefault()
+ }
+}
+// 验证输入值
+const validateInput = (value, field) => {
+ if (value === '') {
+ state.basicStyleForm[field] = 1
+ return
+ }
+
+ let num = parseInt(value, 10)
+
+ if (isNaN(num)) {
+ num = 1
+ } else if (num < 1) {
+ num = 1
+ } else if (num > 100) {
+ num = 100
+ }
+ state.basicStyleForm[field] = num
+}
onMounted(() => {
init()
getMapKey().then(res => {
@@ -1421,7 +1446,9 @@ onMounted(() => {
:max="100"
class="basic-input-number"
:controls="false"
+ @input="validateInput($event, 'innerRadius')"
@change="changeBasicStyle('innerRadius')"
+ @keydown="preventInvalidKeydown"
>
%
@@ -1456,7 +1483,9 @@ onMounted(() => {
:max="100"
class="basic-input-number"
:controls="false"
+ @input="validateInput($event, 'radius')"
@change="changeBasicStyle('radius')"
+ @keydown="preventInvalidKeydown"
>
%