Try fix, click tray icon, run main window (#7540)

* Try fix, click tray icon, run main window

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Remove start uni link on Windows, use 'run_me' instead

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-03-28 11:14:03 +08:00 committed by GitHub
parent 22356940d9
commit 810b980e6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,14 +88,20 @@ pub fn make_tray() -> hbb_common::ResultType<()> {
crate::platform::macos::handle_application_should_open_untitled_file(); crate::platform::macos::handle_application_should_open_untitled_file();
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
use std::os::windows::process::CommandExt; // Do not use the follwoing code (start uni link).
use std::process::Command; // It may be unable to open the app on some machines.
Command::new("cmd") // eg. crate::get_uri_prefix() has some special characters or non-ascii characters.
.arg("/c") //
.arg(&format!("start {}", crate::get_uri_prefix())) // Command::new("cmd")
.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW) // .arg("/c")
.spawn() // .arg(&format!("start {}", crate::get_uri_prefix()))
.ok(); // .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")] #[cfg(target_os = "linux")]
if !std::process::Command::new("xdg-open") if !std::process::Command::new("xdg-open")