diff --git a/src/components/practice/InputArea.tsx b/src/components/practice/InputArea.tsx index 80d3012..d65d8dc 100644 --- a/src/components/practice/InputArea.tsx +++ b/src/components/practice/InputArea.tsx @@ -41,13 +41,27 @@ export function InputArea({ if (inputLocked) return const newInput = [...userInput] - // 只取第一个字符 - newInput[index] = value.slice(0, 1) - onInputChange(newInput) - // 自动跳转到下一个输入框 - if (value && index < userInput.length - 1) { - inputRefs.current[index + 1]?.focus() + // 处理多字符输入(连续输入或粘贴) + if (value.length > 1) { + const chars = value.split('') + for (let i = 0; i < chars.length && index + i < userInput.length; i++) { + newInput[index + i] = chars[i] + } + onInputChange(newInput) + + // 聚焦到最后填充的位置的下一个 + const nextIndex = Math.min(index + chars.length, userInput.length - 1) + inputRefs.current[nextIndex]?.focus() + } else { + // 单字符输入 + newInput[index] = value + onInputChange(newInput) + + // 自动跳转到下一个输入框 + if (value && index < userInput.length - 1) { + inputRefs.current[index + 1]?.focus() + } } } @@ -80,7 +94,7 @@ export function InputArea({ } return ( -