mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 19:11:58 +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);
|
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;
|
/// Quit via the frontend so the debounced autosave gets flushed first;
|
||||||
/// a watchdog exits anyway in case the webview is unresponsive.
|
/// a watchdog exits anyway in case the webview is unresponsive.
|
||||||
fn request_quit(app: &AppHandle) {
|
fn request_quit(app: &AppHandle) {
|
||||||
|
|
@ -494,7 +501,7 @@ fn main() {
|
||||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||||
.plugin(tauri_plugin_autostart::init(
|
.plugin(tauri_plugin_autostart::init(
|
||||||
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
tauri_plugin_autostart::MacosLauncher::LaunchAgent,
|
||||||
None,
|
Some(vec!["--hidden"]),
|
||||||
))
|
))
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
|
|
@ -513,7 +520,8 @@ fn main() {
|
||||||
open_extensions_folder,
|
open_extensions_folder,
|
||||||
get_launch_file,
|
get_launch_file,
|
||||||
read_text_file,
|
read_text_file,
|
||||||
exit_app
|
exit_app,
|
||||||
|
is_hidden_launch
|
||||||
])
|
])
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
let handle = app.handle().clone();
|
let handle = app.handle().clone();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Summarum",
|
"productName": "Summarum",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"identifier": "app.summarum.calc",
|
"identifier": "app.summarum.calc",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"minWidth": 320,
|
"minWidth": 320,
|
||||||
"minHeight": 240,
|
"minHeight": 240,
|
||||||
"center": true,
|
"center": true,
|
||||||
"visible": true,
|
"visible": false,
|
||||||
"decorations": false
|
"decorations": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
18
src/main.ts
18
src/main.ts
|
|
@ -308,8 +308,13 @@ async function registerHotkey(old: string | null, combo: string): Promise<boolea
|
||||||
if (e.state !== "Pressed") return;
|
if (e.state !== "Pressed") return;
|
||||||
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||||
const win = getCurrentWindow();
|
const win = getCurrentWindow();
|
||||||
if (await win.isVisible() && await win.isFocused()) {
|
if (await win.isVisible()) {
|
||||||
await win.hide();
|
if (document.hasFocus()) {
|
||||||
|
await win.hide();
|
||||||
|
} else {
|
||||||
|
await win.show();
|
||||||
|
await win.setFocus();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await win.show();
|
await win.show();
|
||||||
await win.setFocus();
|
await win.setFocus();
|
||||||
|
|
@ -605,6 +610,15 @@ async function boot(): Promise<void> {
|
||||||
void onOpenFile((content) => newDoc(content));
|
void onOpenFile((content) => newDoc(content));
|
||||||
|
|
||||||
editor.focus();
|
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();
|
void boot();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue