feat:修改学习逻辑

This commit is contained in:
zyronon
2025-07-28 02:51:34 +08:00
parent 685c0277bb
commit a3b648d3c8
8 changed files with 112 additions and 52 deletions

View File

@@ -117,8 +117,6 @@ function next(isTyping: boolean = true) {
let now = Date.now()
stat.endDate = now
stat.spend = now - stat.startDate
emitter.emit(EventKey.openStatModal, stat)
}
} else {
data.index++

View File

@@ -146,7 +146,6 @@ function over() {
wrong: statisticsStore.wrong,
}
stat.correctRate = 100 - Math.trunc(((stat.wrong) / (stat.total)) * 100)
emitter.emit(EventKey.openStatModal, stat)
} else {
tabIndex = 1
wordData.index = 0

View File

@@ -2,17 +2,19 @@
import Dialog from "@/pages/pc/components/dialog/Dialog.vue";
import {useBaseStore} from "@/stores/base.ts";
import BaseButton from "@/components/BaseButton.vue";
import {ShortcutKey, Statistics} from "@/types.ts";
import {ShortcutKey, Statistics, StudyData} from "@/types.ts";
import {emitter, EventKey, useEvents} from "@/utils/eventBus.ts";
import {Icon} from '@iconify/vue';
import {useSettingStore} from "@/stores/setting.ts";
import {usePracticeStore} from "@/stores/practice.ts";
import dayjs from "dayjs";
import isBetween from "dayjs/plugin/isBetween";
import {watch} from "vue";
import {inject, watch} from "vue";
dayjs.extend(isBetween);
let dictIsEnd = inject<boolean>('dictIsEnd')
const store = useBaseStore()
const settingStore = useSettingStore()
const statStore = usePracticeStore()
@@ -78,11 +80,6 @@ function options(emitType: string) {
emitter.emit(EventKey[emitType])
}
//todo
const isEnd = $computed(() => {
return false
})
</script>
<template>
@@ -156,14 +153,13 @@ const isEnd = $computed(() => {
<BaseButton
:keyboard="settingStore.shortcutKeyMap[ShortcutKey.RepeatChapter]"
@click="options(EventKey.repeatStudy)">
重学
重学一遍
</BaseButton>
<BaseButton
:keyboard="settingStore.shortcutKeyMap[ShortcutKey.NextChapter]"
@click="options(EventKey.continueStudy)">
{{ isEnd ? '重新练习' : '再来一组' }}
{{ dictIsEnd ? '重新练习' : '再来一组' }}
</BaseButton>
<BaseButton>
分享
</BaseButton>

View File

@@ -56,7 +56,6 @@ let data = $ref<StudyData>({
wrongWords: [],
})
provide('studyData', data)
onMounted(() => {
if (runtimeStore.routeData) {
@@ -81,10 +80,17 @@ watch(() => studyData, () => {
statStore.index = 0
}, {immediate: true, deep: true})
const dictIsEnd = $computed(() => {
return store.sdict.lastLearnIndex === store.sdict.length
})
provide('studyData', data)
provide('dictIsEnd', dictIsEnd)
const word = $computed(() => {
return data.words[data.index] ?? getDefaultWord()
})
const prevWord: Word = $computed(() => {
return data.words?.[data.index - 1] ?? undefined
})
@@ -94,8 +100,8 @@ const nextWord: Word = $computed(() => {
})
function next(isTyping: boolean = true) {
showStatDialog = true
return
// showStatDialog = true
// return
if (data.index === data.words.length - 1) {
if (data.wrongWords.length) {
console.log('当前学完了,但还有错词')
@@ -104,37 +110,66 @@ function next(isTyping: boolean = true) {
data.wrongWords = []
} else {
console.log('当前学完了,没错词', statStore.total, statStore.step, data.index)
isTyping && statStore.inputWordNumber++
if (isTyping) statStore.inputWordNumber++
//学完了
if (statStore.step === 2) {
if (statStore.step === 4) {
statStore.spend = Date.now() - statStore.startDate
console.log('全完学完了')
emitter.emit(EventKey.openStatModal, {})
showStatDialog = true
// emit('complete', {})
}
//开始默认所有单词
if (statStore.step === 1) {
console.log('开始默认所有单词')
if (statStore.step === 3) {
statStore.step++
settingStore.dictation = true
data.words = shuffle(studyData.write.concat(studyData.new).concat(studyData.review))
data.index = 0
}
//开始复习
if (statStore.step === 0) {
statStore.step++
if (studyData.review.length) {
console.log('开始复习')
data.words = shuffle(studyData.review)
settingStore.dictation = false
if (studyData.write.length) {
console.log('开始默认所有单词')
settingStore.dictation = true
data.words = shuffle(studyData.write)
data.index = 0
} else {
console.log('开始默认所有单词-无单词路过')
next()
}
}
//开始默写昨日
if (statStore.step === 2) {
statStore.step++
if (studyData.review.length) {
console.log('开始默写昨日')
settingStore.dictation = true
data.words = shuffle(studyData.review)
data.index = 0
} else {
console.log('开始默写昨日-无单词路过')
next()
}
}
//开始复习昨日
if (statStore.step === 1) {
statStore.step++
if (studyData.review.length) {
console.log('开始复习昨日')
settingStore.dictation = false
data.words = shuffle(studyData.review)
data.index = 0
} else {
console.log('开始复习昨日-无单词路过')
next()
}
}
//开始默写新词
if (statStore.step === 0) {
statStore.step++
console.log('开始默写新词')
settingStore.dictation = true
data.words = shuffle(studyData.new)
data.index = 0
}
}
} else {
data.index++
@@ -180,8 +215,10 @@ useStartKeyboardEventListener()
useOnKeyboardEventListener(onKeyDown, onKeyUp)
function repeat() {
console.log('repeat')
console.log('重学一遍')
settingStore.dictation = false
//将学习进度减回去
store.sdict.lastLearnIndex = store.sdict.lastLearnIndex - statStore.newWordNumber
emitter.emit(EventKey.resetWord)
let temp = cloneDeep(studyData)
//排除已掌握单词
@@ -248,9 +285,18 @@ function togglePanel() {
settingStore.showPanel = !settingStore.showPanel
}
function continueStudy() {
if (dictIsEnd) {
} else {
settingStore.dictation = false
studyData = getCurrentStudyWord()
}
}
useEvents([
[EventKey.repeatStudy, repeat],
[EventKey.continueStudy, next],
[EventKey.continueStudy, continueStudy],
[EventKey.changeDict, () => {
studyData = getCurrentStudyWord()
}],
@@ -360,9 +406,7 @@ useEvents([
</Panel>
</div>
</div>
<Statistics v-model="showStatDialog"
/>
<Statistics v-model="showStatDialog"/>
</template>
<style scoped lang="scss">

View File

@@ -278,7 +278,7 @@ function clickActivityEvent(e) {
<div class="center text-sm" :style="{ opacity: tempPerDayStudyNumber === 20 ? 1 : 0 }">
推荐
</div>
<el-slider :min="10" :step="10" show-stops :marks="{ 10: '10', 200: '200' }" size="small" class="my-6"
<el-slider :min="3" :step="10" show-stops :marks="{ 10: '10', 200: '200' }" size="small" class="my-6"
:max="200" v-model="tempPerDayStudyNumber"/>
<div class="flex gap-2 mb-2 mt-10 items-center">
<div>预计</div>

View File

@@ -43,20 +43,25 @@ onUnmounted(() => {
timer && clearInterval(timer)
})
const statStore = usePracticeStore()
let studyData = inject<StudyData>('studyData')
const status = $computed(() => {
let str = '正在'
switch (statStore.step) {
switch (statisticsStore.step) {
case 0:
str += `学习新词`
break
case 1:
str += `复习`
str += `默写新词`
break
case 2:
str += '默写'
str += `复习上次`
break
case 3:
str += `默写上次`
break
case 4:
str += '默写之前'
break
}
return str
@@ -100,12 +105,12 @@ const progress = $computed(() => {
<div class="row">
<div class="num">{{ format(statisticsStore.inputWordNumber, '', 0) }}</div>
<div class="line"></div>
<div class="name">输入数</div>
<div class="name">输入数</div>
</div>
<div class="row">
<div class="num">{{ format(statisticsStore.wrong, '', 0) }}</div>
<div class="line"></div>
<div class="name">错误数</div>
<div class="name">错误数</div>
</div>
</div>
<div class="flex justify-center items-center">

View File

@@ -4,9 +4,10 @@ import VolumeIcon from "@/components/icon/VolumeIcon.vue";
import {useSettingStore} from "@/stores/setting.ts";
import {usePlayBeep, usePlayCorrect, usePlayKeyboardAudio, usePlayWordAudio, useTTsPlayAudio} from "@/hooks/sound.ts";
import {emitter, EventKey} from "@/utils/eventBus.ts";
import {onMounted, onUnmounted, watch} from "vue";
import {nextTick, onMounted, onUnmounted, watch} from "vue";
import Tooltip from "@/pages/pc/components/Tooltip.vue";
import SentenceHightLightWord from "@/pages/pc/word/components/SentenceHightLightWord.vue";
import {usePracticeStore} from "@/stores/practice.ts";
interface IProps {
word: Word,
@@ -130,10 +131,20 @@ function del() {
}
}
const statStore = usePracticeStore()
function showWord() {
if (settingStore.allowWordTip) {
showFullWord = true
}
//系统设定的默认模式情况下,如果看了单词统计到错词里面去
switch (statStore.step) {
case 1:
case 3:
case 4:
emit('wrong')
break
}
}
function hideWord() {
@@ -147,6 +158,13 @@ function play() {
defineExpose({del, showWord, hideWord, play})
let tab = $ref(0)
function mouseleave() {
setTimeout(() => {
showFullWord = false
}, 50)
}
</script>
<template>
@@ -172,15 +190,14 @@ let tab = $ref(0)
<div class="word my-1"
:class="wrong && 'is-wrong'"
:style="{fontSize: settingStore.fontSize.wordForeignFontSize +'px'}"
@mouseenter="showWord"
@mouseleave="mouseleave"
>
<span class="input" v-if="input">{{ input }}</span>
<span class="wrong" v-if="wrong">{{ wrong }}</span>
<template v-if="settingStore.dictation">
<span class="letter" v-if="!showFullWord"
@mouseenter="settingStore.allowWordTip && (showFullWord = true)">{{
displayWord.split('').map(() => '_').join('')
}}</span>
<span class="letter" v-else @mouseleave="showFullWord = false">{{ displayWord }}</span>
<span class="letter" v-if="!showFullWord">{{ displayWord.split('').map(() => '_').join('') }}</span>
<span class="letter" v-else>{{ displayWord }}</span>
</template>
<span class="letter" v-else>{{ displayWord }}</span>
</div>