修复:解决测试发现的问题

This commit is contained in:
2025-11-12 16:00:44 +08:00
parent 1da75a59f2
commit 1daa6367c9
29 changed files with 133 additions and 182 deletions

View File

@@ -130,11 +130,9 @@ async function loadBookInfo() {
// 加载章节列表
async function loadChapterList() {
try {
uni.showLoading({ title: t('global.loading') })
const res = await bookApi.getBookChapter({
bookId: bookId.value
})
uni.hideLoading()
if (res.chapterList && res.chapterList.length > 0) {
chapterList.value = res.chapterList
@@ -142,7 +140,6 @@ async function loadChapterList() {
nullText.value = t('common.data_null')
}
} catch (error) {
uni.hideLoading()
nullText.value = t('common.data_null')
console.error('Failed to load chapter list:', error)
}

View File

@@ -258,8 +258,6 @@ async function loadBookInfo() {
// 加载章节列表
async function loadChapterList() {
try {
uni.showLoading({ title: t('common.loading') })
const res = await bookApi.getBookChapter({
bookId: bookId.value
})
@@ -269,8 +267,6 @@ async function loadChapterList() {
if (res.chapterList && res.chapterList.length > 0) {
chapterList.value = res.chapterList
uni.hideLoading()
// 加载当前章节内容
if (currentChapterIndex.value < chapterList.value.length) {
const currentChapter = chapterList.value[currentChapterIndex.value]
@@ -280,14 +276,12 @@ async function loadChapterList() {
playChapter(currentChapter)
}
} else {
uni.hideLoading()
uni.showToast({
title: '章节列表为空',
icon: 'none'
})
}
} catch (error) {
uni.hideLoading()
console.error('Failed to load chapter list:', error)
uni.showToast({
title: '加载章节失败',
@@ -298,9 +292,7 @@ async function loadChapterList() {
// 加载章节内容(带音频时间点)
async function loadChapterContent(chapterId: number) {
try {
uni.showLoading({ title: t('common.loading') })
try {
console.log('加载章节内容, chapterId:', chapterId)
const res = await bookApi.getChapterContentListen(chapterId)
console.log('章节内容响应:', res)
@@ -327,11 +319,8 @@ async function loadChapterContent(chapterId: number) {
console.log('章节内容为空')
currentContent.value = '暂无内容'
}
uni.hideLoading()
} catch (error) {
console.error('Failed to load chapter content:', error)
uni.hideLoading()
uni.showToast({
title: '加载内容失败',
icon: 'none'
@@ -364,7 +353,6 @@ function playChapter(chapter: IChapter) {
if (audioContext.value) {
console.log('设置音频源:', chapter.voices)
uni.showLoading({ title: t('common.readAudio') })
audioContext.value.src = chapter.voices
audioContext.value.playbackRate = playbackRate.value
@@ -372,7 +360,6 @@ function playChapter(chapter: IChapter) {
// 监听音频准备就绪
audioContext.value.onCanplay(() => {
console.log('音频准备就绪')
uni.hideLoading()
})
audioContext.value.play()