feat(api): add abstractions to updater and window event listeners (#4569)

This commit is contained in:
Lucas Fernandes Nogueira
2022-07-05 16:57:53 -03:00
committed by GitHub
parent e29fff2566
commit b02fc90f45
9 changed files with 431 additions and 147 deletions

View File

@@ -22,8 +22,18 @@
import { listen } from '@tauri-apps/api/event'
import { ask } from '@tauri-apps/api/dialog'
appWindow.listen('tauri://file-drop', function (event) {
onMessage(`File drop: ${event.payload}`)
if (appWindow.label !== 'main') {
appWindow.onCloseRequested(async (event) => {
const confirmed = await confirm('Are you sure?')
if (!confirmed) {
// user did not confirm closing the window; let's prevent it
event.preventDefault()
}
})
}
appWindow.onFileDropEvent((event) => {
onMessage(`File drop: ${JSON.stringify(event.payload)}`)
})
const views = [