diff --git a/src/api/book.js b/src/api/book.js
index 4d98b58..fd360be 100644
--- a/src/api/book.js
+++ b/src/api/book.js
@@ -8,6 +8,10 @@ export function getLastChapterAbout(params) {
return request.get('/book/lastChapterAbout', { params });
}
+export function listRecBooks(params) {
+ return request.get('/book/recList', { params });
+}
+
export function getBookContent(chapterId) {
return request.get(`/book/content/${chapterId}`);
}
diff --git a/src/components/book/LastChapterAbout.vue b/src/components/book/LastChapterAbout.vue
deleted file mode 100644
index f928f6f..0000000
--- a/src/components/book/LastChapterAbout.vue
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
-
-
-
最新章节
- ({{chapterAbout.chapterTotal}}章)
-
-
全部目录
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/router/index.js b/src/router/index.js
index 05cbdc9..3d7f04d 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -35,4 +35,9 @@ const router = createRouter({
]
})
+// 解决 vue 中路由跳转时,总是从新页面中间开始显示
+router.afterEach((to,from,next) => {
+ window.scrollTo(0,0)
+})
+
export default router
\ No newline at end of file
diff --git a/src/views/Book.vue b/src/views/Book.vue
index c7dcd94..23b6a42 100644
--- a/src/views/Book.vue
+++ b/src/views/Book.vue
@@ -4,34 +4,45 @@
-
-
- 类别:{{book.categoryName}}
- 状态:{{book.bookStatus == 0 ? '连载中' : '已完结'}}
- 总点击:{{book.visitCount}}
- 总字数:{{book.wordCount}}
+ 类别:{{ book.categoryName }}
+ 状态:{{
+ book.bookStatus == 0 ? "连载中" : "已完结"
+ }}
+ 总点击:{{ book.visitCount }}
+ 总字数:{{ book.wordCount }}
-
-
-
+
收起
@@ -40,9 +51,9 @@
>
-
-
点击阅读
@@ -63,8 +74,52 @@
-
-
+
+
+
+
+
+
最新章节
+ ({{ chapterAbout.chapterTotal }}章)
+
+
全部目录
+
+
+
+
+
@@ -74,7 +129,7 @@
作品评论区
-
发表评论
+
+
+
请先 登录|注册
+
+
+ -->
@@ -143,7 +203,9 @@
@@ -161,75 +223,26 @@
- -
+
-
-
-
-
- -
-
-
-

-
-
-
-
- -
-
-
-

-
-
-
-
- -
-
-
-

-
-
@@ -248,11 +261,9 @@
import "@/assets/styles/book.css";
import { reactive, toRefs, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
-import { getBookById } from "@/api/book";
-import { ElMessage, ElLoading } from "element-plus";
+import { getBookById,getLastChapterAbout,listRecBooks } from "@/api/book";
import Header from "@/components/common/Header";
import Footer from "@/components/common/Footer";
-import LastChapterAbout from "@/components/book/LastChapterAbout.vue"
import author_head from "@/assets/images/author_head.png";
import no_comment from "@/assets/images/no_comment.png";
export default {
@@ -260,7 +271,6 @@ export default {
components: {
Header,
Footer,
- LastChapterAbout
},
setup() {
const route = useRoute();
@@ -268,23 +278,49 @@ export default {
const state = reactive({
book: {},
+ books: {},
+ chapterAbout:{},
imgBaseUrl: process.env.VUE_APP_BASE_IMG_URL,
});
- const bookId = route.params.id;
- onMounted(async () => {
- const { data } = await getBookById(bookId)
- state.book = data
+ onMounted(() => {
+ const bookId = route.params.id;
+ loadBook(bookId)
+ loadRecBooks(bookId)
+ loadLastChapterAbout(bookId)
});
- const bookContent = (bookId,chapterId) => {
+ const loadBook = async (bookId) => {
+ const { data } = await getBookById(bookId);
+ state.book = data;
+ };
+
+ const loadRecBooks = async (bookId) => {
+ const { data } = await listRecBooks({ bookId: bookId });
+ state.books = data;
+ };
+
+ const loadLastChapterAbout = async (bookId) => {
+ const { data } = await getLastChapterAbout({ bookId: bookId });
+ state.chapterAbout = data;
+ }
+
+ const bookContent = (bookId, chapterId) => {
router.push({ path: `/book/${bookId}/${chapterId}` });
};
+ const bookDetail = (bookId) => {
+ router.push({ path: `/book/${bookId}` });
+ loadBook(bookId)
+ loadRecBooks(bookId)
+ loadLastChapterAbout(bookId)
+ };
+
return {
...toRefs(state),
author_head,
no_comment,
- bookContent
+ bookContent,
+ bookDetail,
};
},
mounted() {
diff --git a/src/views/BookContent.vue b/src/views/BookContent.vue
index e9dd958..fe5ed19 100644
--- a/src/views/BookContent.vue
+++ b/src/views/BookContent.vue
@@ -249,11 +249,8 @@ import "@/assets/styles/read.css"
import { reactive, toRefs, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import {getBookContent } from "@/api/book";
-import { ElMessage, ElLoading } from "element-plus";
import Top from "@/components/common/Top";
import Footer from "@/components/common/Footer";
-import author_head from "@/assets/images/author_head.png";
-import no_comment from "@/assets/images/no_comment.png";
export default {
name: "bookContent",
components: {