diff --git a/public/migrate.html b/public/migrate.html index 6da68ad4..0db735d0 100644 --- a/public/migrate.html +++ b/public/migrate.html @@ -8,14 +8,14 @@ diff --git a/src/components/list/ArticleList.vue b/src/components/list/ArticleList.vue index a4491444..8591efa9 100644 --- a/src/components/list/ArticleList.vue +++ b/src/components/list/ArticleList.vue @@ -7,13 +7,11 @@ import BaseInput from "@/components/base/BaseInput.vue"; interface IProps { list: Article[]; showTranslate?: boolean; - activeId: string | number; } const props = withDefaults(defineProps(), { list: () => [] as Article[], showTranslate: true, - activeId: "" }) const emit = defineEmits<{ @@ -79,7 +77,10 @@ defineExpose({ scrollToBottom, scrollToItem }) - + diff --git a/src/components/list/BaseList.vue b/src/components/list/BaseList.vue index 85c6e2de..b3b86186 100644 --- a/src/components/list/BaseList.vue +++ b/src/components/list/BaseList.vue @@ -5,13 +5,13 @@ import { nextTick, watch } from 'vue' const props = withDefaults(defineProps<{ list?: any[], activeIndex?: number, - activeId?: number, + activeId?: number | string, isActive?: boolean static?: boolean }>(), { list: [], activeIndex: -1, - activeId: null, + activeId: '', isActive: false, static: true }) @@ -94,7 +94,7 @@ function scrollToItem(index: number) { function itemIsActive(item: any, index: number) { return props.activeId ? - props.activeId === item.id + props.activeId == item.id : props.activeIndex === index } diff --git a/src/pages/article/PracticeArticles.vue b/src/pages/article/PracticeArticles.vue index 7de7e146..1b062627 100644 --- a/src/pages/article/PracticeArticles.vue +++ b/src/pages/article/PracticeArticles.vue @@ -42,7 +42,7 @@ const store = useBaseStore() const runtimeStore = useRuntimeStore() const settingStore = useSettingStore() const statStore = usePracticeStore() -const { toggleTheme } = useTheme() +const {toggleTheme} = useTheme() let articleData = $ref({ list: [], @@ -132,6 +132,7 @@ async function init() { router.push('/articles') } } + const initAudio = () => { _nextTick(() => { audioRef.volume = settingStore.articleSoundVolume / 100 @@ -154,11 +155,11 @@ const handleSpeedUpdate = (speed: number) => { watch(() => store.load, (n) => { if (n && loading) init() -}, { immediate: true }) +}, {immediate: true}) watch(() => settingStore.$state, (n) => { initAudio() -}, { immediate: true, deep: true }) +}, {immediate: true, deep: true}) onMounted(() => { if (store.sbook?.articles?.length) { @@ -190,9 +191,9 @@ function savePracticeData(init = true, regenerate = true) { let data = obj.val //如果全是0,说明未进行练习,直接重置 if ( - data.practiceData.sectionIndex === 0 && - data.practiceData.sentenceIndex === 0 && - data.practiceData.wordIndex === 0 + data.practiceData.sectionIndex === 0 && + data.practiceData.sentenceIndex === 0 && + data.practiceData.wordIndex === 0 ) { throw new Error() } @@ -262,6 +263,10 @@ function setArticle(val: Article) { }) } +watch(() => articleData.article.id, n => { + console.log('articleData.article.id', n) +}) + async function complete() { clearInterval(timer) setTimeout(() => { @@ -279,7 +284,7 @@ async function complete() { } if (AppEnv.CAN_REQUEST) { - let res = await addStat({ ...data, type: 'article' }) + let res = await addStat({...data, type: 'article'}) if (!res.success) { Toast.error(res.msg) } @@ -438,7 +443,8 @@ onUnmounted(() => { timer && clearInterval(timer) }) -const { playSentenceAudio } = usePlaySentenceAudio() +const {playSentenceAudio} = usePlaySentenceAudio() + function play2(e) { _nextTick(() => { if (settingStore.articleSound || e.handle) { @@ -485,7 +491,7 @@ provide('currentPractice', currentPractice) :static="false" :show-translate="settingStore.translate" @click="changeArticle" - :active-id="articleData.article.id" + :active-id="articleData.article.id??''" :list="articleData.list ">