Added a confirmation popup which will be triggered when user is closing the page while some tabs in Sshwifty is still open
This commit is contained in:
14
ui/home.vue
14
ui/home.vue
@@ -253,20 +253,32 @@ export default {
|
|||||||
this.$emit("navigate-to", "");
|
this.$emit("navigate-to", "");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener("beforeunload", this.onBrowserClose);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
window.removeEventListener("beforeunload", this.onBrowserClose);
|
||||||
|
|
||||||
if (this.ticker === null) {
|
if (this.ticker === null) {
|
||||||
clearInterval(this.ticker);
|
clearInterval(this.ticker);
|
||||||
this.ticker = null;
|
this.ticker = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onBrowserClose(e) {
|
||||||
|
if (this.tab.current < 0) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const msg = "Some tabs are still open, are you sure you want to exit?";
|
||||||
|
(e || window.event).returnValue = msg;
|
||||||
|
return msg;
|
||||||
|
},
|
||||||
tick() {
|
tick() {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
|
|
||||||
this.socket.update(now, this);
|
this.socket.update(now, this);
|
||||||
},
|
},
|
||||||
closeAllWindow() {
|
closeAllWindow(e) {
|
||||||
for (let i in this.windows) {
|
for (let i in this.windows) {
|
||||||
this.windows[i] = false;
|
this.windows[i] = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user