fix(desktop): allow native quit before frontend ready

This commit is contained in:
t8y2 committed 2026-07-21 18:45:02 +08:00
1 parent c153e93d54
commit 1410c92710
3 files changed
+59 -6

No files matched your search

@@ -2,6 +2,7 @@ import { ref } from "vue";
import { useSettingsStore } from "@/stores/settingsStore";
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
import * as api from "@/lib/backend/api";
import { invoke } from "@tauri-apps/api/core";
export type AppCloseAction = "quit" | "hide";
type AppCloseRequestTarget = "settings" | "quit";
@@ -62,7 +63,12 @@ export function useCloseActionPrompt(options: { requestClose: (action: AppCloseA
void import("@tauri-apps/api/event").then(({ listen }) => {
listen<AppCloseRequestTarget>("dbx-app-close-requested", (event: AppCloseRequestPayload) => {
handleCloseRequest(event.payload === "quit" ? "quit" : "settings");
}).then((unlisten) => unlistenHandles.push(unlisten));
}).then((unlisten) => {
unlistenHandles.push(unlisten);
// Rust falls back to native Quit until this listener is installed, so a
// failed WebView2 startup cannot leave the tray request waiting forever.
void invoke("mark_frontend_ready");
});
});
}