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