修复:解决测试发现的问题
This commit is contained in:
@@ -2,12 +2,27 @@
|
||||
<view class="reader-page" :class="themeClass">
|
||||
<!-- 顶部标题栏 (可隐藏) -->
|
||||
<view class="reader-header" :style="{ top: notchHeight + 'px' }">
|
||||
<wd-icon name="arrow-left" size="20px" @click="goBack" />
|
||||
<wd-icon name="arrow-left" size="20px" @click="onPageBack" />
|
||||
<text class="chapter-title">{{ currentChapterTitle }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 阅读内容区域 -->
|
||||
<view class="reader-content" @click="toggleControls">
|
||||
<!-- 仿真翻页 -->
|
||||
<!-- <view class="content-wrapper">
|
||||
<nx-turn
|
||||
:initPage="0"
|
||||
:pageCount="4"
|
||||
>
|
||||
<template v-slot:page-content="{ page }">
|
||||
<text>{{ page }}</text>
|
||||
</template>
|
||||
<template v-slot:next-page-content="{ page }">
|
||||
<text>{{ page }}</text>
|
||||
</template>
|
||||
</nx-turn>
|
||||
</view> -->
|
||||
|
||||
<!-- 左右翻页模式 -->
|
||||
<view
|
||||
v-if="readMode === 'page'"
|
||||
@@ -37,9 +52,9 @@
|
||||
</view>
|
||||
|
||||
<!-- 页码指示器 -->
|
||||
<view v-show="showControls" class="page-indicator">
|
||||
<!-- <view v-show="showControls" class="page-indicator">
|
||||
{{ currentPage }} / {{ totalPages }}
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 上下滚动模式 -->
|
||||
@@ -99,8 +114,6 @@
|
||||
<wd-icon v-if="isLocked(index)" name="lock" size="20px" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 底部占位 -->
|
||||
<view class="setting-ooter-placeholder"></view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
@@ -165,13 +178,11 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部占位 -->
|
||||
<view class="setting-ooter-placeholder"></view>
|
||||
</wd-popup>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="chapterList.length === 0 && !loading" class="empty-state">
|
||||
<text>{{ nullStatus }}</text>
|
||||
<text>{{ $t('common.data_null') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -183,6 +194,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useBookStore } from '@/stores/book'
|
||||
import { bookApi } from '@/api/modules/book'
|
||||
import type { IChapter, IChapterContent, IReadProgress } from '@/types/book'
|
||||
import { onPageBack } from '@/utils/index'
|
||||
|
||||
const { t } = useI18n()
|
||||
const bookStore = useBookStore()
|
||||
@@ -199,7 +211,6 @@ const currentChapterIndex = ref(0)
|
||||
const currentChapterId = ref(0)
|
||||
const currentContentId = ref(0)
|
||||
const loading = ref(false)
|
||||
const nullStatus = ref('')
|
||||
|
||||
// 阅读设置
|
||||
const fontSizeLevel = ref(1)
|
||||
@@ -260,7 +271,6 @@ const currentChapterTitle = computed(() => {
|
||||
return chapter.chapter + (chapter.content ? ' - ' + chapter.content : '')
|
||||
})
|
||||
|
||||
// 生命周期
|
||||
onLoad((options: any) => {
|
||||
if (options.bookId) bookId.value = Number(options.bookId)
|
||||
if (options.isBuy) isBuy.value = options.isBuy
|
||||
@@ -290,20 +300,23 @@ onShow(() => {
|
||||
}, 300)
|
||||
} else {
|
||||
currentPage.value = 1
|
||||
calculatePages()
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
initHeights()
|
||||
calculatePages()
|
||||
})
|
||||
|
||||
onHide(() => {
|
||||
saveProgress()
|
||||
console.log('onHide')
|
||||
})
|
||||
|
||||
onBackPress(() => {
|
||||
saveProgress()
|
||||
console.log('onBackPress')
|
||||
return false
|
||||
})
|
||||
|
||||
@@ -313,7 +326,7 @@ function initHeights() {
|
||||
const windowHeight = systemInfo.windowHeight
|
||||
|
||||
// 翻页模式高度
|
||||
const math = Math.floor((windowHeight - (notchHeight.value + 130)) / lineHeight.value)
|
||||
const math = Math.floor((windowHeight - (notchHeight.value + 80)) / lineHeight.value)
|
||||
wrapHeight.value = math * lineHeight.value
|
||||
|
||||
// 滚动模式高度
|
||||
@@ -359,11 +372,8 @@ async function loadChapterList() {
|
||||
|
||||
// 默认加载第一章
|
||||
await loadChapterContent(chapterList.value[0].id, 0)
|
||||
} else {
|
||||
nullStatus.value = t('common.data_null')
|
||||
}
|
||||
} catch (error) {
|
||||
nullStatus.value = t('common.data_null')
|
||||
console.error('Failed to load chapter list:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -373,9 +383,7 @@ async function loadChapterList() {
|
||||
// 加载章节内容
|
||||
async function loadChapterContent(chapterId: number, index: number) {
|
||||
try {
|
||||
uni.showLoading({ title: t('global.loading') })
|
||||
const res = await bookApi.getChapterContent(chapterId)
|
||||
uni.hideLoading()
|
||||
|
||||
if (res.contentPage && res.contentPage.length > 0) {
|
||||
contentList.value = res.contentPage
|
||||
@@ -402,7 +410,6 @@ async function loadChapterContent(chapterId: number, index: number) {
|
||||
catalogVisible.value = false
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('Failed to load chapter content:', error)
|
||||
}
|
||||
}
|
||||
@@ -524,6 +531,7 @@ function toggleControls() {
|
||||
function showCatalog() {
|
||||
catalogVisible.value = true
|
||||
settingsVisible.value = false
|
||||
showControls.value = false
|
||||
}
|
||||
|
||||
// 关闭目录
|
||||
@@ -534,9 +542,9 @@ function closeCatalog() {
|
||||
|
||||
// 显示设置
|
||||
function showSettings() {
|
||||
console.log('currentLanguage', currentLanguage.value)
|
||||
settingsVisible.value = true
|
||||
catalogVisible.value = false
|
||||
showControls.value = false
|
||||
}
|
||||
// 关闭设置
|
||||
function closeSettings() {
|
||||
@@ -615,21 +623,12 @@ const changeBookLanguage = (language: any) => {
|
||||
|
||||
// 保存进度
|
||||
async function saveProgress() {
|
||||
if (isBuy.value === '0') {
|
||||
try {
|
||||
await bookApi.saveReadProgress(bookId.value, currentChapterId.value, currentContentId.value)
|
||||
} catch (error) {
|
||||
console.error('Failed to save progress:', error)
|
||||
}
|
||||
try {
|
||||
await bookApi.saveReadProgress(bookId.value, currentChapterId.value, currentContentId.value)
|
||||
} catch (error) {
|
||||
console.error('Failed to save progress:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 返回
|
||||
function goBack() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/book/detail?id=' + bookId.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -885,10 +884,5 @@ function goBack() {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
/* 底部占位 */
|
||||
.setting-ooter-placeholder {
|
||||
height: 55px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user