diff --git a/src/assets/css/style.scss b/src/assets/css/style.scss index 6b110e1f..ebc820ff 100644 --- a/src/assets/css/style.scss +++ b/src/assets/css/style.scss @@ -3,6 +3,7 @@ :root { --color-reverse-white: white; --color-reverse-black: black; + --bg-history: white; --color-item-bg: rgb(228, 230, 232); --color-item-hover: white; //--color-item-active: rgb(75, 110, 175); @@ -92,6 +93,7 @@ html.dark { --color-select-text: black; --color-notice-bg: rgb(43, 45, 48); + --bg-history: rgb(43, 45, 48); --color-item-bg: rgb(43, 45, 48); --color-item-hover: rgb(67, 69, 74); --color-item-active: rgb(84, 84, 84); diff --git a/src/pages/article/ArticlesPage.vue b/src/pages/article/ArticlesPage.vue index 7b78fb88..0916f26c 100644 --- a/src/pages/article/ArticlesPage.vue +++ b/src/pages/article/ArticlesPage.vue @@ -113,6 +113,12 @@ const totalSpend = $computed(() => { } return 0 }) +const todayTotalSpend = $computed(() => { + if (base.sbook.statistics?.length) { + return msToHourMinute(total(base.sbook.statistics.filter(v => dayjs(v.startDate).isSame(dayjs(), 'day')), 'spend')) + } + return 0 +}) const totalDay = $computed(() => { if (base.sbook.statistics?.length) { @@ -176,16 +182,16 @@ const weekList = $computed(() => {
-
{{ totalSpend }}
-
总学习时长
+
{{ todayTotalSpend }}
+
今日学习时长
{{ totalDay }}
总学习天数
-
{{ base.sbook?.statistics?.length || 0 }}
-
总学习次数
+
{{ totalSpend }}
+
总学习时长
@@ -263,7 +269,7 @@ const weekList = $computed(() => { border: 1px solid gainsboro; .num { - @apply color-[#409eff] text-2xl font-bold; + @apply color-[#409eff] text-xl font-bold; } .txt { diff --git a/src/pages/article/BookDetail.vue b/src/pages/article/BookDetail.vue index 914d40ff..ff8ca796 100644 --- a/src/pages/article/BookDetail.vue +++ b/src/pages/article/BookDetail.vue @@ -182,10 +182,11 @@ const totalSpend = $computed(() => {
-
-
学习记录:{{ 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) }}