fix: 开发模式退出时正确终止依赖任务

- 开发模式下退出时发送异常信号以终止依赖任务,生产模式下正常清理 Sidecar 进程。
This commit is contained in:
2026-01-18 17:04:08 +08:00
parent 8a8b873642
commit 7656a371a0

View File

@@ -145,12 +145,15 @@ pub fn spawn_sidecar(app_handle: tauri::AppHandle) {
/// 清理 Sidecar 进程 (在应用退出时调用)
pub fn cleanup_sidecar_process(app_handle: &tauri::AppHandle) {
// 只在生产模式下清理 sidecar 进程
let is_dev = cfg!(debug_assertions);
if is_dev {
return;
// 开发模式退出时发送异常信号exit 1让 Turbo 停止 Vite 服务器
println!("🔧 开发模式退出,终止所有依赖任务...");
std::process::exit(1);
}
// 生产模式:正常清理 sidecar 进程
println!("应用退出,正在清理 Sidecar 进程...");
if let Some(state) = app_handle.try_state::<SidecarProcess>() {
if let Ok(mut process) = state.0.lock() {