build windows install

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-10-11 14:52:46 +08:00
parent 2ced73cdda
commit e2924f0d41
6 changed files with 74 additions and 26 deletions

View File

@@ -544,7 +544,7 @@ pub fn is_ip(id: &str) -> bool {
}
pub fn is_setup(name: &str) -> bool {
name.to_lowercase().ends_with("setdown.exe") || name.to_lowercase().ends_with("安装.exe")
name.to_lowercase().ends_with("install.exe") || name.to_lowercase().ends_with("安装.exe")
}
pub fn get_custom_rendezvous_server(custom: String) -> String {

View File

@@ -6,6 +6,7 @@ pub fn core_main() -> Option<Vec<String>> {
// though async logger more efficient, but it also causes more problems, disable it for now
// let mut _async_logger_holder: Option<flexi_logger::LoggerHandle> = None;
let mut args = Vec::new();
let mut flutter_args = Vec::new();
let mut i = 0;
let mut is_setup = false;
let mut _is_elevate = false;
@@ -25,13 +26,18 @@ pub fn core_main() -> Option<Vec<String>> {
}
i += 1;
}
if args.contains(&"--install".to_string()) {
is_setup = true;
}
if is_setup {
if args.is_empty() {
args.push("--install".to_owned());
} else if args[0] == "--noinstall" {
args.clear();
flutter_args.push("--install".to_string());
}
}
if args.contains(&"--noinstall".to_string()) {
args.clear();
}
if args.len() > 0 && args[0] == "--version" {
println!("{}", crate::VERSION);
return None;
@@ -171,7 +177,10 @@ pub fn core_main() -> Option<Vec<String>> {
}
}
//_async_logger_holder.map(|x| x.flush());
Some(args)
#[cfg(feature = "flutter")]
return Some(flutter_args);
#[cfg(not(feature = "flutter"))]
return Some(args);
}
fn import_config(path: &str) {

View File

@@ -1025,6 +1025,18 @@ copy /Y \"{tmp_path}\\Uninstall {app_name}.lnk\" \"{start_menu}\\\"
app_name = crate::get_app_name(),
);
}
let mut flutter_copy = Default::default();
if options.contains("--flutter") {
flutter_copy = format!(
"XCOPY \"{}\" \"{}\" /Y /E /H /C /I /K /R /Z",
std::env::current_exe()?
.parent()
.unwrap()
.to_string_lossy()
.to_string(),
path
);
}
let meta = std::fs::symlink_metadata(std::env::current_exe()?)?;
let size = meta.len() / 1024;
@@ -1052,6 +1064,7 @@ if exist \"{tmp_path}\\{app_name} Tray.lnk\" del /f /q \"{tmp_path}\\{app_name}
{uninstall_str}
chcp 65001
md \"{path}\"
{flutter_copy}
copy /Y \"{src_exe}\" \"{exe}\"
copy /Y \"{ORIGIN_PROCESS_EXE}\" \"{path}\\{broker_exe}\"
\"{src_exe}\" --extract \"{path}\"
@@ -1114,6 +1127,7 @@ sc delete {app_name}
} else {
&dels
},
flutter_copy = flutter_copy,
);
run_cmds(cmds, debug, "install")?;
std::thread::sleep(std::time::Duration::from_millis(2000));