[feat] launch game code optim + open path after mkdir

This commit is contained in:
2025-08-06 17:59:57 +08:00
parent 0c306b658e
commit 84d0cd7473
2 changed files with 17 additions and 13 deletions

View File

@@ -24,11 +24,11 @@ pub fn launch_game(
let mut opt = launch_option.replace("\n", " ");
if server == "perfectworld" {
opt = opt.replace("-worldwide", "") + " -perfectworld";
} else if server == "worldwide" {
opt = opt.replace("-perfectworld", "") + " -worldwide";
}
opt = match server {
"perfectworld" => opt.replace("-worldwide", "") + " -perfectworld",
"worldwide" => opt.replace("-perfectworld", "") + " -worldwide",
_ => opt,
};
let opts = format!("-applaunch 730 {}", opt);
let opts_split = opts.split_whitespace().collect::<Vec<&str>>();

View File

@@ -1,3 +1,4 @@
use std::fs;
use std::process::Command;
#[cfg(windows)]
@@ -23,10 +24,8 @@ pub fn run_steam() -> std::io::Result<std::process::Output> {
.creation_flags(CREATE_NO_WINDOW)
.output();
#[cfg(target_os = "macos")]
Command::new("open")
.args(&["-a", "Steam"])
.output()
#[cfg(target_os = "macos")]
Command::new("open").args(&["-a", "Steam"]).output()
}
pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
@@ -44,10 +43,13 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
.creation_flags(CREATE_NO_WINDOW)
.output()?;
#[cfg(target_os = "macos")]
let output = Command::new("osascript")
.args(&["-e", &format!("tell application \"{}\" to get path to me", name)])
.output()?;
#[cfg(target_os = "macos")]
let output = Command::new("osascript")
.args(&[
"-e",
&format!("tell application \"{}\" to get path to me", name),
])
.output()?;
let out = String::from_utf8_lossy(&output.stdout).to_string();
@@ -68,6 +70,8 @@ pub fn get_exe_path(name: &str) -> Result<String, std::io::Error> {
pub fn open_path(path: &str) -> Result<(), std::io::Error> {
// path中所有/ 转换为 \
let path = path.replace("/", "\\");
fs::create_dir_all(path)?;
#[cfg(windows)]
Command::new("cmd.exe")
.args(["/c", "start", "", &path])