prevent accidental navigation

main
km0 1 year ago
parent 1d09b52f64
commit 3f3b9df321

@ -34,7 +34,7 @@
import SceneEntry from './components/SceneEntry.vue' import SceneEntry from './components/SceneEntry.vue'
import {utils} from './composables/utils.js' import {utils} from './composables/utils.js'
import {ref} from 'vue' import {ref, onBeforeMount, onBeforeUnmount } from 'vue'
const {base64ToBlob} = utils() const {base64ToBlob} = utils()
@ -79,6 +79,22 @@ const load = (e) => {
}) })
} }
// Prevent accidental navigation
const preventNav = (e) => {
console.log('Sure to leave?')
e.preventDefault()
e.returnValue = ""
}
onBeforeMount(()=>{
window.addEventListener("beforeunload", preventNav)
})
onBeforeUnmount(()=>{
window.addEventListener("beforeunload", preventNav)
})
</script> </script>
<style> <style>

Loading…
Cancel
Save