添加统计
This commit is contained in:
@@ -30,9 +30,14 @@ function next() {
|
||||
}
|
||||
|
||||
function repeatWrong() {
|
||||
store.lastDictType = store.currentDictType
|
||||
if (store.currentDictType !== DictType.currentWrongDict){
|
||||
store.lastDictType = store.currentDictType
|
||||
}
|
||||
store.currentDictType = DictType.currentWrongDict
|
||||
store.currentWrongDict.chapterList = [store.currentWrongDict.wordList]
|
||||
store.currentWrongDict.chapterIndex = 0
|
||||
store.currentWrongDict.wordIndex = 0
|
||||
store.currentWrongDict.wordList = []
|
||||
store.statModalIsOpen = false
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@ import WordList from "@/components/WordList.vue"
|
||||
import {ArrowLeft, ArrowRight, MenuFold} from '@icon-park/vue-next'
|
||||
|
||||
import {$ref} from "vue/macros"
|
||||
import {computed, provide} from "vue"
|
||||
import {computed, nextTick, onMounted, provide} from "vue"
|
||||
import {Swiper, SwiperSlide} from 'swiper/vue';
|
||||
import 'swiper/css';
|
||||
import {Swiper as SwiperClass} from "swiper/types"
|
||||
@@ -14,13 +14,19 @@ import BaseButton from "@/components/BaseButton.vue";
|
||||
|
||||
const store = useBaseStore()
|
||||
const swiperIns0: SwiperClass = $ref(null as any)
|
||||
let tabIndex = $ref(0)
|
||||
let tabIndex = $ref(1)
|
||||
provide('tabIndex', computed(() => tabIndex))
|
||||
|
||||
function slideTo(index: number) {
|
||||
swiperIns0.slideTo(tabIndex = index)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
slideTo(1)
|
||||
}, 300)
|
||||
})
|
||||
|
||||
function changeDict(dict: Dict, i: number) {
|
||||
if (store.currentDictType !== dict.type) {
|
||||
store.currentDictType = dict.type
|
||||
@@ -31,17 +37,41 @@ function changeDict(dict: Dict, i: number) {
|
||||
</script>
|
||||
<template>
|
||||
<Transition name="fade">
|
||||
<div class="side" v-if="store.sideIsOpen">
|
||||
<div class="side" v-if="store.sideIsOpen">
|
||||
<header>
|
||||
<div class="tabs">
|
||||
<div class="tab" :class="tabIndex===0&&'active'" @click="slideTo(0)">单词表</div>
|
||||
<div class="tab" :class="tabIndex===1&&'active'" @click="slideTo(1)">生词本</div>
|
||||
<div class="tab" :class="tabIndex===2&&'active'" @click="slideTo(2)">纠错本</div>
|
||||
<div class="tab" :class="tabIndex===3&&'active'" @click="slideTo(3)">已忽略</div>
|
||||
<div class="tab" v-if="store.isWrongMode" :class="tabIndex===0&&'active'" @click="slideTo(0)">错词模式</div>
|
||||
<div class="tab" :class="tabIndex===1&&'active'" @click="slideTo(1)">单词表</div>
|
||||
<div class="tab" :class="tabIndex===2&&'active'" @click="slideTo(2)">生词本</div>
|
||||
<div class="tab" :class="tabIndex===3&&'active'" @click="slideTo(3)">纠错本</div>
|
||||
<div class="tab" :class="tabIndex===4&&'active'" @click="slideTo(4)">已忽略</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="side-content">
|
||||
<swiper @swiper="e=>swiperIns0 = e" class="mySwiper" :allow-touch-move="false">
|
||||
<swiper-slide>
|
||||
<div class="page0">
|
||||
<header>
|
||||
<div class="dict-name">总词数:{{ store.currentDict.chapterList[0].length }}</div>
|
||||
</header>
|
||||
<WordList
|
||||
class="word-list"
|
||||
@change="(e:number) => store.changeDict(store.currentWrongDict,-1,e)"
|
||||
:isActive="store.sideIsOpen && tabIndex === 0"
|
||||
:list="store.currentDict.chapterList[0]??[]"
|
||||
:activeIndex="store.currentDict.wordIndex"/>
|
||||
<footer v-if="![DictType.custom,DictType.inner].includes(store.currentDictType)">
|
||||
<PopConfirm
|
||||
:title="`确认切换?`"
|
||||
@confirm="store.changeDict(store.dict)"
|
||||
>
|
||||
<div class="my-button">
|
||||
切换
|
||||
</div>
|
||||
</PopConfirm>
|
||||
</footer>
|
||||
</div>
|
||||
</swiper-slide>
|
||||
<swiper-slide>
|
||||
<div class="page0">
|
||||
<header>
|
||||
@@ -50,7 +80,7 @@ function changeDict(dict: Dict, i: number) {
|
||||
<WordList
|
||||
class="word-list"
|
||||
@change="(e:number) => store.changeDict(store.dict,-1,e)"
|
||||
:isActive="store.sideIsOpen && tabIndex === 0"
|
||||
:isActive="store.sideIsOpen && tabIndex === 1"
|
||||
:list="store.dict.chapterList[store.dict.chapterIndex]??[]"
|
||||
:activeIndex="store.dict.wordIndex"/>
|
||||
<footer v-if="![DictType.custom,DictType.inner].includes(store.currentDictType)">
|
||||
@@ -73,7 +103,7 @@ function changeDict(dict: Dict, i: number) {
|
||||
<WordList
|
||||
class="word-list"
|
||||
@change="(e:number) => store.changeDict(store.newWordDict,-1,e)"
|
||||
:isActive="store.sideIsOpen && tabIndex === 1"
|
||||
:isActive="store.sideIsOpen && tabIndex === 2"
|
||||
:list="store.newWordDict.wordList"
|
||||
:activeIndex="store.newWordDict.wordIndex"/>
|
||||
<footer v-if="store.currentDictType !== DictType.newWordDict && store.newWordDict.wordList.length">
|
||||
@@ -97,7 +127,7 @@ function changeDict(dict: Dict, i: number) {
|
||||
<WordList
|
||||
class="word-list"
|
||||
@change="(e:number) => store.changeDict(store.allWrongDict,-1,e)"
|
||||
:isActive="store.sideIsOpen && tabIndex === 2"
|
||||
:isActive="store.sideIsOpen && tabIndex === 3"
|
||||
:list="store.allWrongDict.wordList"
|
||||
:activeIndex="store.allWrongDict.wordIndex"/>
|
||||
<footer v-if="store.currentDictType !== DictType.allWrongDict && store.allWrongDict.wordList.length">
|
||||
@@ -120,7 +150,7 @@ function changeDict(dict: Dict, i: number) {
|
||||
<WordList
|
||||
class="word-list"
|
||||
@change="(e:number) => store.changeDict(store.skipWordDict,-1,e)"
|
||||
:isActive="store.sideIsOpen && tabIndex === 3"
|
||||
:isActive="store.sideIsOpen && tabIndex === 4"
|
||||
:list="store.skipWordDict.wordList"
|
||||
:activeIndex="store.skipWordDict.wordIndex"/>
|
||||
<footer v-if="store.currentDictType !== DictType.skipWordDict && store.skipWordDict.wordList.length">
|
||||
|
||||
@@ -78,6 +78,7 @@ function next() {
|
||||
store.statModalIsOpen = true
|
||||
} else {
|
||||
console.log('这本书完了')
|
||||
store.statModalIsOpen = true
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -126,6 +126,9 @@ export const useBaseStore = defineStore('base', {
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
isWrongMode(state: State) {
|
||||
return state.currentDictType === DictType.currentWrongDict
|
||||
},
|
||||
skipWordNames: (state: State) => {
|
||||
return state.skipWordDict.wordList.map(v => v.name)
|
||||
},
|
||||
@@ -137,6 +140,8 @@ export const useBaseStore = defineStore('base', {
|
||||
return state.skipWordDict
|
||||
case DictType.allWrongDict:
|
||||
return state.allWrongDict
|
||||
case DictType.currentWrongDict:
|
||||
return state.currentWrongDict
|
||||
case DictType.inner:
|
||||
case DictType.custom:
|
||||
return state.dict
|
||||
@@ -214,6 +219,8 @@ export const useBaseStore = defineStore('base', {
|
||||
this[dict.type].chapterList = [this[dict.type].wordList]
|
||||
this[dict.type].chapterIndex = 0
|
||||
this[dict.type].wordIndex = wordIndex === -1 ? 0 : wordIndex
|
||||
} else if (dict.type === DictType.currentWrongDict) {
|
||||
this[dict.type].wordIndex = wordIndex === -1 ? 0 : wordIndex
|
||||
} else {
|
||||
this.dict = cloneDeep(dict)
|
||||
this.currentDictType = dict.type
|
||||
|
||||
Reference in New Issue
Block a user