fix(web/addToBookShelfConfirm): set ElMessageBox.closeOnHashChange to false

This commit is contained in:
Xwite 2024-10-05 06:41:21 +08:00
parent 28f11e148b
commit 83d2cf43dc
2 changed files with 45 additions and 47 deletions

View File

@ -20,8 +20,8 @@ import { useSourceStore } from "@/store";
const store = useSourceStore();
const current_tab = computed({
get:() => store.currentTab,
set:(val) => store.currentTab = val
get: () => store.currentTab,
set: (val) => (store.currentTab = val),
});
const tabData = ref([

View File

@ -146,7 +146,32 @@ const chapterIndex = computed({
set: (value) => (store.readingBook.index = value),
});
//
const infiniteLoading = computed(() => store.config.infiniteLoading);
let scrollObserver;
const loading = ref();
watchEffect(() => {
if (!infiniteLoading.value) {
scrollObserver?.disconnect();
} else {
scrollObserver?.observe(loading.value);
}
});
const loadMore = () => {
let index = chapterData.value.slice(-1)[0].index;
if (catalog.value.length - 1 > index) {
getContent(index + 1, false);
store.saveBookProgress(); //
}
};
// IntersectionObserver
const onReachBottom = (entries) => {
if (isLoading.value) return;
for (let { isIntersecting } of entries) {
if (!isIntersecting) return;
loadMore();
}
};
//
const fontFamily = computed(() => {
@ -388,32 +413,6 @@ const toPreChapter = () => {
}
};
//
let scrollObserver;
const loading = ref();
watchEffect(() => {
if (!infiniteLoading.value) {
scrollObserver?.disconnect();
} else {
scrollObserver?.observe(loading.value);
}
});
const loadMore = () => {
let index = chapterData.value.slice(-1)[0].index;
if (catalog.value.length - 1 > index) {
getContent(index + 1, false);
store.saveBookProgress(); //
}
};
// IntersectionObserver
const onReachBottom = (entries) => {
if (isLoading.value) return;
for (let { isIntersecting } of entries) {
if (!isIntersecting) return;
loadMore();
}
};
let canJump = true;
//
const handleKeyPress = (event) => {
@ -548,25 +547,24 @@ const addToBookShelfConfirm = async () => {
sessionStorage.removeItem("isSeachBook");
//
if (isSeachBook === "true") {
const addtoshelf = window.confirm(`是否将《${bookName}》放入书架?`);
if (!addtoshelf) await API.deleteBook(book);
/* //按下返回键时不能触发 ElMessageBox.confirm
await ElMessageBox.confirm(
`是否将《${bookName}》放入书架?`,
"放入书架",
{
confirmButtonText: "确认",
cancelButtonText: "否",
type: "info"
}
).then(() => {
//
}).catch(async () => {
//
await API.deleteBook(book);
}) */
await ElMessageBox.confirm(`是否将《${bookName}》放入书架?`, "放入书架", {
confirmButtonText: "确认",
cancelButtonText: "否",
type: "info",
/*
ElMessageBox.confirm默认在触发hashChange事件时自动关闭
按下物理返回键时触发hashChange事件
使用router.push("/")则不会触发hashChange事件
*/
closeOnHashChange: false,
})
.then(() => {
//
})
.catch(async () => {
//
await API.deleteBook(book);
});
}
};
onBeforeRouteLeave(async (to, from, next) => {