From 810b980e6b993594598eebd2177d572de798b4f3 Mon Sep 17 00:00:00 2001 From: fufesou Date: Thu, 28 Mar 2024 11:14:03 +0800 Subject: [PATCH] Try fix, click tray icon, run main window (#7540) * Try fix, click tray icon, run main window Signed-off-by: fufesou * Remove start uni link on Windows, use 'run_me' instead Signed-off-by: fufesou --------- Signed-off-by: fufesou --- src/tray.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/tray.rs b/src/tray.rs index 0f625df48..ab395091d 100644 --- a/src/tray.rs +++ b/src/tray.rs @@ -88,14 +88,20 @@ pub fn make_tray() -> hbb_common::ResultType<()> { crate::platform::macos::handle_application_should_open_untitled_file(); #[cfg(target_os = "windows")] { - use std::os::windows::process::CommandExt; - use std::process::Command; - Command::new("cmd") - .arg("/c") - .arg(&format!("start {}", crate::get_uri_prefix())) - .creation_flags(winapi::um::winbase::CREATE_NO_WINDOW) - .spawn() - .ok(); + // Do not use the follwoing code (start uni link). + // It may be unable to open the app on some machines. + // eg. crate::get_uri_prefix() has some special characters or non-ascii characters. + // + // Command::new("cmd") + // .arg("/c") + // .arg(&format!("start {}", crate::get_uri_prefix())) + // .creation_flags(winapi::um::winbase::CREATE_NO_WINDOW) + // .spawn() + // .ok(); + + // Use `run_me` instead. + // `allow_multiple_instances` in `flutter/windows/runner/main.cpp` allows only one instance without args. + crate::run_me::<&str>(vec![]).ok(); } #[cfg(target_os = "linux")] if !std::process::Command::new("xdg-open")