Skip to content

Commit

Permalink
fix(modules/web): use native confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
Xwite committed Sep 30, 2024
1 parent dd1202b commit 40d5a75
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions modules/web/src/views/BookChapter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -545,34 +545,38 @@ 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");
const book = JSON.parse(localStorage.getItem(bookUrl));
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>
Expand Down

0 comments on commit 40d5a75

Please sign in to comment.