feat(core): allow listening to event loop events & prevent window close (#2131)

This commit is contained in:
Lucas Fernandes Nogueira
2021-07-06 13:36:37 -03:00
committed by GitHub
parent d69b1cf6d7
commit 8157a68af1
12 changed files with 169 additions and 56 deletions

View File

@@ -4,6 +4,7 @@
import hotkeys from "hotkeys-js";
import { open } from "@tauri-apps/api/shell";
import { invoke } from "@tauri-apps/api/tauri";
import { appWindow, getCurrent } from "@tauri-apps/api/window";
import Welcome from "./components/Welcome.svelte";
import Cli from "./components/Cli.svelte";
@@ -24,6 +25,12 @@
hotkeys(MENU_TOGGLE_HOTKEY, () => {
invoke('menu_toggle');
});
getCurrent().listen('close-requested', async () => {
if (await confirm('Are you sure?')) {
await appWindow.close()
}
})
});
const views = [