From dc120ff37540ed3087f2fc598a94a10914a0fb51 Mon Sep 17 00:00:00 2001 From: zyronon Date: Wed, 30 Jul 2025 01:47:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=8B=86=E5=88=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 2 +- src/App.vue | 2 - src/assets/css/style.scss | 10 +- src/pages/pc/Setting.vue | 646 ++++++++++++++++++ src/pages/pc/article/BookDetail.vue | 2 +- src/{ => pages/pc}/components/BackIcon.vue | 0 src/pages/pc/components/BasePage.vue | 7 +- src/pages/pc/components/CollectNotice.vue | 4 +- src/pages/pc/components/DictListPanel.vue | 96 --- .../pc/components/dialog/SettingDialog.vue | 154 ----- src/pages/pc/index.vue | 2 +- src/pages/pc/word/DictDetail.vue | 20 +- src/pages/pc/word/DictList.vue | 114 ++++ src/pages/pc/word/WordHomePage.vue | 35 +- src/router.ts | 4 + src/stores/base.ts | 12 +- src/types.ts | 30 +- 17 files changed, 827 insertions(+), 313 deletions(-) create mode 100644 src/pages/pc/Setting.vue rename src/{ => pages/pc}/components/BackIcon.vue (100%) delete mode 100644 src/pages/pc/components/DictListPanel.vue delete mode 100644 src/pages/pc/components/dialog/SettingDialog.vue create mode 100644 src/pages/pc/word/DictList.vue diff --git a/components.d.ts b/components.d.ts index aa90b1f7..ba81faec 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,7 +7,7 @@ export {} declare module 'vue' { export interface GlobalComponents { - BackIcon: typeof import('./src/components/BackIcon.vue')['default'] + BackIcon: typeof import('./src/components/icon/BackIcon.vue')['default'] BaseButton: typeof import('./src/components/BaseButton.vue')['default'] BaseIcon: typeof import('./src/components/BaseIcon.vue')['default'] Close: typeof import('./src/components/icon/Close.vue')['default'] diff --git a/src/App.vue b/src/App.vue index 36cc53ef..8c2af1fd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,7 +5,6 @@ import {useRuntimeStore} from "@/stores/runtime.ts"; import {useSettingStore} from "@/stores/setting.ts"; import useTheme from "@/hooks/theme.ts"; import * as localforage from "localforage"; -import SettingDialog from "@/pages/pc/components/dialog/SettingDialog.vue"; import CollectNotice from "@/pages/pc/components/CollectNotice.vue"; import {SAVE_DICT_KEY, SAVE_SETTING_KEY} from "@/utils/const.ts"; import {isMobile, shakeCommonDict} from "@/utils"; @@ -76,7 +75,6 @@ watch(() => route.path, (to, from) => { - diff --git a/src/pages/pc/article/BookDetail.vue b/src/pages/pc/article/BookDetail.vue index bea1e262..4747eb53 100644 --- a/src/pages/pc/article/BookDetail.vue +++ b/src/pages/pc/article/BookDetail.vue @@ -1,7 +1,7 @@ - - - - diff --git a/src/pages/pc/components/dialog/SettingDialog.vue b/src/pages/pc/components/dialog/SettingDialog.vue deleted file mode 100644 index 6dbe0446..00000000 --- a/src/pages/pc/components/dialog/SettingDialog.vue +++ /dev/null @@ -1,154 +0,0 @@ - - - - - diff --git a/src/pages/pc/index.vue b/src/pages/pc/index.vue index 1544abb6..c5a5f6d3 100644 --- a/src/pages/pc/index.vue +++ b/src/pages/pc/index.vue @@ -42,7 +42,7 @@ const {toggleTheme} = useTheme()
设置 diff --git a/src/pages/pc/word/DictDetail.vue b/src/pages/pc/word/DictDetail.vue index 2182a52b..6a94dd6c 100644 --- a/src/pages/pc/word/DictDetail.vue +++ b/src/pages/pc/word/DictDetail.vue @@ -1,5 +1,5 @@ + + + + diff --git a/src/pages/pc/word/WordHomePage.vue b/src/pages/pc/word/WordHomePage.vue index a8553de5..85f8c3b8 100644 --- a/src/pages/pc/word/WordHomePage.vue +++ b/src/pages/pc/word/WordHomePage.vue @@ -6,12 +6,11 @@ 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, _getDictDataByUrl, useNav, _dateFormat} from "@/utils"; +import {_dateFormat, _getAccomplishDate, _getAccomplishDays, _getDictDataByUrl, useNav} from "@/utils"; import BasePage from "@/pages/pc/components/BasePage.vue"; import {DictResource, getDefaultDict} from "@/types.ts"; import {onMounted, watch} from "vue"; import {getCurrentStudyWord} from "@/hooks/dict.ts"; -import DictListPanel from "@/pages/pc/components/DictListPanel.vue"; import {useRuntimeStore} from "@/stores/runtime.ts"; import Book from "@/pages/pc/components/Book.vue"; import PopConfirm from "@/pages/pc/components/PopConfirm.vue"; @@ -28,13 +27,8 @@ let currentStudy = $ref({ write: [] }) -onMounted(() => { - init() -}) - -watch(() => store.load, () => { - init() -}) +onMounted(init) +watch(() => store.load, init) async function init() { if (store.word.studyIndex >= 3) { @@ -46,7 +40,6 @@ async function init() { if (!currentStudy.new.length && store.sdict.words.length) { currentStudy = getCurrentStudyWord() } - } function startStudy() { @@ -64,7 +57,6 @@ function startStudy() { nav('study-word', {}, currentStudy) } else { ElMessage.warning('请先选择一本词典') - dictListRef.startSearch() } } @@ -74,7 +66,6 @@ function setPerDayStudyNumber() { tempPerDayStudyNumber = store.sdict.perDayStudyNumber } else { ElMessage.warning('请先选择一本词典') - dictListRef.startSearch() } } @@ -86,17 +77,11 @@ function changePerDayStudyNumber() { currentStudy = getCurrentStudyWord() } -function selectDict(e) { - console.log(e.dict) - getDictDetail(e.dict) -} - -async function getDictDetail(val: DictResource) { +async function goDictDetail(val: DictResource) { runtimeStore.editDict = getDefaultDict(val) nav('dict-detail', {}) } -let dictListRef = $ref() let isMultiple = $ref(false) let selectIds = $ref([]) @@ -113,6 +98,7 @@ function handleBatchDel() { store.word.bookList.splice(r, 1) } }) + selectIds = [] ElMessage.success("删除成功!") } @@ -190,7 +176,7 @@ const progressTextRight = $computed(() => { {{ store.sdict.name || '请选择书籍开始学习' }} + @click="router.push('/dict-list')"/>
@@ -224,14 +210,14 @@ const progressTextRight = $computed(() => {
-
+
每日目标
{{ store.sdict.id ? store.sdict.perDayStudyNumber : 0 }}
- 个单词 + 个单词 更改
@@ -258,12 +244,11 @@ const progressTextRight = $computed(() => {
- + v-for="(item, j) in store.word.bookList" @click="goDictDetail(item)"/> +
-
diff --git a/src/router.ts b/src/router.ts index b2340200..f97b1c15 100644 --- a/src/router.ts +++ b/src/router.ts @@ -12,6 +12,8 @@ import StudyWord from "@/pages/pc/word/StudyWord.vue"; import EditArticlePage from "@/pages/pc/article/EditArticlePage.vue"; import BookDetail from "@/pages/pc/article/BookDetail.vue"; import BatchEditArticlePage from "@/pages/pc/article/BatchEditArticlePage.vue"; +import DictList from "@/pages/pc/word/DictList.vue"; +import Setting from "@/pages/pc/Setting.vue"; export const routes: RouteRecordRaw[] = [ { @@ -20,6 +22,7 @@ export const routes: RouteRecordRaw[] = [ children: [ {path: 'home', component: HomeIndex}, {path: 'word', component: WordHomePage}, + {path: 'dict-list', component: DictList}, {path: 'study-word', component: StudyWord}, {path: 'dict-detail', component: DictDetail}, {path: 'article', component: ArticleHomePage}, @@ -27,6 +30,7 @@ export const routes: RouteRecordRaw[] = [ {path: 'edit-article', component: EditArticlePage}, {path: 'batch-edit-article', component: BatchEditArticlePage}, {path: 'book-detail', component: BookDetail}, + {path: 'setting', component: Setting}, ] }, diff --git a/src/stores/base.ts b/src/stores/base.ts index 5e5eb95e..131f3979 100644 --- a/src/stores/base.ts +++ b/src/stores/base.ts @@ -1,5 +1,5 @@ import {defineStore} from 'pinia' -import {Article, Dict, DictType, getDefaultDict, Sort, Word} from "../types.ts" +import {Article, Dict, DictId, DictType, getDefaultDict, Sort, Word} from "../types.ts" import {cloneDeep, merge, reverse, shuffle} from "lodash-es"; import {emitter, EventKey} from "@/utils/eventBus.ts" import * as localforage from "localforage"; @@ -32,11 +32,9 @@ export const DefaultBaseState = (): BaseState => ({ load: false, word: { bookList: [ - getDefaultDict({ - id: 'word-collect', name: '收藏', words: [] - }), - getDefaultDict({id: 'word-wrong', name: '错词'}), - getDefaultDict({id: 'word-known', name: '已掌握'}), + getDefaultDict({id: DictId.wordCollect, name: '收藏', words: []}), + getDefaultDict({id: DictId.wordWrong, name: '错词'}), + getDefaultDict({id: DictId.wordKnown, name: '已掌握'}), // getDefaultDict({ // id: 'nce-new-2', // name: '新概念英语(新版)-2', @@ -54,7 +52,7 @@ export const DefaultBaseState = (): BaseState => ({ }, article: { bookList: [ - getDefaultDict({id: 'article-collect', name: '收藏'}) + getDefaultDict({id: DictId.articleCollect, name: '收藏'}) ], studyIndex: -1, } diff --git a/src/types.ts b/src/types.ts index 94f929b1..9dcd769e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -74,7 +74,6 @@ export enum DictType { simple = 'simple', wrong = 'wrong', known = 'known', - collectWord = 'collect-word', word = 'word', article = 'article', } @@ -240,10 +239,21 @@ export type DictResource = { category: string tags: string[] translateLanguage: TranslateLanguageType + //todo 可以考虑删除了 type: DictType language: LanguageType } +export interface Dict extends DictResource { + lastLearnIndex: number, + perDayStudyNumber: number, + words: Word[], + articles: Article[], + statistics: Statistics[], + custom: boolean,//是否是自定义词典 + complete: boolean,//是否学习完成,学完了设为true,然后lastLearnIndex重置 +} + export function getDefaultDict(val: Partial = {}): Dict { return { id: '', @@ -262,20 +272,11 @@ export function getDefaultDict(val: Partial = {}): Dict { articles: [], statistics: [], custom: false, + complete: false, ...val } } -export interface Dict extends DictResource { - lastLearnIndex: number, - perDayStudyNumber: number, - words: Word[], - articles: Article[], - statistics: Statistics[], - custom: boolean,//是否是自定义词典 - complete: boolean,//是否学习完成,学完了设为true,然后lastLearnIndex重置 -} - export interface ArticleItem { item: Article, index: number @@ -291,3 +292,10 @@ export interface StudyData { words: any[], wrongWords: any[], } + +export class DictId { + static wordCollect = 'wordCollect' + static wordWrong = 'wordWrong' + static wordKnown = 'wordKnown' + static articleCollect = 'articleCollect' +}