<template>
	<reader-component :novel-id="novelId" @back="handleBack" @search="handleSearch" @add-to-shelf="handleAddToShelf"
		@add-bookmark="handleAddBookmark" @show-notes="handleShowNotes" @show-progress="handleShowProgress"
		@prev-page="handlePrevPage" @next-page="handleNextPage" @chapter-change="handleChapterChange"
		@chapter-loaded="handleChapterLoaded" @chapters-loaded="handleChaptersLoaded" @theme-change="handleThemeChange"
		@font-size-change="handleFontSizeChange" @margin-change="handleMarginChange"
		@line-height-change="handleLineHeightChange" />
</template>

<script>
	import ReaderComponent from './reader/reader-component.vue'

	export default {
		components: {
			ReaderComponent
		},
		data() {
			return {
				novelId: 1
			}
		},
		onLoad(options) {
			if (options && options.id) {
				this.novelId = Number(options.id)
			}
		},
		methods: {
			handleBack() {
				uni.navigateBack(1)
				console.log('返回上一页')
			},
			handleSearch() {
				console.log('搜索')
			},
			handleAddToShelf() {
				uni.showToast({
					title: '已加入书架',
					icon: 'success'
				})
			},
			handleAddBookmark() {
				console.log('添加书签')
			},
			handleShowNotes() {
				uni.showToast({
					title: '笔记功能开发中',
					icon: 'none'
				})
			},
			handleShowProgress() {
				uni.showToast({
					title: '进度功能开发中',
					icon: 'none'
				})
			},
			handlePrevPage() {
				console.log('上一页')
			},
			handleNextPage() {
				console.log('下一页')
			},
			handleChapterChange(chapter) {
				console.log('章节切换', chapter)
			},
			handleChapterLoaded(chapter) {
				console.log('章节加载完成', chapter)
			},
			handleChaptersLoaded(chapters) {
				console.log('目录加载完成', chapters)
			},
			handleThemeChange(index) {
				console.log('主题切换', index)
			},
			handleFontSizeChange(size) {
				console.log('字体大小改变', size)
			},
			handleMarginChange(margin) {
				console.log('边距改变', margin)
			},
			handleLineHeightChange(lineHeight) {
				console.log('行高改变', lineHeight)
			}
		}
	}
</script>