This commit is contained in:
zyronon
2024-05-22 18:13:25 +08:00
parent 25c3797322
commit 943f095200
5 changed files with 59 additions and 59 deletions

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import {onMounted, onUnmounted, watch} from "vue"
import {useBaseStore} from "@/stores/base.ts"
import {DefaultDisplayStatistics, DictType, ShortcutKey, Sort, Word} from "../../../../types.ts";
import {DefaultDisplayStatistics, DictType, ShortcutKey, Sort, Word} from "@/types.ts";
import {emitter, EventKey} from "@/utils/eventBus.ts"
import {cloneDeep, reverse, shuffle} from "lodash-es"
import {usePracticeStore} from "@/stores/practice.ts"
@@ -12,9 +12,8 @@ import Tooltip from "@/pages/pc/components/Tooltip.vue";
import Options from "@/pages/pc/practice/Options.vue";
import Typing from "@/pages/pc/practice/practice-word/Typing.vue";
import Panel from "@/pages/pc/practice/Panel.vue";
import IconWrapper from "@/pages/pc/components/IconWrapper.vue";
import {useRuntimeStore} from "@/stores/runtime.ts";
import {syncMyDictList, useWordOptions} from "@/hooks/dict.ts";
import {useWordOptions} from "@/hooks/dict.ts";
import BaseIcon from "@/components/BaseIcon.vue";
import WordList from "@/pages/pc/components/list/WordList.vue";
import Empty from "@/components/Empty.vue";
@@ -147,8 +146,8 @@ function next(isTyping: boolean = true) {
}
function wordWrong() {
if (!store.wrong.originWords.find((v: Word) => v.word.toLowerCase() === word.word.toLowerCase())) {
store.wrong.originWords.push(word)
if (!store.wrong2.find((v: Word) => v.word.toLowerCase() === word.word.toLowerCase())) {
store.wrong2.push(word)
}
if (!data.wrongWords.find((v: Word) => v.word.toLowerCase() === word.word.toLowerCase())) {
data.wrongWords.push(word)

View File

@@ -21,38 +21,27 @@ let wordData = $ref({
})
function getCurrentPractice() {
if (store.chapter.length) {
if (store.currentWordDict.words?.length) {
wordData.index = 0
wordData.words = cloneDeep(store.chapter)
wordData.words = cloneDeep(store.currentWordDict.words.slice(store.currentStudy.word.lastWordIndex, store.currentStudy.word.lastWordIndex + store.currentStudy.word.perDayStudyNumber))
emitter.emit(EventKey.resetWord)
}
}
//TODO wait
function sort(list: Word[]) {
store.currentDict.chapterWords[store.currentDict.chapterIndex] = wordData.words = list
wordData.index = 0
syncMyDictList(store.currentDict)
}
function next() {
if (store.currentDict.chapterIndex >= store.currentDict.chapterWords.length - 1) {
store.currentDict.chapterIndex = 0
} else store.currentDict.chapterIndex++
getCurrentPractice()
}
onMounted(() => {
getCurrentPractice()
emitter.on(EventKey.changeDict, getCurrentPractice)
emitter.on(EventKey.next, next)
emitter.on(ShortcutKey.NextChapter, next)
})
onUnmounted(() => {
emitter.off(EventKey.changeDict, getCurrentPractice)
emitter.off(EventKey.next, next)
emitter.off(ShortcutKey.NextChapter, next)
})
defineExpose({getCurrentPractice})

View File

@@ -24,9 +24,17 @@ function clickEvent(e) {
我的词典
</div>
<div class="grid flex-1 flex gap-5 mt-4">
<div class="p-4 flex-1 rounded-md bg-slate-200 relative" v-for="i in 3">
<div class="p-4 flex-1 rounded-md bg-slate-200 relative">
<span>收藏</span>
<div class="absolute bottom-4 right-4">333个词</div>
<div class="absolute bottom-4 right-4">{{ base.collectWord.length}}个词</div>
</div>
<div class="p-4 flex-1 rounded-md bg-slate-200 relative">
<span>生词本</span>
<div class="absolute bottom-4 right-4">{{ base.wrong2.length}}个词</div>
</div>
<div class="p-4 flex-1 rounded-md bg-slate-200 relative">
<span>简单词</span>
<div class="absolute bottom-4 right-4">{{ base.simple2.length}}个词</div>
</div>
</div>
</div>
@@ -34,7 +42,7 @@ function clickEvent(e) {
<div class="card ">
<div class="flex justify-between items-center">
<div class="bg-slate-200 p-3 rounded-md cursor-pointer flex items-center">
<span class="text-lg font-bold">{{ base.currentDict.name }}</span>
<span class="text-lg font-bold">{{ base.currentWordDict.name }}</span>
<Icon icon="gg:arrows-exchange" class="text-2xl ml-2"/>
<Icon icon="uil:setting" class="text-2xl ml-2"/>
</div>
@@ -59,7 +67,7 @@ function clickEvent(e) {
更改目标
</div>
</div>
<div class="mt-2 text-xs">学习 50 个单词</div>
<div class="mt-2 text-xs">学习 {{ base.currentStudy.word.perDayStudyNumber }} 个单词</div>
<el-progress class="flex-1 mt-1" :percentage="80" :show-text="false"></el-progress>
</div>
</div>