mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 02:12:00 +03:00
fix white screen on autostart and hotkey toggle
This commit is contained in:
parent
9fe8dd74f8
commit
ece0ea1a14
3 changed files with 28 additions and 6 deletions
|
|
@ -452,6 +452,13 @@ fn exit_app(app: AppHandle) {
|
|||
app.exit(0);
|
||||
}
|
||||
|
||||
/// True when the app was launched by autostart (passes --hidden arg).
|
||||
/// The frontend uses this to stay in the tray instead of showing the window.
|
||||
#[tauri::command]
|
||||
fn is_hidden_launch() -> bool {
|
||||
std::env::args().any(|a| a == "--hidden")
|
||||
}
|
||||
|
||||
/// Quit via the frontend so the debounced autosave gets flushed first;
|
||||
/// a watchdog exits anyway in case the webview is unresponsive.
|
||||
fn request_quit(app: &AppHandle) {
|
||||
|
|
@ -494,7 +501,7 @@ fn main() {
|
|||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
||||
None,
|
||||
Some(vec!["--hidden"]),
|
||||
))
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
|
|
@ -513,7 +520,8 @@ fn main() {
|
|||
open_extensions_folder,
|
||||
get_launch_file,
|
||||
read_text_file,
|
||||
exit_app
|
||||
exit_app,
|
||||
is_hidden_launch
|
||||
])
|
||||
.setup(|app| {
|
||||
let handle = app.handle().clone();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Summarum",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"identifier": "app.summarum.calc",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
"minWidth": 320,
|
||||
"minHeight": 240,
|
||||
"center": true,
|
||||
"visible": true,
|
||||
"visible": false,
|
||||
"decorations": false
|
||||
}
|
||||
],
|
||||
|
|
|
|||
16
src/main.ts
16
src/main.ts
|
|
@ -308,12 +308,17 @@ async function registerHotkey(old: string | null, combo: string): Promise<boolea
|
|||
if (e.state !== "Pressed") return;
|
||||
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||
const win = getCurrentWindow();
|
||||
if (await win.isVisible() && await win.isFocused()) {
|
||||
if (await win.isVisible()) {
|
||||
if (document.hasFocus()) {
|
||||
await win.hide();
|
||||
} else {
|
||||
await win.show();
|
||||
await win.setFocus();
|
||||
}
|
||||
} else {
|
||||
await win.show();
|
||||
await win.setFocus();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
|
@ -605,6 +610,15 @@ async function boot(): Promise<void> {
|
|||
void onOpenFile((content) => newDoc(content));
|
||||
|
||||
editor.focus();
|
||||
|
||||
if (isTauri()) {
|
||||
const { invoke } = await import("@tauri-apps/api/core");
|
||||
const hidden = await invoke<boolean>("is_hidden_launch");
|
||||
if (!hidden) {
|
||||
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||
await getCurrentWindow().show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void boot();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue