diff --git a/src/components/BaseButton.vue b/src/components/BaseButton.vue index f5770e8c..5f87e4a0 100644 --- a/src/components/BaseButton.vue +++ b/src/components/BaseButton.vue @@ -7,11 +7,15 @@ const props = defineProps<{ active?: boolean }>() +defineEmits(['click']) + diff --git a/src/components/Modal/DictModal.vue b/src/components/Modal/DictModal.vue index 79c34f79..1af42afa 100644 --- a/src/components/Modal/DictModal.vue +++ b/src/components/Modal/DictModal.vue @@ -3,20 +3,19 @@ import {childrenEnglish} from '@/assets/dictionary.ts' import {ArrowLeft, ArrowRight, Close} from '@icon-park/vue-next' import {useBaseStore} from "@/stores/base.ts" import {watch} from "vue" -import {Dict, Word} from "@/types.ts" +import {Dict, DictType, Sort, Word} from "@/types.ts" import {chunk} from "lodash"; import {$computed, $ref} from "vue/macros"; import WordList from "@/components/WordList.vue"; import ChapterList from "@/components/ChapterList.vue" import Modal from "@/components/Modal/Modal.vue"; -import IconWrapper from "@/components/IconWrapper.vue"; import BaseButton from "@/components/BaseButton.vue"; const store = useBaseStore() let currentSelectDict: Dict = $ref({ name: '新概念英语-2', chapterList: [], - chapterIndex: -1 + chapterIndex: -1, } as any) let step = $ref(0) @@ -30,18 +29,30 @@ watch(store.currentDict, (n: Dict) => { async function selectDict(item: Dict) { currentSelectDict = { + type: DictType.inner, + sort: Sort.normal, ...item, wordList: [], chapterList: [], chapterIndex: 0, + chapterWordNumber: 15, wordIndex: 0, + dictStatistics: [] } let r = await fetch(`/public/${item.url}`) r.json().then(v => { currentSelectDict.wordList = v - currentSelectDict.chapterList = chunk(v, 15) + currentSelectDict.chapterList = chunk(v, currentSelectDict.chapterWordNumber) }) } + +function changeDict() { + store.changeDict(currentSelectDict) +} + +function resetChapterList() { + currentSelectDict.chapterList = chunk(currentSelectDict.wordList, currentSelectDict.chapterWordNumber) +}