feat:删除未使用的定义的方法
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
@use 'element-plus/theme-chalk/dark/css-vars' as *;
|
||||
|
||||
:root {
|
||||
//修改element-ui的进度条底色
|
||||
--el-border-color-lighter: #d1d1d1 !important;
|
||||
|
||||
--color-background: #E6E8EB;
|
||||
//--color-main-bg: #E6E8EB;
|
||||
--color-main-bg: rgb(238, 240, 244);
|
||||
|
||||
@@ -87,25 +87,6 @@ export function useArticleOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
//同步到我的词典列表
|
||||
export function syncMyDictList(dict: Dict, isCustom = true) {
|
||||
const store = useBaseStore()
|
||||
//任意修改,都将其变为自定义词典
|
||||
dict.custom = isCustom
|
||||
if (isArticle(dict.type)) {
|
||||
dict.length = dict.articles.length
|
||||
} else {
|
||||
dict.length = dict.words.length
|
||||
}
|
||||
|
||||
let rIndex = store.myDictList.findIndex(v => v.id === dict.id)
|
||||
if (rIndex > -1) {
|
||||
store.myDictList[rIndex] = cloneDeep(dict)
|
||||
} else {
|
||||
store.myDictList.push(cloneDeep(dict))
|
||||
}
|
||||
}
|
||||
|
||||
export function getCurrentStudyWord() {
|
||||
// console.time()
|
||||
const store = useBaseStore()
|
||||
|
||||
@@ -3,7 +3,6 @@ import './assets/css/style.scss'
|
||||
import App from './App.vue'
|
||||
// import Mobile from './Mobile.vue'
|
||||
import {createPinia} from "pinia"
|
||||
// import ElementPlus from 'element-plus'
|
||||
import ZH from "@/locales/zh-CN.ts";
|
||||
import {createI18n} from 'vue-i18n'
|
||||
import router from "@/router.ts";
|
||||
|
||||
@@ -17,21 +17,16 @@ const store = useBaseStore()
|
||||
let index = $ref(0)
|
||||
const router = useRouter()
|
||||
|
||||
|
||||
const onChange = ({selectedValues}) => {
|
||||
showToast(`当前值: ${selectedValues.join(',')}`);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
})
|
||||
|
||||
function handleDel(item: Dict, index: number) {
|
||||
if (item.id === store.currentDict.id) {
|
||||
if (item.id === store.sdict.id) {
|
||||
//TODO
|
||||
} else {
|
||||
showConfirmDialog({title: '确认删除?', message: '删除后无法撤销,确认删除吗?',})
|
||||
.then(() => {
|
||||
store.myDictList.splice(index, 1)
|
||||
store.word.bookList.splice(index, 1)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -53,10 +48,10 @@ function handleDel(item: Dict, index: number) {
|
||||
<SlideItem>
|
||||
<div class="my-dcits">
|
||||
<div class="list">
|
||||
<div class="dict" v-for="(item,index) in store.myDictList">
|
||||
<div class="dict" v-for="(item,index) in store.word.bookList">
|
||||
<div class="title">
|
||||
<div class="name">{{ item.name }}</div>
|
||||
<span v-if="item.id === store.currentDict.id">当前在学</span>
|
||||
<span v-if="item.id === store.sdict.id">当前在学</span>
|
||||
<template v-else>
|
||||
<DeleteIcon
|
||||
v-if="index>=3"
|
||||
@@ -175,4 +170,4 @@ header {
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -39,7 +39,7 @@ const groupByTranslateLanguage = $computed(() => {
|
||||
data = groupBy(articleList, 'translateLanguage')
|
||||
} else if (currentLanguage === 'my') {
|
||||
data = {
|
||||
common: store.myDictList.concat([{id: '',} as any])
|
||||
common: store.word.bookList.concat([{id: '',} as any])
|
||||
}
|
||||
} else {
|
||||
data = groupBy(groupByLanguage[currentLanguage], 'translateLanguage')
|
||||
@@ -134,7 +134,7 @@ function selectDict(val: { dict: DictResource | Dict, index: number }) {
|
||||
</div>
|
||||
<DictGroup
|
||||
v-for="item in articleData.dictList"
|
||||
:select-id="store.currentDict.id"
|
||||
:select-id="store.sdict.id"
|
||||
:groupByTag="item[1]"
|
||||
:category="item[0]"
|
||||
/>
|
||||
@@ -153,7 +153,7 @@ function selectDict(val: { dict: DictResource | Dict, index: number }) {
|
||||
<DictGroup
|
||||
@select-dict="selectDict"
|
||||
v-for="item in wordData.dictList"
|
||||
:select-id="store.currentDict.id"
|
||||
:select-id="store.sdict.id"
|
||||
:groupByTag="item[1]"
|
||||
:category="item[0]"
|
||||
/>
|
||||
@@ -183,4 +183,4 @@ function selectDict(val: { dict: DictResource | Dict, index: number }) {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -27,7 +27,7 @@ function goPractice() {
|
||||
<div class="current-dict">
|
||||
<div class="top">
|
||||
<div class="left" @click="router.push('/mobile/dict-detail')">
|
||||
<div class="name">{{ store.currentDict.name }}</div>
|
||||
<div class="name">{{ store.sdict.name }}</div>
|
||||
<Icon class="arrow" icon="mingcute:right-line" width="20"/>
|
||||
</div>
|
||||
<span>词表</span>
|
||||
@@ -97,4 +97,4 @@ function goPractice() {
|
||||
margin: 20rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -22,7 +22,7 @@ let load = $ref(false)
|
||||
onMounted(() => {
|
||||
// console.log('route', route.query.id)
|
||||
let item = dictionaryResources.find(v => v.id === route.query.id)
|
||||
let find: Dict = store.myDictList.find((v: Dict) => v.id === item.id)
|
||||
let find: Dict = store.word.bookList.find((v: Dict) => v.id === item.id)
|
||||
if (find) {
|
||||
runtimeStore.editDict = cloneDeep(find)
|
||||
} else {
|
||||
@@ -31,8 +31,6 @@ onMounted(() => {
|
||||
...item,
|
||||
})
|
||||
runtimeStore.editDict.id = nanoid(6)
|
||||
//设置默认章节单词数
|
||||
runtimeStore.editDict.chapterWordNumber = settingStore.chapterWordNumber
|
||||
}
|
||||
load = true
|
||||
})
|
||||
@@ -47,4 +45,4 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -19,14 +19,14 @@ const settingStore = useSettingStore()
|
||||
let practiceType = $ref(DictType.word)
|
||||
|
||||
const showCollectToggleButton = $computed(() => {
|
||||
if (store.currentDict.type === DictType.collect) {
|
||||
if (store.current.practiceType !== practiceType) {
|
||||
return (practiceType === DictType.word && store.collect.words.length) ||
|
||||
(practiceType === DictType.article && store.collect.articles.length)
|
||||
}
|
||||
if (store.sdict.type === DictType.collect) {
|
||||
// if (store.current.practiceType !== practiceType) {
|
||||
// return (practiceType === DictType.word && store.collectWord.words.length) ||
|
||||
// (practiceType === DictType.article && store.collectWord.articles.length)
|
||||
// }
|
||||
} else {
|
||||
return (practiceType === DictType.word && store.collect.words.length) ||
|
||||
(practiceType === DictType.article && store.collect.articles.length)
|
||||
return (practiceType === DictType.word && store.collectWord.words.length) ||
|
||||
(practiceType === DictType.article && store.collectWord.articles.length)
|
||||
}
|
||||
return false
|
||||
})
|
||||
@@ -52,7 +52,7 @@ const {
|
||||
<div class="panel-page-item">
|
||||
<div class="list-header">
|
||||
<div class="left">
|
||||
<div class="dict-name">总词数:{{ store.collect.words.length }}</div>
|
||||
<div class="dict-name">总词数:{{ store.collectWord.words.length }}</div>
|
||||
<BaseIcon icon="fluent:add-12-regular" title="添加" @click="addCollect"/>
|
||||
</div>
|
||||
<template v-if="showCollectToggleButton">
|
||||
@@ -65,9 +65,9 @@ const {
|
||||
</template>
|
||||
</div>
|
||||
<WordList
|
||||
v-if="store.collect.words.length"
|
||||
v-if="store.collectWord.words.length"
|
||||
class="word-list"
|
||||
:list="store.collect.words">
|
||||
:list="store.collectWord.words">
|
||||
<template v-slot:suffix="{item,index}">
|
||||
<BaseIcon
|
||||
class="del"
|
||||
@@ -81,4 +81,4 @@ const {
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -32,9 +32,9 @@ useEvent(EventKey.changeDict, () => {
|
||||
<header>
|
||||
<div class="tabs">
|
||||
<div class="tab" :class="tabIndex === 0 && 'active'" @click="tabIndex = 0">当前</div>
|
||||
<div class="tab" :class="tabIndex === 1 && 'active'" @click="tabIndex = 1">{{ store.collect.name }}</div>
|
||||
<div class="tab" :class="tabIndex === 1 && 'active'" @click="tabIndex = 1">{{ store.collectWord.name }}</div>
|
||||
<div class="tab" :class="tabIndex === 2 && 'active'" @click="tabIndex = 2">{{ store.wrong.name }}</div>
|
||||
<div class="tab" :class="tabIndex === 3 && 'active'" @click="tabIndex = 3">{{ store.simple.name }}</div>
|
||||
<div class="tab" :class="tabIndex === 3 && 'active'" @click="tabIndex = 3">{{ store.known.name }}</div>
|
||||
</div>
|
||||
</header>
|
||||
<SlideHorizontal v-model:index="tabIndex">
|
||||
|
||||
@@ -38,22 +38,22 @@ function addSimple() {
|
||||
<div class="panel-page-item">
|
||||
<div class="list-header">
|
||||
<div class="left">
|
||||
<div class="dict-name">总词数:{{ store.simple.words.length }}</div>
|
||||
<div class="dict-name">总词数:{{ store.known.words.length }}</div>
|
||||
<BaseIcon icon="fluent:add-12-regular" title="添加" @click="addSimple"/>
|
||||
</div>
|
||||
<template v-if="store.currentDict.type !== DictType.simple && store.simple.words.length">
|
||||
<template v-if="store.sdict.type !== DictType.known && store.known.words.length">
|
||||
<PopConfirm
|
||||
:title="`确认切换?`"
|
||||
@confirm="changeIndex( store.simple)"
|
||||
@confirm="changeIndex( store.known)"
|
||||
>
|
||||
<BaseButton size="small">切换</BaseButton>
|
||||
</PopConfirm>
|
||||
</template>
|
||||
</div>
|
||||
<WordList
|
||||
v-if="store.simple.words.length"
|
||||
v-if="store.known.words.length"
|
||||
class="word-list"
|
||||
:list="store.simple.words">
|
||||
:list="store.known.words">
|
||||
<template v-slot:suffix="{item,index}">
|
||||
<BaseIcon
|
||||
class="del"
|
||||
@@ -68,4 +68,4 @@ function addSimple() {
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -29,7 +29,7 @@ const {
|
||||
<div class="list-header">
|
||||
<div class="dict-name">总词数:{{ store.wrong.words.length }}</div>
|
||||
<template
|
||||
v-if="store.currentDict.type !== DictType.wrong && store.wrong.words.length">
|
||||
v-if="store.sdict.type !== DictType.wrong && store.wrong.words.length">
|
||||
<PopConfirm
|
||||
:title="`确认切换?`"
|
||||
@confirm="changeIndex( store.wrong)"
|
||||
@@ -56,4 +56,4 @@ const {
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -39,10 +39,10 @@ function repeat() {
|
||||
|
||||
function prev() {
|
||||
// console.log('next')
|
||||
if (store.currentDict.chapterIndex === 0) {
|
||||
if (store.sdict.chapterIndex === 0) {
|
||||
ElMessage.warning('已经在第一章了~')
|
||||
} else {
|
||||
store.currentDict.chapterIndex--
|
||||
store.sdict.chapterIndex--
|
||||
repeat()
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ function togglePanel() {
|
||||
}
|
||||
|
||||
function jumpSpecifiedChapter(val: number) {
|
||||
store.currentDict.chapterIndex = val
|
||||
store.sdict.chapterIndex = val
|
||||
repeat()
|
||||
}
|
||||
|
||||
|
||||
@@ -124,8 +124,8 @@ function next(isTyping: boolean = true) {
|
||||
data.index++
|
||||
isTyping && statisticsStore.inputWordNumber++
|
||||
console.log('这个词完了')
|
||||
if ([DictType.word].includes(store.currentDict.type)
|
||||
&& store.skipWordNames.includes(word.word.toLowerCase())) {
|
||||
if ([DictType.word].includes(store.sdict.type)
|
||||
&& store.knownWords.includes(word.word.toLowerCase())) {
|
||||
next()
|
||||
}
|
||||
}
|
||||
@@ -342,7 +342,7 @@ onMounted(() => {
|
||||
</div>
|
||||
<BaseIcon icon="bi:arrow-right"
|
||||
@click="next"
|
||||
v-if="store.currentDict.chapterIndex < store.currentDict.chapterWords.length - 1"/>
|
||||
v-if="store.sdict.chapterIndex < store.sdict.chapterWords.length - 1"/>
|
||||
</div>
|
||||
<div class="right">
|
||||
{{ data.words.length }}个单词
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
import TypingWord from "@/pages/mobile/practice/practice-word/TypingWord.vue";
|
||||
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {onMounted, onUnmounted} from "vue";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {onMounted} from "vue";
|
||||
import {ShortcutKey, Word} from "@/types.ts";
|
||||
import {emitter, EventKey, useEvent, useEvents} from "@/utils/eventBus.ts";
|
||||
import {useSettingStore} from "@/stores/setting.ts";
|
||||
import {syncMyDictList} from "@/hooks/dict.ts";
|
||||
import {EventKey, useEvents} from "@/utils/eventBus.ts";
|
||||
|
||||
const store = useBaseStore()
|
||||
|
||||
@@ -24,7 +19,7 @@ function getCurrentPractice() {
|
||||
|
||||
function sort(list: Word[]) {
|
||||
wordData.index = 0
|
||||
syncMyDictList(store.currentDict)
|
||||
// syncMyDictList(store.currentDict)
|
||||
}
|
||||
|
||||
function next() {
|
||||
|
||||
@@ -11,10 +11,10 @@ import {useDisableEventListener, useWindowClick} from "@/hooks/event.ts";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
import {syncMyDictList} from "@/hooks/dict.ts";
|
||||
import MiniDialog from "@/pages/pc/components/dialog/MiniDialog.vue";
|
||||
import EditArticle2 from "@/pages/pc/article/components/EditArticle2.vue";
|
||||
import BaseIcon from "@/components/BaseIcon.vue";
|
||||
import {_nextTick} from "@/utils";
|
||||
|
||||
const emit = defineEmits<{
|
||||
importData: [val: Event]
|
||||
@@ -123,10 +123,28 @@ function saveArticle(val: Article): boolean {
|
||||
article = cloneDeep(val)
|
||||
//TODO 保存完成后滚动到对应位置
|
||||
ElMessage.success('保存成功!')
|
||||
syncMyDictList(runtimeStore.editDict)
|
||||
syncBookInMyStudyList()
|
||||
return true
|
||||
}
|
||||
|
||||
//todo 考虑与syncDictInMyStudyList、changeDict方法合并
|
||||
function syncBookInMyStudyList(study = false) {
|
||||
_nextTick(() => {
|
||||
let rIndex = base.article.bookList.findIndex(v => v.id === runtimeStore.editDict.id)
|
||||
let temp = cloneDeep(runtimeStore.editDict);
|
||||
console.log(temp)
|
||||
temp.custom = true
|
||||
temp.length = temp.articles.length
|
||||
if (rIndex > -1) {
|
||||
base.article.bookList[rIndex] = temp
|
||||
if (study) base.article.studyIndex = rIndex
|
||||
} else {
|
||||
base.article.bookList.push(temp)
|
||||
if (study) base.article.studyIndex = base.article.bookList.length - 1
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
function saveAndNext(val: Article) {
|
||||
if (saveArticle(val)) {
|
||||
add()
|
||||
|
||||
@@ -34,10 +34,10 @@ function repeat() {
|
||||
|
||||
function prev() {
|
||||
// console.log('next')
|
||||
if (store.currentDict.chapterIndex === 0) {
|
||||
if (store.currentBook.chapterIndex === 0) {
|
||||
ElMessage.warning('已经在第一章了~')
|
||||
} else {
|
||||
store.currentDict.chapterIndex--
|
||||
store.currentBook.chapterIndex--
|
||||
repeat()
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ function togglePanel() {
|
||||
}
|
||||
|
||||
function jumpSpecifiedChapter(val: number) {
|
||||
store.currentDict.chapterIndex = val
|
||||
store.currentBook.chapterIndex = val
|
||||
repeat()
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import {useDisableEventListener, useWindowClick} from "@/hooks/event.ts";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {nanoid} from "nanoid";
|
||||
import {syncMyDictList} from "@/hooks/dict.ts";
|
||||
import MiniDialog from "@/pages/pc/components/dialog/MiniDialog.vue";
|
||||
import EditArticle2 from "@/pages/pc/article/components/EditArticle2.vue";
|
||||
import {_nextTick} from "@/utils";
|
||||
|
||||
const emit = defineEmits<{
|
||||
importData: [val: Event]
|
||||
@@ -123,10 +123,28 @@ function saveArticle(val: Article): boolean {
|
||||
article = cloneDeep(val)
|
||||
//TODO 保存完成后滚动到对应位置
|
||||
ElMessage.success('保存成功!')
|
||||
syncMyDictList(runtimeStore.editDict)
|
||||
syncBookInMyStudyList()
|
||||
return true
|
||||
}
|
||||
|
||||
//todo 考虑与syncDictInMyStudyList、changeDict方法合并
|
||||
function syncBookInMyStudyList(study = false) {
|
||||
_nextTick(() => {
|
||||
let rIndex = base.article.bookList.findIndex(v => v.id === runtimeStore.editDict.id)
|
||||
let temp = cloneDeep(runtimeStore.editDict);
|
||||
console.log(temp)
|
||||
temp.custom = true
|
||||
temp.length = temp.articles.length
|
||||
if (rIndex > -1) {
|
||||
base.article.bookList[rIndex] = temp
|
||||
if (study) base.article.studyIndex = rIndex
|
||||
} else {
|
||||
base.article.bookList.push(temp)
|
||||
if (study) base.article.studyIndex = base.article.bookList.length - 1
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
function saveAndNext(val: Article) {
|
||||
if (saveArticle(val)) {
|
||||
add()
|
||||
|
||||
@@ -7,7 +7,6 @@ import {FormInstance, FormRules} from "element-plus";
|
||||
import {onMounted, reactive} from "vue";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {useBaseStore} from "@/stores/base.ts";
|
||||
import {syncMyDictList} from "@/hooks/dict.ts";
|
||||
|
||||
const props = defineProps<{
|
||||
isAdd: boolean,
|
||||
|
||||
@@ -161,7 +161,7 @@ function nextSentence() {
|
||||
input = wrong = ''
|
||||
|
||||
//todo 计得把略过的单词加上统计里面去
|
||||
// if (!store.skipWordNamesWithSimpleWords.includes(currentWord.word.toLowerCase()) && !currentWord.isSymbol) {
|
||||
// if (!store.knownWordsWithSimpleWords.includes(currentWord.word.toLowerCase()) && !currentWord.isSymbol) {
|
||||
// statisticsStore.inputNumber++
|
||||
// }
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ function setArticle(val: Article) {
|
||||
articleData.article.sections.map((v, i) => {
|
||||
v.map((w, j) => {
|
||||
w.words.map(s => {
|
||||
if (!store.skipWordNamesWithSimpleWords.includes(s.word.toLowerCase()) && !s.isSymbol) {
|
||||
if (!store.knownWordsWithSimpleWords.includes(s.word.toLowerCase()) && !s.isSymbol) {
|
||||
statisticsStore.total++
|
||||
}
|
||||
})
|
||||
@@ -128,7 +128,7 @@ function wrong(word: Word) {
|
||||
if (!store.wrong.originWords.find((v: Word) => v.word.toLowerCase() === lowerName)) {
|
||||
store.wrong.originWords.push(word)
|
||||
}
|
||||
if (!store.skipWordNamesWithSimpleWords.includes(lowerName)) {
|
||||
if (!store.knownWordsWithSimpleWords.includes(lowerName)) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ function over() {
|
||||
}
|
||||
|
||||
function nextWord(word: ArticleWord) {
|
||||
if (!store.skipWordNamesWithSimpleWords.includes(word.word.toLowerCase()) && !word.isSymbol) {
|
||||
if (!store.knownWordsWithSimpleWords.includes(word.word.toLowerCase()) && !word.isSymbol) {
|
||||
statisticsStore.inputWordNumber++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {Dict} from "@/types.ts";
|
||||
import {Icon} from "@iconify/vue";
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
item?: Dict
|
||||
quantifier?: string
|
||||
isAdd: boolean
|
||||
@@ -14,17 +14,25 @@ defineEmits<{
|
||||
check: []
|
||||
}>()
|
||||
|
||||
const progress = $computed(() => {
|
||||
return Number(((props.item?.lastLearnIndex / props.item?.length) * 100).toFixed())
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="book">
|
||||
<div class="book relative">
|
||||
<template v-if="!isAdd">
|
||||
<div>
|
||||
<div>{{ item?.name }}</div>
|
||||
<div class="text-sm line-clamp-3" v-opacity="item.name !== item.description">{{ item?.description }}</div>
|
||||
</div>
|
||||
<div class="absolute bottom-4 right-4">
|
||||
{{ item?.lastLearnIndex ? item?.lastLearnIndex + '/' : '' }}{{ item?.length }}{{ quantifier }}
|
||||
<div>{{ item?.lastLearnIndex ? item?.lastLearnIndex + '/' : '' }}{{ item?.length }}{{ quantifier }}</div>
|
||||
</div>
|
||||
<div class="absolute bottom-2 left-4 right-4">
|
||||
<el-progress v-if="item?.lastLearnIndex" class="mt-1"
|
||||
:percentage="progress"
|
||||
:show-text="false"></el-progress>
|
||||
</div>
|
||||
<el-checkbox v-if="showCheckbox"
|
||||
:model-value="checked"
|
||||
|
||||
@@ -8,20 +8,8 @@ import {SAVE_DICT_KEY} from "@/utils/const.ts";
|
||||
import {_checkDictWords, _getDictDataByUrl, _getStudyProgress, checkAndUpgradeSaveDict, getDictFile} from "@/utils";
|
||||
|
||||
export interface BaseState {
|
||||
myDictList: Dict[],
|
||||
current: {
|
||||
index: number,
|
||||
practiceType: DictType,//练习类型,目前仅词典为collect时判断是练单词还是文章使用
|
||||
},
|
||||
simpleWords: string[],
|
||||
load: boolean
|
||||
|
||||
wordDictList?: Dict[],
|
||||
currentStudy?: {
|
||||
word: {
|
||||
dictIndex: number,
|
||||
},
|
||||
},
|
||||
word: {
|
||||
studyIndex: number,
|
||||
bookList: Dict[],
|
||||
@@ -33,23 +21,13 @@ export interface BaseState {
|
||||
}
|
||||
|
||||
export const DefaultBaseState = (): BaseState => ({
|
||||
wordDictList: [],
|
||||
currentStudy: {
|
||||
word: {
|
||||
dictIndex: 0,
|
||||
},
|
||||
},
|
||||
myDictList: [],
|
||||
current: {
|
||||
index: 4,
|
||||
practiceType: DictType.article,
|
||||
},
|
||||
simpleWords: [
|
||||
'a', 'an',
|
||||
'i', 'my', 'you', 'your', 'me', 'it',
|
||||
'i', 'my', 'me', 'you', 'your', 'he', 'his', 'she', 'her', 'it',
|
||||
'what', 'who', 'where', 'how', 'when', 'which',
|
||||
'be', 'am', 'is', 'do', 'are', 'did', 'were', 'was', 'can', 'could', 'will', 'would',
|
||||
'the', 'that', 'this', 'to', 'of', 'for', 'and', 'at', 'not', 'no', 'yes',
|
||||
'be', 'am', 'is', 'was', 'are', 'were', 'do', 'did', 'can', 'could', 'will', 'would',
|
||||
'the', 'that', 'this', 'and', 'not', 'no', 'yes',
|
||||
'to', 'of', 'for', 'at', 'in'
|
||||
],
|
||||
load: false,
|
||||
word: {
|
||||
@@ -87,18 +65,12 @@ export const useBaseStore = defineStore('base', {
|
||||
return DefaultBaseState()
|
||||
},
|
||||
getters: {
|
||||
collect(): Dict {
|
||||
return this.word.bookList[0]
|
||||
},
|
||||
collectWord(): Dict {
|
||||
return this.word.bookList[0]
|
||||
},
|
||||
collectArticle(): Dict {
|
||||
return this.article.bookList[0]
|
||||
},
|
||||
simple(): Dict {
|
||||
return this.word.bookList[2]
|
||||
},
|
||||
wrong(): Dict {
|
||||
return this.word.bookList[1]
|
||||
},
|
||||
@@ -106,25 +78,10 @@ export const useBaseStore = defineStore('base', {
|
||||
return this.word.bookList[2]
|
||||
},
|
||||
knownWords(): string[] {
|
||||
return this.known.words.map(v => v.word)
|
||||
return this.known.words.map((v: Word) => v.word)
|
||||
},
|
||||
skipWordNames() {
|
||||
return this.simple.words.map(v => v.word.toLowerCase())
|
||||
},
|
||||
skipWordNamesWithSimpleWords() {
|
||||
return this.simple.words.map(v => v.word.toLowerCase()).concat(this.simpleWords)
|
||||
},
|
||||
isArticle(state: BaseState): boolean {
|
||||
//如果是收藏时,特殊判断
|
||||
if (this.currentDict.type === DictType.collect) {
|
||||
return state.current.practiceType === DictType.article
|
||||
}
|
||||
return [
|
||||
DictType.article,
|
||||
].includes(this.currentDict.type)
|
||||
},
|
||||
currentDict(): Dict {
|
||||
return this.myDictList[this.current.index] ?? {}
|
||||
knownWordsWithSimpleWords() {
|
||||
return this.known.words.map((v: Word) => v.word).concat(this.simpleWords)
|
||||
},
|
||||
currentStudyWordDict(): Dict {
|
||||
if (this.word.studyIndex >= 0) {
|
||||
@@ -139,9 +96,6 @@ export const useBaseStore = defineStore('base', {
|
||||
if (!this.sdict.words?.length) return 0
|
||||
return _getStudyProgress(this.sdict.lastLearnIndex, this.sdict.words?.length)
|
||||
},
|
||||
currentArticleCollectDict(): Dict {
|
||||
return this.article.bookList[0]
|
||||
},
|
||||
currentBook(): Dict {
|
||||
return this.article.bookList[this.article.studyIndex] ?? {}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user