import { onMounted, onUnmounted } from 'vue';
import { onBeforeRouteLeave } from 'vue-router';
function _beforeUnloadHandler(event: Event) {
event.preventDefault();
return;
}
function _useWindow() {
onMounted(() => {
window.addEventListener('beforeunload', _beforeUnloadHandler);
});
onUnmounted(() => {
window.removeEventListener('beforeunload', _beforeUnloadHandler);
});
onBeforeRouteLeave((_$1, { meta }, next) => {
if (meta.ignoreConfirm) {
next();
return;
}
const isAccept = window.confirm('페이지를 이동하시겠습니까?');
next(isAccept);
});
}
export {
_useWindow as useWindow
};