完善刷新/关闭编辑界面提示 https://github.com/rymcu/forest/issues/34

This commit is contained in:
ronger 2021-03-19 12:10:43 +08:00
parent 7763a1cc0d
commit 267f05fd25
4 changed files with 57 additions and 0 deletions

View File

@ -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() { mounted() {
window.addEventListener('beforeunload', e => { window.addEventListener('beforeunload', e => {
e = e || window.event; e = e || window.event;

View File

@ -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() { async mounted() {
window.addEventListener('beforeunload', e => { window.addEventListener('beforeunload', e => {
e = e || window.event; e = e || window.event;

View File

@ -48,6 +48,7 @@
<script> <script>
import Vue from 'vue'; import Vue from 'vue';
import {mapState} from 'vuex'; import {mapState} from 'vuex';
import { isBrowser } from '~/environment'
export default { export default {
name: "PostArticle", name: "PostArticle",
@ -321,6 +322,20 @@
}) })
} }
}, },
beforeRouteLeave(to, from, next) {
this.$confirm('系统可能不会保存您所做的更改。', '离开此网站?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
next();
}).catch(() => {
return false
});
},
beforeDestroy() {
window.onbeforeunload = null;
},
async mounted() { async mounted() {
window.addEventListener('beforeunload', e => { window.addEventListener('beforeunload', e => {
e = e || window.event; e = e || window.event;

View File

@ -338,6 +338,20 @@ export default {
} }
} }
}, },
beforeRouteLeave(to, from, next) {
this.$confirm('系统可能不会保存您所做的更改。', '离开此网站?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
next();
}).catch(() => {
return false
});
},
beforeDestroy() {
window.onbeforeunload = null;
},
mounted() { mounted() {
window.addEventListener('beforeunload', e => { window.addEventListener('beforeunload', e => {
e = e || window.event; e = e || window.event;