This commit is contained in:
Zyronon
2025-11-17 23:44:45 +08:00
parent 697db5f975
commit 135ae13b6f
5 changed files with 118 additions and 56 deletions

View File

@@ -7,13 +7,11 @@ import BaseInput from "@/components/base/BaseInput.vue";
interface IProps {
list: Article[];
showTranslate?: boolean;
activeId: string | number;
}
const props = withDefaults(defineProps<IProps>(), {
list: () => [] as Article[],
showTranslate: true,
activeId: ""
})
const emit = defineEmits<{
@@ -79,7 +77,10 @@ defineExpose({ scrollToBottom, scrollToItem })
</template>
</BaseInput>
</div>
<BaseList ref="listRef" @click="(e: any) => emit('click', e)" :list="localList" v-bind="$attrs">
<BaseList ref="listRef"
@click="(e: any) => emit('click', e)"
:list="localList"
v-bind="$attrs">
<template v-slot:prefix="{ item, index }">
<slot name="prefix" :item="item" :index="index"></slot>
</template>

View File

@@ -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
}

View File

@@ -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 ">
<template v-slot:suffix="{item,index}">
<BaseIcon