Files
ComfyUI_frontend/src/components/dialog/UnloadWindowConfirmDialog.vue
2024-08-30 16:51:10 -04:00

22 lines
537 B
Vue

<script setup lang="ts">
import { useSettingStore } from '@/stores/settingStore'
import { onMounted, onUnmounted } from 'vue'
const settingStore = useSettingStore()
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
if (settingStore.get('Comfy.Window.UnloadConfirmation')) {
event.preventDefault()
return true
}
return undefined
}
onMounted(() => {
window.addEventListener('beforeunload', handleBeforeUnload)
})
onUnmounted(() => {
window.removeEventListener('beforeunload', handleBeforeUnload)
})
</script>