From 40d5a75fa9685146d6ae2bc91aea3adb94fb2c8d Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 30 Sep 2024 21:39:28 +0800 Subject: [PATCH] fix(modules/web): use native confirm --- modules/web/src/views/BookChapter.vue | 40 +++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/modules/web/src/views/BookChapter.vue b/modules/web/src/views/BookChapter.vue index ea7e9760a27c..7351a314dc68 100644 --- a/modules/web/src/views/BookChapter.vue +++ b/modules/web/src/views/BookChapter.vue @@ -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(); }); -**/