the problem encountered now is that the axios request can not be submitted when the page is closed. Is there any solution?
window.addEventListener("beforeunload", function() {
beforeUnloadTimestamp = new Date().getTime();
})
window.addEventListener("unload", function() {
beforeUnloadTimestamp = beforeUnloadTimestamp || 0;
localStorage.setItem("onload", new Date().getTime());
// chromeie11 chromeIE11 // chrome >=11ms ie11 >=2ms chrome >=2msIE11 >=3000ms
if (isIE) {
if (new Date().getTime() - beforeUnloadTimestamp > 500) {
isClose = true;
}
} else {
if (new Date().getTime() - beforeUnloadTimestamp < 5) {
isClose = true;
}
}
if (isClose) {
axios.get("/au/logout").then(res => {
window.sessionStorage.clear();
});
localStorage.setItem("close", new Date().getTime());
}else{
localStorage.setItem("refresh", new Date().getTime());
}
})