diff --git a/client/lib/system_tray.dart b/client/lib/system_tray.dart index 1eea776..3bf786e 100644 --- a/client/lib/system_tray.dart +++ b/client/lib/system_tray.dart @@ -86,8 +86,14 @@ class TrayService with TrayListener, WindowListener { case 'quit': // 退出前先停内核拆隧道(避免 sudo sing-box 孤儿 + TUN 残留)。 await onBeforeQuit?.call(); - await windowManager.setPreventClose(false); - await windowManager.destroy(); + // 不要用 windowManager.destroy():它在托盘回调里触发 DestroyWindow/WM_CLOSE + // 回调链(还会回调 onWindowClose → await isPreventClose),异常穿过 Win32 回调 + // 边界 → 0xC000041D(STATUS_FATAL_USER_CALLBACK_EXCEPTION)崩溃。内核已停、隧道 + // 已拆,先摘掉托盘图标避免残留,再直接干净退出进程。 + try { + await trayManager.destroy(); + } catch (_) {} + exit(0); } }