From 267f05fd2514b7ec015ef568924b3bdc66545824 Mon Sep 17 00:00:00 2001 From: ronger Date: Fri, 19 Mar 2021 12:10:43 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=8C=E5=96=84=E5=88=B7?= =?UTF-8?q?=E6=96=B0/=E5=85=B3=E9=97=AD=E7=BC=96=E8=BE=91=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=8F=90=E7=A4=BA=20https://github.com/rymcu/forest/i?= =?UTF-8?q?ssues/34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/admin/tag/post/_tag_id.vue | 14 ++++++++++++++ pages/admin/topic/post/_topic_id.vue | 14 ++++++++++++++ pages/article/post/_article_id.vue | 15 +++++++++++++++ pages/portfolio/post/_portfolio_id.vue | 14 ++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/pages/admin/tag/post/_tag_id.vue b/pages/admin/tag/post/_tag_id.vue index ce3043f..defede7 100644 --- a/pages/admin/tag/post/_tag_id.vue +++ b/pages/admin/tag/post/_tag_id.vue @@ -238,6 +238,20 @@ export default { }) } }, + beforeRouteLeave(to, from, next) { + this.$confirm('系统可能不会保存您所做的更改。', '离开此网站?', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + next(); + }).catch(() => { + return false + }); + }, + beforeDestroy() { + window.onbeforeunload = null; + }, mounted() { window.addEventListener('beforeunload', e => { e = e || window.event; diff --git a/pages/admin/topic/post/_topic_id.vue b/pages/admin/topic/post/_topic_id.vue index aa992b8..9da4c6f 100644 --- a/pages/admin/topic/post/_topic_id.vue +++ b/pages/admin/topic/post/_topic_id.vue @@ -254,6 +254,20 @@ export default { }) } }, + beforeRouteLeave(to, from, next) { + this.$confirm('系统可能不会保存您所做的更改。', '离开此网站?', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + next(); + }).catch(() => { + return false + }); + }, + beforeDestroy() { + window.onbeforeunload = null; + }, async mounted() { window.addEventListener('beforeunload', e => { e = e || window.event; diff --git a/pages/article/post/_article_id.vue b/pages/article/post/_article_id.vue index 0d3a43f..62c71ff 100644 --- a/pages/article/post/_article_id.vue +++ b/pages/article/post/_article_id.vue @@ -48,6 +48,7 @@