fix: stabilize silent updater and release 0.1.22

This commit is contained in:
2026-02-19 21:41:44 +08:00
parent 7563664733
commit cdfe45b3a2
7 changed files with 17 additions and 10 deletions

View File

@@ -1115,6 +1115,7 @@ fn api_silent_install_and_restart(installer_path: String) -> Result<BridgeRespon
#[cfg(target_os = "windows")]
{
let current_exe = env::current_exe().map_err(|err| format!("获取当前程序路径失败: {}", err))?;
let current_pid = std::process::id();
let temp_dir = env::temp_dir().join("wanwan-cloud-desktop");
fs::create_dir_all(&temp_dir).map_err(|err| format!("创建更新脚本目录失败: {}", err))?;
let script_stamp = SystemTime::now()
@@ -1130,20 +1131,26 @@ fn api_silent_install_and_restart(installer_path: String) -> Result<BridgeRespon
setlocal enableextensions\r\n\
set \"INSTALLER={installer}\"\r\n\
set \"APP_EXE={app_exe}\"\r\n\
set \"APP_PID={app_pid}\"\r\n\
if not exist \"%INSTALLER%\" exit /b 1\r\n\
timeout /t 2 /nobreak >nul\r\n\
timeout /t 1 /nobreak >nul\r\n\
taskkill /PID %APP_PID% /T /F >nul 2>nul\r\n\
timeout /t 1 /nobreak >nul\r\n\
start \"\" /wait \"%INSTALLER%\" /S\r\n\
timeout /t 1 /nobreak >nul\r\n\
if exist \"%APP_EXE%\" start \"\" \"%APP_EXE%\"\r\n\
del \"%~f0\" >nul 2>nul\r\n",
installer = installer_text,
app_exe = app_text
app_exe = app_text,
app_pid = current_pid
);
fs::write(&script_path, script_content).map_err(|err| format!("写入更新脚本失败: {}", err))?;
let script_arg = format!("\"{}\"", script_path.to_string_lossy().replace('\"', "\"\""));
let mut updater_cmd = Command::new("cmd");
updater_cmd
.args(["/D", "/C", &script_arg])
.arg("/D")
.arg("/C")
.arg(&script_path)
.current_dir(&temp_dir)
.creation_flags(CREATE_NO_WINDOW)
.spawn()