How does Angular differentiate between refresh event and close browser/close tab event?
I tried to listen to the event beforeunload, but I found that this event is fired whether I refresh the web page or close the browser
@HostListener('window:beforeunload', ['$event'])
public beforeunloadHandler() {
console.log('Click the refresh page button, or close the browser, this time will be called ');
}
The desired effect: I need to send a request when closing the browser: clear the token on the server side, but when refreshing the webpage, I don't want to trigger the request to clear the token, how can I distinguish between the refresh webpage event and the browser close event?