diff --git a/src/pages/pc/word/StudyWord.vue b/src/pages/pc/word/StudyWord.vue
index 8a157791..6460a0d2 100644
--- a/src/pages/pc/word/StudyWord.vue
+++ b/src/pages/pc/word/StudyWord.vue
@@ -265,7 +265,6 @@ async function onKeyDown(e: KeyboardEvent) {
}
}
-
useOnKeyboardEventListener(onKeyDown, onKeyUp)
function repeat() {
diff --git a/src/pages/pc/word/components/TypeWord.vue b/src/pages/pc/word/components/TypeWord.vue
index 6361309c..d7beaedf 100644
--- a/src/pages/pc/word/components/TypeWord.vue
+++ b/src/pages/pc/word/components/TypeWord.vue
@@ -9,6 +9,7 @@ import Tooltip from "@/pages/pc/components/base/Tooltip.vue";
import SentenceHightLightWord from "@/pages/pc/word/components/SentenceHightLightWord.vue";
import {usePracticeStore} from "@/stores/practice.ts";
import {getDefaultWord} from "@/types/func.ts";
+import {sleep} from "@/utils";
interface IProps {
word: Word,
@@ -78,10 +79,15 @@ function repeat() {
}
async function onTyping(e: KeyboardEvent) {
- if (inputLock) return
- console.log('onTyping', inputLock)
- inputLock = true
+ if (inputLock) {
+ //如果是锁定状态,说明要么输入太快;要么就是设置了不自动跳转,然后输入完了,当这种情况时,监听空格键,按下切换下一个
+ if (e.code === 'Space' && input.toLowerCase() === props.word.word.toLowerCase()) {
+ return emit('complete')
+ }
+ return
+ }
let letter = e.key
+ inputLock = true
let isTypingRight = false
if (settingStore.ignoreCase) {
isTypingRight = letter.toLowerCase() === props.word.word[input.length].toLowerCase()
@@ -93,13 +99,13 @@ async function onTyping(e: KeyboardEvent) {
wrong = ''
playKeyboardAudio()
} else {
+ emit('wrong')
wrong = letter
playBeep()
volumeIconRef?.play()
- setTimeout(() => {
- wrong = ''
- }, 500)
- emit('wrong')
+ await sleep(500)
+ if (settingStore.inputWrongClear) input = ''
+ wrong = ''
}
if (input.toLowerCase() === props.word.word.toLowerCase()) {
diff --git a/src/stores/setting.ts b/src/stores/setting.ts
index f985425a..6675e2dd 100644
--- a/src/stores/setting.ts
+++ b/src/stores/setting.ts
@@ -5,9 +5,6 @@ import {SAVE_SETTING_KEY} from "@/utils/const.ts";
import {get} from "idb-keyval";
export interface SettingState {
- showToolbar: boolean,
- show: boolean,
-
allSound: boolean,
wordSound: boolean,
wordSoundVolume: number,
@@ -18,22 +15,24 @@ export interface SettingState {
keyboardSoundFile: string,
effectSound: boolean,
effectSoundVolume: number,
- repeatCount: number,
- repeatCustomCount?: number,
- dictation: boolean,
- translate: boolean,
- showNearWord: boolean
- ignoreCase: boolean
- allowWordTip: boolean
- waitTimeForChangeWord: number
+
+ repeatCount: number, //重复次数
+ repeatCustomCount?: number, //自定义重复次数
+ dictation: boolean,//显示默写
+ translate: boolean, //显示翻译
+ showNearWord: boolean //显示上/下一个词
+ ignoreCase: boolean //忽略大小写
+ allowWordTip: boolean //默写时时否允许查看提示
+ waitTimeForChangeWord: number // 切下一个词的等待时间
fontSize: {
articleForeignFontSize: number,
articleTranslateFontSize: number,
wordForeignFontSize: number,
wordTranslateFontSize: number,
},
- showPanel: boolean,
- sideExpand: boolean,
+ showToolbar: boolean, //收起/展开工具栏
+ showPanel: boolean, // 收起/展开面板
+ sideExpand: boolean, //收起/展开左侧侧边栏
theme: string,
shortcutKeyMap: Record,
first: boolean
@@ -44,11 +43,11 @@ export interface SettingState {
wordPracticeMode: number // 单词练习模式,0:智能模式,1:自由模式
disableShowPracticeSettingDialog: boolean // 不默认显示练习设置弹框
autoNextWord: boolean //自动切换下一个单词
+ inputWrongClear: boolean //单词输入错误,清空已输入内容
}
export const getDefaultSettingState = (): SettingState => ({
showToolbar: true,
- show: false,
showPanel: true,
sideExpand: false,
@@ -86,7 +85,8 @@ export const getDefaultSettingState = (): SettingState => ({
ignoreSimpleWord: false,
wordPracticeMode: 0,
disableShowPracticeSettingDialog: false,
- autoNextWord: true
+ autoNextWord: true,
+ inputWrongClear: false
})
export const useSettingStore = defineStore('setting', {
diff --git a/src/utils/const.ts b/src/utils/const.ts
index 9c95c05e..17c3b4c1 100644
--- a/src/utils/const.ts
+++ b/src/utils/const.ts
@@ -14,7 +14,7 @@ export const SAVE_DICT_KEY = {
}
export const SAVE_SETTING_KEY = {
key: 'typing-word-setting',
- version: 12
+ version: 13
}
export const EXPORT_DATA_KEY = {
key: 'typing-word-export',