-
学习记录:{{ msToHourMinute(total(currentPractice, 'spend'))}}
-
- {{_dateFormat(i.startDate,'YYYY/MM/DD HH:mm')}}: {{ msToHourMinute(i.spend) }}
+
+
学习记录
+
总学习时长:{{ msToHourMinute(total(currentPractice, 'spend'))}}
+
+ {{_dateFormat(i.startDate,'YYYY/MM/DD HH:mm')}} {{ msToHourMinute(i.spend) }}
diff --git a/src/pages/article/components/TypingArticle.vue b/src/pages/article/components/TypingArticle.vue
index 2252e8fb..233d6e68 100644
--- a/src/pages/article/components/TypingArticle.vue
+++ b/src/pages/article/components/TypingArticle.vue
@@ -5,7 +5,7 @@ import { useBaseStore } from "@/stores/base.ts";
import { useSettingStore } from "@/stores/setting.ts";
import { usePlayBeep, usePlayCorrect, usePlayKeyboardAudio } from "@/hooks/sound.ts";
import { emitter, EventKey } from "@/utils/eventBus.ts";
-import { _dateFormat, _nextTick, msToMinute } from "@/utils";
+import { _dateFormat, _nextTick, msToHourMinute, msToMinute, total } from "@/utils";
import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'
import ContextMenu from '@imengyu/vue3-context-menu'
import { getTranslateText } from "@/hooks/article.ts";
@@ -250,75 +250,81 @@ function onTyping(e: KeyboardEvent) {
if (isTyping) return;
isTyping = true;
// console.log('keyDown', e.key, e.code, e.keyCode)
- let currentSection = props.article.sections[sectionIndex]
- let currentSentence = currentSection[sentenceIndex]
- let currentWord: ArticleWord = currentSentence.words[wordIndex]
- wrong = ''
+ try {
+ let currentSection = props.article.sections[sectionIndex]
+ let currentSentence = currentSection[sentenceIndex]
+ let currentWord: ArticleWord = currentSentence.words[wordIndex]
+ wrong = ''
- const next = () => {
- isSpace = false;
- input = wrong = ''
- stringIndex = 0;
- // 检查下一个单词是否存在
- if (wordIndex + 1 < currentSentence.words.length) {
- wordIndex++;
- emit('nextWord', currentWord);
- } else {
- nextSentence()
- }
- }
-
- if (isSpace) {
- if (e.code === 'Space') {
- next()
- } else {
- wrong = ' '
- playBeep()
- setTimeout(() => {
- wrong = ''
- wrong = input = ''
- }, 500)
- }
- } else {
- //如果是首句首词
- if (sectionIndex === 0 && sentenceIndex === 0 && wordIndex === 0 && stringIndex === 0) {
- emit('play', {sentence: currentSection[sentenceIndex], handle: false})
- }
- let letter = e.key
- let key = currentWord.word[stringIndex]
- // console.log('key', key,)
-
- let isRight = false
- if (settingStore.ignoreCase) {
- isRight = key.toLowerCase() === letter.toLowerCase()
- } else {
- isRight = key === letter
- }
- if (!isRight) {
- if (currentWord.type === PracticeArticleWordType.Word) {
- emit('wrong', currentWord)
- }
- playBeep()
- }
-
- input += letter
- currentWord.input = input
- stringIndex++
- //单词输入完毕
- if (!currentWord.word[stringIndex]) {
- input = ''
- //如果不是符号,播放完成音效
- if (currentWord.type === PracticeArticleWordType.Word) playCorrect()
- if (currentWord.nextSpace) {
- isSpace = true
+ const next = () => {
+ isSpace = false;
+ input = wrong = ''
+ stringIndex = 0;
+ // 检查下一个单词是否存在
+ if (wordIndex + 1 < currentSentence.words.length) {
+ wordIndex++;
+ emit('nextWord', currentWord);
} else {
- next()
+ nextSentence()
}
}
+
+ if (isSpace) {
+ if (e.code === 'Space') {
+ next()
+ } else {
+ wrong = ' '
+ playBeep()
+ setTimeout(() => {
+ wrong = ''
+ wrong = input = ''
+ }, 500)
+ }
+ } else {
+ //如果是首句首词
+ if (sectionIndex === 0 && sentenceIndex === 0 && wordIndex === 0 && stringIndex === 0) {
+ emit('play', {sentence: currentSection[sentenceIndex], handle: false})
+ }
+ let letter = e.key
+ let key = currentWord.word[stringIndex]
+ // console.log('key', key,)
+
+ let isRight = false
+ if (settingStore.ignoreCase) {
+ isRight = key.toLowerCase() === letter.toLowerCase()
+ } else {
+ isRight = key === letter
+ }
+ if (!isRight) {
+ if (currentWord.type === PracticeArticleWordType.Word) {
+ emit('wrong', currentWord)
+ }
+ playBeep()
+ }
+
+ input += letter
+ currentWord.input = input
+ stringIndex++
+ //单词输入完毕
+ if (!currentWord.word[stringIndex]) {
+ input = ''
+ //如果不是符号,播放完成音效
+ if (currentWord.type === PracticeArticleWordType.Word) playCorrect()
+ if (currentWord.nextSpace) {
+ isSpace = true
+ } else {
+ next()
+ }
+ }
+ }
+ playKeyboardAudio()
+ e.preventDefault()
+ isTyping = false
+ } catch (e) {
+ //todo 上报
+ localStorage.removeItem(PracticeSaveArticleKey.key)
+ init()
}
- playKeyboardAudio()
- e.preventDefault()
- isTyping = false
}
function play() {
@@ -614,25 +620,22 @@ const currentPractice = inject('currentPractice', [])
@click="emit('next')">下一篇
-
-
历史记录
-
+
学习记录
+
总学习时长:{{ msToHourMinute(total(currentPractice, 'spend')) }}
+
- {{ i + 1 }}.
- {{ _dateFormat(item.startDate, 'YYYY-MM-DD HH:mm') }}
- {{ msToMinute(item.spend) }}
+ {{
+ i === currentPractice.length - 1 ? '当前' : i + 1
+ }}. {{ _dateFormat(item.startDate, 'YYYY/MM/DD HH:mm') }}
+ {{ msToHourMinute(item.spend) }}
-
显示题目
diff --git a/uno.config.ts b/uno.config.ts
index 95e39ed3..466cc218 100644
--- a/uno.config.ts
+++ b/uno.config.ts
@@ -7,11 +7,13 @@ export default defineConfig({
'bg-second': 'bg-[var(--color-second)]',
'bg-third': 'bg-[var(--color-third)]',
'bg-card-active': 'bg-[var(--color-card-active)]',
+ 'bg-item': 'bg-[var(--color-item-bg)]',
'color-main': 'color-[var(--color-main-text)]',
'gap-space': 'gap-[var(--space)]',
'p-space': 'p-[var(--space)]',
'px-space': 'px-[var(--space)]',
'py-space': 'py-[var(--space)]',
+ 'border-item': 'border-[var(--color-item-border)]',
},
presets: [
presetWind3(),