Skip to content

Commit

Permalink
fix(modues/web): deal with readingRecent tag clik event; remove keyup…
Browse files Browse the repository at this point in the history
… eventListener when addToBookShelfConfirm visible
  • Loading branch information
Xwite committed Oct 5, 2024
1 parent 83d2cf4 commit 0898ef2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions modules/web/src/views/BookChapter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ const addToBookShelfConfirm = async () => {
}
};
onBeforeRouteLeave(async (to, from, next) => {
console.log("onBeforeRouteLeave");
// 弹窗时停止响应按键翻页
window.removeEventListener("keyup", handleKeyPress);
await addToBookShelfConfirm();
next();
});
Expand Down
14 changes: 13 additions & 1 deletion modules/web/src/views/BookShelf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
readingRecent.author,
readingRecent.chapterIndex,
readingRecent.chapterPos,
readingRecent.isSeachBook,
true,
)
"
:class="{ 'no-point': readingRecent.url == '' }"
Expand Down Expand Up @@ -110,6 +112,7 @@ export default defineComponent({
url: "",
chapterIndex: 0,
chapterPos: 0,
isSeachBook: false,
});
const shelfWrapper = ref(null);
const { showLoading, closeLoading, loadingWrapper, isLoading } = useLoading(
Expand Down Expand Up @@ -249,20 +252,28 @@ export default defineComponent({
chapterIndex,
chapterPos,
isSeachBook,
fromReadRecentClick = false,
) => {
if (bookName === "尚无阅读记录") return;
// 最近书籍不再书架上 自动搜索
if (isSeachBook === true && fromReadRecentClick) {
searchWord.value = bookName;
searchBook();
return;
}
sessionStorage.setItem("bookUrl", bookUrl);
sessionStorage.setItem("bookName", bookName);
sessionStorage.setItem("bookAuthor", bookAuthor);
sessionStorage.setItem("chapterIndex", chapterIndex);
sessionStorage.setItem("chapterPos", chapterPos);
sessionStorage.setItem("isSeachBook", isSeachBook);
sessionStorage.setItem("isSeachBook", String(isSeachBook));
readingRecent.value = {
name: bookName,
author: bookAuthor,
url: bookUrl,
chapterIndex: chapterIndex,
chapterPos: chapterPos,
isSeachBook,
};
localStorage.setItem(
"readingRecent",
Expand Down Expand Up @@ -343,6 +354,7 @@ export default defineComponent({
searchBook,
books,
handleBookClick,
toDetail,
isSearching,
SearchIcon,
githubUrl,
Expand Down

0 comments on commit 0898ef2

Please sign in to comment.