fix(modues/web): deal with readingRecent tag clik event; remove keyup eventListener when addToBookShelfConfirm visible

This commit is contained in:
Xwite
2024-10-05 08:26:58 +08:00
parent 83d2cf43dc
commit 0898ef264e
2 changed files with 16 additions and 1 deletions
+3
View File
@@ -568,6 +568,9 @@ const addToBookShelfConfirm = async () => {
} }
}; };
onBeforeRouteLeave(async (to, from, next) => { onBeforeRouteLeave(async (to, from, next) => {
console.log("onBeforeRouteLeave");
// 弹窗时停止响应按键翻页
window.removeEventListener("keyup", handleKeyPress);
await addToBookShelfConfirm(); await addToBookShelfConfirm();
next(); next();
}); });
+13 -1
View File
@@ -32,6 +32,8 @@
readingRecent.author, readingRecent.author,
readingRecent.chapterIndex, readingRecent.chapterIndex,
readingRecent.chapterPos, readingRecent.chapterPos,
readingRecent.isSeachBook,
true,
) )
" "
:class="{ 'no-point': readingRecent.url == '' }" :class="{ 'no-point': readingRecent.url == '' }"
@@ -110,6 +112,7 @@ export default defineComponent({
url: "", url: "",
chapterIndex: 0, chapterIndex: 0,
chapterPos: 0, chapterPos: 0,
isSeachBook: false,
}); });
const shelfWrapper = ref(null); const shelfWrapper = ref(null);
const { showLoading, closeLoading, loadingWrapper, isLoading } = useLoading( const { showLoading, closeLoading, loadingWrapper, isLoading } = useLoading(
@@ -249,20 +252,28 @@ export default defineComponent({
chapterIndex, chapterIndex,
chapterPos, chapterPos,
isSeachBook, isSeachBook,
fromReadRecentClick = false,
) => { ) => {
if (bookName === "尚无阅读记录") return; if (bookName === "尚无阅读记录") return;
// 最近书籍不再书架上 自动搜索
if (isSeachBook === true && fromReadRecentClick) {
searchWord.value = bookName;
searchBook();
return;
}
sessionStorage.setItem("bookUrl", bookUrl); sessionStorage.setItem("bookUrl", bookUrl);
sessionStorage.setItem("bookName", bookName); sessionStorage.setItem("bookName", bookName);
sessionStorage.setItem("bookAuthor", bookAuthor); sessionStorage.setItem("bookAuthor", bookAuthor);
sessionStorage.setItem("chapterIndex", chapterIndex); sessionStorage.setItem("chapterIndex", chapterIndex);
sessionStorage.setItem("chapterPos", chapterPos); sessionStorage.setItem("chapterPos", chapterPos);
sessionStorage.setItem("isSeachBook", isSeachBook); sessionStorage.setItem("isSeachBook", String(isSeachBook));
readingRecent.value = { readingRecent.value = {
name: bookName, name: bookName,
author: bookAuthor, author: bookAuthor,
url: bookUrl, url: bookUrl,
chapterIndex: chapterIndex, chapterIndex: chapterIndex,
chapterPos: chapterPos, chapterPos: chapterPos,
isSeachBook,
}; };
localStorage.setItem( localStorage.setItem(
"readingRecent", "readingRecent",
@@ -343,6 +354,7 @@ export default defineComponent({
searchBook, searchBook,
books, books,
handleBookClick, handleBookClick,
toDetail,
isSearching, isSearching,
SearchIcon, SearchIcon,
githubUrl, githubUrl,