windows replace uni with cmd to start up main window after installation (#8235)

This is to avoid uni link not working

Other change: The install window now has the title "appname - Install" to distinguish it from the main application window.

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2024-06-01 20:28:21 +08:00 committed by GitHub
parent ed5487a1fc
commit 18464ec570
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 7 deletions

View File

@ -338,7 +338,6 @@ void runInstallPage() async {
windowManager.focus();
windowManager.setOpacity(1);
windowManager.setAlignment(Alignment.center); // ensure
windowManager.setTitle(getWindowName());
});
}

View File

@ -116,15 +116,27 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
if (!command_line_arguments.empty() && command_line_arguments.front().compare(0, cmParam.size(), cmParam.c_str()) == 0) {
is_cm_page = true;
}
bool is_install_page = false;
auto installParam = std::string("--install");
if (!command_line_arguments.empty() && command_line_arguments.front().compare(0, installParam.size(), installParam.c_str()) == 0) {
is_install_page = true;
}
command_line_arguments.insert(command_line_arguments.end(), rust_args.begin(), rust_args.end());
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(800, 600);
if (!window.CreateAndShow(
is_cm_page ? app_name + L" - Connection Manager" : app_name, origin,
size, !is_cm_page)) {
std::wstring window_title;
if (is_cm_page) {
window_title = app_name + L" - Connection Manager";
} else if (is_install_page) {
window_title = app_name + L" - Install";
} else {
window_title = app_name;
}
if (!window.CreateAndShow(window_title, origin, size, !is_cm_page)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);

View File

@ -2185,12 +2185,10 @@ sc start {app_name}
fn run_after_run_cmds(silent: bool) {
let (_, _, _, exe) = get_install_info();
let app = crate::get_app_name().to_lowercase();
if !silent {
log::debug!("Spawn new window");
allow_err!(std::process::Command::new("cmd")
.arg("/c")
.arg(format!("timeout /t 2 & start {app}://"))
.args(&["/c", "timeout", "/t", "2", "&", &format!("{exe}")])
.creation_flags(winapi::um::winbase::CREATE_NO_WINDOW)
.spawn());
}