|
@@ -33,7 +33,7 @@
|
|
|
:value="currentScore"
|
|
|
@focus="onInputFocus"
|
|
|
@blur="onBlur"
|
|
|
- @keydown="onValidScore"
|
|
|
+ @keydown="onValidScoreDebounce"
|
|
|
@input="scoreChange"
|
|
|
/>
|
|
|
</div>
|
|
@@ -47,7 +47,7 @@
|
|
|
:value="currentScore"
|
|
|
@focus="onInputFocus"
|
|
|
@blur="onBlur"
|
|
|
- @keydown="onValidScore"
|
|
|
+ @keydown="onValidScoreDebounce"
|
|
|
@input="scoreChange"
|
|
|
/>
|
|
|
</div>
|
|
@@ -68,6 +68,7 @@ import { watch, computed, ref, nextTick, withDefaults, defineComponent, useSlots
|
|
|
import SvgIcon from '@/components/common/SvgIcon.vue'
|
|
|
import useVModel from '@/hooks/useVModel'
|
|
|
import { getNumbers } from '@/utils/common'
|
|
|
+import { debounce } from 'lodash-es'
|
|
|
|
|
|
interface QuestionInfo {
|
|
|
mainNumber: number
|
|
@@ -206,7 +207,7 @@ const joinStringChart = (str: string, index: number, chart: string) => {
|
|
|
return str.substring(0, index) + chart + str.substring(index + 1)
|
|
|
}
|
|
|
|
|
|
-const onValidScore = (e: KeyboardEvent) => {
|
|
|
+const onValidScore = (e: any) => {
|
|
|
const target = e.target as HTMLInputElement
|
|
|
const oldScore = `${currentScore.value ?? ''}`
|
|
|
const start = target.selectionStart || 0
|
|
@@ -221,6 +222,10 @@ const onValidScore = (e: KeyboardEvent) => {
|
|
|
}
|
|
|
|
|
|
if ('Enter' === e.key) {
|
|
|
+ let targetInputValue = e.target?.value
|
|
|
+ if (!targetInputValue) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (oldScore && !scoreStrictValidFail(oldScore)) {
|
|
|
nextTick(() => {
|
|
|
emit('enter')
|
|
@@ -246,6 +251,7 @@ const onValidScore = (e: KeyboardEvent) => {
|
|
|
e.preventDefault()
|
|
|
}
|
|
|
}
|
|
|
+const onValidScoreDebounce = debounce(onValidScore, 50)
|
|
|
|
|
|
const scoreChange = (e: Event) => {
|
|
|
const target = e.target as HTMLInputElement
|