mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat(core): allow listening to event loop events & prevent window close (#2131)
This commit is contained in:
committed by
GitHub
parent
d69b1cf6d7
commit
8157a68af1
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user