diff --git a/apps/nuxt/app/pages/(articles)/articles.vue b/apps/nuxt/app/pages/(articles)/articles.vue index e4d3d889..03a8d7b6 100644 --- a/apps/nuxt/app/pages/(articles)/articles.vue +++ b/apps/nuxt/app/pages/(articles)/articles.vue @@ -34,7 +34,7 @@ useHead({ title: APP_NAME + ' 文章', }) -const { nav } = useNav() +const {nav} = useNav() const base = useBaseStore() const store = useBaseStore() const settingStore = useSettingStore() @@ -50,7 +50,7 @@ watch( init() } }, - { immediate: true } + {immediate: true} ) async function onvisibilitychange() { @@ -72,14 +72,38 @@ async function init() { document.addEventListener('visibilitychange', onvisibilitychange) if (AppEnv.CAN_REQUEST) { - let res = await myDictList({ type: 'article' }) + let res = await myDictList({type: 'article'}) if (res.success) { store.setState(Object.assign(store.$state, res.data)) } } - if (store.article.studyIndex >= 1) { + let studyIndex = store.article.studyIndex + if (studyIndex >= 1) { if (!store.sbook.custom && !store.sbook.articles.length) { - store.article.bookList[store.article.studyIndex] = await _getDictDataByUrl(store.sbook, DictType.article) + let dictList = await fetch(resourceWrap(DICT_LIST.ARTICLE.ALL)).then(r => r.json()) + let dict = await _getDictDataByUrl(store.sbook, DictType.article) + let r = dictList.find(v => [v.enName, v.id].includes(store.sbook.id)) + if (r) { + store.article.bookList[studyIndex].articles = dict.articles + store.article.bookList[studyIndex].id = r.id + store.article.bookList[studyIndex].enName = r.enName + store.article.bookList[studyIndex].cover = r.cover + store.article.bookList[studyIndex].category = r.category + store.article.bookList[studyIndex].tags = r.tags + store.article.bookList[studyIndex].url = r.url + store.article.bookList[studyIndex].description = r.description + store.article.bookList[studyIndex].name = r.name + } else { + store.article.bookList[studyIndex] = dict + } + store.article.bookList[studyIndex].length = dict.articles.length + let s = store.article.bookList[studyIndex] + if (s.lastLearnIndex > s.length) { + store.article.bookList[studyIndex].lastLearnIndex = s.length + store.article.bookList[studyIndex].complete = true + //todo 后续加上 + // await resetCacheData() + } } } const d = await articlePersistence.load() @@ -110,7 +134,7 @@ watch( text: `下一步(7/${TourConfig.total})`, action() { tour.next() - nav('/practice-articles/article_nce2', { guide: 1 }) + nav('/practice-articles/article_nce2', {guide: 1}) }, }, ], @@ -123,7 +147,7 @@ watch( }, 500) } }, - { immediate: true } + {immediate: true} ) function startStudy() { @@ -231,7 +255,7 @@ const weekList = $computed(() => { return list }) -const { data: recommendBookList, isFetching } = useFetch(resourceWrap(DICT_LIST.ARTICLE.RECOMMENDED)).json() +const {data: recommendBookList, isFetching} = useFetch(resourceWrap(DICT_LIST.ARTICLE.RECOMMENDED)).json() let isOldHost = $ref(false) onMounted(() => { @@ -257,7 +281,7 @@ onMounted(() => { :show-progress="false" @click="goBookDetail(base.sbook)" /> - +
@@ -310,7 +334,7 @@ onMounted(() => {
{{ isSaveData ? $t('continue_learning') : $t('start_learning') }} - +
@@ -323,7 +347,7 @@ onMounted(() => {
- + @@ -356,7 +380,7 @@ onMounted(() => { v-for="(item, j) in base.article.bookList" @click="goBookDetail(item)" /> - +
diff --git a/apps/nuxt/app/pages/(words)/dict-list.vue b/apps/nuxt/app/pages/(words)/dict-list.vue index d958ddd5..d30d5dd6 100644 --- a/apps/nuxt/app/pages/(words)/dict-list.vue +++ b/apps/nuxt/app/pages/(words)/dict-list.vue @@ -52,7 +52,7 @@ const groupedByCategoryAndTag = $computed(() => { for (const [key, value] of Object.entries(groupByCategory)) { data.push([key, groupByDictTags(value)]) } - ;[data[2], data[3]] = [data[3], data[2]] + // ;[data[2], data[3]] = [data[3], data[2]] // console.log('data', data) return data }) diff --git a/apps/nuxt/app/pages/(words)/words.vue b/apps/nuxt/app/pages/(words)/words.vue index 1b61a884..aecac910 100644 --- a/apps/nuxt/app/pages/(words)/words.vue +++ b/apps/nuxt/app/pages/(words)/words.vue @@ -26,7 +26,7 @@ import { useNav, } from '@typewords/core/utils' import type { DictResource, Statistics } from '@typewords/core/types/types.ts' -import { watch } from 'vue' +import { shallowReactive, watch } from 'vue' import { getCurrentStudyWord } from '@typewords/core/hooks/dict.ts' import { useRuntimeStore } from '@typewords/core/stores/runtime.ts' import Book from '@typewords/core/components/Book.vue' @@ -62,7 +62,7 @@ const settingStore = useSettingStore() const wordPersistence = usePracticeWordPersistence() const dataSync = useDataSyncPersistence() const router = useRouter() -const { nav } = useNav() +const {nav} = useNav() const runtimeStore = useRuntimeStore() let loading = $ref(true) let isSaveData = $ref(false) @@ -125,7 +125,7 @@ watch( }, 500) } }), - { immediate: true } + {immediate: true} ) async function onvisibilitychange() { @@ -141,7 +141,7 @@ async function onvisibilitychange() { async function init() { if (AppEnv.CAN_REQUEST) { - let res = await myDictList({ type: 'word' }) + let res = await myDictList({type: 'word'}) if (res.success) { store.setState(Object.assign(store.$state, res.data)) } @@ -150,9 +150,32 @@ async function init() { document.removeEventListener('visibilitychange', onvisibilitychange) document.addEventListener('visibilitychange', onvisibilitychange) - if (store.word.studyIndex >= 3) { + let studyIndex = store.word.studyIndex; + if (studyIndex >= 3) { if (!store.sdict.custom && !store.sdict.words.length) { - store.word.bookList[store.word.studyIndex] = await _getDictDataByUrl(store.sdict) + let dictList = await fetch(resourceWrap(DICT_LIST.WORD.ALL)).then(r => r.json()) + let dict = await _getDictDataByUrl(store.sdict) + let r = dictList.find(v => [v.enName, v.id].includes(store.sdict.id)) + if (r) { + store.word.bookList[studyIndex].words = dict.words + store.word.bookList[studyIndex].id = r.id + store.word.bookList[studyIndex].enName = r.enName + store.word.bookList[studyIndex].cover = r.cover + store.word.bookList[studyIndex].category = r.category + store.word.bookList[studyIndex].tags = r.tags + store.word.bookList[studyIndex].url = r.url + store.word.bookList[studyIndex].description = r.description + store.word.bookList[studyIndex].name = r.name + } else { + store.word.bookList[studyIndex] = dict + } + store.word.bookList[studyIndex].length = dict.words.length + let s = store.word.bookList[studyIndex] + if (s.lastLearnIndex > s.length) { + store.word.bookList[studyIndex].lastLearnIndex = s.length + store.word.bookList[studyIndex].complete = true + await resetCacheData() + } } } @@ -205,6 +228,7 @@ async function startPractice(practiceMode: WordPracticeMode, resetCache: boolean function freePractice() { startPractice(WordPracticeMode.Free, settingStore.wordPracticeMode !== WordPracticeMode.Free) } + function systemPractice() { startPractice( settingStore.wordPracticeMode === WordPracticeMode.Free ? WordPracticeMode.System : settingStore.wordPracticeMode, @@ -308,7 +332,7 @@ function onSelectCalendarDate(dateKey: string) { for (const book of store.word.bookList) { for (const stat of book.statistics ?? []) { if (dayjs(stat.startDate).format('YYYY-MM-DD') === dateKey) { - rows.push({ ...stat, dictName: book.name }) + rows.push({...stat, dictName: book.name}) } } } @@ -450,7 +474,7 @@ async function saveLastPracticeIndex(e) { Toast.success('修改成功') } -const { data: recommendDictList, isFetching } = useFetch(resourceWrap(DICT_LIST.WORD.RECOMMENDED)).json() +const {data: recommendDictList, isFetching} = useFetch(resourceWrap(DICT_LIST.WORD.RECOMMENDED)).json() const systemPracticeText = $computed(() => { if (settingStore.wordPracticeMode === WordPracticeMode.Free) { @@ -484,7 +508,7 @@ onUnmounted(() => {
- +
{{ store.sdict.name || $t('no_dict_selected') }} @@ -513,7 +537,7 @@ onUnmounted(() => {
- + {{ $t('select_dict') }}
@@ -524,13 +548,13 @@ onUnmounted(() => { >
- + {{ $t('change_progress') }}
- 学习记录 + 学习记录
@@ -538,7 +562,7 @@ onUnmounted(() => {
{{ $t('select_dict_to_start') }}
- + {{ $t('select_dict') }}
@@ -548,14 +572,14 @@ onUnmounted(() => {
- +
{{ isSaveData ? $t('last_task') : $t('today_task') }}
{{ - $t('word_list') - }} + $t('word_list') + }}
{{ $t('daily_goal') }} @@ -568,7 +592,7 @@ onUnmounted(() => { title="当前存在未完成的学习任务,修改会重新生成学习任务,是否继续?" @confirm="check(() => (showPracticeSettingDialog = true))" > - {{ $t('change') }} + {{ $t('change') }}
@@ -595,7 +619,7 @@ onUnmounted(() => { >
{{ systemPracticeText }} - +