From 99341a699f0dca38f80382568e1504899a39e4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BF=B5=E8=B6=85?= <王念超@163.com> Date: Thu, 6 Jun 2024 16:25:36 +0800 Subject: [PATCH] save --- package.json | 3 +- src/pages/pc/components/dialog/DictDiglog.vue | 144 +++--------------- src/pages/pc/word/StudyWord.vue | 3 +- src/pages/pc/word/WordHome.vue | 10 +- src/stores/base.ts | 10 +- src/utils/eventBus.ts | 2 +- src/utils/index.ts | 7 + 7 files changed, 46 insertions(+), 133 deletions(-) diff --git a/package.json b/package.json index c894383a..5f809cbe 100644 --- a/package.json +++ b/package.json @@ -71,5 +71,6 @@ "commitizen": { "path": "./node_modules/cz-conventional-changelog" } - } + }, + "packageManager": "pnpm@9.1.4+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0" } diff --git a/src/pages/pc/components/dialog/DictDiglog.vue b/src/pages/pc/components/dialog/DictDiglog.vue index 3409557a..bb51666d 100644 --- a/src/pages/pc/components/dialog/DictDiglog.vue +++ b/src/pages/pc/components/dialog/DictDiglog.vue @@ -1,61 +1,43 @@ diff --git a/src/pages/pc/word/StudyWord.vue b/src/pages/pc/word/StudyWord.vue index 2ec8f825..0e8a57ab 100644 --- a/src/pages/pc/word/StudyWord.vue +++ b/src/pages/pc/word/StudyWord.vue @@ -96,7 +96,8 @@ useEvent(ShortcutKey.TogglePanel, togglePanel) let data = $ref({ new: [], - review: [] + review: [], + write: [] }) function getCurrentPractice() { diff --git a/src/pages/pc/word/WordHome.vue b/src/pages/pc/word/WordHome.vue index e447e880..396a7ca1 100644 --- a/src/pages/pc/word/WordHome.vue +++ b/src/pages/pc/word/WordHome.vue @@ -6,7 +6,7 @@ import "vue-activity-calendar/style.css"; import {useRouter} from "vue-router"; import BaseIcon from "@/components/BaseIcon.vue"; import Dialog from "@/pages/pc/components/dialog/Dialog.vue"; -import {_getAccomplishDate, _getAccomplishDays, useNav} from "@/utils"; +import {_getAccomplishDate, _getAccomplishDays, _getStudyProgress, useNav} from "@/utils"; import BasePage from "@/pages/pc/components/BasePage.vue"; import {getDefaultDict} from "@/types.ts"; import {onMounted, watch} from "vue"; @@ -90,12 +90,12 @@ function changePerDayStudyNumber() {
- 已学习{{ store.currentStudyWordProgress }}% - {{ store.currentStudyWordDict.lastLearnIndex }} / {{ - store.currentStudyWordDict.words.length + 已学习{{ store.currentStudyProgress }}% + {{ store.sdict.lastLearnIndex }} / {{ + store.sdict.words.length }}
- +
diff --git a/src/stores/base.ts b/src/stores/base.ts index daa2f3e0..46e28743 100644 --- a/src/stores/base.ts +++ b/src/stores/base.ts @@ -5,7 +5,7 @@ import {emitter, EventKey} from "@/utils/eventBus.ts" import * as localforage from "localforage"; import {nanoid} from "nanoid"; import {SAVE_DICT_KEY} from "@/utils/const.ts"; -import {_checkDictWords, checkAndUpgradeSaveDict, getDictFile} from "@/utils"; +import {_checkDictWords, _getStudyProgress, checkAndUpgradeSaveDict, getDictFile} from "@/utils"; export interface BaseState { myDictList: Dict[], @@ -291,12 +291,12 @@ export const useBaseStore = defineStore('base', { sword() { return this.currentStudy.word }, - currentStudyWordProgress(): number { - if (!this.currentStudyWordDict.words?.length) return 0 - return Number(((this.currentStudyWordDict.lastLearnIndex / this.currentStudyWordDict.words?.length) * 100).toFixed()) + currentStudyProgress(): number { + if (!this.sdict.words?.length) return 0 + return _getStudyProgress(this.sdict.lastLearnIndex, this.sdict.words?.length) }, otherWordDictList(): Dict[] { - return this.wordDictList.filter(v => this.currentStudyWordDict.id !== v.id) + return this.wordDictList.filter(v => this.sdict.id !== v.id) }, currentArticleDict(): Dict { return this.articleDictList[this.currentStudy.article.dictIndex] ?? {} diff --git a/src/utils/eventBus.ts b/src/utils/eventBus.ts index 850b3a8f..533e1315 100644 --- a/src/utils/eventBus.ts +++ b/src/utils/eventBus.ts @@ -22,7 +22,7 @@ export const EventKey = { jumpSpecifiedChapter: 'jumpSpecifiedChapter', } -export function useEvent(key: string, func: () => void) { +export function useEvent(key: string, func: any) { onMounted(() => { emitter.on(key, func) }) diff --git a/src/utils/index.ts b/src/utils/index.ts index c21c53b5..e9b3d5df 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -227,11 +227,18 @@ export async function _checkDictWords(dict: Dict) { } } +//获取完成天数 export function _getAccomplishDays(total: number, dayNumber: number) { return Math.ceil(total / dayNumber) } +//获取完成日期 export function _getAccomplishDate(total: number, dayNumber: number) { let d = _getAccomplishDays(total, dayNumber) return dayjs().add(d, 'day').format('YYYY-MM-DD') +} + +//获取学习进度 +export function _getStudyProgress(index: number, total: number) { + return Number(((index / total) * 100).toFixed()) } \ No newline at end of file