fix(desktop): nur eine Instanz — zweiter Start holt das Fenster nach vorne
- tauri-plugin-single-instance als erstes Plugin registriert - show_main_window-Helper ersetzt die dreifach duplizierte Fenster-Sequenz Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -694,8 +694,24 @@ fn get_client_info() -> String {
|
||||
client_info_label(env!("CARGO_PKG_VERSION"), env!("APP_COMMIT"))
|
||||
}
|
||||
|
||||
/// Hauptfenster nach vorne holen. Ein minimiertes Fenster (z. B. per Win+D)
|
||||
/// wird zuerst wiederhergestellt.
|
||||
fn show_main_window(app: &AppHandle) {
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
let _ = w.unminimize();
|
||||
let _ = w.show();
|
||||
let _ = w.set_focus();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run() {
|
||||
let app = tauri::Builder::default()
|
||||
// Muss als erstes Plugin stehen. Verhindert den Doppelstart (z. B. beim
|
||||
// Windows-Login) mit zwei Tray-Symbolen: Ein zweiter Start holt nur das
|
||||
// Fenster der laufenden Instanz nach vorne und beendet sich sofort.
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {
|
||||
show_main_window(app);
|
||||
}))
|
||||
.plugin(tauri_plugin_store::Builder::new().build())
|
||||
.plugin(tauri_plugin_notification::init())
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
@@ -819,21 +835,12 @@ pub fn run() {
|
||||
.tooltip(tray_labels(server_url.as_deref()).0)
|
||||
.show_menu_on_left_click(false)
|
||||
.on_menu_event(move |app, event| match event.id().as_ref() {
|
||||
"open" => {
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
// Minimiertes Fenster (z. B. per Win+D) zuerst wiederherstellen
|
||||
let _ = w.unminimize();
|
||||
let _ = w.show();
|
||||
let _ = w.set_focus();
|
||||
}
|
||||
}
|
||||
"open" => show_main_window(app),
|
||||
"change_server" => {
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
let _ = w.navigate(setup_page_url(cfg!(windows)));
|
||||
let _ = w.unminimize();
|
||||
let _ = w.show();
|
||||
let _ = w.set_focus();
|
||||
}
|
||||
show_main_window(app);
|
||||
}
|
||||
"update" => {
|
||||
// `take()` verhindert Doppelklick-Downloads, der
|
||||
@@ -889,11 +896,7 @@ pub fn run() {
|
||||
..
|
||||
} = event
|
||||
{
|
||||
if let Some(w) = tray.app_handle().get_webview_window("main") {
|
||||
let _ = w.unminimize();
|
||||
let _ = w.show();
|
||||
let _ = w.set_focus();
|
||||
}
|
||||
show_main_window(tray.app_handle());
|
||||
}
|
||||
})
|
||||
.build(app)?;
|
||||
|
||||
Reference in New Issue
Block a user