From ecfbe4e061d1ddc9b44d993370f4e63e604bc2e2 Mon Sep 17 00:00:00 2001 From: zyronon Date: Mon, 30 Oct 2023 10:35:00 +0800 Subject: [PATCH] bf --- components.d.ts | 2 + src/components/Article/ArticleList.vue | 220 ++++++++++++++++++ .../Practice/PracticeArticle/ArticlePanel.vue | 89 ++----- .../PracticeArticle/PracticeArticle.vue | 49 +++- 4 files changed, 283 insertions(+), 77 deletions(-) create mode 100644 src/components/Article/ArticleList.vue diff --git a/components.d.ts b/components.d.ts index 64f01a5e..696bf8b4 100644 --- a/components.d.ts +++ b/components.d.ts @@ -9,6 +9,8 @@ declare module 'vue' { export interface GlobalComponents { Add: typeof import('./src/components/Toolbar/Add.vue')['default'] AddDict: typeof import('./src/components/Add/AddDict.vue')['default'] + ArticleItem: typeof import('./src/components/Article/ArticleItem.vue')['default'] + ArticleList: typeof import('./src/components/Article/ArticleList.vue')['default'] ArticlePanel: typeof import('./src/components/Practice/PracticeArticle/ArticlePanel.vue')['default'] Backgorund: typeof import('./src/components/Backgorund.vue')['default'] BaseButton: typeof import('./src/components/BaseButton.vue')['default'] diff --git a/src/components/Article/ArticleList.vue b/src/components/Article/ArticleList.vue new file mode 100644 index 00000000..0c64c724 --- /dev/null +++ b/src/components/Article/ArticleList.vue @@ -0,0 +1,220 @@ + + + + + \ No newline at end of file diff --git a/src/components/Practice/PracticeArticle/ArticlePanel.vue b/src/components/Practice/PracticeArticle/ArticlePanel.vue index 5b70bf5e..e26c5e80 100644 --- a/src/components/Practice/PracticeArticle/ArticlePanel.vue +++ b/src/components/Practice/PracticeArticle/ArticlePanel.vue @@ -10,13 +10,6 @@ import BaseButton from "@/components/BaseButton.vue"; import {useSettingStore} from "@/stores/setting.ts"; import Close from "@/components/Close.vue"; -const props = defineProps<{ - list?: Word[], - index: number -}>() -const emit = defineEmits<{ - 'update:index': [i: number] -}>() const store = useBaseStore() const settingStore = useSettingStore() let tabIndex = $ref(0) @@ -38,41 +31,8 @@ watch(() => settingStore.showPanel, n => { } }) -const currentDict: Dict = $computed(() => { - return store.myDicts[store.current.index] -}) - -const currentData = $computed(() => { - if (store.current.dictType !== currentDict.type) return { - list: currentDict.chapterWords[currentDict.chapterIndex] ?? [], - index: -1 - } - else return props -}) - -const newData = $computed(() => { - if (store.current.dictType !== DictType.collect) return {list: store.collect.words ?? [], index: -1} - else return props -}) - -const wrongData = $computed(() => { - if (store.current.dictType !== DictType.wrong) return {list: store.wrong.words ?? [], index: -1} - else return props -}) - -const skipData = $computed(() => { - if (store.current.dictType !== DictType.skip) return {list: store.skip.words ?? [], index: -1} - else return props -}) - function changeIndex(i: number, dict: Dict) { - dict.wordIndex = i - console.log('i', i, dict.type) - if (store.current.dictType === dict.type) { - emit('update:index', i) - } else { - store.changeDict(dict, dict.chapterIndex, i) - } + store.changeDict(dict, dict.chapterIndex, i) } @@ -86,47 +46,30 @@ function changeIndex(i: number, dict: Dict) { v-if="!settingStore.showToolbar"/>
-
- {{ currentDict.name + ` 第${currentDict.chapterIndex + 1}章` }} -
+
当前
{{ store.collect.name }}
-
- {{ store.wrong.name }} -
+
{{ store.wrong.name }}
{{ store.skip.name }}
-
-
词数:{{ currentData.list.length }}
-
-
- -
-
- - 切换 - -
+
-
总词数:{{ newData.list.length }}
+
总词数:{{ store.collect.words.length }}
+ :list="store.collect.words" + :activeIndex="-1"/>
-