mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 11:40:00 +00:00
Add confirm dialog on window close
This commit is contained in:
21
src/components/dialog/UnloadWindowConfirmDialog.vue
Normal file
21
src/components/dialog/UnloadWindowConfirmDialog.vue
Normal file
@@ -0,0 +1,21 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user