fix(modules/web): use native confirm

This commit is contained in:
Xwite
2024-09-30 21:39:28 +08:00
parent dd1202bd0a
commit 40d5a75fa9

View File

@@ -545,9 +545,8 @@ onUnmounted(() => {
scrollObserver = null;
});
/**
onBeforeRouteLeave(async (to, from, next) => {
按下返回键时不能触发 ElMessageBox.confirm
const addToBookShelfConfirm = async () => {
const bookUrl = sessionStorage.getItem("bookUrl");
const bookName = sessionStorage.getItem("bookName");
const isSeachBook = sessionStorage.getItem("isSeachBook");
@@ -555,24 +554,29 @@ onBeforeRouteLeave(async (to, from, next) => {
sessionStorage.removeItem("isSeachBook");
// 阅读的是搜索的书籍 并未在书架
if (isSeachBook === "true") {
await ElMessageBox.confirm(
`是否将《${bookName}》放入书架?`,
"放入书架",
{
confirmButtonText: "确认",
cancelButtonText: "否",
type: "info"
}
).then(() => {
//选择是,无动作
}).catch(async () => {
//选择否,删除书籍
await API.deleteBook(book);
})
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);
}) */
}
}
onBeforeRouteLeave(async (to, from, next) => {
await addToBookShelfConfirm();
next();
});
**/
</script>
<style lang="scss" scoped>